Browse files

don't force volume to be an int

  • Loading branch information...
1 parent f00be44 commit 1ad9ffce7c4baa27f952a5606105daac563e7d24 @holman holman committed May 19, 2011
Showing with 10 additions and 3 deletions.
  1. +1 −1 lib/play/app/api.rb
  2. +9 −2 test/test_api.rb
View
2 lib/play/app/api.rb
@@ -79,7 +79,7 @@ class App < Sinatra::Base
end
post "/api/volume" do
- if Play::Client.volume(params[:level].to_i)
+ if Play::Client.volume(params[:level])
{ :success => 'true' }.to_json
else
error "There's a problem adjusting the volume."
View
11 test/test_api.rb
@@ -111,8 +111,15 @@ def app
end
test "/api/volume" do
- Play::Client.expects(:volume).with(3).returns(true)
- post "/api/volume", {:level => '3'}
+ Play::Client.expects(:volume).with('3').returns(true)
+ post "/api/volume", {:level => 3}
+ resp = parse_json(last_response.body.strip)
+ assert_equal 'true', resp[:success]
+ end
+
+ test "/api/volume with a float" do
+ Play::Client.expects(:volume).with("2.5").returns(true)
+ post "/api/volume", {:level => '2.5'}
resp = parse_json(last_response.body.strip)
assert_equal 'true', resp[:success]
end

0 comments on commit 1ad9ffc

Please sign in to comment.