rails_4_session_flash_backport 0.1.0 → 0.2.0

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: 63cb81e1721af494a2b7ae4f05715d8f7c3d3e2a
4
- data.tar.gz: b774150f014fb78bf4b0c964ddc3d78c87b155ab
3
+ metadata.gz: 5bec082af8784a5cfbe67965d2b61f16fd39e324
4
+ data.tar.gz: 4c99d009b9753f05b04f9cd1a541215f1aa1ef61
5
5
  SHA512:
6
- metadata.gz: 01b2eeb5c36ebff671e5521b8905545d97f5956c6f5a52fd2cddacb250336757015417be93cede9cbd838b551cf388003a9a130247ddb8b87c96dd59f1a83d4e
7
- data.tar.gz: 92f2a7a0e6e711e7a01fb4a6f6255e22b536eac7eca0efd232b76adc0fb441b838bbc41a03483867636b7419fc3b5b01b8353e7b95e8e95ed9c5740f278aa624
6
+ metadata.gz: 28bcbea323dfe7f6c54ecadfb4d1e79f0d1eded87dca7963fcc5b5008beb725c45a0dee82f9899ac5e96b851f4a76f23f69a024f118ff5ec727eb94d6a1e8278
7
+ data.tar.gz: 224b6591d14db906d8909422cbea3087eaf0d36cf6d36b3af7b391bd0cf90717e5a5465ed8adca4322b6237bd4457938c6713fbc381abd8a292bb571f587bad6
checksums.yaml.gz.sig CHANGED
Binary file
data.tar.gz.sig CHANGED
Binary file
data/.travis.yml CHANGED
@@ -4,3 +4,11 @@ rvm:
4
4
  - 2.0.0
5
5
  - 2.1.5
6
6
  - 2.2.0
7
+ gemfile:
8
+ - gemfiles/Gemfile.rails-2.3.x
9
+ - gemfiles/Gemfile.rails-3.0.x
10
+ - gemfiles/Gemfile.rails-3.1.x
11
+ - gemfiles/Gemfile.rails-3.2.x
12
+ - gemfiles/Gemfile.rails-4.0.x
13
+ - gemfiles/Gemfile.rails-4.1.x
14
+ - gemfiles/Gemfile.rails-4.2.x
data/README.md CHANGED
@@ -12,31 +12,55 @@ crazy stuff we might as well go and use the far more sensible practice from
12
12
  Rails 4 of storing the flash as basic ruby types and sweeping the flash before
13
13
  persisting into the session.
14
14
 
15
- For more details of the how and why, check out our blog post
16
- [Happily upgrading Ruby on Rails at production scale](http://webuild.envato.com/blog/upgrading-ruby-on-rails-at-production-scale/)
15
+ For more details of the how and why, check out our blog post [Happily upgrading
16
+ Ruby on Rails at production scale][blog-post].
17
17
 
18
- When using this gem on a Rails 2 or 3 app:
18
+ [blog-post]: http://webuild.envato.com/blog/upgrading-ruby-on-rails-at-production-scale/
19
19
 
20
- - Flash messages are stored as basic objects in the Rails 4 style, pre-swept.
21
- - Flash messages in the Rails 2 format can be successfully decoded.
22
- - Flash messages in the Rails 3 format can be successfully decoded.
23
- - Flash messages in the Rails 4 format can be successfully decoded.
20
+ When using this gem on a Rails 2.3, 3.1+ or 4 app:
24
21
 
25
- Additionally, on Rails 2 we include some patches for the SessionHash and
26
- CookieStore in order to make them act more like a HashWithIndifferentAccess,
27
- like the versions on Rails 3, so that your session_id can survive a trip to
28
- Rails 3 and back.
22
+ * Flash messages are stored as basic objects in the Rails 4 style, pre-swept.
23
+ * Flash messages in the Rails 2 format can be successfully decoded.
24
+ * Flash messages in the Rails 3.1 format can be successfully decoded.
25
+ * Flash messages in the Rails 4 format can be successfully decoded.
29
26
 
30
27
  This actually makes it possible to bounce requests from a Rails 2 server, to a
31
28
  Rails 3 server and back again so long as both servers are using this gem. Very
32
29
  helpful when you're doing a big Rails 2 => 3 upgrade and want to run a few
33
30
  Rails 3 servers concurrently with your Rails 2 cluster to verify everything is
34
- fine and performance is acceptable without
35
- having to do the all-in switch.
31
+ fine and performance is acceptable without having to do the all-in switch.
32
+
33
+ ### Rails 2
34
+
35
+ Additionally, on Rails 2 we include some patches for the SessionHash and
36
+ CookieStore in order to make them act more like a HashWithIndifferentAccess,
37
+ like the versions on Rails 3, so that your session_id can survive a trip to
38
+ Rails 3 and back.
39
+
40
+ ### Rails 3.0
41
+
42
+ Rails 3.0 was a weird half-way house between 2.x and 3.1. The 3.0 to 3.1
43
+ upgrade gave many of us an [Argument Error (dump format error)
44
+ problem][argumenterror-so].
45
+
46
+ [argumenterror-so]: http://stackoverflow.com/questions/9120501/what-causes-the-argumenterror-dump-format-error
47
+
48
+ Consequently rails 3.0 with this gem can decode a rails 2.3 flash and a rails
49
+ 3.0 flash but not a rails 3.1+ or 4.x flash.
50
+
51
+ Once this gem is installed, rails 3.0 flashes will be stored in the rails 4
52
+ style simple format and can be used with any other rails version with this gem,
53
+ and from rails 4 without the gem, so it actually alleviates the upgrade pain.
54
+ Be aware that older sessions may still contain the older formatted hash if
55
+ you've been running on rails 3.0 for some time.
56
+
57
+ Using this gem from rails 2.3 will completely skip the issue.
58
+
59
+ ### Rails 4
36
60
 
37
- This gem also now backports functionality for Rails 2, 3 and 4 which backports
38
- sweeping the flash before persisting it into the session. This means putting
39
- large objects into `flash.now` shouldn't cause `CookieOverflow` errors.
61
+ This gem also now backports functionality for Rails 2, 3 and 4 which sweeps the
62
+ flash before persisting it into the session. This means putting large objects
63
+ into `flash.now` shouldn't cause `CookieOverflow` errors.
40
64
 
41
65
  ## Installation
42
66
 
@@ -52,8 +76,7 @@ Or install it yourself as:
52
76
 
53
77
  $ gem install rails_4_session_flash_backport
54
78
 
55
- Copyright
56
- ---------
79
+ ## Copyright
57
80
 
58
81
  Copyright (c) 2012 [Envato](http://envato.com), [Lucas Parry](http://github.com/lparry), [chendo](http://github.com/chendo), [sj26](http://github.com/sj26). See LICENSE.txt for further details.
59
82
 
data/Rakefile CHANGED
@@ -1,46 +1,26 @@
1
- require "bundler/gem_tasks"
2
-
3
- namespace :spec do
4
- task :rails2 do
5
- Bundler.with_clean_env do
6
- ENV["BUNDLE_GEMFILE"] = File.expand_path("../gemfiles/Gemfile.rails2", __FILE__)
7
-
8
- system "bundle", "check" or
9
- system "bundle" or
10
- raise "Couldn't install bundle from gemfiles/Gemfile.rails2"
11
-
12
- system "bundle", "exec", "rspec", "--color", "spec/rails2" or
13
- fail
1
+ require 'rubygems'
2
+ require 'bundler/setup'
3
+ require 'bundler/gem_tasks'
4
+
5
+ desc "Run specs for loaded version of rails"
6
+ task :spec do
7
+ rails_version = Gem.loaded_specs["rails"].version.to_s
8
+
9
+ spec_dir =
10
+ case rails_version
11
+ when /\A2\./
12
+ "spec/rails2"
13
+ when /\A3\.0\./
14
+ "spec/rails3-0"
15
+ when /\A3\./
16
+ "spec/rails3-1"
17
+ when /\A4\./
18
+ "spec/rails4"
19
+ else
20
+ fail "rails_4_session_flash_backport doesnt yet do anything on Rails #{rails_version}"
14
21
  end
15
- end
16
22
 
17
- task :rails3 do
18
- Bundler.with_clean_env do
19
- ENV["BUNDLE_GEMFILE"] = File.expand_path("../gemfiles/Gemfile.rails3", __FILE__)
20
-
21
- system "bundle", "check" or
22
- system "bundle" or
23
- raise "Couldn't install bundle from gemfiles/Gemfile.rails3"
24
-
25
- system "bundle", "exec", "rspec", "--color", "spec/rails3" or
26
- fail
27
- end
28
- end
29
-
30
- task :rails4 do
31
- Bundler.with_clean_env do
32
- ENV["BUNDLE_GEMFILE"] = File.expand_path("../gemfiles/Gemfile.rails4", __FILE__)
33
-
34
- system "bundle", "check" or
35
- system "bundle" or
36
- raise "Couldn't install bundle from gemfiles/Gemfile.rails4"
37
-
38
- system "bundle", "exec", "rspec", "--color", "spec/rails4" or
39
- fail
40
- end
41
- end
23
+ system "bundle", "exec", "rspec", "--color", spec_dir or fail
42
24
  end
43
25
 
44
- task :spec => ["spec:rails2", "spec:rails3", "spec:rails4"]
45
-
46
26
  task :default => :spec
File without changes
@@ -1,8 +1,8 @@
1
1
  PATH
2
2
  remote: ..
3
3
  specs:
4
- rails_4_session_flash_backport (0.0.4)
5
- rails (< 4.0.0)
4
+ rails_4_session_flash_backport (0.1.0)
5
+ rails (>= 2.0, < 4.3)
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
@@ -34,18 +34,19 @@ GEM
34
34
  activesupport (= 2.3.18)
35
35
  rake (>= 0.8.3)
36
36
  rake (10.4.2)
37
- rspec (3.1.0)
38
- rspec-core (~> 3.1.0)
39
- rspec-expectations (~> 3.1.0)
40
- rspec-mocks (~> 3.1.0)
41
- rspec-core (3.1.7)
42
- rspec-support (~> 3.1.0)
43
- rspec-expectations (3.1.2)
37
+ rspec (3.2.0)
38
+ rspec-core (~> 3.2.0)
39
+ rspec-expectations (~> 3.2.0)
40
+ rspec-mocks (~> 3.2.0)
41
+ rspec-core (3.2.0)
42
+ rspec-support (~> 3.2.0)
43
+ rspec-expectations (3.2.0)
44
44
  diff-lcs (>= 1.2.0, < 2.0)
45
- rspec-support (~> 3.1.0)
46
- rspec-mocks (3.1.3)
47
- rspec-support (~> 3.1.0)
48
- rspec-support (3.1.2)
45
+ rspec-support (~> 3.2.0)
46
+ rspec-mocks (3.2.0)
47
+ diff-lcs (>= 1.2.0, < 2.0)
48
+ rspec-support (~> 3.2.0)
49
+ rspec-support (3.2.1)
49
50
  slop (3.6.0)
50
51
 
51
52
  PLATFORMS
@@ -3,5 +3,5 @@ source "https://rubygems.org"
3
3
  gemspec :path => ".."
4
4
 
5
5
  group :development do
6
- gem "actionpack", "~> 4.0"
6
+ gem "actionpack", "3.0.20"
7
7
  end
@@ -0,0 +1,107 @@
1
+ PATH
2
+ remote: ..
3
+ specs:
4
+ rails_4_session_flash_backport (0.1.0)
5
+ rails (>= 2.0, < 4.3)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ abstract (1.0.0)
11
+ actionmailer (3.0.20)
12
+ actionpack (= 3.0.20)
13
+ mail (~> 2.2.19)
14
+ actionpack (3.0.20)
15
+ activemodel (= 3.0.20)
16
+ activesupport (= 3.0.20)
17
+ builder (~> 2.1.2)
18
+ erubis (~> 2.6.6)
19
+ i18n (~> 0.5.0)
20
+ rack (~> 1.2.5)
21
+ rack-mount (~> 0.6.14)
22
+ rack-test (~> 0.5.7)
23
+ tzinfo (~> 0.3.23)
24
+ activemodel (3.0.20)
25
+ activesupport (= 3.0.20)
26
+ builder (~> 2.1.2)
27
+ i18n (~> 0.5.0)
28
+ activerecord (3.0.20)
29
+ activemodel (= 3.0.20)
30
+ activesupport (= 3.0.20)
31
+ arel (~> 2.0.10)
32
+ tzinfo (~> 0.3.23)
33
+ activeresource (3.0.20)
34
+ activemodel (= 3.0.20)
35
+ activesupport (= 3.0.20)
36
+ activesupport (3.0.20)
37
+ arel (2.0.10)
38
+ builder (2.1.2)
39
+ coderay (1.1.0)
40
+ diff-lcs (1.2.5)
41
+ erubis (2.6.6)
42
+ abstract (>= 1.0.0)
43
+ i18n (0.5.4)
44
+ json (1.8.2)
45
+ mail (2.2.20)
46
+ activesupport (>= 2.3.6)
47
+ i18n (>= 0.4.0)
48
+ mime-types (~> 1.16)
49
+ treetop (~> 1.4.8)
50
+ method_source (0.8.2)
51
+ mime-types (1.25.1)
52
+ polyglot (0.3.5)
53
+ pry (0.10.1)
54
+ coderay (~> 1.1.0)
55
+ method_source (~> 0.8.1)
56
+ slop (~> 3.4)
57
+ rack (1.2.8)
58
+ rack-mount (0.6.14)
59
+ rack (>= 1.0.0)
60
+ rack-test (0.5.7)
61
+ rack (>= 1.0)
62
+ rails (3.0.20)
63
+ actionmailer (= 3.0.20)
64
+ actionpack (= 3.0.20)
65
+ activerecord (= 3.0.20)
66
+ activeresource (= 3.0.20)
67
+ activesupport (= 3.0.20)
68
+ bundler (~> 1.0)
69
+ railties (= 3.0.20)
70
+ railties (3.0.20)
71
+ actionpack (= 3.0.20)
72
+ activesupport (= 3.0.20)
73
+ rake (>= 0.8.7)
74
+ rdoc (~> 3.4)
75
+ thor (~> 0.14.4)
76
+ rake (10.4.2)
77
+ rdoc (3.12.2)
78
+ json (~> 1.4)
79
+ rspec (3.2.0)
80
+ rspec-core (~> 3.2.0)
81
+ rspec-expectations (~> 3.2.0)
82
+ rspec-mocks (~> 3.2.0)
83
+ rspec-core (3.2.0)
84
+ rspec-support (~> 3.2.0)
85
+ rspec-expectations (3.2.0)
86
+ diff-lcs (>= 1.2.0, < 2.0)
87
+ rspec-support (~> 3.2.0)
88
+ rspec-mocks (3.2.0)
89
+ diff-lcs (>= 1.2.0, < 2.0)
90
+ rspec-support (~> 3.2.0)
91
+ rspec-support (3.2.1)
92
+ slop (3.6.0)
93
+ thor (0.14.6)
94
+ treetop (1.4.15)
95
+ polyglot
96
+ polyglot (>= 0.3.1)
97
+ tzinfo (0.3.43)
98
+
99
+ PLATFORMS
100
+ ruby
101
+
102
+ DEPENDENCIES
103
+ actionpack (= 3.0.20)
104
+ pry
105
+ rails_4_session_flash_backport!
106
+ rake
107
+ rspec
@@ -3,5 +3,5 @@ source "https://rubygems.org"
3
3
  gemspec :path => ".."
4
4
 
5
5
  group :development do
6
- gem "actionpack", "~> 3.2"
6
+ gem "actionpack", "3.1.12"
7
7
  end
@@ -0,0 +1,118 @@
1
+ PATH
2
+ remote: ..
3
+ specs:
4
+ rails_4_session_flash_backport (0.1.0)
5
+ rails (>= 2.0, < 4.3)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ actionmailer (3.1.12)
11
+ actionpack (= 3.1.12)
12
+ mail (~> 2.4.4)
13
+ actionpack (3.1.12)
14
+ activemodel (= 3.1.12)
15
+ activesupport (= 3.1.12)
16
+ builder (~> 3.0.0)
17
+ erubis (~> 2.7.0)
18
+ i18n (~> 0.6)
19
+ rack (~> 1.3.6)
20
+ rack-cache (~> 1.2)
21
+ rack-mount (~> 0.8.2)
22
+ rack-test (~> 0.6.1)
23
+ sprockets (~> 2.0.4)
24
+ activemodel (3.1.12)
25
+ activesupport (= 3.1.12)
26
+ builder (~> 3.0.0)
27
+ i18n (~> 0.6)
28
+ activerecord (3.1.12)
29
+ activemodel (= 3.1.12)
30
+ activesupport (= 3.1.12)
31
+ arel (~> 2.2.3)
32
+ tzinfo (~> 0.3.29)
33
+ activeresource (3.1.12)
34
+ activemodel (= 3.1.12)
35
+ activesupport (= 3.1.12)
36
+ activesupport (3.1.12)
37
+ multi_json (~> 1.0)
38
+ arel (2.2.3)
39
+ builder (3.0.4)
40
+ coderay (1.1.0)
41
+ diff-lcs (1.2.5)
42
+ erubis (2.7.0)
43
+ hike (1.2.3)
44
+ i18n (0.7.0)
45
+ json (1.8.2)
46
+ mail (2.4.4)
47
+ i18n (>= 0.4.0)
48
+ mime-types (~> 1.16)
49
+ treetop (~> 1.4.8)
50
+ method_source (0.8.2)
51
+ mime-types (1.25.1)
52
+ multi_json (1.10.1)
53
+ polyglot (0.3.5)
54
+ pry (0.10.1)
55
+ coderay (~> 1.1.0)
56
+ method_source (~> 0.8.1)
57
+ slop (~> 3.4)
58
+ rack (1.3.10)
59
+ rack-cache (1.2)
60
+ rack (>= 0.4)
61
+ rack-mount (0.8.3)
62
+ rack (>= 1.0.0)
63
+ rack-ssl (1.3.4)
64
+ rack
65
+ rack-test (0.6.3)
66
+ rack (>= 1.0)
67
+ rails (3.1.12)
68
+ actionmailer (= 3.1.12)
69
+ actionpack (= 3.1.12)
70
+ activerecord (= 3.1.12)
71
+ activeresource (= 3.1.12)
72
+ activesupport (= 3.1.12)
73
+ bundler (~> 1.0)
74
+ railties (= 3.1.12)
75
+ railties (3.1.12)
76
+ actionpack (= 3.1.12)
77
+ activesupport (= 3.1.12)
78
+ rack-ssl (~> 1.3.2)
79
+ rake (>= 0.8.7)
80
+ rdoc (~> 3.4)
81
+ thor (~> 0.14.6)
82
+ rake (10.4.2)
83
+ rdoc (3.12.2)
84
+ json (~> 1.4)
85
+ rspec (3.2.0)
86
+ rspec-core (~> 3.2.0)
87
+ rspec-expectations (~> 3.2.0)
88
+ rspec-mocks (~> 3.2.0)
89
+ rspec-core (3.2.0)
90
+ rspec-support (~> 3.2.0)
91
+ rspec-expectations (3.2.0)
92
+ diff-lcs (>= 1.2.0, < 2.0)
93
+ rspec-support (~> 3.2.0)
94
+ rspec-mocks (3.2.0)
95
+ diff-lcs (>= 1.2.0, < 2.0)
96
+ rspec-support (~> 3.2.0)
97
+ rspec-support (3.2.1)
98
+ slop (3.6.0)
99
+ sprockets (2.0.5)
100
+ hike (~> 1.2)
101
+ rack (~> 1.0)
102
+ tilt (~> 1.1, != 1.3.0)
103
+ thor (0.14.6)
104
+ tilt (1.4.1)
105
+ treetop (1.4.15)
106
+ polyglot
107
+ polyglot (>= 0.3.1)
108
+ tzinfo (0.3.43)
109
+
110
+ PLATFORMS
111
+ ruby
112
+
113
+ DEPENDENCIES
114
+ actionpack (= 3.1.12)
115
+ pry
116
+ rails_4_session_flash_backport!
117
+ rake
118
+ rspec
@@ -0,0 +1,7 @@
1
+ source "https://rubygems.org"
2
+
3
+ gemspec :path => ".."
4
+
5
+ group :development do
6
+ gem "actionpack", "3.2.21"
7
+ end
@@ -1,8 +1,8 @@
1
1
  PATH
2
2
  remote: ..
3
3
  specs:
4
- rails_4_session_flash_backport (0.0.4)
5
- rails (< 4.0.0)
4
+ rails_4_session_flash_backport (0.1.0)
5
+ rails (>= 2.0, < 4.3)
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
@@ -79,18 +79,19 @@ GEM
79
79
  rake (10.4.2)
80
80
  rdoc (3.12.2)
81
81
  json (~> 1.4)
82
- rspec (3.1.0)
83
- rspec-core (~> 3.1.0)
84
- rspec-expectations (~> 3.1.0)
85
- rspec-mocks (~> 3.1.0)
86
- rspec-core (3.1.7)
87
- rspec-support (~> 3.1.0)
88
- rspec-expectations (3.1.2)
82
+ rspec (3.2.0)
83
+ rspec-core (~> 3.2.0)
84
+ rspec-expectations (~> 3.2.0)
85
+ rspec-mocks (~> 3.2.0)
86
+ rspec-core (3.2.0)
87
+ rspec-support (~> 3.2.0)
88
+ rspec-expectations (3.2.0)
89
89
  diff-lcs (>= 1.2.0, < 2.0)
90
- rspec-support (~> 3.1.0)
91
- rspec-mocks (3.1.3)
92
- rspec-support (~> 3.1.0)
93
- rspec-support (3.1.2)
90
+ rspec-support (~> 3.2.0)
91
+ rspec-mocks (3.2.0)
92
+ diff-lcs (>= 1.2.0, < 2.0)
93
+ rspec-support (~> 3.2.0)
94
+ rspec-support (3.2.1)
94
95
  slop (3.6.0)
95
96
  sprockets (2.2.3)
96
97
  hike (~> 1.2)
@@ -102,13 +103,13 @@ GEM
102
103
  treetop (1.4.15)
103
104
  polyglot
104
105
  polyglot (>= 0.3.1)
105
- tzinfo (0.3.42)
106
+ tzinfo (0.3.43)
106
107
 
107
108
  PLATFORMS
108
109
  ruby
109
110
 
110
111
  DEPENDENCIES
111
- actionpack (~> 3.2)
112
+ actionpack (= 3.2.21)
112
113
  pry
113
114
  rails_4_session_flash_backport!
114
115
  rake
@@ -0,0 +1,7 @@
1
+ source "https://rubygems.org"
2
+
3
+ gemspec :path => ".."
4
+
5
+ group :development do
6
+ gem "actionpack", "4.0.13"
7
+ end
@@ -0,0 +1,104 @@
1
+ PATH
2
+ remote: ..
3
+ specs:
4
+ rails_4_session_flash_backport (0.1.0)
5
+ rails (>= 2.0, < 4.3)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ actionmailer (4.0.13)
11
+ actionpack (= 4.0.13)
12
+ mail (~> 2.5, >= 2.5.4)
13
+ actionpack (4.0.13)
14
+ activesupport (= 4.0.13)
15
+ builder (~> 3.1.0)
16
+ erubis (~> 2.7.0)
17
+ rack (~> 1.5.2)
18
+ rack-test (~> 0.6.2)
19
+ activemodel (4.0.13)
20
+ activesupport (= 4.0.13)
21
+ builder (~> 3.1.0)
22
+ activerecord (4.0.13)
23
+ activemodel (= 4.0.13)
24
+ activerecord-deprecated_finders (~> 1.0.2)
25
+ activesupport (= 4.0.13)
26
+ arel (~> 4.0.0)
27
+ activerecord-deprecated_finders (1.0.3)
28
+ activesupport (4.0.13)
29
+ i18n (~> 0.6, >= 0.6.9)
30
+ minitest (~> 4.2)
31
+ multi_json (~> 1.3)
32
+ thread_safe (~> 0.1)
33
+ tzinfo (~> 0.3.37)
34
+ arel (4.0.2)
35
+ builder (3.1.4)
36
+ coderay (1.1.0)
37
+ diff-lcs (1.2.5)
38
+ erubis (2.7.0)
39
+ hike (1.2.3)
40
+ i18n (0.7.0)
41
+ mail (2.6.3)
42
+ mime-types (>= 1.16, < 3)
43
+ method_source (0.8.2)
44
+ mime-types (2.4.3)
45
+ minitest (4.7.5)
46
+ multi_json (1.10.1)
47
+ pry (0.10.1)
48
+ coderay (~> 1.1.0)
49
+ method_source (~> 0.8.1)
50
+ slop (~> 3.4)
51
+ rack (1.5.2)
52
+ rack-test (0.6.3)
53
+ rack (>= 1.0)
54
+ rails (4.0.13)
55
+ actionmailer (= 4.0.13)
56
+ actionpack (= 4.0.13)
57
+ activerecord (= 4.0.13)
58
+ activesupport (= 4.0.13)
59
+ bundler (>= 1.3.0, < 2.0)
60
+ railties (= 4.0.13)
61
+ sprockets-rails (~> 2.0)
62
+ railties (4.0.13)
63
+ actionpack (= 4.0.13)
64
+ activesupport (= 4.0.13)
65
+ rake (>= 0.8.7)
66
+ thor (>= 0.18.1, < 2.0)
67
+ rake (10.4.2)
68
+ rspec (3.2.0)
69
+ rspec-core (~> 3.2.0)
70
+ rspec-expectations (~> 3.2.0)
71
+ rspec-mocks (~> 3.2.0)
72
+ rspec-core (3.2.0)
73
+ rspec-support (~> 3.2.0)
74
+ rspec-expectations (3.2.0)
75
+ diff-lcs (>= 1.2.0, < 2.0)
76
+ rspec-support (~> 3.2.0)
77
+ rspec-mocks (3.2.0)
78
+ diff-lcs (>= 1.2.0, < 2.0)
79
+ rspec-support (~> 3.2.0)
80
+ rspec-support (3.2.1)
81
+ slop (3.6.0)
82
+ sprockets (2.12.3)
83
+ hike (~> 1.2)
84
+ multi_json (~> 1.0)
85
+ rack (~> 1.0)
86
+ tilt (~> 1.1, != 1.3.0)
87
+ sprockets-rails (2.2.4)
88
+ actionpack (>= 3.0)
89
+ activesupport (>= 3.0)
90
+ sprockets (>= 2.8, < 4.0)
91
+ thor (0.19.1)
92
+ thread_safe (0.3.4)
93
+ tilt (1.4.1)
94
+ tzinfo (0.3.43)
95
+
96
+ PLATFORMS
97
+ ruby
98
+
99
+ DEPENDENCIES
100
+ actionpack (= 4.0.13)
101
+ pry
102
+ rails_4_session_flash_backport!
103
+ rake
104
+ rspec
@@ -0,0 +1,7 @@
1
+ source "https://rubygems.org"
2
+
3
+ gemspec :path => ".."
4
+
5
+ group :development do
6
+ gem "actionpack", "4.1.9"
7
+ end
@@ -0,0 +1,110 @@
1
+ PATH
2
+ remote: ..
3
+ specs:
4
+ rails_4_session_flash_backport (0.1.0)
5
+ rails (>= 2.0, < 4.3)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ actionmailer (4.1.9)
11
+ actionpack (= 4.1.9)
12
+ actionview (= 4.1.9)
13
+ mail (~> 2.5, >= 2.5.4)
14
+ actionpack (4.1.9)
15
+ actionview (= 4.1.9)
16
+ activesupport (= 4.1.9)
17
+ rack (~> 1.5.2)
18
+ rack-test (~> 0.6.2)
19
+ actionview (4.1.9)
20
+ activesupport (= 4.1.9)
21
+ builder (~> 3.1)
22
+ erubis (~> 2.7.0)
23
+ activemodel (4.1.9)
24
+ activesupport (= 4.1.9)
25
+ builder (~> 3.1)
26
+ activerecord (4.1.9)
27
+ activemodel (= 4.1.9)
28
+ activesupport (= 4.1.9)
29
+ arel (~> 5.0.0)
30
+ activesupport (4.1.9)
31
+ i18n (~> 0.6, >= 0.6.9)
32
+ json (~> 1.7, >= 1.7.7)
33
+ minitest (~> 5.1)
34
+ thread_safe (~> 0.1)
35
+ tzinfo (~> 1.1)
36
+ arel (5.0.1.20140414130214)
37
+ builder (3.2.2)
38
+ coderay (1.1.0)
39
+ diff-lcs (1.2.5)
40
+ erubis (2.7.0)
41
+ hike (1.2.3)
42
+ i18n (0.7.0)
43
+ json (1.8.2)
44
+ mail (2.6.3)
45
+ mime-types (>= 1.16, < 3)
46
+ method_source (0.8.2)
47
+ mime-types (2.4.3)
48
+ minitest (5.5.1)
49
+ multi_json (1.10.1)
50
+ pry (0.10.1)
51
+ coderay (~> 1.1.0)
52
+ method_source (~> 0.8.1)
53
+ slop (~> 3.4)
54
+ rack (1.5.2)
55
+ rack-test (0.6.3)
56
+ rack (>= 1.0)
57
+ rails (4.1.9)
58
+ actionmailer (= 4.1.9)
59
+ actionpack (= 4.1.9)
60
+ actionview (= 4.1.9)
61
+ activemodel (= 4.1.9)
62
+ activerecord (= 4.1.9)
63
+ activesupport (= 4.1.9)
64
+ bundler (>= 1.3.0, < 2.0)
65
+ railties (= 4.1.9)
66
+ sprockets-rails (~> 2.0)
67
+ railties (4.1.9)
68
+ actionpack (= 4.1.9)
69
+ activesupport (= 4.1.9)
70
+ rake (>= 0.8.7)
71
+ thor (>= 0.18.1, < 2.0)
72
+ rake (10.4.2)
73
+ rspec (3.2.0)
74
+ rspec-core (~> 3.2.0)
75
+ rspec-expectations (~> 3.2.0)
76
+ rspec-mocks (~> 3.2.0)
77
+ rspec-core (3.2.0)
78
+ rspec-support (~> 3.2.0)
79
+ rspec-expectations (3.2.0)
80
+ diff-lcs (>= 1.2.0, < 2.0)
81
+ rspec-support (~> 3.2.0)
82
+ rspec-mocks (3.2.0)
83
+ diff-lcs (>= 1.2.0, < 2.0)
84
+ rspec-support (~> 3.2.0)
85
+ rspec-support (3.2.1)
86
+ slop (3.6.0)
87
+ sprockets (2.12.3)
88
+ hike (~> 1.2)
89
+ multi_json (~> 1.0)
90
+ rack (~> 1.0)
91
+ tilt (~> 1.1, != 1.3.0)
92
+ sprockets-rails (2.2.4)
93
+ actionpack (>= 3.0)
94
+ activesupport (>= 3.0)
95
+ sprockets (>= 2.8, < 4.0)
96
+ thor (0.19.1)
97
+ thread_safe (0.3.4)
98
+ tilt (1.4.1)
99
+ tzinfo (1.2.2)
100
+ thread_safe (~> 0.1)
101
+
102
+ PLATFORMS
103
+ ruby
104
+
105
+ DEPENDENCIES
106
+ actionpack (= 4.1.9)
107
+ pry
108
+ rails_4_session_flash_backport!
109
+ rake
110
+ rspec
@@ -0,0 +1,7 @@
1
+ source "https://rubygems.org"
2
+
3
+ gemspec :path => ".."
4
+
5
+ group :development do
6
+ gem "actionpack", "4.2.0"
7
+ end
@@ -1,8 +1,8 @@
1
1
  PATH
2
2
  remote: ..
3
3
  specs:
4
- rails_4_session_flash_backport (0.0.4)
5
- rails (< 4.0.0)
4
+ rails_4_session_flash_backport (0.1.0)
5
+ rails (>= 2.0, < 4.3)
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
@@ -47,8 +47,9 @@ GEM
47
47
  coderay (1.1.0)
48
48
  diff-lcs (1.2.5)
49
49
  erubis (2.7.0)
50
- globalid (0.3.0)
50
+ globalid (0.3.3)
51
51
  activesupport (>= 4.1.0)
52
+ hike (1.2.3)
52
53
  i18n (0.7.0)
53
54
  json (1.8.2)
54
55
  loofah (2.0.1)
@@ -59,6 +60,7 @@ GEM
59
60
  mime-types (2.4.3)
60
61
  mini_portile (0.6.2)
61
62
  minitest (5.5.1)
63
+ multi_json (1.10.1)
62
64
  nokogiri (1.6.6.2)
63
65
  mini_portile (~> 0.6.0)
64
66
  pry (0.10.1)
@@ -68,11 +70,17 @@ GEM
68
70
  rack (1.6.0)
69
71
  rack-test (0.6.3)
70
72
  rack (>= 1.0)
71
- rails (0.9.5)
72
- actionmailer (>= 0.6.1)
73
- actionpack (>= 1.4.0)
74
- activerecord (>= 1.6.0)
75
- rake (>= 0.4.15)
73
+ rails (4.2.0)
74
+ actionmailer (= 4.2.0)
75
+ actionpack (= 4.2.0)
76
+ actionview (= 4.2.0)
77
+ activejob (= 4.2.0)
78
+ activemodel (= 4.2.0)
79
+ activerecord (= 4.2.0)
80
+ activesupport (= 4.2.0)
81
+ bundler (>= 1.3.0, < 2.0)
82
+ railties (= 4.2.0)
83
+ sprockets-rails
76
84
  rails-deprecated_sanitizer (1.0.3)
77
85
  activesupport (>= 4.2.0.alpha)
78
86
  rails-dom-testing (1.0.5)
@@ -81,21 +89,38 @@ GEM
81
89
  rails-deprecated_sanitizer (>= 1.0.1)
82
90
  rails-html-sanitizer (1.0.1)
83
91
  loofah (~> 2.0)
92
+ railties (4.2.0)
93
+ actionpack (= 4.2.0)
94
+ activesupport (= 4.2.0)
95
+ rake (>= 0.8.7)
96
+ thor (>= 0.18.1, < 2.0)
84
97
  rake (10.4.2)
85
- rspec (3.1.0)
86
- rspec-core (~> 3.1.0)
87
- rspec-expectations (~> 3.1.0)
88
- rspec-mocks (~> 3.1.0)
89
- rspec-core (3.1.7)
90
- rspec-support (~> 3.1.0)
91
- rspec-expectations (3.1.2)
98
+ rspec (3.2.0)
99
+ rspec-core (~> 3.2.0)
100
+ rspec-expectations (~> 3.2.0)
101
+ rspec-mocks (~> 3.2.0)
102
+ rspec-core (3.2.0)
103
+ rspec-support (~> 3.2.0)
104
+ rspec-expectations (3.2.0)
105
+ diff-lcs (>= 1.2.0, < 2.0)
106
+ rspec-support (~> 3.2.0)
107
+ rspec-mocks (3.2.0)
92
108
  diff-lcs (>= 1.2.0, < 2.0)
93
- rspec-support (~> 3.1.0)
94
- rspec-mocks (3.1.3)
95
- rspec-support (~> 3.1.0)
96
- rspec-support (3.1.2)
109
+ rspec-support (~> 3.2.0)
110
+ rspec-support (3.2.1)
97
111
  slop (3.6.0)
112
+ sprockets (2.12.3)
113
+ hike (~> 1.2)
114
+ multi_json (~> 1.0)
115
+ rack (~> 1.0)
116
+ tilt (~> 1.1, != 1.3.0)
117
+ sprockets-rails (2.2.4)
118
+ actionpack (>= 3.0)
119
+ activesupport (>= 3.0)
120
+ sprockets (>= 2.8, < 4.0)
121
+ thor (0.19.1)
98
122
  thread_safe (0.3.4)
123
+ tilt (1.4.1)
99
124
  tzinfo (1.2.2)
100
125
  thread_safe (~> 0.1)
101
126
 
@@ -103,7 +128,7 @@ PLATFORMS
103
128
  ruby
104
129
 
105
130
  DEPENDENCIES
106
- actionpack (~> 4.0)
131
+ actionpack (= 4.2.0)
107
132
  pry
108
133
  rails_4_session_flash_backport!
109
134
  rake
@@ -1,13 +1,15 @@
1
1
  # encoding: utf-8
2
2
  require "rails_4_session_flash_backport/version"
3
3
 
4
- case Rails.version.to_i
5
- when 2
4
+ case Rails.version
5
+ when /\A2\./
6
6
  require 'rails_4_session_flash_backport/rails2/flash_hash'
7
7
  require 'rails_4_session_flash_backport/rails2/session_with_indifferent_access'
8
- when 3
9
- require 'rails_4_session_flash_backport/rails3/flash_hash'
10
- when 4
8
+ when /\A3\.0\./
9
+ require 'rails_4_session_flash_backport/rails3-0/flash_hash'
10
+ when /\A3\./
11
+ require 'rails_4_session_flash_backport/rails3-1/flash_hash'
12
+ when /\A4\./
11
13
  require 'rails_4_session_flash_backport/rails4/flash_hash'
12
14
  else
13
15
  Rails.logger.warn "rails_4_session_flash_backport doesnt yet do anything on Rails #{Rails.version}"
@@ -0,0 +1,91 @@
1
+ # encoding: utf-8
2
+ require 'active_support/core_ext/hash/except'
3
+ require 'action_dispatch'
4
+ require 'action_dispatch/middleware/flash'
5
+
6
+ # Backport Rails 4 style storing the flash as basic ruby types to Rails 3.0
7
+ module ActionDispatch
8
+ class Request < Rack::Request
9
+ def flash
10
+ @env[Flash::KEY] ||= Flash::FlashHash.from_session_value(session["flash"])
11
+ end
12
+ end
13
+
14
+ class Flash
15
+ KEY = 'action_dispatch.request.flash_hash'.freeze
16
+
17
+ class FlashHash < Hash
18
+ def self.from_session_value(value)
19
+ flashes = discard = nil
20
+
21
+ case value
22
+ when ::ActionController::Flash::FlashHash # Rails 2.x
23
+ flashes = Hash.new.update(value)
24
+ discard = value.instance_variable_get(:@used).select{|a,b| b}.keys
25
+ when ::ActionDispatch::Flash::FlashHash # Rails 3.1, 3.2
26
+ flashes = value.tap(&:sweep).to_hash
27
+ when Hash # Rails 4.0, we backported to 2.3 too
28
+ flashes = value['flashes']
29
+ discard = value['discard']
30
+ end
31
+
32
+ flashes ||= {}
33
+ if discard
34
+ flashes.except!(*discard)
35
+ end
36
+
37
+ new_from_session(flashes)
38
+ end
39
+
40
+ def to_session_value
41
+ flashes_to_keep = except(*@used)
42
+ return nil if flashes_to_keep.empty?
43
+ {'flashes' => flashes_to_keep}
44
+ end
45
+
46
+ private
47
+
48
+ def self.new_from_session(flashes)
49
+ new.tap do |flash|
50
+ flashes.each do |key, value|
51
+ flash[key] = value
52
+ flash.discard key
53
+ end
54
+ end
55
+ end
56
+ end
57
+
58
+ def call(env)
59
+ @app.call(env)
60
+ ensure
61
+ session = env['rack.session'] || {}
62
+ flash_hash = env[KEY]
63
+
64
+ if flash_hash
65
+ if !flash_hash.empty? || session.key?('flash')
66
+ session["flash"] = flash_hash.to_session_value
67
+ new_hash = flash_hash.dup
68
+ else
69
+ new_hash = flash_hash
70
+ end
71
+
72
+ env[KEY] = new_hash
73
+ end
74
+
75
+ if session.key?('flash') && session['flash'].nil?
76
+ session.delete('flash')
77
+ end
78
+ end
79
+ end
80
+ end
81
+
82
+ # This magic here allows us to unmarshal the old Rails 2.x ActionController::Flash::FlashHash
83
+ module ActionController
84
+ module Flash
85
+ class FlashHash < Hash
86
+ def self._load(args)
87
+ {}
88
+ end
89
+ end
90
+ end
91
+ end
@@ -1,3 +1,3 @@
1
1
  module Rails4SessionFlashBackport
2
- VERSION = "0.1.0"
2
+ VERSION = "0.2.0"
3
3
  end
@@ -1,6 +1,6 @@
1
1
  require 'base64'
2
2
 
3
- require 'rails_4_session_flash_backport/rails3/flash_hash'
3
+ require 'rails_4_session_flash_backport/rails3-0/flash_hash'
4
4
 
5
5
  describe ActionDispatch::Flash::FlashHash, "backport" do
6
6
  context "#from_session_value" do
@@ -24,10 +24,20 @@ describe ActionDispatch::Flash::FlashHash, "backport" do
24
24
  end
25
25
  end
26
26
 
27
- context "with rails 3 style session value" do
27
+ context "with rails 3.1 style session value" do
28
28
  # {"session_id"=>"f8e1b8152ba7609c28bbb17ec9263ba7", "flash"=>#<ActionDispatch::Flash::FlashHash:0x00000000000000 @used=#<Set: {"farewell"}>, @closed=false, @flashes={"greeting"=>"Hello", "farewell"=>"Goodbye"}, @now=nil>}
29
29
  let(:cookie) { 'BAh7B0kiD3Nlc3Npb25faWQGOgZFRkkiJWY4ZTFiODE1MmJhNzYwOWMyOGJiYjE3ZWM5MjYzYmE3BjsAVEkiCmZsYXNoBjsARm86JUFjdGlvbkRpc3BhdGNoOjpGbGFzaDo6Rmxhc2hIYXNoCToKQHVzZWRvOghTZXQGOgpAaGFzaHsGSSINZmFyZXdlbGwGOwBUVDoMQGNsb3NlZEY6DUBmbGFzaGVzewdJIg1ncmVldGluZwY7AFRJIgpIZWxsbwY7AFRJIg1mYXJld2VsbAY7AFRJIgxHb29kYnllBjsAVDoJQG5vdzA=' }
30
30
  let(:session) { Marshal.load(Base64.decode64(cookie)) }
31
+
32
+ it "is breaks spectacularly" do
33
+ expect { session }.to raise_error(/dump format error/)
34
+ end
35
+ end
36
+
37
+ context "with rails 3.0 style session value" do
38
+ # {"session_id"=>"f8e1b8152ba7609c28bbb17ec9263ba7", "flash"=>{"greeting"=>"Hello", "farewell"=>"Goodbye"}} # <= (actually a FlashHash < Hash)
39
+ let(:cookie) { 'BAh7B0kiD3Nlc3Npb25faWQGOgZFVEkiJWY4ZTFiODE1MmJhNzYwOWMyOGJiYjE3ZWM5MjYzYmE3BjsAVEkiCmZsYXNoBjsAVElDOiVBY3Rpb25EaXNwYXRjaDo6Rmxhc2g6OkZsYXNoSGFzaHsHSSINZ3JlZXRpbmcGOwBUSSIKSGVsbG8GOwBUSSINZmFyZXdlbGwGOwBUSSIMR29vZGJ5ZQY7AFQGOgpAdXNlZG86CFNldAY6CkBoYXNoewZJIg1mYXJld2VsbAY7AFRU' }
40
+ let(:session) { Marshal.load(Base64.decode64(cookie)) }
31
41
  let(:value) { session["flash"] }
32
42
 
33
43
  it "is the expected flash" do
@@ -0,0 +1,72 @@
1
+ require 'base64'
2
+
3
+ require 'rails_4_session_flash_backport/rails3-1/flash_hash'
4
+
5
+ describe ActionDispatch::Flash::FlashHash, "backport" do
6
+ context "#from_session_value" do
7
+ subject(:flash) { described_class.from_session_value(value) }
8
+
9
+ context "with rails 4 style session value" do
10
+ context "without discards" do
11
+ let(:value) { {"flashes" => {"greeting" => "Hello"}} }
12
+
13
+ it "is the expected flash" do
14
+ expect(flash.to_hash).to eq("greeting" => "Hello")
15
+ end
16
+ end
17
+
18
+ context "with discards" do
19
+ let(:value) { {"flashes" => {"greeting" => "Hello", "farewell" => "Goodbye"}, "discard" => ["farewell"]} }
20
+
21
+ it "is the expected flash" do
22
+ expect(flash.to_hash).to eq("greeting" => "Hello")
23
+ end
24
+ end
25
+ end
26
+
27
+ context "with rails 3.1 style session value" do
28
+ # {"session_id"=>"f8e1b8152ba7609c28bbb17ec9263ba7", "flash"=>#<ActionDispatch::Flash::FlashHash:0x00000000000000 @used=#<Set: {"farewell"}>, @closed=false, @flashes={"greeting"=>"Hello", "farewell"=>"Goodbye"}, @now=nil>}
29
+ let(:cookie) { 'BAh7B0kiD3Nlc3Npb25faWQGOgZFRkkiJWY4ZTFiODE1MmJhNzYwOWMyOGJiYjE3ZWM5MjYzYmE3BjsAVEkiCmZsYXNoBjsARm86JUFjdGlvbkRpc3BhdGNoOjpGbGFzaDo6Rmxhc2hIYXNoCToKQHVzZWRvOghTZXQGOgpAaGFzaHsGSSINZmFyZXdlbGwGOwBUVDoMQGNsb3NlZEY6DUBmbGFzaGVzewdJIg1ncmVldGluZwY7AFRJIgpIZWxsbwY7AFRJIg1mYXJld2VsbAY7AFRJIgxHb29kYnllBjsAVDoJQG5vdzA=' }
30
+ let(:session) { Marshal.load(Base64.decode64(cookie)) }
31
+ let(:value) { session["flash"] }
32
+
33
+ it "is the expected flash" do
34
+ expect(flash.to_hash).to eq("greeting" => "Hello")
35
+ end
36
+ end
37
+
38
+ context "with rails 3.0 style session value" do
39
+ # {"session_id"=>"f8e1b8152ba7609c28bbb17ec9263ba7", "flash"=>{"greeting"=>"Hello", "farewell"=>"Goodbye"}} # <= (actually a FlashHash < Hash)
40
+ let(:cookie) { 'BAh7B0kiD3Nlc3Npb25faWQGOgZFVEkiJWY4ZTFiODE1MmJhNzYwOWMyOGJiYjE3ZWM5MjYzYmE3BjsAVEkiCmZsYXNoBjsAVElDOiVBY3Rpb25EaXNwYXRjaDo6Rmxhc2g6OkZsYXNoSGFzaHsHSSINZ3JlZXRpbmcGOwBUSSIKSGVsbG8GOwBUSSINZmFyZXdlbGwGOwBUSSIMR29vZGJ5ZQY7AFQGOgpAdXNlZG86CFNldAY6CkBoYXNoewZJIg1mYXJld2VsbAY7AFRU' }
41
+ let(:session) { Marshal.load(Base64.decode64(cookie)) }
42
+
43
+ it "is breaks spectacularly" do
44
+ expect { session }.to raise_error(/dump format error/)
45
+ end
46
+ end
47
+
48
+ context "with rails 2 style session value" do
49
+ # {"session_id"=>"f8e1b8152ba7609c28bbb17ec9263ba7", "flash"=>#<ActionController::Flash::FlashHash:0x00000000000000 @used={"farewell"=>true}, {"greeting"=>"Hello", "farewell"=>"Goodbye"}>}
50
+ let(:cookie) { 'BAh7B0kiD3Nlc3Npb25faWQGOgZFVEkiJWY4ZTFiODE1MmJhNzYwOWMyOGJiYjE3ZWM5MjYzYmE3BjsAVEkiCmZsYXNoBjsAVElDOidBY3Rpb25Db250cm9sbGVyOjpGbGFzaDo6Rmxhc2hIYXNoewdJIg1mYXJld2VsbAY7AFRJIgxHb29kYnllBjsAVEkiDWdyZWV0aW5nBjsAVEkiCkhlbGxvBjsAVAY6CkB1c2VkewZJIg1mYXJld2VsbAY7AFRU' }
51
+ let(:session) { Marshal.load(Base64.decode64(cookie)) }
52
+ let(:value) { session["flash"] }
53
+
54
+ it "is the expected flash" do
55
+ expect(flash.to_hash).to eq("greeting" => "Hello")
56
+ end
57
+ end
58
+ end
59
+
60
+ context "#to_session_value" do
61
+ subject(:flash) { described_class.new }
62
+
63
+ before do
64
+ flash["greeting"] = "Hello"
65
+ flash.now["farewell"] = "Goodbye"
66
+ end
67
+
68
+ it "dumps to basic objects like rails 4" do
69
+ expect(flash.to_session_value).to eq("flashes" => {"greeting" => "Hello"})
70
+ end
71
+ end
72
+ end
@@ -24,7 +24,7 @@ describe ActionDispatch::Flash::FlashHash, "backport" do
24
24
  end
25
25
  end
26
26
 
27
- context "with rails 3 style session value" do
27
+ context "with rails 3.1 style session value" do
28
28
  # {"session_id"=>"f8e1b8152ba7609c28bbb17ec9263ba7", "flash"=>#<ActionDispatch::Flash::FlashHash:0x00000000000000 @used=#<Set: {"farewell"}>, @closed=false, @flashes={"greeting"=>"Hello", "farewell"=>"Goodbye"}, @now=nil>}
29
29
  let(:cookie) { 'BAh7B0kiD3Nlc3Npb25faWQGOgZFRkkiJWY4ZTFiODE1MmJhNzYwOWMyOGJiYjE3ZWM5MjYzYmE3BjsAVEkiCmZsYXNoBjsARm86JUFjdGlvbkRpc3BhdGNoOjpGbGFzaDo6Rmxhc2hIYXNoCToKQHVzZWRvOghTZXQGOgpAaGFzaHsGSSINZmFyZXdlbGwGOwBUVDoMQGNsb3NlZEY6DUBmbGFzaGVzewdJIg1ncmVldGluZwY7AFRJIgpIZWxsbwY7AFRJIg1mYXJld2VsbAY7AFRJIgxHb29kYnllBjsAVDoJQG5vdzA=' }
30
30
  let(:session) { Marshal.load(Base64.decode64(cookie)) }
@@ -35,6 +35,16 @@ describe ActionDispatch::Flash::FlashHash, "backport" do
35
35
  end
36
36
  end
37
37
 
38
+ context "with rails 3.0 style session value" do
39
+ # {"session_id"=>"f8e1b8152ba7609c28bbb17ec9263ba7", "flash"=>{"greeting"=>"Hello", "farewell"=>"Goodbye"}} # <= (actually a FlashHash < Hash)
40
+ let(:cookie) { 'BAh7B0kiD3Nlc3Npb25faWQGOgZFVEkiJWY4ZTFiODE1MmJhNzYwOWMyOGJiYjE3ZWM5MjYzYmE3BjsAVEkiCmZsYXNoBjsAVElDOiVBY3Rpb25EaXNwYXRjaDo6Rmxhc2g6OkZsYXNoSGFzaHsHSSINZ3JlZXRpbmcGOwBUSSIKSGVsbG8GOwBUSSINZmFyZXdlbGwGOwBUSSIMR29vZGJ5ZQY7AFQGOgpAdXNlZG86CFNldAY6CkBoYXNoewZJIg1mYXJld2VsbAY7AFRU' }
41
+ let(:session) { Marshal.load(Base64.decode64(cookie)) }
42
+
43
+ it "is breaks spectacularly" do
44
+ expect { session }.to raise_error(/dump format error/)
45
+ end
46
+ end
47
+
38
48
  context "with rails 2 style session value" do
39
49
  # {"session_id"=>"f8e1b8152ba7609c28bbb17ec9263ba7", "flash"=>#<ActionController::Flash::FlashHash:0x00000000000000 @used={"farewell"=>true}, {"greeting"=>"Hello", "farewell"=>"Goodbye"}>}
40
50
  let(:cookie) { 'BAh7B0kiD3Nlc3Npb25faWQGOgZFVEkiJWY4ZTFiODE1MmJhNzYwOWMyOGJiYjE3ZWM5MjYzYmE3BjsAVEkiCmZsYXNoBjsAVElDOidBY3Rpb25Db250cm9sbGVyOjpGbGFzaDo6Rmxhc2hIYXNoewdJIg1mYXJld2VsbAY7AFRJIgxHb29kYnllBjsAVEkiDWdyZWV0aW5nBjsAVEkiCkhlbGxvBjsAVAY6CkB1c2VkewZJIg1mYXJld2VsbAY7AFRU' }
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails_4_session_flash_backport
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lucas Parry
@@ -29,7 +29,7 @@ cert_chain:
29
29
  HLacq0o6ejD7AFG3HPAVFeYEnrwCYd6siMnzpVrt3pHfZJxsuhbNnteASNcnk9Uk
30
30
  YIxHmqJUGGnmqwuBfXe8LZHC5ETJLuZlzO2odzNueQlhukD4wdNa/r4pD1o=
31
31
  -----END CERTIFICATE-----
32
- date: 2015-02-02 00:00:00.000000000 Z
32
+ date: 2015-02-16 00:00:00.000000000 Z
33
33
  dependencies:
34
34
  - !ruby/object:Gem::Dependency
35
35
  name: rails
@@ -107,21 +107,31 @@ files:
107
107
  - LICENSE.txt
108
108
  - README.md
109
109
  - Rakefile
110
- - gemfiles/Gemfile.rails2
111
- - gemfiles/Gemfile.rails2.lock
112
- - gemfiles/Gemfile.rails3
113
- - gemfiles/Gemfile.rails3.lock
114
- - gemfiles/Gemfile.rails4
115
- - gemfiles/Gemfile.rails4.lock
110
+ - gemfiles/Gemfile.rails-2.3.x
111
+ - gemfiles/Gemfile.rails-2.3.x.lock
112
+ - gemfiles/Gemfile.rails-3.0.x
113
+ - gemfiles/Gemfile.rails-3.0.x.lock
114
+ - gemfiles/Gemfile.rails-3.1.x
115
+ - gemfiles/Gemfile.rails-3.1.x.lock
116
+ - gemfiles/Gemfile.rails-3.2.x
117
+ - gemfiles/Gemfile.rails-3.2.x.lock
118
+ - gemfiles/Gemfile.rails-4.0.x
119
+ - gemfiles/Gemfile.rails-4.0.x.lock
120
+ - gemfiles/Gemfile.rails-4.1.x
121
+ - gemfiles/Gemfile.rails-4.1.x.lock
122
+ - gemfiles/Gemfile.rails-4.2.x
123
+ - gemfiles/Gemfile.rails-4.2.x.lock
116
124
  - lib/rails_4_session_flash_backport.rb
117
125
  - lib/rails_4_session_flash_backport/rails2/flash_hash.rb
118
126
  - lib/rails_4_session_flash_backport/rails2/session_with_indifferent_access.rb
119
- - lib/rails_4_session_flash_backport/rails3/flash_hash.rb
127
+ - lib/rails_4_session_flash_backport/rails3-0/flash_hash.rb
128
+ - lib/rails_4_session_flash_backport/rails3-1/flash_hash.rb
120
129
  - lib/rails_4_session_flash_backport/rails4/flash_hash.rb
121
130
  - lib/rails_4_session_flash_backport/version.rb
122
131
  - rails_4_session_flash_backport.gemspec
123
132
  - spec/rails2/flash_hash_spec.rb
124
- - spec/rails3/flash_hash_spec.rb
133
+ - spec/rails3-0/flash_hash_spec.rb
134
+ - spec/rails3-1/flash_hash_spec.rb
125
135
  - spec/rails4/flash_hash_spec.rb
126
136
  homepage: https://github.com/envato/rails_4_session_flash_backport
127
137
  licenses: []
@@ -149,6 +159,6 @@ summary: Backport of the way Rails 4 stores flash messages in the session to Rai
149
159
  2/3/4, so you can safely take a session betweens Rails versions without things exploding.
150
160
  test_files:
151
161
  - spec/rails2/flash_hash_spec.rb
152
- - spec/rails3/flash_hash_spec.rb
162
+ - spec/rails3-0/flash_hash_spec.rb
163
+ - spec/rails3-1/flash_hash_spec.rb
153
164
  - spec/rails4/flash_hash_spec.rb
154
- has_rdoc:
metadata.gz.sig CHANGED
Binary file