split_cacheable 1.0.2 → 1.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 22e06b2f81c3e8f5389c47602d567ee68a545063
4
- data.tar.gz: 5359958686cab76e5217bd85dac85f1aa273e64c
3
+ metadata.gz: 514a9d878ce909f2c3de0c556c52caf32804cc75
4
+ data.tar.gz: 0ddd41fcdb78e194904ab73a07cd69c7d83ee66d
5
5
  SHA512:
6
- metadata.gz: b4e8a6305f0d4a2266787f536a15c75c463f477d1b41d236a9ca35318041b7cec51ce1e41dda972e83fca4e8592989ae063f59cfa17175b39e11c7ab38fe9610
7
- data.tar.gz: 26048216a8d1f48fb6d674b12946ce373d82f0fa40fb1d6f655fc22326125cc2348ed2dbe584713c7e8d2a909bb2688b3f65e551cadb49be32a48c76d09bbee0
6
+ metadata.gz: f781f6ea770b92cfdc324e6683f56eb849bb17df545c9ee1f19b65d19aff7baae0d349333afcb5306e8f3be11ac16320fed8ca2e7ecac77ad620a116360b4e0e
7
+ data.tar.gz: 4e1510714732bc8d7c5a240acbfc418323a89854e9d098085fcbe89d1a6ed59aaee0e12505470fba6fc0db8f72b09fba3e4fec5513af3c6f979b26c86b6c912d
@@ -1,5 +1,5 @@
1
1
  module Split
2
2
  module Cacheable
3
- VERSION = "1.0.2"
3
+ VERSION = "1.0.3"
4
4
  end
5
5
  end
@@ -80,10 +80,13 @@ module Split
80
80
  when 0
81
81
  return [DEFAULT_KEY]
82
82
  when 1
83
+ test_variations[0].unshift(DEFAULT_KEY)
83
84
  return test_variations[0]
84
85
  else
85
86
  first_test = test_variations.shift
86
- return first_test.product(*test_variations).map{|a| a.join("/")}
87
+ all_variations = first_test.product(*test_variations).map{|a| a.join("/")}
88
+ all_variations.unshift(DEFAULT_KEY)
89
+ return all_variations
87
90
  end
88
91
  end
89
92
  end
@@ -1,29 +1,39 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Split::Cacheable do
4
- ALL_VARIATIONS = ["test_1/old/test_2/left", "test_1/old/test_2/right", "test_1/new/test_2/left", "test_1/new/test_2/right"]
4
+ ALL_VARIATIONS = [Split::Cacheable::Adapter::DEFAULT_KEY, "test_1/old/test_2/left", "test_1/old/test_2/right", "test_1/new/test_2/left", "test_1/new/test_2/right"]
5
5
 
6
6
  it "should return the default variation if there is no request" do
7
- Split::Cacheable::Adapter.new(TestControllerWithoutRequest.new, :index).get_current_variations.should eql Split::Cacheable::Adapter::DEFAULT_KEY
7
+ expect(Split::Cacheable::Adapter.new(TestControllerWithoutRequest.new, :index).get_current_variations).to eql Split::Cacheable::Adapter::DEFAULT_KEY
8
8
  end
9
9
 
10
10
  it "should return a possible active variation if the controller has a request" do
11
- ALL_VARIATIONS.should include(Split::Cacheable::Adapter.new(TestControllerWithRequest.new, :index).get_current_variations)
11
+ expect(ALL_VARIATIONS).to include(Split::Cacheable::Adapter.new(TestControllerWithRequest.new, :index).get_current_variations)
12
12
  end
13
13
 
14
14
  it "should return all active tests for a controller/action combination" do
15
- Split::Cacheable::Adapter.new(TestControllerWithRequest.new, :index).active_tests.should eql [{:only=>[:index], :except=>[], :test_name=>:test_1}, {:only=>[], :except=>[:show], :test_name=>:test_2}]
16
- end
17
-
18
- it "should return all possible variations of the cachekey" do
19
- Split::Cacheable::Adapter.new(TestControllerWithoutRequest.new, :index).get_all_possible_variations.should eql ALL_VARIATIONS
15
+ expect(Split::Cacheable::Adapter.new(TestControllerWithRequest.new, :index).active_tests).to eql [{:only=>[:index], :except=>[], :test_name=>:test_1}, {:only=>[], :except=>[:show], :test_name=>:test_2}]
20
16
  end
21
17
 
22
18
  it "should disregard tests that don't pass the :if Proc" do
23
19
  controller = TestControllerWithRequestAndProc.new
24
- Split::Cacheable::Adapter.new(controller, :index).get_current_variations.should eql Split::Cacheable::Adapter::DEFAULT_KEY
20
+ expect(Split::Cacheable::Adapter.new(controller, :index).get_current_variations).to eql Split::Cacheable::Adapter::DEFAULT_KEY
25
21
 
26
22
  controller.instance_variable_set("@mobile_device", true)
27
- ALL_VARIATIONS.should include(Split::Cacheable::Adapter.new(TestControllerWithRequest.new, :index).get_current_variations)
23
+ expect(ALL_VARIATIONS).to include(Split::Cacheable::Adapter.new(TestControllerWithRequest.new, :index).get_current_variations)
24
+ end
25
+
26
+ describe "get_all_possible_variations method" do
27
+ it "should return all possible variations of the cachekey" do
28
+ expect(Split::Cacheable::Adapter.new(TestControllerWithoutRequest.new, :index).get_all_possible_variations).to eql ALL_VARIATIONS
29
+ end
30
+
31
+ it "should return the default key when there are no variations" do
32
+ expect(Split::Cacheable::Adapter.new(TestControllerWithNoVariations.new, :index).get_all_possible_variations).to eql [Split::Cacheable::Adapter::DEFAULT_KEY]
33
+ end
34
+
35
+ it "should return one test plus the default key when there is one test" do
36
+ expect(Split::Cacheable::Adapter.new(TestControllerWithOneVariation.new, :index).get_all_possible_variations).to eql [Split::Cacheable::Adapter::DEFAULT_KEY, "test_1/old", "test_1/new"]
37
+ end
28
38
  end
29
39
  end
data/spec/spec_helper.rb CHANGED
@@ -47,6 +47,13 @@ class TestControllerWithoutRequest
47
47
  end
48
48
  end
49
49
 
50
+ class TestControllerWithNoVariations < TestControllerWithoutRequest
51
+ end
52
+
53
+ class TestControllerWithOneVariation < TestControllerWithoutRequest
54
+ cacheable_ab_test :test_1, :only => :index
55
+ end
56
+
50
57
  class TestControllerWithRequest < TestControllerWithoutRequest
51
58
  cacheable_ab_test :test_1, :only => :index
52
59
  cacheable_ab_test :test_2, :except => :show
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: split_cacheable
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 1.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Schwartz
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-04-02 00:00:00.000000000 Z
11
+ date: 2014-08-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: split
@@ -136,7 +136,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
136
136
  version: '0'
137
137
  requirements: []
138
138
  rubyforge_project:
139
- rubygems_version: 2.2.2
139
+ rubygems_version: 2.0.14
140
140
  signing_key:
141
141
  specification_version: 4
142
142
  summary: We use action caching in Rails 3 to cache both our standard and mobile site.