cacheable_flash 0.3.2 → 0.3.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.document +5 -5
- data/CHANGELOG +5 -0
- data/LICENSE +23 -23
- data/README.rdoc +21 -5
- data/init.rb +6 -6
- data/install.rb +18 -18
- data/lib/cacheable_flash.rb +7 -5
- data/lib/cacheable_flash/config.rb +3 -1
- data/lib/cacheable_flash/engine.rb +10 -7
- data/lib/cacheable_flash/middleware.rb +6 -22
- data/lib/cacheable_flash/railtie.rb +10 -10
- data/lib/cacheable_flash/rspec_matchers.rb +6 -6
- data/lib/cacheable_flash/test_helpers.rb +1 -1
- data/lib/cacheable_flash/version.rb +3 -3
- data/lib/generators/cacheable_flash/install/install_generator.rb +24 -23
- data/lib/tasks/cacheable-flash_tasks.rake +4 -4
- data/spec/cacheable_flash/cacheable_flash_spec.rb +17 -12
- data/spec/cacheable_flash/install_spec.rb +68 -68
- data/spec/controllers/controller_test_using_test_unit_spec.rb +28 -0
- data/spec/dummy/Rakefile +7 -7
- data/spec/dummy/app/assets/javascripts/application.js +15 -15
- data/spec/dummy/app/assets/stylesheets/application.css +13 -13
- data/spec/dummy/app/controllers/application_controller.rb +3 -3
- data/spec/dummy/app/helpers/application_helper.rb +2 -2
- data/spec/dummy/app/views/layouts/application.html.erb +14 -14
- data/spec/dummy/config.ru +4 -4
- data/spec/dummy/config/application.rb +62 -62
- data/spec/dummy/config/boot.rb +9 -9
- data/spec/dummy/config/database.yml +25 -25
- data/spec/dummy/config/environment.rb +5 -5
- data/spec/dummy/config/environments/development.rb +39 -39
- data/spec/dummy/config/environments/production.rb +67 -67
- data/spec/dummy/config/environments/test.rb +39 -39
- data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -7
- data/spec/dummy/config/initializers/inflections.rb +15 -15
- data/spec/dummy/config/initializers/mime_types.rb +5 -5
- data/spec/dummy/config/initializers/secret_token.rb +7 -7
- data/spec/dummy/config/initializers/session_store.rb +8 -8
- data/spec/dummy/config/initializers/wrap_parameters.rb +14 -14
- data/spec/dummy/config/locales/en.yml +5 -5
- data/spec/dummy/public/404.html +26 -26
- data/spec/dummy/public/422.html +26 -26
- data/spec/dummy/public/500.html +25 -25
- data/spec/dummy/script/rails +6 -6
- data/spec/js_unit/cookie_test.html +60 -60
- data/spec/js_unit/flash_test.html +112 -112
- data/tasks/cacheable_flash_tasks.rake +3 -3
- data/vendor/assets/javascripts/{flash.js → flash.js.erb} +2 -2
- data/vendor/assets/javascripts/jquery.cookie.js +47 -47
- metadata +29 -49
data/spec/dummy/public/422.html
CHANGED
@@ -1,26 +1,26 @@
|
|
1
|
-
<!DOCTYPE html>
|
2
|
-
<html>
|
3
|
-
<head>
|
4
|
-
<title>The change you wanted was rejected (422)</title>
|
5
|
-
<style type="text/css">
|
6
|
-
body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
|
7
|
-
div.dialog {
|
8
|
-
width: 25em;
|
9
|
-
padding: 0 4em;
|
10
|
-
margin: 4em auto 0 auto;
|
11
|
-
border: 1px solid #ccc;
|
12
|
-
border-right-color: #999;
|
13
|
-
border-bottom-color: #999;
|
14
|
-
}
|
15
|
-
h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
|
16
|
-
</style>
|
17
|
-
</head>
|
18
|
-
|
19
|
-
<body>
|
20
|
-
<!-- This file lives in public/422.html -->
|
21
|
-
<div class="dialog">
|
22
|
-
<h1>The change you wanted was rejected.</h1>
|
23
|
-
<p>Maybe you tried to change something you didn't have access to.</p>
|
24
|
-
</div>
|
25
|
-
</body>
|
26
|
-
</html>
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>The change you wanted was rejected (422)</title>
|
5
|
+
<style type="text/css">
|
6
|
+
body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
|
7
|
+
div.dialog {
|
8
|
+
width: 25em;
|
9
|
+
padding: 0 4em;
|
10
|
+
margin: 4em auto 0 auto;
|
11
|
+
border: 1px solid #ccc;
|
12
|
+
border-right-color: #999;
|
13
|
+
border-bottom-color: #999;
|
14
|
+
}
|
15
|
+
h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
|
16
|
+
</style>
|
17
|
+
</head>
|
18
|
+
|
19
|
+
<body>
|
20
|
+
<!-- This file lives in public/422.html -->
|
21
|
+
<div class="dialog">
|
22
|
+
<h1>The change you wanted was rejected.</h1>
|
23
|
+
<p>Maybe you tried to change something you didn't have access to.</p>
|
24
|
+
</div>
|
25
|
+
</body>
|
26
|
+
</html>
|
data/spec/dummy/public/500.html
CHANGED
@@ -1,25 +1,25 @@
|
|
1
|
-
<!DOCTYPE html>
|
2
|
-
<html>
|
3
|
-
<head>
|
4
|
-
<title>We're sorry, but something went wrong (500)</title>
|
5
|
-
<style type="text/css">
|
6
|
-
body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
|
7
|
-
div.dialog {
|
8
|
-
width: 25em;
|
9
|
-
padding: 0 4em;
|
10
|
-
margin: 4em auto 0 auto;
|
11
|
-
border: 1px solid #ccc;
|
12
|
-
border-right-color: #999;
|
13
|
-
border-bottom-color: #999;
|
14
|
-
}
|
15
|
-
h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
|
16
|
-
</style>
|
17
|
-
</head>
|
18
|
-
|
19
|
-
<body>
|
20
|
-
<!-- This file lives in public/500.html -->
|
21
|
-
<div class="dialog">
|
22
|
-
<h1>We're sorry, but something went wrong.</h1>
|
23
|
-
</div>
|
24
|
-
</body>
|
25
|
-
</html>
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>We're sorry, but something went wrong (500)</title>
|
5
|
+
<style type="text/css">
|
6
|
+
body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
|
7
|
+
div.dialog {
|
8
|
+
width: 25em;
|
9
|
+
padding: 0 4em;
|
10
|
+
margin: 4em auto 0 auto;
|
11
|
+
border: 1px solid #ccc;
|
12
|
+
border-right-color: #999;
|
13
|
+
border-bottom-color: #999;
|
14
|
+
}
|
15
|
+
h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
|
16
|
+
</style>
|
17
|
+
</head>
|
18
|
+
|
19
|
+
<body>
|
20
|
+
<!-- This file lives in public/500.html -->
|
21
|
+
<div class="dialog">
|
22
|
+
<h1>We're sorry, but something went wrong.</h1>
|
23
|
+
</div>
|
24
|
+
</body>
|
25
|
+
</html>
|
data/spec/dummy/script/rails
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
# This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
|
3
|
-
|
4
|
-
APP_PATH = File.expand_path('../../config/application', __FILE__)
|
5
|
-
require File.expand_path('../../config/boot', __FILE__)
|
6
|
-
require 'rails/commands'
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
|
3
|
+
|
4
|
+
APP_PATH = File.expand_path('../../config/application', __FILE__)
|
5
|
+
require File.expand_path('../../config/boot', __FILE__)
|
6
|
+
require 'rails/commands'
|
@@ -1,60 +1,60 @@
|
|
1
|
-
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
2
|
-
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
3
|
-
<html xmlns="http://www.w3.org/1999/xhtml">
|
4
|
-
<head>
|
5
|
-
<!-- You will need to change this to point to your jsUnitCore.js -->
|
6
|
-
<script src="http://localhost:3000/jsunit/app/jsUnitCore.js" type="text/javascript"></script>
|
7
|
-
|
8
|
-
<script src="../../javascripts/jquery.js" type="text/javascript"></script>
|
9
|
-
<script src="../../javascripts/cookie.js" type="text/javascript"></script>
|
10
|
-
|
11
|
-
<script language="javascript" type="text/javascript">
|
12
|
-
var content;
|
13
|
-
function setUp() {
|
14
|
-
content = $('#content');
|
15
|
-
Cookie.eraseAll();
|
16
|
-
}
|
17
|
-
|
18
|
-
function tearDown() {
|
19
|
-
Cookie.eraseAll();
|
20
|
-
}
|
21
|
-
|
22
|
-
function test_read() {
|
23
|
-
var expires = new Date();
|
24
|
-
expires.setYear(expires.getFullYear() + 1);
|
25
|
-
document.cookie = "foobar=baz; path=/; expires=" + expires.toGMTString();
|
26
|
-
|
27
|
-
assertEquals('baz', Cookie.get('foobar'));
|
28
|
-
}
|
29
|
-
|
30
|
-
function test_write() {
|
31
|
-
Cookie.set('foobar', 'baz');
|
32
|
-
assertEquals("baz", Cookie.get('foobar'));
|
33
|
-
}
|
34
|
-
|
35
|
-
function test_expire() {
|
36
|
-
Cookie.set('foobar', 'baz');
|
37
|
-
Cookie.erase('foobar');
|
38
|
-
assertNull(Cookie.get('foobar'));
|
39
|
-
}
|
40
|
-
|
41
|
-
function test_expireAll() {
|
42
|
-
Cookie.set('foobar', 'baz');
|
43
|
-
Cookie.set('another', 'cookie');
|
44
|
-
|
45
|
-
Cookie.eraseAll();
|
46
|
-
|
47
|
-
assertNull(Cookie.get('foobar'));
|
48
|
-
assertNull(Cookie.get('another'));
|
49
|
-
}
|
50
|
-
|
51
|
-
</script>
|
52
|
-
|
53
|
-
</head>
|
54
|
-
|
55
|
-
<body>
|
56
|
-
<div id="fixture">
|
57
|
-
<div id="content"></div>
|
58
|
-
</div>
|
59
|
-
</body>
|
60
|
-
</html>
|
1
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
2
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
3
|
+
<html xmlns="http://www.w3.org/1999/xhtml">
|
4
|
+
<head>
|
5
|
+
<!-- You will need to change this to point to your jsUnitCore.js -->
|
6
|
+
<script src="http://localhost:3000/jsunit/app/jsUnitCore.js" type="text/javascript"></script>
|
7
|
+
|
8
|
+
<script src="../../javascripts/jquery.js" type="text/javascript"></script>
|
9
|
+
<script src="../../javascripts/cookie.js" type="text/javascript"></script>
|
10
|
+
|
11
|
+
<script language="javascript" type="text/javascript">
|
12
|
+
var content;
|
13
|
+
function setUp() {
|
14
|
+
content = $('#content');
|
15
|
+
Cookie.eraseAll();
|
16
|
+
}
|
17
|
+
|
18
|
+
function tearDown() {
|
19
|
+
Cookie.eraseAll();
|
20
|
+
}
|
21
|
+
|
22
|
+
function test_read() {
|
23
|
+
var expires = new Date();
|
24
|
+
expires.setYear(expires.getFullYear() + 1);
|
25
|
+
document.cookie = "foobar=baz; path=/; expires=" + expires.toGMTString();
|
26
|
+
|
27
|
+
assertEquals('baz', Cookie.get('foobar'));
|
28
|
+
}
|
29
|
+
|
30
|
+
function test_write() {
|
31
|
+
Cookie.set('foobar', 'baz');
|
32
|
+
assertEquals("baz", Cookie.get('foobar'));
|
33
|
+
}
|
34
|
+
|
35
|
+
function test_expire() {
|
36
|
+
Cookie.set('foobar', 'baz');
|
37
|
+
Cookie.erase('foobar');
|
38
|
+
assertNull(Cookie.get('foobar'));
|
39
|
+
}
|
40
|
+
|
41
|
+
function test_expireAll() {
|
42
|
+
Cookie.set('foobar', 'baz');
|
43
|
+
Cookie.set('another', 'cookie');
|
44
|
+
|
45
|
+
Cookie.eraseAll();
|
46
|
+
|
47
|
+
assertNull(Cookie.get('foobar'));
|
48
|
+
assertNull(Cookie.get('another'));
|
49
|
+
}
|
50
|
+
|
51
|
+
</script>
|
52
|
+
|
53
|
+
</head>
|
54
|
+
|
55
|
+
<body>
|
56
|
+
<div id="fixture">
|
57
|
+
<div id="content"></div>
|
58
|
+
</div>
|
59
|
+
</body>
|
60
|
+
</html>
|
@@ -1,112 +1,112 @@
|
|
1
|
-
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
2
|
-
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
3
|
-
<html xmlns="http://www.w3.org/1999/xhtml">
|
4
|
-
<head>
|
5
|
-
<!-- You will need to change this to point to your jsUnitCore.js -->
|
6
|
-
<script src="http://localhost:3000/jsunit/app/jsUnitCore.js" type="text/javascript"></script>
|
7
|
-
|
8
|
-
<script src="../../javascripts/jquery.js" type="text/javascript"></script>
|
9
|
-
<script src="../../javascripts/cookie.js" type="text/javascript"></script>
|
10
|
-
<script src="../../javascripts/json.js" type="text/javascript"></script>
|
11
|
-
<script src="../../vendor/assets/javascripts/flash.js" type="text/javascript"></script>
|
12
|
-
<script type="text/javascript">
|
13
|
-
Include.jsUnitCore();
|
14
|
-
Include.allProduction();
|
15
|
-
Include.allCommonTest();
|
16
|
-
Include.testHelper();
|
17
|
-
</script>
|
18
|
-
|
19
|
-
<script language="javascript" type="text/javascript">
|
20
|
-
var content;
|
21
|
-
function setUp() {
|
22
|
-
content = $('#content');
|
23
|
-
content.html("");
|
24
|
-
Cookie.eraseAll();
|
25
|
-
}
|
26
|
-
|
27
|
-
function tearDown() {
|
28
|
-
Cookie.eraseAll();
|
29
|
-
}
|
30
|
-
|
31
|
-
function test_transferFromCookies_setsFlashData_whenCookieExists() {
|
32
|
-
var expectedData = {
|
33
|
-
'error': "The Error",
|
34
|
-
'notice': "The Notice"
|
35
|
-
};
|
36
|
-
setUpCookieWithData(expectedData);
|
37
|
-
Flash.transferFromCookies();
|
38
|
-
assertHashEquals(expectedData, Flash.data);
|
39
|
-
}
|
40
|
-
|
41
|
-
function test_transferFromCookies_setsFlashDataToEmptyHash_whenCookieDoesNotExist() {
|
42
|
-
Flash.transferFromCookies();
|
43
|
-
assertHashEquals({}, Flash.data);
|
44
|
-
}
|
45
|
-
|
46
|
-
function test_transferFromCookies_setsFlashDataToEmptyHash_whenCookieIsEmpty() {
|
47
|
-
setUpCookieWithData("");
|
48
|
-
Flash.transferFromCookies();
|
49
|
-
assertHashEquals({}, Flash.data);
|
50
|
-
}
|
51
|
-
|
52
|
-
function test_transferFromCookies_removeFlashCookie() {
|
53
|
-
setUpCookieWithData({
|
54
|
-
'error': "The Error",
|
55
|
-
'notice': "The Notice"
|
56
|
-
});
|
57
|
-
Flash.transferFromCookies();
|
58
|
-
assertNull(Cookie.get("flash"));
|
59
|
-
}
|
60
|
-
|
61
|
-
// how do I test this??
|
62
|
-
function test_transferFromCookies_whenValueContainsAPlusSign() {
|
63
|
-
setUpCookieWithData({
|
64
|
-
'notice': "Book+%2B+Gift+Box"
|
65
|
-
});
|
66
|
-
Flash.transferFromCookies();
|
67
|
-
assertEquals("Book + Gift Box", Cookie.get("notice"));
|
68
|
-
}
|
69
|
-
|
70
|
-
function test_writeDataTo_whenThereIsACookieValue() {
|
71
|
-
setUpCookieWithData({
|
72
|
-
'error': "This+is%20An+Error"
|
73
|
-
});
|
74
|
-
Flash.transferFromCookies();
|
75
|
-
Flash.writeDataTo('error', content);
|
76
|
-
|
77
|
-
assertEquals("This is An Error", content.html());
|
78
|
-
}
|
79
|
-
|
80
|
-
function test_writeDataTo_whenThereIsNoCookieValue() {
|
81
|
-
setUpCookieWithData({});
|
82
|
-
Flash.transferFromCookies();
|
83
|
-
Flash.writeDataTo('notice', content);
|
84
|
-
|
85
|
-
assertEquals("", content.html());
|
86
|
-
}
|
87
|
-
|
88
|
-
function test_writeDataTo_whenPassedAnElementId() {
|
89
|
-
setUpCookieWithData({
|
90
|
-
'error': "This+is%20An+Error"
|
91
|
-
});
|
92
|
-
|
93
|
-
Flash.transferFromCookies();
|
94
|
-
Flash.writeDataTo('error', '#content');
|
95
|
-
|
96
|
-
assertEquals("This is An Error", content.html());
|
97
|
-
}
|
98
|
-
|
99
|
-
function setUpCookieWithData(values) {
|
100
|
-
Cookie.set('flash', JSON.stringify(values));
|
101
|
-
}
|
102
|
-
|
103
|
-
</script>
|
104
|
-
|
105
|
-
</head>
|
106
|
-
|
107
|
-
<body>
|
108
|
-
<div id="fixture">
|
109
|
-
<div id="content"></div>
|
110
|
-
</div>
|
111
|
-
</body>
|
112
|
-
</html>
|
1
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
2
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
3
|
+
<html xmlns="http://www.w3.org/1999/xhtml">
|
4
|
+
<head>
|
5
|
+
<!-- You will need to change this to point to your jsUnitCore.js -->
|
6
|
+
<script src="http://localhost:3000/jsunit/app/jsUnitCore.js" type="text/javascript"></script>
|
7
|
+
|
8
|
+
<script src="../../javascripts/jquery.js" type="text/javascript"></script>
|
9
|
+
<script src="../../javascripts/cookie.js" type="text/javascript"></script>
|
10
|
+
<script src="../../javascripts/json.js" type="text/javascript"></script>
|
11
|
+
<script src="../../vendor/assets/javascripts/flash.js" type="text/javascript"></script>
|
12
|
+
<script type="text/javascript">
|
13
|
+
Include.jsUnitCore();
|
14
|
+
Include.allProduction();
|
15
|
+
Include.allCommonTest();
|
16
|
+
Include.testHelper();
|
17
|
+
</script>
|
18
|
+
|
19
|
+
<script language="javascript" type="text/javascript">
|
20
|
+
var content;
|
21
|
+
function setUp() {
|
22
|
+
content = $('#content');
|
23
|
+
content.html("");
|
24
|
+
Cookie.eraseAll();
|
25
|
+
}
|
26
|
+
|
27
|
+
function tearDown() {
|
28
|
+
Cookie.eraseAll();
|
29
|
+
}
|
30
|
+
|
31
|
+
function test_transferFromCookies_setsFlashData_whenCookieExists() {
|
32
|
+
var expectedData = {
|
33
|
+
'error': "The Error",
|
34
|
+
'notice': "The Notice"
|
35
|
+
};
|
36
|
+
setUpCookieWithData(expectedData);
|
37
|
+
Flash.transferFromCookies();
|
38
|
+
assertHashEquals(expectedData, Flash.data);
|
39
|
+
}
|
40
|
+
|
41
|
+
function test_transferFromCookies_setsFlashDataToEmptyHash_whenCookieDoesNotExist() {
|
42
|
+
Flash.transferFromCookies();
|
43
|
+
assertHashEquals({}, Flash.data);
|
44
|
+
}
|
45
|
+
|
46
|
+
function test_transferFromCookies_setsFlashDataToEmptyHash_whenCookieIsEmpty() {
|
47
|
+
setUpCookieWithData("");
|
48
|
+
Flash.transferFromCookies();
|
49
|
+
assertHashEquals({}, Flash.data);
|
50
|
+
}
|
51
|
+
|
52
|
+
function test_transferFromCookies_removeFlashCookie() {
|
53
|
+
setUpCookieWithData({
|
54
|
+
'error': "The Error",
|
55
|
+
'notice': "The Notice"
|
56
|
+
});
|
57
|
+
Flash.transferFromCookies();
|
58
|
+
assertNull(Cookie.get("flash"));
|
59
|
+
}
|
60
|
+
|
61
|
+
// how do I test this??
|
62
|
+
function test_transferFromCookies_whenValueContainsAPlusSign() {
|
63
|
+
setUpCookieWithData({
|
64
|
+
'notice': "Book+%2B+Gift+Box"
|
65
|
+
});
|
66
|
+
Flash.transferFromCookies();
|
67
|
+
assertEquals("Book + Gift Box", Cookie.get("notice"));
|
68
|
+
}
|
69
|
+
|
70
|
+
function test_writeDataTo_whenThereIsACookieValue() {
|
71
|
+
setUpCookieWithData({
|
72
|
+
'error': "This+is%20An+Error"
|
73
|
+
});
|
74
|
+
Flash.transferFromCookies();
|
75
|
+
Flash.writeDataTo('error', content);
|
76
|
+
|
77
|
+
assertEquals("This is An Error", content.html());
|
78
|
+
}
|
79
|
+
|
80
|
+
function test_writeDataTo_whenThereIsNoCookieValue() {
|
81
|
+
setUpCookieWithData({});
|
82
|
+
Flash.transferFromCookies();
|
83
|
+
Flash.writeDataTo('notice', content);
|
84
|
+
|
85
|
+
assertEquals("", content.html());
|
86
|
+
}
|
87
|
+
|
88
|
+
function test_writeDataTo_whenPassedAnElementId() {
|
89
|
+
setUpCookieWithData({
|
90
|
+
'error': "This+is%20An+Error"
|
91
|
+
});
|
92
|
+
|
93
|
+
Flash.transferFromCookies();
|
94
|
+
Flash.writeDataTo('error', '#content');
|
95
|
+
|
96
|
+
assertEquals("This is An Error", content.html());
|
97
|
+
}
|
98
|
+
|
99
|
+
function setUpCookieWithData(values) {
|
100
|
+
Cookie.set('flash', JSON.stringify(values));
|
101
|
+
}
|
102
|
+
|
103
|
+
</script>
|
104
|
+
|
105
|
+
</head>
|
106
|
+
|
107
|
+
<body>
|
108
|
+
<div id="fixture">
|
109
|
+
<div id="content"></div>
|
110
|
+
</div>
|
111
|
+
</body>
|
112
|
+
</html>
|