Skip to content

Commit

Permalink
fix params with stringified keys that are part of the URL getting app…
Browse files Browse the repository at this point in the history
…ended to query (#119)
  • Loading branch information
balvig authored Apr 19, 2021
1 parent e83847d commit 9d256d4
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
6 changes: 5 additions & 1 deletion lib/spyke/relation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class Relation
include Enumerable

attr_reader :klass
attr_accessor :params
attr_reader :params
delegate :to_ary, :[], :any?, :empty?, :last, :size, :metadata, to: :find_some

def initialize(klass, options = {})
Expand All @@ -21,6 +21,10 @@ def where(conditions = {})
relation
end

def params=(params)
@params = params.symbolize_keys
end

def with(uri)
if uri.is_a? Symbol
@options[:uri] = File.join @options[:uri], uri.to_s
Expand Down
2 changes: 1 addition & 1 deletion lib/spyke/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module Spyke
VERSION = '5.4.2'
VERSION = '5.4.3'
end
8 changes: 8 additions & 0 deletions test/scopes_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,14 @@ def test_chainable_where
assert_requested endpoint
end

def test_where_with_stringified_keys
endpoint = stub_request(:get, 'http://sushi.com/recipes/1/image')

RecipeImage.where("recipe_id" => 1).to_a

assert_requested endpoint
end

def test_chainable_class_method
endpoint = stub_request(:get, 'http://sushi.com/recipes?status=published&per_page=3')

Expand Down

0 comments on commit 9d256d4

Please sign in to comment.