Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Allow an array of symbols as the except option

  • Loading branch information...
commit 5c648cb5111cfe6a24eb91c443ed3f57cc078edf 1 parent cca7a7b
Sandro Turriate authored April 02, 2012
2  lib/mobylette/controllers/respond_to_mobile_requests.rb
@@ -96,7 +96,7 @@ def respond_to_mobile_requests(options = {})
96 96
           # works on 1.9, but not on 1.8
97 97
           #valid_options = [:fall_back, :skip_xhr_requests]
98 98
           #self.mobylette_options = options.reject {|option| !valid_options.include?(option)}
99  
-          options[:except] = Array(options[:except])
  99
+          options[:except] = Array(options[:except]).map {|ua| ua.to_s}
100 100
           self.mobylette_options = options
101 101
 
102 102
           self.send(:include, Mobylette::Controllers::RespondToMobileRequestsMethods)
20  spec/respond_to_mobile_requests_spec.rb
@@ -23,12 +23,12 @@ def session
23 23
 
24 24
   it "supports a single exception" do
25 25
     controller.respond_to_mobile_requests :except => :ipad
26  
-    controller.mobylette_options[:except].should == [:ipad]
  26
+    controller.mobylette_options[:except].should == ['ipad']
27 27
   end
28 28
 
29 29
   it "supports multiple exceptions" do
30 30
     controller.respond_to_mobile_requests :except => [:ipad, :android]
31  
-    controller.mobylette_options[:except].should == [:ipad, :android]
  31
+    controller.mobylette_options[:except].should == ['ipad', 'android']
32 32
   end
33 33
 
34 34
   describe "when iPad is excepted" do
@@ -44,4 +44,20 @@ def session
44 44
     end
45 45
 
46 46
   end
  47
+
  48
+  describe "when iPad and Android are excepted" do
  49
+    let(:controller) { new_controller('android') }
  50
+
  51
+    context "request is Android" do
  52
+      it "remains a mobile request" do
  53
+        controller.respond_to_mobile_requests :except => [:ipad, :android]
  54
+        controller.new.send(:is_mobile_request?).should be_true
  55
+      end
  56
+
  57
+      it "does not respond as mobile" do
  58
+        controller.respond_to_mobile_requests :except => [:ipad, :android]
  59
+        controller.new.send(:respond_as_mobile?).should be_false
  60
+      end
  61
+    end
  62
+  end
47 63
 end

0 notes on commit 5c648cb

Please sign in to comment.
Something went wrong with that request. Please try again.