cacheable_flash 0.2.8 → 0.2.9
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/{CHANGES → CHANGELOG} +5 -0
- data/lib/cacheable_flash/railtie.rb +1 -1
- data/{spec/support → lib/cacheable_flash}/test_helpers.rb +2 -2
- data/lib/cacheable_flash/version.rb +1 -1
- data/spec/cacheable_flash/test_helpers_spec.rb +40 -36
- data/spec/controllers/dummy_controller_spec.rb +19 -12
- data/spec/dummy/app/controllers/dummy_controller.rb +1 -0
- data/spec/spec_helper.rb +1 -1
- data/vendor/assets/javascripts/jquery.cookie.js +37 -81
- metadata +3 -10
- data/app/assets/images/cacheable_flash/.gitkeep +0 -0
- data/app/assets/javascripts/cacheable_flash/application.js +0 -15
- data/app/assets/stylesheets/cacheable_flash/application.css +0 -13
- data/app/controllers/cacheable_flash/application_controller.rb +0 -5
- data/app/helpers/cacheable_flash/application_helper.rb +0 -4
- data/app/views/layouts/cacheable_flash/application.html.erb +0 -14
data/{CHANGES → CHANGELOG}
RENAMED
@@ -1,3 +1,8 @@
|
|
1
|
+
0.2.9 - AUG.08.2012
|
2
|
+
- More rearranging
|
3
|
+
- Improved integration test of CacheableFlash & CacheableFlash::TestHelpers
|
4
|
+
- Updated to latest jquery.cookie
|
5
|
+
|
1
6
|
0.2.8 - AUG.07.2012
|
2
7
|
- switch from jeweler to gem-release for bumping and tagging
|
3
8
|
- bundler update (1.0.24)
|
@@ -3,7 +3,7 @@ module CacheableFlash
|
|
3
3
|
class Railtie < ::Rails::Railtie
|
4
4
|
if ::Rails::VERSION::MAJOR == 3
|
5
5
|
config.before_configuration do
|
6
|
-
config.action_view.javascript_expansions[:cacheable_flash] = %w(
|
6
|
+
config.action_view.javascript_expansions[:cacheable_flash] = %w(jquery.cookie flash)
|
7
7
|
end
|
8
8
|
end
|
9
9
|
end
|
@@ -1,36 +1,40 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
#
|
5
|
-
#
|
6
|
-
#
|
7
|
-
#
|
8
|
-
#
|
9
|
-
#
|
10
|
-
#
|
11
|
-
#
|
12
|
-
# controller
|
13
|
-
#
|
14
|
-
# @
|
15
|
-
#
|
16
|
-
#
|
17
|
-
#
|
18
|
-
#
|
19
|
-
#
|
20
|
-
#
|
21
|
-
#
|
22
|
-
#
|
23
|
-
#
|
24
|
-
#
|
25
|
-
#
|
26
|
-
#
|
27
|
-
#
|
28
|
-
#
|
29
|
-
#
|
30
|
-
#
|
31
|
-
#
|
32
|
-
#
|
33
|
-
#
|
34
|
-
#
|
35
|
-
#
|
36
|
-
#
|
1
|
+
## Testing the cookie is now notoriously difficult, and entirely undocumented for Rails 3.2:
|
2
|
+
## https://www.relishapp.com/rspec/rspec-rails/docs/controller-specs/cookies
|
3
|
+
## CacheableFlash::TestHelpers is now integration tested in the controllers/dummy_controller_spec.rb
|
4
|
+
#
|
5
|
+
#require 'spec_helper'
|
6
|
+
#
|
7
|
+
#module CacheableFlash
|
8
|
+
# describe TestHelpers do
|
9
|
+
# attr_reader :controller, :request, :response, :flash, :cookies
|
10
|
+
# include TestHelpers
|
11
|
+
# before do
|
12
|
+
# @controller = ActionController::Base.new
|
13
|
+
# @request = ActionDispatch::TestRequest.new
|
14
|
+
# @response = ActionDispatch::TestResponse.new
|
15
|
+
# controller.send(:initialize_template_class, response)
|
16
|
+
# controller.send(:assign_shortcuts, request, response)
|
17
|
+
#
|
18
|
+
# @flash = controller.send(:flash)
|
19
|
+
# class << controller
|
20
|
+
# include CacheableFlash
|
21
|
+
# end
|
22
|
+
# end
|
23
|
+
#
|
24
|
+
# describe "#flash_cookie" do
|
25
|
+
# it "returns the flash hash send as a cookie" do
|
26
|
+
# expected_flash = {
|
27
|
+
# 'errors' => "This is an Error",
|
28
|
+
# 'notice' => "This is a Notice"
|
29
|
+
# }
|
30
|
+
# flash['errors'] = expected_flash['errors']
|
31
|
+
# flash['notice'] = expected_flash['notice']
|
32
|
+
#
|
33
|
+
# controller.write_flash_to_cookie
|
34
|
+
# @cookies = response.cookies # simulate setting the cookie instance variable in rails tests
|
35
|
+
#
|
36
|
+
# flash_cookie.should == expected_flash
|
37
|
+
# end
|
38
|
+
# end
|
39
|
+
# end
|
40
|
+
#end
|
@@ -1,19 +1,26 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe DummyController do
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
4
|
+
|
5
|
+
include CacheableFlash::TestHelpers
|
6
|
+
|
7
|
+
render_views
|
8
|
+
|
9
|
+
before(:each) do
|
10
|
+
@expected_flash = {
|
11
|
+
'errors' => "This is an Error",
|
12
|
+
'notice' => "This is a Notice"
|
13
|
+
}
|
14
|
+
get :index
|
15
|
+
end
|
16
|
+
|
17
|
+
describe "TestHelpers" do
|
18
|
+
it "should assign flashes to cookie" do
|
19
|
+
flash_cookie['errors'].should == @expected_flash['errors']
|
20
|
+
flash_cookie['notice'].should == @expected_flash['notice']
|
21
|
+
flash_cookie.should == @expected_flash
|
16
22
|
end
|
17
23
|
end
|
24
|
+
|
18
25
|
end
|
19
26
|
|
data/spec/spec_helper.rb
CHANGED
@@ -16,7 +16,7 @@ require 'cacheable_flash'
|
|
16
16
|
#$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
17
17
|
#$LOAD_PATH.unshift(File.dirname(__FILE__))
|
18
18
|
|
19
|
-
require '
|
19
|
+
require 'cacheable_flash/test_helpers'
|
20
20
|
|
21
21
|
# Requires supporting files with custom matchers and macros, etc,
|
22
22
|
# in ./support/ and its subdirectories.
|
@@ -1,91 +1,47 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
* jQuery Cookie plugin
|
1
|
+
/*!
|
2
|
+
* jQuery Cookie Plugin
|
3
|
+
* https://github.com/carhartl/jquery-cookie
|
5
4
|
*
|
6
|
-
* Copyright
|
7
|
-
* Dual licensed under the MIT
|
5
|
+
* Copyright 2011, Klaus Hartl
|
6
|
+
* Dual licensed under the MIT or GPL Version 2 licenses.
|
8
7
|
* http://www.opensource.org/licenses/mit-license.php
|
9
|
-
* http://www.
|
10
|
-
*
|
8
|
+
* http://www.opensource.org/licenses/GPL-2.0
|
11
9
|
*/
|
10
|
+
(function($) {
|
11
|
+
$.cookie = function(key, value, options) {
|
12
12
|
|
13
|
-
//
|
13
|
+
// key and at least value given, set cookie...
|
14
|
+
if (arguments.length > 1 && (!/Object/.test(Object.prototype.toString.call(value)) || value === null || value === undefined)) {
|
15
|
+
options = $.extend({}, options);
|
14
16
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
* @example $.cookie('the_cookie', 'the_value');
|
19
|
-
* @desc Set the value of a cookie.
|
20
|
-
* @example $.cookie('the_cookie', 'the_value', { expires: 7, path: '/', domain: 'jquery.com', secure: true });
|
21
|
-
* @desc Create a cookie with all available options.
|
22
|
-
* @example $.cookie('the_cookie', 'the_value');
|
23
|
-
* @desc Create a session cookie.
|
24
|
-
* @example $.cookie('the_cookie', null);
|
25
|
-
* @desc Delete a cookie by passing null as value. Keep in mind that you have to use the same path and domain
|
26
|
-
* used when the cookie was set.
|
27
|
-
*
|
28
|
-
* @param String key The key of the cookie.
|
29
|
-
* @param String value The value of the cookie.
|
30
|
-
* @param Object options An object literal containing key/value pairs to provide optional cookie attributes.
|
31
|
-
* @option Number|Date expires Either an integer specifying the expiration date from now on in days or a Date object.
|
32
|
-
* If a negative value is specified (e.g. a date in the past), the cookie will be deleted.
|
33
|
-
* If set to null or omitted, the cookie will be a session cookie and will not be retained
|
34
|
-
* when the the browser exits.
|
35
|
-
* @option String path The value of the path atribute of the cookie (default: path of page that created the cookie).
|
36
|
-
* @option String domain The value of the domain attribute of the cookie (default: domain of page that created the cookie).
|
37
|
-
* @option Boolean secure If true, the secure attribute of the cookie will be set and the cookie transmission will
|
38
|
-
* require a secure protocol (like HTTPS).
|
39
|
-
* @type undefined
|
40
|
-
*
|
41
|
-
* @name $.cookie
|
42
|
-
* @cat Plugins/Cookie
|
43
|
-
* @author Klaus Hartl/klaus.hartl@stilbuero.de
|
44
|
-
*/
|
17
|
+
if (value === null || value === undefined) {
|
18
|
+
options.expires = -1;
|
19
|
+
}
|
45
20
|
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
* @desc Get the value of a cookie.
|
51
|
-
*
|
52
|
-
* @param String key The key of the cookie.
|
53
|
-
* @return The value of the cookie.
|
54
|
-
* @type String
|
55
|
-
*
|
56
|
-
* @name $.cookie
|
57
|
-
* @cat Plugins/Cookie
|
58
|
-
* @author Klaus Hartl/klaus.hartl@stilbuero.de
|
59
|
-
*/
|
60
|
-
jQuery.cookie = function (key, value, options) {
|
61
|
-
|
62
|
-
// key and at least value given, set cookie...
|
63
|
-
if (arguments.length > 1 && String(value) !== "[object Object]") {
|
64
|
-
options = jQuery.extend({}, options);
|
21
|
+
if (typeof options.expires === 'number') {
|
22
|
+
var days = options.expires, t = options.expires = new Date();
|
23
|
+
t.setDate(t.getDate() + days);
|
24
|
+
}
|
65
25
|
|
66
|
-
|
67
|
-
options.expires = -1;
|
68
|
-
}
|
26
|
+
value = String(value);
|
69
27
|
|
70
|
-
|
71
|
-
|
72
|
-
|
28
|
+
return (document.cookie = [
|
29
|
+
encodeURIComponent(key), '=', options.raw ? value : encodeURIComponent(value),
|
30
|
+
options.expires ? '; expires=' + options.expires.toUTCString() : '', // use expires attribute, max-age is not supported by IE
|
31
|
+
options.path ? '; path=' + options.path : '',
|
32
|
+
options.domain ? '; domain=' + options.domain : '',
|
33
|
+
options.secure ? '; secure' : ''
|
34
|
+
].join(''));
|
73
35
|
}
|
74
|
-
|
75
|
-
value = String(value);
|
76
|
-
|
77
|
-
return (document.cookie = [
|
78
|
-
encodeURIComponent(key), '=',
|
79
|
-
options.raw ? value : encodeURIComponent(value),
|
80
|
-
options.expires ? '; expires=' + options.expires.toUTCString() : '', // use expires attribute, max-age is not supported by IE
|
81
|
-
options.path ? '; path=' + options.path : '',
|
82
|
-
options.domain ? '; domain=' + options.domain : '',
|
83
|
-
options.secure ? '; secure' : ''
|
84
|
-
].join(''));
|
85
|
-
}
|
86
36
|
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
37
|
+
// key and possibly options given, get cookie...
|
38
|
+
options = value || {};
|
39
|
+
var decode = options.raw ? function(s) { return s; } : decodeURIComponent;
|
40
|
+
|
41
|
+
var pairs = document.cookie.split('; ');
|
42
|
+
for (var i = 0, pair; pair = pairs[i] && pairs[i].split('='); i++) {
|
43
|
+
if (decode(pair[0]) === key) return decode(pair[1] || ''); // IE saves cookies with empty string as "c; ", e.g. without "=" as opposed to EOMB, thus pair[1] may be undefined
|
44
|
+
}
|
45
|
+
return null;
|
46
|
+
};
|
47
|
+
})(jQuery);
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cacheable_flash
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.9
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -172,17 +172,11 @@ extra_rdoc_files:
|
|
172
172
|
files:
|
173
173
|
- .document
|
174
174
|
- .gitignore
|
175
|
-
-
|
175
|
+
- CHANGELOG
|
176
176
|
- Gemfile
|
177
177
|
- LICENSE
|
178
178
|
- README.rdoc
|
179
179
|
- Rakefile
|
180
|
-
- app/assets/images/cacheable_flash/.gitkeep
|
181
|
-
- app/assets/javascripts/cacheable_flash/application.js
|
182
|
-
- app/assets/stylesheets/cacheable_flash/application.css
|
183
|
-
- app/controllers/cacheable_flash/application_controller.rb
|
184
|
-
- app/helpers/cacheable_flash/application_helper.rb
|
185
|
-
- app/views/layouts/cacheable_flash/application.html.erb
|
186
180
|
- cacheable_flash.gemspec
|
187
181
|
- config/routes.rb
|
188
182
|
- init.rb
|
@@ -192,6 +186,7 @@ files:
|
|
192
186
|
- lib/cacheable_flash/engine.rb
|
193
187
|
- lib/cacheable_flash/middleware.rb
|
194
188
|
- lib/cacheable_flash/railtie.rb
|
189
|
+
- lib/cacheable_flash/test_helpers.rb
|
195
190
|
- lib/cacheable_flash/version.rb
|
196
191
|
- lib/generators/cacheable_flash/install/install_generator.rb
|
197
192
|
- lib/tasks/cacheable-flash_tasks.rake
|
@@ -237,7 +232,6 @@ files:
|
|
237
232
|
- spec/js_unit/cookie_test.html
|
238
233
|
- spec/js_unit/flash_test.html
|
239
234
|
- spec/spec_helper.rb
|
240
|
-
- spec/support/test_helpers.rb
|
241
235
|
- tasks/cacheable_flash_tasks.rake
|
242
236
|
- vendor/assets/javascripts/flash.js
|
243
237
|
- vendor/assets/javascripts/jquery.cookie.js
|
@@ -309,4 +303,3 @@ test_files:
|
|
309
303
|
- spec/js_unit/cookie_test.html
|
310
304
|
- spec/js_unit/flash_test.html
|
311
305
|
- spec/spec_helper.rb
|
312
|
-
- spec/support/test_helpers.rb
|
File without changes
|
@@ -1,15 +0,0 @@
|
|
1
|
-
// This is a manifest file that'll be compiled into application.js, which will include all the files
|
2
|
-
// listed below.
|
3
|
-
//
|
4
|
-
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
|
5
|
-
// or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
|
6
|
-
//
|
7
|
-
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
|
8
|
-
// the compiled file.
|
9
|
-
//
|
10
|
-
// WARNING: THE FIRST BLANK LINE MARKS THE END OF WHAT'S TO BE PROCESSED, ANY BLANK LINE SHOULD
|
11
|
-
// GO AFTER THE REQUIRES BELOW.
|
12
|
-
//
|
13
|
-
//= require jquery
|
14
|
-
//= require jquery_ujs
|
15
|
-
//= require_tree .
|
@@ -1,13 +0,0 @@
|
|
1
|
-
/*
|
2
|
-
* This is a manifest file that'll be compiled into application.css, which will include all the files
|
3
|
-
* listed below.
|
4
|
-
*
|
5
|
-
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
|
6
|
-
* or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
|
7
|
-
*
|
8
|
-
* You're free to add application-wide styles to this file and they'll appear at the top of the
|
9
|
-
* compiled file, but it's generally better to create a new file per style scope.
|
10
|
-
*
|
11
|
-
*= require_self
|
12
|
-
*= require_tree .
|
13
|
-
*/
|
@@ -1,14 +0,0 @@
|
|
1
|
-
<!DOCTYPE html>
|
2
|
-
<html>
|
3
|
-
<head>
|
4
|
-
<title>CacheableFlash</title>
|
5
|
-
<%= stylesheet_link_tag "cacheable_flash/application", :media => "all" %>
|
6
|
-
<%= javascript_include_tag "cacheable_flash/application" %>
|
7
|
-
<%= csrf_meta_tags %>
|
8
|
-
</head>
|
9
|
-
<body>
|
10
|
-
|
11
|
-
<%= yield %>
|
12
|
-
|
13
|
-
</body>
|
14
|
-
</html>
|