Browse Source

Add new engagement json payload and new method for specs

Scott King 8 years ago
parent
commit
2802befab1
2 changed files with 33 additions and 0 deletions
  1. 15 0
      test/fixtures/engagement.json
  2. 18 0
      test/marketing_event_test.rb

+ 15 - 0
test/fixtures/engagement.json

@@ -0,0 +1,15 @@
+{
+  "engagements": [
+    {
+      "occurred_on": "2017-04-20",
+      "impressions_count": null,
+      "views_count": null,
+      "clicks_count": 10,
+      "shares_count": null,
+      "favorites_count": null,
+      "comments_count": null,
+      "ad_spend": null,
+      "is_cumulative": true
+    }
+  ]
+}

+ 18 - 0
test/marketing_event_test.rb

@@ -46,4 +46,22 @@ class MarketingEventTest < Test::Unit::TestCase
     marketing_events_count = ShopifyAPI::MarketingEvent.get(:count)
     assert_equal 2, marketing_events_count
   end
+
+  def test_add_engagements
+    fake "marketing_events/1", method: :get, body: load_fixture('marketing_event')
+    marketing_events = ShopifyAPI::MarketingEvent.find(1)
+    fake "marketing_events/1/engagements", method: :post, status: 201, body: load_fixture('engagement')
+    engagement = ShopifyAPI::Engagement.new(
+      occurred_on: "2017-04-20",
+      impressions_count: nil,
+      views_count: nil,
+      clicks_count: 10,
+      shares_count: nil,
+      favorites_count: nil,
+      comments_count: nil,
+      ad_spend: nil,
+      is_cumulative: true
+    )
+    assert "2017-04-20", engagement.occurred_on
+  end
 end