Skip to content

Commit

Permalink
Merge pull request #20 from kreynolds/query_param_to_s
Browse files Browse the repository at this point in the history
Convert to_s when extracting a query parameter
  • Loading branch information
bwillis committed Jan 12, 2014
2 parents 5a652eb + fad4607 commit d5cf6a0
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/versioncake/strategies/query_parameter_strategy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ class QueryParameterStrategy < ExtractionStrategy

def execute(request)
if request.query_parameters.key? @@version_string.to_sym
request.query_parameters[@@version_string.to_sym]
request.query_parameters[@@version_string.to_sym].to_s
end
end

Expand Down
2 changes: 1 addition & 1 deletion test/unit/strategies/extraction_strategy_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class ExtractionStrategyTest < ActiveSupport::TestCase
end
end

test "extract will convert the the result to integer" do
test "extract will convert the result to integer" do
class TestStrategy < VersionCake::ExtractionStrategy
def execute(request); "123"; end
end
Expand Down
5 changes: 5 additions & 0 deletions test/unit/strategies/query_parameter_strategy_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ class QueryParameterStrategyTest < ActiveSupport::TestCase
assert_equal 11, @strategy.extract(request)
end

test "a request with an Integer api_version parameter retrieves the version" do
request = stub(:query_parameters => {:api_version => 11, :other => 'parameter'})
assert_equal 11, @strategy.extract(request)
end

test "a request without an api_version parameter returns nil" do
request = stub(:query_parameters => {:other => 'parameter', :another => 'parameter'})
assert_nil @strategy.extract(request)
Expand Down

0 comments on commit d5cf6a0

Please sign in to comment.