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 CHANGED
@@ -1 +1 @@
1
- 0.3.0
1
+ 0.3.1
@@ -2,7 +2,7 @@ module Rack
2
2
  module Schmobile
3
3
  module Request
4
4
  def is_mobile?
5
- unless defined?(@is_mobile)
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
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{schmobile}
8
- s.version = "0.3.0"
8
+ s.version = "0.3.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Morten Primdahl"]
@@ -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: 19
4
+ hash: 17
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 3
9
- - 0
10
- version: 0.3.0
9
+ - 1
10
+ version: 0.3.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - Morten Primdahl