Permalink
Browse files

Monkey pacthes active resource build and delete to include custom hea…

…ders
  • Loading branch information...
1 parent 1810400 commit 6a3a4262ef92546f68c9232a0e68236c05004637 @jnormore jnormore committed Oct 31, 2012
Showing with 23 additions and 1 deletion.
  1. +8 −0 lib/active_resource/base_ext.rb
  2. +15 −1 test/base_test.rb
@@ -10,5 +10,13 @@ def self.headers
@headers
end
end
+ # https://github.com/rails/activeresource/commit/dfef85ce8f653f75673631b2950fcdb0781c313c
+ def self.delete(id, options = {})
+ connection.delete(element_path(id, options), headers)
+ end
+ def self.build(attributes = {})
+ attrs = self.format.decode(connection.get("#{new_element_path}", headers).body).merge(attributes)
+ self.new(attrs)
+ end
end
end
View
@@ -47,4 +47,18 @@ def setup
assert_equal 'token2', ShopifyAPI::Shop.headers['X-Shopify-Access-Token']
end
-end
+ test "#delete should send custom headers with request" do
+ ShopifyAPI::Base.activate_session @session1
+ ShopifyAPI::Base.expects(:headers).returns({'X-Custom' => 'abc'})
+ ShopifyAPI::Base.connection.expects(:delete).with('/admin/bases/1.json', {'X-Custom' => 'abc'})
+ ShopifyAPI::Base.delete "1"
+ end
+
+ test "#build should send custom headers with request" do
+ ShopifyAPI::Base.activate_session @session1
+ ShopifyAPI::Base.expects(:headers).returns({'X-Custom' => 'abc'})
+ ShopifyAPI::Base.connection.expects(:delete).with('/admin/bases/1.json', {'X-Custom' => 'abc'})
+ ShopifyAPI::Base.delete "1"
+ end
+
+end

0 comments on commit 6a3a426

Please sign in to comment.