Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Adding or removing user agents accept a symbol

  • Loading branch information...
commit 1cf0c416a4aef73e7e082ade4ee2e9eb95644210 1 parent 1b2dedf
@sandro sandro authored
View
4 lib/mobylette/controllers/respond_to_mobile_requests.rb
@@ -103,11 +103,11 @@ def respond_to_mobile_requests(options = {})
end
def add_mobile_user_agent(agent)
- MOBILE_USER_AGENTS << agent
+ MOBILE_USER_AGENTS << agent.to_s
end
def remove_mobile_user_agent(agent)
- MOBILE_USER_AGENTS.delete agent
+ MOBILE_USER_AGENTS.delete agent.to_s
end
end
View
31 spec/respond_to_mobile_requests_spec.rb
@@ -1,6 +1,7 @@
require 'spec_helper'
describe Mobylette::Controllers::RespondToMobileRequests do
+ ORIGINAL_USER_AGENTS = Mobylette::Controllers::RespondToMobileRequests::MOBILE_USER_AGENTS.dup
def new_controller(user_agent = 'iPad')
Class.new(ActionController::Base) do
include Mobylette::Controllers::RespondToMobileRequests
@@ -64,18 +65,38 @@ def session
end
describe "#add_mobile_user_agent" do
+ before do
+ controller::MOBILE_USER_AGENTS.replace(ORIGINAL_USER_AGENTS)
+ end
+
it "adds a user agent to the list of agents" do
- controller.const_get(:MOBILE_USER_AGENTS).should_not include('killerapp')
+ controller::MOBILE_USER_AGENTS.should_not include('killerapp')
controller.add_mobile_user_agent 'killerapp'
- controller.const_get(:MOBILE_USER_AGENTS).should include('killerapp')
+ controller::MOBILE_USER_AGENTS.should include('killerapp')
+ end
+
+ it "converts symbols to strings" do
+ controller::MOBILE_USER_AGENTS.should_not include('killerapp')
+ controller.add_mobile_user_agent :killerapp
+ controller::MOBILE_USER_AGENTS.should include('killerapp')
end
end
describe "#remove_mobile_user_agent" do
+ before do
+ controller::MOBILE_USER_AGENTS.replace(ORIGINAL_USER_AGENTS)
+ end
+
it "removes a user agent from the list of agents" do
- controller.add_mobile_user_agent 'killerapp'
- controller.remove_mobile_user_agent 'killerapp'
- controller.const_get(:MOBILE_USER_AGENTS).should_not include('killerapp')
+ controller.add_mobile_user_agent 'appkiller'
+ controller.remove_mobile_user_agent 'appkiller'
+ controller::MOBILE_USER_AGENTS.should_not include('appkiller')
+ end
+
+ it "converts symbols to strings" do
+ controller.add_mobile_user_agent 'appkiller'
+ controller.remove_mobile_user_agent :appkiller
+ controller::MOBILE_USER_AGENTS.should_not include('appkiller')
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.