Forráskód Böngészése

Adding post and put tests for script tags

Ben Cox 11 éve
szülő
commit
7d9cd5eee4
1 módosított fájl, 15 hozzáadás és 0 törlés
  1. 15 0
      test/script_tag_test.rb

+ 15 - 0
test/script_tag_test.rb

@@ -12,4 +12,19 @@ class ScriptTagTest < Test::Unit::TestCase
     script_tag = ShopifyAPI::ScriptTag.find(421379493)
     assert_equal "http://js-aplenty.com/bar.js", script_tag.src
   end
+
+  test "create should create a new script tag" do
+    fake 'script_tags', :method => :post, :status => 201, :body => load_fixture('script_tag')
+    script_tag = ShopifyAPI::ScriptTag.create(event: "onload", src: "http://js-aplenty.com/bar.js")
+    assert_equal "http://js-aplenty.com/bar.js", script_tag.src
+  end
+
+  test "editing script tag should update script tag" do
+    fake 'script_tags/421379493', :method => :get, :status => 200, :body => load_fixture('script_tag')
+    script_tag = ShopifyAPI::ScriptTag.find(421379493)
+    script_tag.src = "http://js-aplenty.com/bar.js"
+    fake 'script_tags/421379493', :method => :put, :status => 200, :body => load_fixture('script_tag')
+    script_tag.save
+    assert_equal "http://js-aplenty.com/bar.js", script_tag.src
+  end
 end