Permalink
Browse files

Allow an array of symbols as the except option

  • Loading branch information...
1 parent cca7a7b commit 5c648cb5111cfe6a24eb91c443ed3f57cc078edf @sandro sandro committed Apr 3, 2012
Showing with 19 additions and 3 deletions.
  1. +1 −1 lib/mobylette/controllers/respond_to_mobile_requests.rb
  2. +18 −2 spec/respond_to_mobile_requests_spec.rb
@@ -96,7 +96,7 @@ def respond_to_mobile_requests(options = {})
# works on 1.9, but not on 1.8
#valid_options = [:fall_back, :skip_xhr_requests]
#self.mobylette_options = options.reject {|option| !valid_options.include?(option)}
- options[:except] = Array(options[:except])
+ options[:except] = Array(options[:except]).map {|ua| ua.to_s}
self.mobylette_options = options
self.send(:include, Mobylette::Controllers::RespondToMobileRequestsMethods)
@@ -23,12 +23,12 @@ def session
it "supports a single exception" do
controller.respond_to_mobile_requests :except => :ipad
- controller.mobylette_options[:except].should == [:ipad]
+ controller.mobylette_options[:except].should == ['ipad']
end
it "supports multiple exceptions" do
controller.respond_to_mobile_requests :except => [:ipad, :android]
- controller.mobylette_options[:except].should == [:ipad, :android]
+ controller.mobylette_options[:except].should == ['ipad', 'android']
end
describe "when iPad is excepted" do
@@ -44,4 +44,20 @@ def session
end
end
+
+ describe "when iPad and Android are excepted" do
+ let(:controller) { new_controller('android') }
+
+ context "request is Android" do
+ it "remains a mobile request" do
+ controller.respond_to_mobile_requests :except => [:ipad, :android]
+ controller.new.send(:is_mobile_request?).should be_true
+ end
+
+ it "does not respond as mobile" do
+ controller.respond_to_mobile_requests :except => [:ipad, :android]
+ controller.new.send(:respond_as_mobile?).should be_false
+ end
+ end
+ end
end

0 comments on commit 5c648cb

Please sign in to comment.