taggable_cache 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.travis.yml +8 -0
- data/Gemfile +6 -2
- data/Gemfile.lock +56 -51
- data/gemfiles/Gemfile-rails.3.0.x +13 -0
- data/gemfiles/Gemfile-rails.3.1.x +13 -0
- data/gemfiles/Gemfile-rails.3.2.x +13 -0
- data/lib/taggable_cache/railtie.rb +11 -0
- data/lib/taggable_cache/spectator.rb +9 -0
- data/lib/taggable_cache/version.rb +1 -1
- data/lib/taggable_cache.rb +1 -1
- data/spec/integration/rails_cache_spec.rb +87 -0
- data/spec/taggable-cache/store_spec.rb +34 -33
- metadata +13 -13
- data/lib/taggable_cache/rails/observer.rb +0 -11
- data/spec/internal/app/models/simple_observer.rb +0 -5
- data/spec/internal/config/initializers/taggable.rb +0 -3
- data/spec/models/page_spec.rb +0 -4
- data/spec/rails_cache_spec.rb +0 -51
data/.travis.yml
CHANGED
data/Gemfile
CHANGED
@@ -1,13 +1,17 @@
|
|
1
|
-
source
|
1
|
+
source :rubygems
|
2
2
|
|
3
3
|
gemspec
|
4
4
|
|
5
5
|
group :development do
|
6
6
|
gem 'pry'
|
7
|
+
gem 'pry-nav'
|
7
8
|
end
|
8
9
|
|
10
|
+
gem 'rake'
|
9
11
|
gem 'rspec-rails', :require => false
|
10
12
|
gem 'rspec'
|
11
13
|
gem 'capybara'
|
12
|
-
gem 'combustion', '~> 0.3.1'
|
14
|
+
gem 'combustion', :git => 'https://brain-geek@github.com/brain-geek/combustion.git' #, '~> 0.3.1'
|
13
15
|
gem 'sqlite3'
|
16
|
+
|
17
|
+
gem 'rails', '~> 3.2.0'
|
data/Gemfile.lock
CHANGED
@@ -1,19 +1,27 @@
|
|
1
|
+
GIT
|
2
|
+
remote: https://brain-geek@github.com/brain-geek/combustion.git
|
3
|
+
revision: 3574c523d1ce6d8805ab2218c8d52257b5848640
|
4
|
+
specs:
|
5
|
+
combustion (0.3.2)
|
6
|
+
rails (>= 3.0.0)
|
7
|
+
thor (>= 0.14.6)
|
8
|
+
|
1
9
|
PATH
|
2
10
|
remote: .
|
3
11
|
specs:
|
4
|
-
taggable_cache (0.2.
|
12
|
+
taggable_cache (0.2.1)
|
5
13
|
rails (>= 3.0.8)
|
6
14
|
redis (>= 2.2.2)
|
7
15
|
|
8
16
|
GEM
|
9
17
|
remote: http://rubygems.org/
|
10
18
|
specs:
|
11
|
-
actionmailer (3.2.
|
12
|
-
actionpack (= 3.2.
|
19
|
+
actionmailer (3.2.2)
|
20
|
+
actionpack (= 3.2.2)
|
13
21
|
mail (~> 2.4.0)
|
14
|
-
actionpack (3.2.
|
15
|
-
activemodel (= 3.2.
|
16
|
-
activesupport (= 3.2.
|
22
|
+
actionpack (3.2.2)
|
23
|
+
activemodel (= 3.2.2)
|
24
|
+
activesupport (= 3.2.2)
|
17
25
|
builder (~> 3.0.0)
|
18
26
|
erubis (~> 2.7.0)
|
19
27
|
journey (~> 1.0.1)
|
@@ -21,21 +29,21 @@ GEM
|
|
21
29
|
rack-cache (~> 1.1)
|
22
30
|
rack-test (~> 0.6.1)
|
23
31
|
sprockets (~> 2.1.2)
|
24
|
-
activemodel (3.2.
|
25
|
-
activesupport (= 3.2.
|
32
|
+
activemodel (3.2.2)
|
33
|
+
activesupport (= 3.2.2)
|
26
34
|
builder (~> 3.0.0)
|
27
|
-
activerecord (3.2.
|
28
|
-
activemodel (= 3.2.
|
29
|
-
activesupport (= 3.2.
|
30
|
-
arel (~> 3.0.
|
35
|
+
activerecord (3.2.2)
|
36
|
+
activemodel (= 3.2.2)
|
37
|
+
activesupport (= 3.2.2)
|
38
|
+
arel (~> 3.0.2)
|
31
39
|
tzinfo (~> 0.3.29)
|
32
|
-
activeresource (3.2.
|
33
|
-
activemodel (= 3.2.
|
34
|
-
activesupport (= 3.2.
|
35
|
-
activesupport (3.2.
|
40
|
+
activeresource (3.2.2)
|
41
|
+
activemodel (= 3.2.2)
|
42
|
+
activesupport (= 3.2.2)
|
43
|
+
activesupport (3.2.2)
|
36
44
|
i18n (~> 0.6)
|
37
45
|
multi_json (~> 1.0)
|
38
|
-
arel (3.0.
|
46
|
+
arel (3.0.2)
|
39
47
|
builder (3.0.0)
|
40
48
|
capybara (1.1.2)
|
41
49
|
mime-types (>= 1.16)
|
@@ -46,50 +54,47 @@ GEM
|
|
46
54
|
xpath (~> 0.1.4)
|
47
55
|
childprocess (0.3.1)
|
48
56
|
ffi (~> 1.0.6)
|
49
|
-
coderay (0.
|
50
|
-
combustion (0.3.1)
|
51
|
-
rails (>= 3.1.0)
|
52
|
-
thor (>= 0.14.6)
|
57
|
+
coderay (1.0.5)
|
53
58
|
diff-lcs (1.1.3)
|
54
59
|
erubis (2.7.0)
|
55
60
|
ffi (1.0.11)
|
56
61
|
hike (1.2.1)
|
57
62
|
i18n (0.6.0)
|
58
|
-
journey (1.0.
|
63
|
+
journey (1.0.3)
|
59
64
|
json (1.6.5)
|
60
|
-
mail (2.4.
|
65
|
+
mail (2.4.3)
|
61
66
|
i18n (>= 0.4.0)
|
62
67
|
mime-types (~> 1.16)
|
63
68
|
treetop (~> 1.4.8)
|
64
|
-
method_source (0.
|
65
|
-
ruby_parser (>= 2.3.1)
|
69
|
+
method_source (0.7.1)
|
66
70
|
mime-types (1.17.2)
|
67
|
-
multi_json (1.0
|
71
|
+
multi_json (1.1.0)
|
68
72
|
nokogiri (1.5.0)
|
69
73
|
polyglot (0.3.3)
|
70
|
-
pry (0.9.
|
71
|
-
coderay (~> 0.
|
72
|
-
method_source (~> 0.
|
73
|
-
|
74
|
-
|
74
|
+
pry (0.9.8.4)
|
75
|
+
coderay (~> 1.0.5)
|
76
|
+
method_source (~> 0.7.1)
|
77
|
+
slop (>= 2.4.4, < 3)
|
78
|
+
pry-nav (0.1.0)
|
79
|
+
pry (~> 0.9.8.1)
|
75
80
|
rack (1.4.1)
|
76
|
-
rack-cache (1.
|
81
|
+
rack-cache (1.2)
|
77
82
|
rack (>= 0.4)
|
78
83
|
rack-ssl (1.3.2)
|
79
84
|
rack
|
80
85
|
rack-test (0.6.1)
|
81
86
|
rack (>= 1.0)
|
82
|
-
rails (3.2.
|
83
|
-
actionmailer (= 3.2.
|
84
|
-
actionpack (= 3.2.
|
85
|
-
activerecord (= 3.2.
|
86
|
-
activeresource (= 3.2.
|
87
|
-
activesupport (= 3.2.
|
87
|
+
rails (3.2.2)
|
88
|
+
actionmailer (= 3.2.2)
|
89
|
+
actionpack (= 3.2.2)
|
90
|
+
activerecord (= 3.2.2)
|
91
|
+
activeresource (= 3.2.2)
|
92
|
+
activesupport (= 3.2.2)
|
88
93
|
bundler (~> 1.0)
|
89
|
-
railties (= 3.2.
|
90
|
-
railties (3.2.
|
91
|
-
actionpack (= 3.2.
|
92
|
-
activesupport (= 3.2.
|
94
|
+
railties (= 3.2.2)
|
95
|
+
railties (3.2.2)
|
96
|
+
actionpack (= 3.2.2)
|
97
|
+
activesupport (= 3.2.2)
|
93
98
|
rack-ssl (~> 1.3.2)
|
94
99
|
rake (>= 0.8.7)
|
95
100
|
rdoc (~> 3.4)
|
@@ -111,16 +116,13 @@ GEM
|
|
111
116
|
activesupport (>= 3.0)
|
112
117
|
railties (>= 3.0)
|
113
118
|
rspec (~> 2.8.0)
|
114
|
-
ruby_parser (2.3.1)
|
115
|
-
sexp_processor (~> 3.0)
|
116
119
|
rubyzip (0.9.6.1)
|
117
|
-
selenium-webdriver (2.
|
120
|
+
selenium-webdriver (2.20.0)
|
118
121
|
childprocess (>= 0.2.5)
|
119
|
-
ffi (~> 1.0
|
120
|
-
multi_json (~> 1.0
|
122
|
+
ffi (~> 1.0)
|
123
|
+
multi_json (~> 1.0)
|
121
124
|
rubyzip
|
122
|
-
|
123
|
-
slop (2.1.0)
|
125
|
+
slop (2.4.4)
|
124
126
|
sprockets (2.1.2)
|
125
127
|
hike (~> 1.2)
|
126
128
|
rack (~> 1.0)
|
@@ -131,7 +133,7 @@ GEM
|
|
131
133
|
treetop (1.4.10)
|
132
134
|
polyglot
|
133
135
|
polyglot (>= 0.3.1)
|
134
|
-
tzinfo (0.3.
|
136
|
+
tzinfo (0.3.32)
|
135
137
|
xpath (0.1.4)
|
136
138
|
nokogiri (~> 1.3)
|
137
139
|
|
@@ -140,8 +142,11 @@ PLATFORMS
|
|
140
142
|
|
141
143
|
DEPENDENCIES
|
142
144
|
capybara
|
143
|
-
combustion
|
145
|
+
combustion!
|
144
146
|
pry
|
147
|
+
pry-nav
|
148
|
+
rails (~> 3.2.0)
|
149
|
+
rake
|
145
150
|
rspec
|
146
151
|
rspec-rails
|
147
152
|
sqlite3
|
@@ -0,0 +1,13 @@
|
|
1
|
+
source :rubygems
|
2
|
+
|
3
|
+
gem 'taggable_cache', :path => '..'
|
4
|
+
|
5
|
+
gem 'rake'
|
6
|
+
gem 'rspec-rails', :require => false
|
7
|
+
gem 'rspec'
|
8
|
+
gem 'capybara'
|
9
|
+
gem 'combustion', :git => 'https://brain-geek@github.com/brain-geek/combustion.git'
|
10
|
+
gem 'sqlite3'
|
11
|
+
|
12
|
+
|
13
|
+
gem 'rails', '~> 3.0.0'
|
@@ -0,0 +1,13 @@
|
|
1
|
+
source :rubygems
|
2
|
+
|
3
|
+
gem 'taggable_cache', :path => '..'
|
4
|
+
|
5
|
+
gem 'rake'
|
6
|
+
gem 'rspec-rails', :require => false
|
7
|
+
gem 'rspec'
|
8
|
+
gem 'capybara'
|
9
|
+
gem 'combustion', :git => 'https://brain-geek@github.com/brain-geek/combustion.git'
|
10
|
+
gem 'sqlite3'
|
11
|
+
|
12
|
+
|
13
|
+
gem 'rails', '~> 3.1.0'
|
@@ -0,0 +1,13 @@
|
|
1
|
+
source :rubygems
|
2
|
+
|
3
|
+
gem 'taggable_cache', :path => '..'
|
4
|
+
|
5
|
+
gem 'rake'
|
6
|
+
gem 'rspec-rails', :require => false
|
7
|
+
gem 'rspec'
|
8
|
+
gem 'capybara'
|
9
|
+
gem 'combustion', :git => 'https://brain-geek@github.com/brain-geek/combustion.git'
|
10
|
+
gem 'sqlite3'
|
11
|
+
|
12
|
+
|
13
|
+
gem 'rails', '~> 3.2.0'
|
@@ -1,3 +1,9 @@
|
|
1
|
+
require 'active_record'
|
2
|
+
require 'action_controller'
|
3
|
+
require 'rails'
|
4
|
+
|
5
|
+
require 'taggable_cache/spectator'
|
6
|
+
|
1
7
|
ActiveSupport::Cache::Store.class_eval do
|
2
8
|
def taggable
|
3
9
|
@taggable ||= ::TaggableCache::Store.new
|
@@ -33,5 +39,10 @@ end
|
|
33
39
|
|
34
40
|
module TaggableCache
|
35
41
|
class Railtie < ::Rails::Railtie
|
42
|
+
initializer "taggable_cache" do |app|
|
43
|
+
# binding.pry
|
44
|
+
ActiveRecord::Base.observers << TaggableCache::Spectator
|
45
|
+
ActiveRecord::Base.add_observer TaggableCache::Spectator.instance
|
46
|
+
end
|
36
47
|
end
|
37
48
|
end
|
data/lib/taggable_cache.rb
CHANGED
@@ -0,0 +1,87 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), '..', 'spec_helper.rb')
|
2
|
+
|
3
|
+
describe 'TaggableCache::Rails::Cache' do
|
4
|
+
before :all do
|
5
|
+
@object = TaggableCache::Store.new
|
6
|
+
@page_object = Page.create
|
7
|
+
end
|
8
|
+
|
9
|
+
before :each do
|
10
|
+
Redis.new.flushall
|
11
|
+
end
|
12
|
+
|
13
|
+
describe "Rails.cache.write integration" do
|
14
|
+
it "adds key to store" do
|
15
|
+
Rails.cache.write('key', 'value', :depends_on => [@page_object])
|
16
|
+
|
17
|
+
@object.get(@page_object).should == ['key']
|
18
|
+
end
|
19
|
+
|
20
|
+
it "does simple writes" do
|
21
|
+
Rails.cache.write 'ipsum', 'lorem'
|
22
|
+
Rails.cache.read('ipsum').should == 'lorem'
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
describe "Activerecord integration" do
|
27
|
+
it "object change" do
|
28
|
+
Rails.cache.write('key', 'value', :depends_on => [@page_object])
|
29
|
+
|
30
|
+
Rails.cache.read('key').should == 'value'
|
31
|
+
|
32
|
+
#save should trigger deleting depending cache entries
|
33
|
+
@page_object.name = @page_object.name.to_s + '1'
|
34
|
+
@page_object.save!
|
35
|
+
|
36
|
+
Rails.cache.read('key').should be_nil
|
37
|
+
end
|
38
|
+
|
39
|
+
it "model change" do
|
40
|
+
Rails.cache.write('lorem', 'impsum', :depends_on => [Page])
|
41
|
+
|
42
|
+
Rails.cache.read('lorem').should == 'impsum'
|
43
|
+
|
44
|
+
Page.create
|
45
|
+
|
46
|
+
Rails.cache.read('lorem').should be_nil
|
47
|
+
end
|
48
|
+
|
49
|
+
pending "scope change" do
|
50
|
+
it "should not drop if changes are unrelated" do
|
51
|
+
Rails.cache.write('lorem', 'impsum', :depends_on => [Page.where(:name => 'bob')])
|
52
|
+
Rails.cache.read('lorem').should == 'impsum'
|
53
|
+
|
54
|
+
page = Page.create(:name => 'jack')
|
55
|
+
page.name = 'alice'
|
56
|
+
page.save!
|
57
|
+
Page.delete(page.id)
|
58
|
+
|
59
|
+
Rails.cache.read('lorem').should == 'impsum'
|
60
|
+
end
|
61
|
+
|
62
|
+
it "should drop if object has been in scope before changes" do
|
63
|
+
page = Page.create(:name => 'jack')
|
64
|
+
|
65
|
+
Rails.cache.write('lorem', 'impsum', :depends_on => [Page.where(:name => 'jack')])
|
66
|
+
Rails.cache.read('lorem').should == 'impsum'
|
67
|
+
|
68
|
+
page.name = 'alice'
|
69
|
+
page.save!
|
70
|
+
|
71
|
+
Rails.cache.read('lorem').should be_nil
|
72
|
+
end
|
73
|
+
|
74
|
+
it "should drop if object is now in scope" do
|
75
|
+
page = Page.create(:name => 'joe')
|
76
|
+
|
77
|
+
Rails.cache.write('lorem', 'impsum', :depends_on => [Page.where(:name => 'jack')])
|
78
|
+
Rails.cache.read('lorem').should == 'impsum'
|
79
|
+
|
80
|
+
page.name = 'jack'
|
81
|
+
page.save!
|
82
|
+
|
83
|
+
Rails.cache.read('lorem').should be_nil
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
@@ -12,11 +12,10 @@ describe TaggableCache::Store do
|
|
12
12
|
before :all do
|
13
13
|
@object = TaggableCache::Store.new
|
14
14
|
@redis = Redis.new
|
15
|
-
#clean up all redis data
|
16
15
|
@redis.flushall
|
17
16
|
end
|
18
17
|
|
19
|
-
describe "
|
18
|
+
describe "id_for" do
|
20
19
|
it "should use id and model name if saved activerecord object" do
|
21
20
|
page = Page.create
|
22
21
|
@object.id_for(page).should == "page-#{page.id}"
|
@@ -35,45 +34,47 @@ describe TaggableCache::Store do
|
|
35
34
|
end
|
36
35
|
end
|
37
36
|
|
38
|
-
describe "
|
39
|
-
|
40
|
-
|
41
|
-
|
37
|
+
describe "Redis interaction" do
|
38
|
+
describe "add data" do
|
39
|
+
it "should push data" do
|
40
|
+
o1 = Object.new
|
41
|
+
o2 = Object.new
|
42
42
|
|
43
|
-
|
44
|
-
|
45
|
-
|
43
|
+
@object.should_receive(:id_for).with(o1).and_return('member1')
|
44
|
+
@object.should_receive(:id_for).with(o2).and_return('member2')
|
45
|
+
@object.should_receive(:id_for).with(nil).and_return(nil)
|
46
46
|
|
47
|
-
|
47
|
+
@object.add('tag_name', o1, nil, o2)
|
48
48
|
|
49
|
-
|
50
|
-
|
51
|
-
|
49
|
+
@redis.smembers(nil).should == []
|
50
|
+
@redis.smembers('member1').should == ['tag_name']
|
51
|
+
@redis.smembers('member2').should == ['tag_name']
|
52
|
+
end
|
52
53
|
end
|
53
|
-
end
|
54
54
|
|
55
|
-
|
56
|
-
|
57
|
-
|
55
|
+
describe "get data" do
|
56
|
+
it "should return keys and leave nothing behind" do
|
57
|
+
page = Page.create
|
58
58
|
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
59
|
+
@object.add('tag_name', page)
|
60
|
+
@redis.smembers("page-#{page.id}").should == ['tag_name']
|
61
|
+
|
62
|
+
@object.get(page).should == ['tag_name']
|
63
|
+
@redis.smembers("page-#{page.id}").should be_empty
|
64
|
+
end
|
65
65
|
|
66
|
-
|
67
|
-
|
66
|
+
it "should do multi-get" do
|
67
|
+
page = Page.create
|
68
68
|
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
69
|
+
@object.add('tag_name', page)
|
70
|
+
@object.add('tag2', Page)
|
71
|
+
@redis.smembers("page-#{page.id}").should == ['tag_name']
|
72
|
+
@redis.smembers("page").should == ['tag2']
|
73
|
+
|
74
|
+
@object.get(page, Page).should == ['tag_name', 'tag2']
|
75
|
+
@redis.smembers("page-#{page.id}").should be_empty
|
76
|
+
@redis.smembers("page").should be_empty
|
77
|
+
end
|
77
78
|
end
|
78
79
|
end
|
79
80
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: taggable_cache
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -13,7 +13,7 @@ date: 2012-02-09 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
16
|
-
requirement: &
|
16
|
+
requirement: &81044650 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: 3.0.8
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *81044650
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: redis
|
27
|
-
requirement: &
|
27
|
+
requirement: &81044090 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,7 +32,7 @@ dependencies:
|
|
32
32
|
version: 2.2.2
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *81044090
|
36
36
|
description: This gem simplifies cache expiration in rails
|
37
37
|
email: brain-geek@yandex.ua
|
38
38
|
executables: []
|
@@ -48,23 +48,23 @@ files:
|
|
48
48
|
- LICENSE.txt
|
49
49
|
- README.rdoc
|
50
50
|
- Rakefile
|
51
|
+
- gemfiles/Gemfile-rails.3.0.x
|
52
|
+
- gemfiles/Gemfile-rails.3.1.x
|
53
|
+
- gemfiles/Gemfile-rails.3.2.x
|
51
54
|
- lib/taggable_cache.rb
|
52
|
-
- lib/taggable_cache/rails/observer.rb
|
53
55
|
- lib/taggable_cache/railtie.rb
|
56
|
+
- lib/taggable_cache/spectator.rb
|
54
57
|
- lib/taggable_cache/store.rb
|
55
58
|
- lib/taggable_cache/version.rb
|
59
|
+
- spec/integration/rails_cache_spec.rb
|
56
60
|
- spec/internal/app/controller/action_caching_controller.rb
|
57
61
|
- spec/internal/app/controller/fragment_caching_controller.rb
|
58
62
|
- spec/internal/app/models/page.rb
|
59
|
-
- spec/internal/app/models/simple_observer.rb
|
60
63
|
- spec/internal/app/views/fragment_caching/index.html.erb
|
61
64
|
- spec/internal/config/database.yml
|
62
|
-
- spec/internal/config/initializers/taggable.rb
|
63
65
|
- spec/internal/config/routes.rb
|
64
66
|
- spec/internal/db/schema.rb
|
65
67
|
- spec/internal/public/favicon.ico
|
66
|
-
- spec/models/page_spec.rb
|
67
|
-
- spec/rails_cache_spec.rb
|
68
68
|
- spec/requests/action_caching_controller_spec.rb
|
69
69
|
- spec/requests/fragment_caching_controller_spec.rb
|
70
70
|
- spec/spec_helper.rb
|
@@ -85,7 +85,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
85
85
|
version: '0'
|
86
86
|
segments:
|
87
87
|
- 0
|
88
|
-
hash: -
|
88
|
+
hash: -685870733
|
89
89
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
90
90
|
none: false
|
91
91
|
requirements:
|
@@ -94,10 +94,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
94
94
|
version: '0'
|
95
95
|
segments:
|
96
96
|
- 0
|
97
|
-
hash: -
|
97
|
+
hash: -685870733
|
98
98
|
requirements: []
|
99
99
|
rubyforge_project:
|
100
|
-
rubygems_version: 1.8.
|
100
|
+
rubygems_version: 1.8.10
|
101
101
|
signing_key:
|
102
102
|
specification_version: 3
|
103
103
|
summary: This gem simplifies cache expiration in rails by providing depends_on option
|
data/spec/models/page_spec.rb
DELETED
data/spec/rails_cache_spec.rb
DELETED
@@ -1,51 +0,0 @@
|
|
1
|
-
require File.join(File.dirname(__FILE__), 'spec_helper.rb')
|
2
|
-
|
3
|
-
describe 'TaggableCache::Rails::Cache' do
|
4
|
-
before :all do
|
5
|
-
@object = TaggableCache::Store.new
|
6
|
-
Redis.new.flushall
|
7
|
-
@page_object = Page.create
|
8
|
-
end
|
9
|
-
|
10
|
-
before :each do
|
11
|
-
Rails.cache.delete 'key'
|
12
|
-
Rails.cache.delete 'lorem'
|
13
|
-
end
|
14
|
-
|
15
|
-
describe "taggable hooked on Rails.cache.write" do
|
16
|
-
it "adds key to store" do
|
17
|
-
Rails.cache.write('key', 'value', :depends_on => [@page_object])
|
18
|
-
|
19
|
-
@object.get(@page_object).should == ['key']
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
describe "taggable hooked as observer" do
|
24
|
-
it "detects object change" do
|
25
|
-
Rails.cache.write('key', 'value', :depends_on => [@page_object])
|
26
|
-
|
27
|
-
Rails.cache.read('key').should == 'value'
|
28
|
-
|
29
|
-
#save should trigger deleting depending cache entries
|
30
|
-
@page_object.name = @page_object.name.to_s + '1'
|
31
|
-
@page_object.save!
|
32
|
-
|
33
|
-
Rails.cache.read('key').should be_nil
|
34
|
-
end
|
35
|
-
|
36
|
-
it "detects model change" do
|
37
|
-
Rails.cache.write('lorem', 'impsum', :depends_on => [Page])
|
38
|
-
|
39
|
-
Rails.cache.read('lorem').should == 'impsum'
|
40
|
-
|
41
|
-
Page.create
|
42
|
-
|
43
|
-
Rails.cache.read('lorem').should be_nil
|
44
|
-
end
|
45
|
-
|
46
|
-
it "does simple writes" do
|
47
|
-
Rails.cache.write 'ipsum', 'lorem'
|
48
|
-
Rails.cache.read('ipsum').should == 'lorem'
|
49
|
-
end
|
50
|
-
end
|
51
|
-
end
|