cacheable_flash 0.2.2 → 0.2.3
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +5 -5
- data/CHANGES +42 -36
- data/Gemfile +20 -17
- data/Gemfile.lock +121 -82
- data/LICENSE.txt +21 -21
- data/README.rdoc +158 -159
- data/Rakefile +54 -54
- data/VERSION +1 -1
- data/cacheable_flash.gemspec +15 -18
- data/init.rb +6 -6
- data/install.rb +18 -18
- data/lib/cacheable_flash.rb +39 -38
- data/lib/cacheable_flash/rails/engine.rb +8 -13
- data/lib/cacheable_flash/rails/railtie.rb +14 -14
- data/lib/generators/cacheable_flash/install/install_generator.rb +23 -23
- data/spec/cacheable_flash/cacheable_flash_spec.rb +105 -101
- data/spec/cacheable_flash/install_spec.rb +68 -68
- data/spec/cacheable_flash/test_helpers_spec.rb +37 -36
- data/spec/js_unit/cookie_test.html +60 -60
- data/spec/js_unit/flash_test.html +112 -112
- data/spec/spec_helper.rb +20 -20
- data/spec/support/test_helpers.rb +10 -10
- data/tasks/cacheable_flash_tasks.rake +3 -3
- data/vendor/assets/javascripts/flash.js +21 -21
- data/vendor/assets/javascripts/jquery.cookie.js +91 -91
- metadata +26 -37
data/.document
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
-
lib/**/*.rb
|
2
|
-
bin/*
|
3
|
-
-
|
4
|
-
features/**/*.feature
|
5
|
-
LICENSE.txt
|
1
|
+
lib/**/*.rb
|
2
|
+
bin/*
|
3
|
+
-
|
4
|
+
features/**/*.feature
|
5
|
+
LICENSE.txt
|
data/CHANGES
CHANGED
@@ -1,36 +1,42 @@
|
|
1
|
-
0.2.
|
2
|
-
-
|
3
|
-
-
|
4
|
-
|
5
|
-
0
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
-
|
10
|
-
|
11
|
-
|
12
|
-
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
-
|
18
|
-
|
19
|
-
0
|
20
|
-
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
1
|
+
0.2.3 - JAN.13.2012
|
2
|
+
- Fixed problems loading assets: Sprockets::FileNotFound - thanks jlxw
|
3
|
+
- reflect move back to pivotal's repo in README.
|
4
|
+
- Updated specs, to running and passing condition!
|
5
|
+
- Made rails > 3.0 a dependency, since it is (uses ::Rails::Engine and :Rails::Railtie)
|
6
|
+
|
7
|
+
0.2.2
|
8
|
+
- Improved deprecation warnings about using the generator (not needed with asset pipeline)
|
9
|
+
- Improved README setup instructions
|
10
|
+
|
11
|
+
0.2.1
|
12
|
+
- Fixed bug in generator for those not using asset pipeline, or pre Rails 3.1
|
13
|
+
|
14
|
+
0.2.0 [Peter Boling begins gemification process]
|
15
|
+
- Converted to a gem
|
16
|
+
- Updated to improved, patched jquery.cookie from https://github.com/pboling/jquery-cookie
|
17
|
+
- Merged a few other forks of cacheable-flash
|
18
|
+
- Added Engine to hook into Rails 3.1 asset pipeline
|
19
|
+
- Added Railtie to improve usability with Rails 3.0
|
20
|
+
- Added Generator to improve usability with Rails < 3
|
21
|
+
|
22
|
+
Unreleased
|
23
|
+
- Implicitly adding js files to Rails include defaults (Patch from Michael Erb)
|
24
|
+
|
25
|
+
0.1.5
|
26
|
+
- Requiring version >= 1.1.2 of the json gem
|
27
|
+
- Converted tests into specs
|
28
|
+
|
29
|
+
0.1.4
|
30
|
+
- Added TestHelpers
|
31
|
+
- Added flash_cookie method for tests
|
32
|
+
|
33
|
+
0.1.3
|
34
|
+
- Require json in init.rb
|
35
|
+
|
36
|
+
0.1.2
|
37
|
+
- Flash on the Rails side is cleared when written to the cookie
|
38
|
+
- Uses existing cookie flash value
|
39
|
+
- Using Scriptaculous cookie.js library
|
40
|
+
|
41
|
+
0.1.1
|
42
|
+
- Added cookies.js
|
data/Gemfile
CHANGED
@@ -1,17 +1,20 @@
|
|
1
|
-
source "http://rubygems.org"
|
2
|
-
|
3
|
-
|
4
|
-
#We don't really need all of rails... so:
|
5
|
-
|
6
|
-
|
7
|
-
gem "
|
8
|
-
|
9
|
-
#
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
gem "
|
15
|
-
gem "
|
16
|
-
gem "
|
17
|
-
|
1
|
+
source "http://rubygems.org"
|
2
|
+
|
3
|
+
gem "rails", "> 3.0"
|
4
|
+
#We don't really need all of rails... so:
|
5
|
+
# Actually we do now that we have rails engine and rails railtie
|
6
|
+
# TODO: Investigate making a rails free version
|
7
|
+
#gem "activesupport"
|
8
|
+
#gem "activemodel"
|
9
|
+
#gem "actionpack"
|
10
|
+
gem "json"
|
11
|
+
|
12
|
+
# Develop dependencies (everything needed to run rake, tests, features, etc.)
|
13
|
+
group :development do
|
14
|
+
gem "rspec", "~> 2.8.0"
|
15
|
+
gem "yard", "~> 0.7.4"
|
16
|
+
gem "bundler", "~> 1.0.21"
|
17
|
+
gem "jeweler", "~> 1.6.4"
|
18
|
+
gem "reek", "~> 1.2.8"
|
19
|
+
gem "roodi", "~> 2.1.0"
|
20
|
+
end
|
data/Gemfile.lock
CHANGED
@@ -1,82 +1,121 @@
|
|
1
|
-
GEM
|
2
|
-
remote: http://rubygems.org/
|
3
|
-
specs:
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
rack
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
1
|
+
GEM
|
2
|
+
remote: http://rubygems.org/
|
3
|
+
specs:
|
4
|
+
actionmailer (3.1.3)
|
5
|
+
actionpack (= 3.1.3)
|
6
|
+
mail (~> 2.3.0)
|
7
|
+
actionpack (3.1.3)
|
8
|
+
activemodel (= 3.1.3)
|
9
|
+
activesupport (= 3.1.3)
|
10
|
+
builder (~> 3.0.0)
|
11
|
+
erubis (~> 2.7.0)
|
12
|
+
i18n (~> 0.6)
|
13
|
+
rack (~> 1.3.5)
|
14
|
+
rack-cache (~> 1.1)
|
15
|
+
rack-mount (~> 0.8.2)
|
16
|
+
rack-test (~> 0.6.1)
|
17
|
+
sprockets (~> 2.0.3)
|
18
|
+
activemodel (3.1.3)
|
19
|
+
activesupport (= 3.1.3)
|
20
|
+
builder (~> 3.0.0)
|
21
|
+
i18n (~> 0.6)
|
22
|
+
activerecord (3.1.3)
|
23
|
+
activemodel (= 3.1.3)
|
24
|
+
activesupport (= 3.1.3)
|
25
|
+
arel (~> 2.2.1)
|
26
|
+
tzinfo (~> 0.3.29)
|
27
|
+
activeresource (3.1.3)
|
28
|
+
activemodel (= 3.1.3)
|
29
|
+
activesupport (= 3.1.3)
|
30
|
+
activesupport (3.1.3)
|
31
|
+
multi_json (~> 1.0)
|
32
|
+
arel (2.2.1)
|
33
|
+
builder (3.0.0)
|
34
|
+
diff-lcs (1.1.3)
|
35
|
+
erubis (2.7.0)
|
36
|
+
git (1.2.5)
|
37
|
+
hike (1.2.1)
|
38
|
+
i18n (0.6.0)
|
39
|
+
jeweler (1.6.4)
|
40
|
+
bundler (~> 1.0)
|
41
|
+
git (>= 1.2.5)
|
42
|
+
rake
|
43
|
+
json (1.6.4)
|
44
|
+
mail (2.3.0)
|
45
|
+
i18n (>= 0.4.0)
|
46
|
+
mime-types (~> 1.16)
|
47
|
+
treetop (~> 1.4.8)
|
48
|
+
mime-types (1.17.2)
|
49
|
+
multi_json (1.0.4)
|
50
|
+
polyglot (0.3.3)
|
51
|
+
rack (1.3.6)
|
52
|
+
rack-cache (1.1)
|
53
|
+
rack (>= 0.4)
|
54
|
+
rack-mount (0.8.3)
|
55
|
+
rack (>= 1.0.0)
|
56
|
+
rack-ssl (1.3.2)
|
57
|
+
rack
|
58
|
+
rack-test (0.6.1)
|
59
|
+
rack (>= 1.0)
|
60
|
+
rails (3.1.3)
|
61
|
+
actionmailer (= 3.1.3)
|
62
|
+
actionpack (= 3.1.3)
|
63
|
+
activerecord (= 3.1.3)
|
64
|
+
activeresource (= 3.1.3)
|
65
|
+
activesupport (= 3.1.3)
|
66
|
+
bundler (~> 1.0)
|
67
|
+
railties (= 3.1.3)
|
68
|
+
railties (3.1.3)
|
69
|
+
actionpack (= 3.1.3)
|
70
|
+
activesupport (= 3.1.3)
|
71
|
+
rack-ssl (~> 1.3.2)
|
72
|
+
rake (>= 0.8.7)
|
73
|
+
rdoc (~> 3.4)
|
74
|
+
thor (~> 0.14.6)
|
75
|
+
rake (0.9.2.2)
|
76
|
+
rdoc (3.12)
|
77
|
+
json (~> 1.4)
|
78
|
+
reek (1.2.8)
|
79
|
+
ruby2ruby (~> 1.2)
|
80
|
+
ruby_parser (~> 2.0)
|
81
|
+
sexp_processor (~> 3.0)
|
82
|
+
roodi (2.1.0)
|
83
|
+
ruby_parser
|
84
|
+
rspec (2.8.0)
|
85
|
+
rspec-core (~> 2.8.0)
|
86
|
+
rspec-expectations (~> 2.8.0)
|
87
|
+
rspec-mocks (~> 2.8.0)
|
88
|
+
rspec-core (2.8.0)
|
89
|
+
rspec-expectations (2.8.0)
|
90
|
+
diff-lcs (~> 1.1.2)
|
91
|
+
rspec-mocks (2.8.0)
|
92
|
+
ruby2ruby (1.3.1)
|
93
|
+
ruby_parser (~> 2.0)
|
94
|
+
sexp_processor (~> 3.0)
|
95
|
+
ruby_parser (2.3.1)
|
96
|
+
sexp_processor (~> 3.0)
|
97
|
+
sexp_processor (3.0.10)
|
98
|
+
sprockets (2.0.3)
|
99
|
+
hike (~> 1.2)
|
100
|
+
rack (~> 1.0)
|
101
|
+
tilt (~> 1.1, != 1.3.0)
|
102
|
+
thor (0.14.6)
|
103
|
+
tilt (1.3.3)
|
104
|
+
treetop (1.4.10)
|
105
|
+
polyglot
|
106
|
+
polyglot (>= 0.3.1)
|
107
|
+
tzinfo (0.3.31)
|
108
|
+
yard (0.7.4)
|
109
|
+
|
110
|
+
PLATFORMS
|
111
|
+
ruby
|
112
|
+
|
113
|
+
DEPENDENCIES
|
114
|
+
bundler (~> 1.0.21)
|
115
|
+
jeweler (~> 1.6.4)
|
116
|
+
json
|
117
|
+
rails (> 3.0)
|
118
|
+
reek (~> 1.2.8)
|
119
|
+
roodi (~> 2.1.0)
|
120
|
+
rspec (~> 2.8.0)
|
121
|
+
yard (~> 0.7.4)
|
data/LICENSE.txt
CHANGED
@@ -1,21 +1,21 @@
|
|
1
|
-
Copyright (c) 2007-2010 Pivotal Labs
|
2
|
-
Copyright (c) 2011 Peter H. Boling (http://peterboling.com)
|
3
|
-
|
4
|
-
Permission is hereby granted, free of charge, to any person obtaining
|
5
|
-
a copy of this software and associated documentation files (the
|
6
|
-
"Software"), to deal in the Software without restriction, including
|
7
|
-
without limitation the rights to use, copy, modify, merge, publish,
|
8
|
-
distribute, sublicense, and/or sell copies of the Software, and to
|
9
|
-
permit persons to whom the Software is furnished to do so, subject to
|
10
|
-
the following conditions:
|
11
|
-
|
12
|
-
The above copyright notice and this permission notice shall be
|
13
|
-
included in all copies or substantial portions of the Software.
|
14
|
-
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
16
|
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
17
|
-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
18
|
-
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
19
|
-
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
20
|
-
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
21
|
-
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
1
|
+
Copyright (c) 2007-2010 Pivotal Labs
|
2
|
+
Copyright (c) 2011 Peter H. Boling (http://peterboling.com)
|
3
|
+
|
4
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
5
|
+
a copy of this software and associated documentation files (the
|
6
|
+
"Software"), to deal in the Software without restriction, including
|
7
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
8
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
9
|
+
permit persons to whom the Software is furnished to do so, subject to
|
10
|
+
the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be
|
13
|
+
included in all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
16
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
17
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
18
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
19
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
20
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
21
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
CHANGED
@@ -1,159 +1,158 @@
|
|
1
|
-
CacheableFlash
|
2
|
-
==============
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
//= require
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
to
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
<div id="
|
88
|
-
<
|
89
|
-
|
90
|
-
Flash.
|
91
|
-
Flash.writeDataTo('
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
@
|
113
|
-
@
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
* Check out the
|
144
|
-
*
|
145
|
-
*
|
146
|
-
*
|
147
|
-
*
|
148
|
-
*
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
Copyright (c)
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
1
|
+
CacheableFlash
|
2
|
+
==============
|
3
|
+
|
4
|
+
cacheable-flash > v0.2 (organized by Peter Boling from many of the community forks)
|
5
|
+
aims to be a drop-in replacement for the original cacheable-flash v0.1 (by Pivotal)
|
6
|
+
but uses JQuery instead of Prototype. The idea was to merge forks to collect the best features and improvements.
|
7
|
+
It has also been made compatible with Rails 3, hooked into the asset pipeline for rails 3.1, and turned into a gem.
|
8
|
+
|
9
|
+
== Installation as plugin
|
10
|
+
|
11
|
+
ruby script/plugin install git://github.com/pivotal/cacheable-flash.git
|
12
|
+
|
13
|
+
== Installation as gem
|
14
|
+
|
15
|
+
gem install 'cacheable_flash'
|
16
|
+
|
17
|
+
add to your Gemfile:
|
18
|
+
gem 'cacheable_flash'
|
19
|
+
|
20
|
+
== Setup
|
21
|
+
|
22
|
+
=== Without asset pipeline, or pre-Rails 3.1:
|
23
|
+
|
24
|
+
First copy the JS assets into your app:
|
25
|
+
rails generate cacheable_flash:install
|
26
|
+
|
27
|
+
CacheableFlash adds its javascript dependencies as a Rails 3 javascript 'expansion',
|
28
|
+
which are only used if you are NOT using the asset pipeline (apparently?).
|
29
|
+
|
30
|
+
So if you have config.assets.enabled = false in application.rb then in your layout:
|
31
|
+
javascript_include_tag :cacheable_flash
|
32
|
+
|
33
|
+
Otherwise, in your layout, just source them like normal:
|
34
|
+
javascript_include_tag 'flash', 'jquery.cookie'
|
35
|
+
|
36
|
+
=== With asset pipeline (requires Rails 3.1)
|
37
|
+
|
38
|
+
The asset pipeline should have access to the assets in this gem via your app/assets/javascripts/application.js:
|
39
|
+
//= require flash
|
40
|
+
//= require jquery.cookie
|
41
|
+
|
42
|
+
== Description
|
43
|
+
|
44
|
+
This plugin enables greater levels of page caching by rendering flash
|
45
|
+
messages from a cookie using JavaScript, instead of in your Rails
|
46
|
+
view template. Flash contents are converted to JSON and placed in
|
47
|
+
a cookie by an after_filter in a controller.
|
48
|
+
|
49
|
+
== Mailing List
|
50
|
+
|
51
|
+
http://groups.google.com/group/PivotalLabsOpenSource
|
52
|
+
*This mailing list is for the original CacheableFlash, and may not be able to help with issues with this gem.
|
53
|
+
|
54
|
+
== Bug/Feature Tracker
|
55
|
+
|
56
|
+
https://github.com/pivotal/cacheable-flash/issues
|
57
|
+
|
58
|
+
== Wiki
|
59
|
+
|
60
|
+
Please help document!
|
61
|
+
|
62
|
+
https://github.com/pivotal/cacheable-flash/wiki
|
63
|
+
|
64
|
+
=== Usage
|
65
|
+
|
66
|
+
To use, include the CacheableFlash module in your controller.
|
67
|
+
It's all or none on the actions in your controller, so you can't
|
68
|
+
mix JS and HTML display of your flash message in a controller.
|
69
|
+
No other modifications to the controller are needed. You will need
|
70
|
+
to add divs and some javascript to your view or layout templates
|
71
|
+
to render the flash in the browser.
|
72
|
+
|
73
|
+
Note that the cookie holding the flash messages is removed as the
|
74
|
+
page is displayed, so a refresh will clear the flash message (just
|
75
|
+
as happens normally).
|
76
|
+
|
77
|
+
=== Example Controller
|
78
|
+
|
79
|
+
class MyController < ActionController::Base
|
80
|
+
include CacheableFlash
|
81
|
+
# ...
|
82
|
+
end
|
83
|
+
|
84
|
+
=== Example Template Markup
|
85
|
+
|
86
|
+
<div id="error_div_id" class="flash flash_error"></div>
|
87
|
+
<div id="notice_div_id" class="flash flash_notice"></div>
|
88
|
+
<script type="text/javascript">
|
89
|
+
Flash.transferFromCookies();
|
90
|
+
Flash.writeDataTo('error', $('#error_div_id'));
|
91
|
+
Flash.writeDataTo('notice', $('#notice_div_id'));
|
92
|
+
</script>
|
93
|
+
|
94
|
+
== Testing
|
95
|
+
You can test your flash cookies by making assertions on the json of the "flash" cookie.
|
96
|
+
Cacheable Flash provides test helpers which includes the flash_cookie method.
|
97
|
+
|
98
|
+
=== Test::Unit Example
|
99
|
+
require "cacheable_flash/test_helpers"
|
100
|
+
|
101
|
+
class TestController < ActionController::Base
|
102
|
+
def index
|
103
|
+
flash["notice"] = "In index"
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
class ControllerTest < Test::Unit::TestCase
|
108
|
+
include CacheableFlash::TestHelpers
|
109
|
+
|
110
|
+
def setup
|
111
|
+
@controller = TestController.new
|
112
|
+
@request = ActionController::TestRequest.new
|
113
|
+
@response = ActionController::TestResponse.new
|
114
|
+
end
|
115
|
+
|
116
|
+
def test_cacheable_flash_action
|
117
|
+
get :index
|
118
|
+
asset_equal "In index", flash_cookie["notice"]
|
119
|
+
end
|
120
|
+
end
|
121
|
+
|
122
|
+
=== Rspec Example
|
123
|
+
require "cacheable_flash/test_helpers"
|
124
|
+
|
125
|
+
class TestController < ActionController::Base
|
126
|
+
def index
|
127
|
+
flash["notice"] = "In index"
|
128
|
+
end
|
129
|
+
end
|
130
|
+
|
131
|
+
describe TestController, "#index" do
|
132
|
+
include CacheableFlash::TestHelpers
|
133
|
+
|
134
|
+
it "writes to the flash cookie" do
|
135
|
+
get :index
|
136
|
+
flash_cookie["notice"].should == "In index"
|
137
|
+
end
|
138
|
+
end
|
139
|
+
|
140
|
+
== Contributing to cacheable-flash
|
141
|
+
|
142
|
+
* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
|
143
|
+
* Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
|
144
|
+
* Fork the project
|
145
|
+
* Start a feature/bugfix branch
|
146
|
+
* Commit and push until you are happy with your contribution
|
147
|
+
* Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
|
148
|
+
* Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
|
149
|
+
|
150
|
+
== Copyright
|
151
|
+
|
152
|
+
Licensed under the MIT License.
|
153
|
+
|
154
|
+
Copyright (c) 2011-2012 Peter H. Boling (http://peterboling.com). See LICENSE.txt (MIT license) for further details.
|
155
|
+
Copyright (c) 2007-2010 Pivotal Labs
|
156
|
+
|
157
|
+
|
158
|
+
|