schmobile 0.3.0 → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/VERSION +1 -1
- data/lib/rack/schmobile/request_extension.rb +2 -1
- data/schmobile.gemspec +1 -1
- data/test/test_rack_request.rb +14 -0
- metadata +3 -3
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.3.
|
1
|
+
0.3.1
|
@@ -2,7 +2,7 @@ module Rack
|
|
2
2
|
module Schmobile
|
3
3
|
module Request
|
4
4
|
def is_mobile?
|
5
|
-
|
5
|
+
if @is_mobile.nil?
|
6
6
|
@is_mobile = Rack::Schmobile::Filters.apply(self)
|
7
7
|
end
|
8
8
|
|
@@ -11,6 +11,7 @@ module Rack
|
|
11
11
|
|
12
12
|
def toggle_mobile_session!
|
13
13
|
session[Rack::Schmobile::IS_MOBILE] = !is_mobile?
|
14
|
+
@is_mobile = nil
|
14
15
|
end
|
15
16
|
|
16
17
|
def is_device?(identifier)
|
data/schmobile.gemspec
CHANGED
data/test/test_rack_request.rb
CHANGED
@@ -15,6 +15,20 @@ class TestRackRequest < Test::Unit::TestCase
|
|
15
15
|
end
|
16
16
|
|
17
17
|
context "#is_mobile?" do
|
18
|
+
should "only call the filter chain once" do
|
19
|
+
Rack::Schmobile::Filters.expects(:apply).once.returns(false)
|
20
|
+
one_request = request
|
21
|
+
3.times { one_request.is_mobile? }
|
22
|
+
end
|
23
|
+
|
24
|
+
should "re-call the filter chain once reset" do
|
25
|
+
Rack::Schmobile::Filters.expects(:apply).twice.returns(false)
|
26
|
+
one_request = request
|
27
|
+
3.times { one_request.is_mobile? }
|
28
|
+
one_request.toggle_mobile_session!
|
29
|
+
3.times { one_request.is_mobile? }
|
30
|
+
end
|
31
|
+
|
18
32
|
context "without params" do
|
19
33
|
setup do
|
20
34
|
Rack::Request.any_instance.stubs(:params).returns({})
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: schmobile
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 17
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 3
|
9
|
-
-
|
10
|
-
version: 0.3.
|
9
|
+
- 1
|
10
|
+
version: 0.3.1
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Morten Primdahl
|