Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Add failing spec

The functionality defined in GoCardless::Resource#initialize for magically
creating methods for sub resources is not merging query parameters correctly.
  • Loading branch information...
commit aaed3cd137d64da571822c6b7d05e59c5eca493b 1 parent aa118d1
@timcraft timcraft authored
Showing with 13 additions and 1 deletion.
  1. +13 −1 spec/resource_spec.rb
View
14 spec/resource_spec.rb
@@ -376,7 +376,7 @@ class UpdatableResource < GoCardless::Resource
r.bills
end
- it "adds provided params to query string params" do
+ it "adds provided params to existing query string params" do
client = mock()
params = { 'merchant_id' => '1', :amount => '10.00' }
client.expects(:api_get).with(anything, params).returns([])
@@ -384,6 +384,18 @@ class UpdatableResource < GoCardless::Resource
r.bills(:amount => '10.00')
end
+ it "adds provided params when there are no existing query string params" do
+ client = mock()
+ params = { :source_id => 'xxx' }
+ client.expects(:api_get).with(anything, params).returns([])
+ r = @test_resource.new_with_client(client, {
+ 'sub_resource_uris' => {
+ 'bills' => 'https://test.com/merchants/1/bills'
+ }
+ })
+ r.bills(:source_id => 'xxx')
+ end
+
it "return instances of the correct resource class" do
client = stub(:api_get => [{:id => 1}])
r = @test_resource.new_with_client(client, @attrs)
Please sign in to comment.
Something went wrong with that request. Please try again.