rails-session_cookie 0.1.0 → 0.2.0

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: aaebe5fd70ce3e0e10e605f5293af233d5fedd98
4
- data.tar.gz: 1a5245e091c0dae70ce4941ba61f32da06e046ac
3
+ metadata.gz: f80af1c121f1523b9b61f6863eacb11204f087ab
4
+ data.tar.gz: 0613e54e03fdd358cd80e6b573114e2a3da22cd8
5
5
  SHA512:
6
- metadata.gz: ccaee593138ee4dc61a25a1952017a98516ebdff2814a4200a63a0cd6503bea61b802c7a34e53e76a08a780d4305f078f9d49af53d7fa36c8e1a03db81bcd598
7
- data.tar.gz: f081b17921a95d6aa87ae4e9ec20ca5cf3d9efb11f11a74a5803da3981d94fbf5391704f572d6a5457c6beef977a6e617a9a725ed70634cb726139d3ebd48666
6
+ metadata.gz: 75df118836f8174f47ad2ecbc8c4ad7d734e0568b57de42306d2ccc219f7aa978722211bc1d70b7745fa0e8001983d68605c3cbb7560636694af2cfed950b540
7
+ data.tar.gz: 1e77956b3dd4a6360ac4530ce1e8fa4905a9a41656cb1de750b3f37a5fa2ec32c001ac17416cae43a9f9c54a49b694945ffd0dc98ff0eda969c1b02cd5cde77d
@@ -3,6 +3,9 @@ AllCops:
3
3
  - 'gemfiles/vendor/**/*'
4
4
  Metrics/LineLength:
5
5
  Max: 120
6
+ Style/MultilineBlockChain:
7
+ Enabled: false
6
8
  Metrics/BlockLength:
7
- Exclude:
8
- - 'spec/**/*_spec.rb'
9
+ Enabled: false
10
+ Lint/AmbiguousBlockAssociation:
11
+ Enabled: false
@@ -7,8 +7,11 @@ rvm:
7
7
  - 2.2.7
8
8
  gemfile:
9
9
  - gemfiles/rails_4.2.gemfile
10
+ - gemfiles/rails_4.2_warden.gemfile
10
11
  - gemfiles/rails_5.0.gemfile
12
+ - gemfiles/rails_5.0_warden.gemfile
11
13
  - gemfiles/rails_5.1.gemfile
14
+ - gemfiles/rails_5.1_warden.gemfile
12
15
  before_install: gem install bundler -v 1.15.4
13
16
  script:
14
17
  - bundle exec rake
data/Appraisals CHANGED
@@ -2,10 +2,31 @@ appraise 'rails-4.2' do
2
2
  gem 'rails', '~> 4.2.9'
3
3
  end
4
4
 
5
+ appraise 'rails-4.2-warden' do
6
+ gem 'rails', '~> 4.2.9'
7
+
8
+ gem 'warden', '>= 1.2'
9
+ gem 'devise', '~> 4.3'
10
+ end
11
+
5
12
  appraise 'rails-5.0' do
6
13
  gem 'rails', '~> 5.0.5'
7
14
  end
8
15
 
16
+ appraise 'rails-5.0-warden' do
17
+ gem 'rails', '~> 5.0.5'
18
+
19
+ gem 'warden', '>= 1.2'
20
+ gem 'devise', '~> 4.3'
21
+ end
22
+
9
23
  appraise 'rails-5.1' do
10
24
  gem 'rails', '~> 5.1.3'
11
25
  end
26
+
27
+ appraise 'rails-5.1-warden' do
28
+ gem 'rails', '~> 5.1.3'
29
+
30
+ gem 'warden', '>= 1.2'
31
+ gem 'devise', '~> 4.3'
32
+ end
data/README.md CHANGED
@@ -4,7 +4,6 @@ Fast, loosely coupled requests specs for a cookie-authenticated application.
4
4
 
5
5
  [![Gem Version][GV img]][Gem Version]
6
6
  [![Build Status][BS img]][Build Status]
7
- [![Code Climate][CC img]][Code Climate]
8
7
  [![Coverage][CV img]][Coverage]
9
8
 
10
9
  ## Why
@@ -53,7 +52,7 @@ Rails is modular, that's cool :)
53
52
  gem 'rails-session_cookie', group: :test
54
53
  ```
55
54
 
56
- ## Usage
55
+ ## Usage in requests specs
57
56
 
58
57
  ```ruby
59
58
  # spec_helper.rb
@@ -100,16 +99,68 @@ Of course, you can just make use (and reuse!) of as many procs as you wish.
100
99
  This effectively achieves the effect as [this PR#18230](https://github.com/rails/rails/pull/18230/files), which allows session mutation
101
100
  in a less invasive way in regard to Rails itself ;)
102
101
 
102
+ ## Warden / Devise
103
+
104
+ Getting session cookie is dead-simple, just get the cookie this way:
105
+
106
+ ```ruby
107
+ raw_session_cookie = Rails::SessionCookie::WardenApp.new(user).session_cookie
108
+ ```
109
+
110
+ ## Feature tests using Capybara
111
+
112
+ Get the cookie as described above according to your setup, and assign this way:
113
+
114
+ ```ruby
115
+ Capybara.current_session.driver.browser.set_cookie raw_session_cookie
116
+ ```
117
+
118
+ *TODO:* Only tested with `:rack_test` driver!
119
+
120
+ ## Benchmarks
121
+
122
+ *NOTE:* Sometimes devise's `sing_in` is still faster than `SessionCookie` (a little though),
123
+ because Warden uses an [ugly hack, in my opinion,](https://github.com/hassox/warden/blob/master/lib/warden/test/helpers.rb#L18L23)
124
+ to support test-mode authentication.
125
+
126
+ But, still, in average performance of this gem is not worse *if used with user_id->cookie caching*
127
+ Besides, authentication becomes as transparent as possible and should increase readability
128
+ if you understand HTTP session cookies principles.
129
+
130
+ ```sh
131
+ $ appraisal rails-5.1-warden rspec -t performance spec/benchmarks
132
+
133
+ Speed using capybara in feature test
134
+ correctness of
135
+ SessionCookie
136
+ is correct
137
+ Devise Helpers
138
+ are correct
139
+ against Devise::Test::Helpers
140
+ is obviously slower separately
141
+ is not slower than devise helpers if using cache and executing multiple specs in a suite
142
+
143
+ Speed using custom sign-in in request test
144
+ correctness of
145
+ SessionCookie
146
+ is correct
147
+ usual session controller
148
+ is correct
149
+ against custom sign in route
150
+ is faster separately without cache
151
+
152
+ Finished in 1.89 seconds (files took 0.89589 seconds to load)
153
+ 7 examples, 0 failures
154
+ ```
155
+
103
156
  ## Contributing
104
157
 
105
158
  Bug reports and pull requests are welcome on GitHub at https://github.com/razum2um/rails-session_cookie.
106
159
 
107
160
  [Gem Version]: https://rubygems.org/gems/rails-session_cookie
108
161
  [Build Status]: https://travis-ci.org/razum2um/rails-session_cookie
109
- [Code Climate]: https://codeclimate.com/github/razum2um/rails-session_cookie
110
162
  [Coverage]: https://codeclimate.com/github/razum2um/rails-session_cookie/coverage
111
163
 
112
- [GV img]: https://badge.fury.io/rb/rails-session_cookie.png
164
+ [GV img]: https://badge.fury.io/rb/rails-session_cookie.svg
113
165
  [BS img]: https://travis-ci.org/razum2um/rails-session_cookie.png
114
- [CC img]: https://codeclimate.com/github/razum2um/rails-session_cookie/badges/gpa.svg
115
166
  [CV img]: https://codeclimate.com/github/razum2um/rails-session_cookie/badges/coverage.svg
@@ -41,14 +41,24 @@ GEM
41
41
  minitest (~> 5.1)
42
42
  thread_safe (~> 0.3, >= 0.3.4)
43
43
  tzinfo (~> 1.1)
44
+ addressable (2.5.2)
45
+ public_suffix (>= 2.0.2, < 4.0)
44
46
  appraisal (2.2.0)
45
47
  bundler
46
48
  rake
47
49
  thor (>= 0.14.0)
48
50
  arel (6.0.4)
49
51
  ast (2.3.0)
52
+ benchmark-perf (0.2.1)
50
53
  builder (3.2.3)
51
54
  byebug (9.0.6)
55
+ capybara (2.15.1)
56
+ addressable
57
+ mini_mime (>= 0.1.3)
58
+ nokogiri (>= 1.3.3)
59
+ rack (>= 1.0.0)
60
+ rack-test (>= 0.5.4)
61
+ xpath (~> 2.0)
52
62
  codeclimate-test-reporter (1.0.8)
53
63
  simplecov (<= 0.13)
54
64
  coderay (1.1.1)
@@ -68,6 +78,7 @@ GEM
68
78
  mime-types (3.1)
69
79
  mime-types-data (~> 3.2015)
70
80
  mime-types-data (3.2016.0521)
81
+ mini_mime (0.1.4)
71
82
  mini_portile2 (2.2.0)
72
83
  minitest (5.10.3)
73
84
  nokogiri (1.8.0)
@@ -83,6 +94,7 @@ GEM
83
94
  pry-byebug (3.4.2)
84
95
  byebug (~> 9.0)
85
96
  pry (~> 0.10)
97
+ public_suffix (3.0.0)
86
98
  rack (1.6.8)
87
99
  rack-test (0.6.3)
88
100
  rack (>= 1.0)
@@ -117,6 +129,9 @@ GEM
117
129
  rspec-core (~> 3.6.0)
118
130
  rspec-expectations (~> 3.6.0)
119
131
  rspec-mocks (~> 3.6.0)
132
+ rspec-benchmark (0.3.0)
133
+ benchmark-perf (~> 0.2.0)
134
+ rspec (>= 3.0.0, < 4.0.0)
120
135
  rspec-core (3.6.0)
121
136
  rspec-support (~> 3.6.0)
122
137
  rspec-expectations (3.6.0)
@@ -155,11 +170,14 @@ GEM
155
170
  actionpack (>= 4.0)
156
171
  activesupport (>= 4.0)
157
172
  sprockets (>= 3.0.0)
173
+ sqlite3 (1.3.13)
158
174
  thor (0.20.0)
159
175
  thread_safe (0.3.6)
160
176
  tzinfo (1.2.3)
161
177
  thread_safe (~> 0.1)
162
178
  unicode-display_width (1.3.0)
179
+ xpath (2.1.0)
180
+ nokogiri (~> 1.3)
163
181
 
164
182
  PLATFORMS
165
183
  ruby
@@ -167,15 +185,18 @@ PLATFORMS
167
185
  DEPENDENCIES
168
186
  appraisal (~> 2.2)
169
187
  bundler (~> 1.15)
188
+ capybara (~> 2.15)
170
189
  codeclimate-test-reporter (= 1.0.8)
171
190
  pry-byebug
172
191
  rails (~> 4.2.9)
173
192
  rails-session_cookie!
174
193
  rake (~> 10.0)
175
194
  rspec (~> 3.0)
195
+ rspec-benchmark (~> 0.3)
176
196
  rspec-rails (~> 3.6.1)
177
197
  rubocop (~> 0.49)
178
198
  simplecov (= 0.13.0)
199
+ sqlite3 (~> 1.3)
179
200
 
180
201
  BUNDLED WITH
181
202
  1.15.4
@@ -0,0 +1,10 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "pry-byebug"
6
+ gem "rails", "~> 4.2.9"
7
+ gem "warden", ">= 1.2"
8
+ gem "devise", "~> 4.3"
9
+
10
+ gemspec path: "../"
@@ -0,0 +1,217 @@
1
+ PATH
2
+ remote: ..
3
+ specs:
4
+ rails-session_cookie (0.1.0)
5
+ rails (>= 4.0)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ actionmailer (4.2.9)
11
+ actionpack (= 4.2.9)
12
+ actionview (= 4.2.9)
13
+ activejob (= 4.2.9)
14
+ mail (~> 2.5, >= 2.5.4)
15
+ rails-dom-testing (~> 1.0, >= 1.0.5)
16
+ actionpack (4.2.9)
17
+ actionview (= 4.2.9)
18
+ activesupport (= 4.2.9)
19
+ rack (~> 1.6)
20
+ rack-test (~> 0.6.2)
21
+ rails-dom-testing (~> 1.0, >= 1.0.5)
22
+ rails-html-sanitizer (~> 1.0, >= 1.0.2)
23
+ actionview (4.2.9)
24
+ activesupport (= 4.2.9)
25
+ builder (~> 3.1)
26
+ erubis (~> 2.7.0)
27
+ rails-dom-testing (~> 1.0, >= 1.0.5)
28
+ rails-html-sanitizer (~> 1.0, >= 1.0.3)
29
+ activejob (4.2.9)
30
+ activesupport (= 4.2.9)
31
+ globalid (>= 0.3.0)
32
+ activemodel (4.2.9)
33
+ activesupport (= 4.2.9)
34
+ builder (~> 3.1)
35
+ activerecord (4.2.9)
36
+ activemodel (= 4.2.9)
37
+ activesupport (= 4.2.9)
38
+ arel (~> 6.0)
39
+ activesupport (4.2.9)
40
+ i18n (~> 0.7)
41
+ minitest (~> 5.1)
42
+ thread_safe (~> 0.3, >= 0.3.4)
43
+ tzinfo (~> 1.1)
44
+ addressable (2.5.2)
45
+ public_suffix (>= 2.0.2, < 4.0)
46
+ appraisal (2.2.0)
47
+ bundler
48
+ rake
49
+ thor (>= 0.14.0)
50
+ arel (6.0.4)
51
+ ast (2.3.0)
52
+ bcrypt (3.1.11)
53
+ benchmark-perf (0.2.1)
54
+ builder (3.2.3)
55
+ byebug (9.1.0)
56
+ capybara (2.15.1)
57
+ addressable
58
+ mini_mime (>= 0.1.3)
59
+ nokogiri (>= 1.3.3)
60
+ rack (>= 1.0.0)
61
+ rack-test (>= 0.5.4)
62
+ xpath (~> 2.0)
63
+ codeclimate-test-reporter (1.0.8)
64
+ simplecov (<= 0.13)
65
+ coderay (1.1.2)
66
+ concurrent-ruby (1.0.5)
67
+ devise (4.3.0)
68
+ bcrypt (~> 3.0)
69
+ orm_adapter (~> 0.1)
70
+ railties (>= 4.1.0, < 5.2)
71
+ responders
72
+ warden (~> 1.2.3)
73
+ diff-lcs (1.3)
74
+ docile (1.1.5)
75
+ erubis (2.7.0)
76
+ globalid (0.4.0)
77
+ activesupport (>= 4.2.0)
78
+ i18n (0.8.6)
79
+ json (2.1.0)
80
+ loofah (2.0.3)
81
+ nokogiri (>= 1.5.9)
82
+ mail (2.6.6)
83
+ mime-types (>= 1.16, < 4)
84
+ method_source (0.8.2)
85
+ mime-types (3.1)
86
+ mime-types-data (~> 3.2015)
87
+ mime-types-data (3.2016.0521)
88
+ mini_mime (0.1.4)
89
+ mini_portile2 (2.2.0)
90
+ minitest (5.10.3)
91
+ nokogiri (1.8.0)
92
+ mini_portile2 (~> 2.2.0)
93
+ orm_adapter (0.5.0)
94
+ parallel (1.12.0)
95
+ parser (2.4.0.0)
96
+ ast (~> 2.2)
97
+ powerpack (0.1.1)
98
+ pry (0.10.4)
99
+ coderay (~> 1.1.0)
100
+ method_source (~> 0.8.1)
101
+ slop (~> 3.4)
102
+ pry-byebug (3.5.0)
103
+ byebug (~> 9.1)
104
+ pry (~> 0.10)
105
+ public_suffix (3.0.0)
106
+ rack (1.6.8)
107
+ rack-test (0.6.3)
108
+ rack (>= 1.0)
109
+ rails (4.2.9)
110
+ actionmailer (= 4.2.9)
111
+ actionpack (= 4.2.9)
112
+ actionview (= 4.2.9)
113
+ activejob (= 4.2.9)
114
+ activemodel (= 4.2.9)
115
+ activerecord (= 4.2.9)
116
+ activesupport (= 4.2.9)
117
+ bundler (>= 1.3.0, < 2.0)
118
+ railties (= 4.2.9)
119
+ sprockets-rails
120
+ rails-deprecated_sanitizer (1.0.3)
121
+ activesupport (>= 4.2.0.alpha)
122
+ rails-dom-testing (1.0.8)
123
+ activesupport (>= 4.2.0.beta, < 5.0)
124
+ nokogiri (~> 1.6)
125
+ rails-deprecated_sanitizer (>= 1.0.1)
126
+ rails-html-sanitizer (1.0.3)
127
+ loofah (~> 2.0)
128
+ railties (4.2.9)
129
+ actionpack (= 4.2.9)
130
+ activesupport (= 4.2.9)
131
+ rake (>= 0.8.7)
132
+ thor (>= 0.18.1, < 2.0)
133
+ rainbow (2.2.2)
134
+ rake
135
+ rake (10.5.0)
136
+ responders (2.4.0)
137
+ actionpack (>= 4.2.0, < 5.3)
138
+ railties (>= 4.2.0, < 5.3)
139
+ rspec (3.6.0)
140
+ rspec-core (~> 3.6.0)
141
+ rspec-expectations (~> 3.6.0)
142
+ rspec-mocks (~> 3.6.0)
143
+ rspec-benchmark (0.3.0)
144
+ benchmark-perf (~> 0.2.0)
145
+ rspec (>= 3.0.0, < 4.0.0)
146
+ rspec-core (3.6.0)
147
+ rspec-support (~> 3.6.0)
148
+ rspec-expectations (3.6.0)
149
+ diff-lcs (>= 1.2.0, < 2.0)
150
+ rspec-support (~> 3.6.0)
151
+ rspec-mocks (3.6.0)
152
+ diff-lcs (>= 1.2.0, < 2.0)
153
+ rspec-support (~> 3.6.0)
154
+ rspec-rails (3.6.1)
155
+ actionpack (>= 3.0)
156
+ activesupport (>= 3.0)
157
+ railties (>= 3.0)
158
+ rspec-core (~> 3.6.0)
159
+ rspec-expectations (~> 3.6.0)
160
+ rspec-mocks (~> 3.6.0)
161
+ rspec-support (~> 3.6.0)
162
+ rspec-support (3.6.0)
163
+ rubocop (0.49.1)
164
+ parallel (~> 1.10)
165
+ parser (>= 2.3.3.1, < 3.0)
166
+ powerpack (~> 0.1)
167
+ rainbow (>= 1.99.1, < 3.0)
168
+ ruby-progressbar (~> 1.7)
169
+ unicode-display_width (~> 1.0, >= 1.0.1)
170
+ ruby-progressbar (1.8.1)
171
+ simplecov (0.13.0)
172
+ docile (~> 1.1.0)
173
+ json (>= 1.8, < 3)
174
+ simplecov-html (~> 0.10.0)
175
+ simplecov-html (0.10.2)
176
+ slop (3.6.0)
177
+ sprockets (3.7.1)
178
+ concurrent-ruby (~> 1.0)
179
+ rack (> 1, < 3)
180
+ sprockets-rails (3.2.1)
181
+ actionpack (>= 4.0)
182
+ activesupport (>= 4.0)
183
+ sprockets (>= 3.0.0)
184
+ sqlite3 (1.3.13)
185
+ thor (0.20.0)
186
+ thread_safe (0.3.6)
187
+ tzinfo (1.2.3)
188
+ thread_safe (~> 0.1)
189
+ unicode-display_width (1.3.0)
190
+ warden (1.2.7)
191
+ rack (>= 1.0)
192
+ xpath (2.1.0)
193
+ nokogiri (~> 1.3)
194
+
195
+ PLATFORMS
196
+ ruby
197
+
198
+ DEPENDENCIES
199
+ appraisal (~> 2.2)
200
+ bundler (~> 1.15)
201
+ capybara (~> 2.15)
202
+ codeclimate-test-reporter (= 1.0.8)
203
+ devise (~> 4.3)
204
+ pry-byebug
205
+ rails (~> 4.2.9)
206
+ rails-session_cookie!
207
+ rake (~> 10.0)
208
+ rspec (~> 3.0)
209
+ rspec-benchmark (~> 0.3)
210
+ rspec-rails (~> 3.6.1)
211
+ rubocop (~> 0.49)
212
+ simplecov (= 0.13.0)
213
+ sqlite3 (~> 1.3)
214
+ warden (>= 1.2)
215
+
216
+ BUNDLED WITH
217
+ 1.15.4
@@ -44,14 +44,24 @@ GEM
44
44
  i18n (~> 0.7)
45
45
  minitest (~> 5.1)
46
46
  tzinfo (~> 1.1)
47
+ addressable (2.5.2)
48
+ public_suffix (>= 2.0.2, < 4.0)
47
49
  appraisal (2.2.0)
48
50
  bundler
49
51
  rake
50
52
  thor (>= 0.14.0)
51
53
  arel (7.1.4)
52
54
  ast (2.3.0)
55
+ benchmark-perf (0.2.1)
53
56
  builder (3.2.3)
54
57
  byebug (9.0.6)
58
+ capybara (2.15.1)
59
+ addressable
60
+ mini_mime (>= 0.1.3)
61
+ nokogiri (>= 1.3.3)
62
+ rack (>= 1.0.0)
63
+ rack-test (>= 0.5.4)
64
+ xpath (~> 2.0)
55
65
  codeclimate-test-reporter (1.0.8)
56
66
  simplecov (<= 0.13)
57
67
  coderay (1.1.1)
@@ -71,6 +81,7 @@ GEM
71
81
  mime-types (3.1)
72
82
  mime-types-data (~> 3.2015)
73
83
  mime-types-data (3.2016.0521)
84
+ mini_mime (0.1.4)
74
85
  mini_portile2 (2.2.0)
75
86
  minitest (5.10.3)
76
87
  nio4r (2.1.0)
@@ -87,6 +98,7 @@ GEM
87
98
  pry-byebug (3.4.2)
88
99
  byebug (~> 9.0)
89
100
  pry (~> 0.10)
101
+ public_suffix (3.0.0)
90
102
  rack (2.0.3)
91
103
  rack-test (0.6.3)
92
104
  rack (>= 1.0)
@@ -120,6 +132,9 @@ GEM
120
132
  rspec-core (~> 3.6.0)
121
133
  rspec-expectations (~> 3.6.0)
122
134
  rspec-mocks (~> 3.6.0)
135
+ rspec-benchmark (0.3.0)
136
+ benchmark-perf (~> 0.2.0)
137
+ rspec (>= 3.0.0, < 4.0.0)
123
138
  rspec-core (3.6.0)
124
139
  rspec-support (~> 3.6.0)
125
140
  rspec-expectations (3.6.0)
@@ -158,6 +173,7 @@ GEM
158
173
  actionpack (>= 4.0)
159
174
  activesupport (>= 4.0)
160
175
  sprockets (>= 3.0.0)
176
+ sqlite3 (1.3.13)
161
177
  thor (0.20.0)
162
178
  thread_safe (0.3.6)
163
179
  tzinfo (1.2.3)
@@ -166,6 +182,8 @@ GEM
166
182
  websocket-driver (0.6.5)
167
183
  websocket-extensions (>= 0.1.0)
168
184
  websocket-extensions (0.1.2)
185
+ xpath (2.1.0)
186
+ nokogiri (~> 1.3)
169
187
 
170
188
  PLATFORMS
171
189
  ruby
@@ -173,15 +191,18 @@ PLATFORMS
173
191
  DEPENDENCIES
174
192
  appraisal (~> 2.2)
175
193
  bundler (~> 1.15)
194
+ capybara (~> 2.15)
176
195
  codeclimate-test-reporter (= 1.0.8)
177
196
  pry-byebug
178
197
  rails (~> 5.0.5)
179
198
  rails-session_cookie!
180
199
  rake (~> 10.0)
181
200
  rspec (~> 3.0)
201
+ rspec-benchmark (~> 0.3)
182
202
  rspec-rails (~> 3.6.1)
183
203
  rubocop (~> 0.49)
184
204
  simplecov (= 0.13.0)
205
+ sqlite3 (~> 1.3)
185
206
 
186
207
  BUNDLED WITH
187
208
  1.15.4
@@ -0,0 +1,10 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "pry-byebug"
6
+ gem "rails", "~> 5.0.5"
7
+ gem "warden", ">= 1.2"
8
+ gem "devise", "~> 4.3"
9
+
10
+ gemspec path: "../"
@@ -0,0 +1,223 @@
1
+ PATH
2
+ remote: ..
3
+ specs:
4
+ rails-session_cookie (0.1.0)
5
+ rails (>= 4.0)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ actioncable (5.0.5)
11
+ actionpack (= 5.0.5)
12
+ nio4r (>= 1.2, < 3.0)
13
+ websocket-driver (~> 0.6.1)
14
+ actionmailer (5.0.5)
15
+ actionpack (= 5.0.5)
16
+ actionview (= 5.0.5)
17
+ activejob (= 5.0.5)
18
+ mail (~> 2.5, >= 2.5.4)
19
+ rails-dom-testing (~> 2.0)
20
+ actionpack (5.0.5)
21
+ actionview (= 5.0.5)
22
+ activesupport (= 5.0.5)
23
+ rack (~> 2.0)
24
+ rack-test (~> 0.6.3)
25
+ rails-dom-testing (~> 2.0)
26
+ rails-html-sanitizer (~> 1.0, >= 1.0.2)
27
+ actionview (5.0.5)
28
+ activesupport (= 5.0.5)
29
+ builder (~> 3.1)
30
+ erubis (~> 2.7.0)
31
+ rails-dom-testing (~> 2.0)
32
+ rails-html-sanitizer (~> 1.0, >= 1.0.3)
33
+ activejob (5.0.5)
34
+ activesupport (= 5.0.5)
35
+ globalid (>= 0.3.6)
36
+ activemodel (5.0.5)
37
+ activesupport (= 5.0.5)
38
+ activerecord (5.0.5)
39
+ activemodel (= 5.0.5)
40
+ activesupport (= 5.0.5)
41
+ arel (~> 7.0)
42
+ activesupport (5.0.5)
43
+ concurrent-ruby (~> 1.0, >= 1.0.2)
44
+ i18n (~> 0.7)
45
+ minitest (~> 5.1)
46
+ tzinfo (~> 1.1)
47
+ addressable (2.5.2)
48
+ public_suffix (>= 2.0.2, < 4.0)
49
+ appraisal (2.2.0)
50
+ bundler
51
+ rake
52
+ thor (>= 0.14.0)
53
+ arel (7.1.4)
54
+ ast (2.3.0)
55
+ bcrypt (3.1.11)
56
+ benchmark-perf (0.2.1)
57
+ builder (3.2.3)
58
+ byebug (9.1.0)
59
+ capybara (2.15.1)
60
+ addressable
61
+ mini_mime (>= 0.1.3)
62
+ nokogiri (>= 1.3.3)
63
+ rack (>= 1.0.0)
64
+ rack-test (>= 0.5.4)
65
+ xpath (~> 2.0)
66
+ codeclimate-test-reporter (1.0.8)
67
+ simplecov (<= 0.13)
68
+ coderay (1.1.2)
69
+ concurrent-ruby (1.0.5)
70
+ devise (4.3.0)
71
+ bcrypt (~> 3.0)
72
+ orm_adapter (~> 0.1)
73
+ railties (>= 4.1.0, < 5.2)
74
+ responders
75
+ warden (~> 1.2.3)
76
+ diff-lcs (1.3)
77
+ docile (1.1.5)
78
+ erubis (2.7.0)
79
+ globalid (0.4.0)
80
+ activesupport (>= 4.2.0)
81
+ i18n (0.8.6)
82
+ json (2.1.0)
83
+ loofah (2.0.3)
84
+ nokogiri (>= 1.5.9)
85
+ mail (2.6.6)
86
+ mime-types (>= 1.16, < 4)
87
+ method_source (0.8.2)
88
+ mime-types (3.1)
89
+ mime-types-data (~> 3.2015)
90
+ mime-types-data (3.2016.0521)
91
+ mini_mime (0.1.4)
92
+ mini_portile2 (2.2.0)
93
+ minitest (5.10.3)
94
+ nio4r (2.1.0)
95
+ nokogiri (1.8.0)
96
+ mini_portile2 (~> 2.2.0)
97
+ orm_adapter (0.5.0)
98
+ parallel (1.12.0)
99
+ parser (2.4.0.0)
100
+ ast (~> 2.2)
101
+ powerpack (0.1.1)
102
+ pry (0.10.4)
103
+ coderay (~> 1.1.0)
104
+ method_source (~> 0.8.1)
105
+ slop (~> 3.4)
106
+ pry-byebug (3.5.0)
107
+ byebug (~> 9.1)
108
+ pry (~> 0.10)
109
+ public_suffix (3.0.0)
110
+ rack (2.0.3)
111
+ rack-test (0.6.3)
112
+ rack (>= 1.0)
113
+ rails (5.0.5)
114
+ actioncable (= 5.0.5)
115
+ actionmailer (= 5.0.5)
116
+ actionpack (= 5.0.5)
117
+ actionview (= 5.0.5)
118
+ activejob (= 5.0.5)
119
+ activemodel (= 5.0.5)
120
+ activerecord (= 5.0.5)
121
+ activesupport (= 5.0.5)
122
+ bundler (>= 1.3.0)
123
+ railties (= 5.0.5)
124
+ sprockets-rails (>= 2.0.0)
125
+ rails-dom-testing (2.0.3)
126
+ activesupport (>= 4.2.0)
127
+ nokogiri (>= 1.6)
128
+ rails-html-sanitizer (1.0.3)
129
+ loofah (~> 2.0)
130
+ railties (5.0.5)
131
+ actionpack (= 5.0.5)
132
+ activesupport (= 5.0.5)
133
+ method_source
134
+ rake (>= 0.8.7)
135
+ thor (>= 0.18.1, < 2.0)
136
+ rainbow (2.2.2)
137
+ rake
138
+ rake (10.5.0)
139
+ responders (2.4.0)
140
+ actionpack (>= 4.2.0, < 5.3)
141
+ railties (>= 4.2.0, < 5.3)
142
+ rspec (3.6.0)
143
+ rspec-core (~> 3.6.0)
144
+ rspec-expectations (~> 3.6.0)
145
+ rspec-mocks (~> 3.6.0)
146
+ rspec-benchmark (0.3.0)
147
+ benchmark-perf (~> 0.2.0)
148
+ rspec (>= 3.0.0, < 4.0.0)
149
+ rspec-core (3.6.0)
150
+ rspec-support (~> 3.6.0)
151
+ rspec-expectations (3.6.0)
152
+ diff-lcs (>= 1.2.0, < 2.0)
153
+ rspec-support (~> 3.6.0)
154
+ rspec-mocks (3.6.0)
155
+ diff-lcs (>= 1.2.0, < 2.0)
156
+ rspec-support (~> 3.6.0)
157
+ rspec-rails (3.6.1)
158
+ actionpack (>= 3.0)
159
+ activesupport (>= 3.0)
160
+ railties (>= 3.0)
161
+ rspec-core (~> 3.6.0)
162
+ rspec-expectations (~> 3.6.0)
163
+ rspec-mocks (~> 3.6.0)
164
+ rspec-support (~> 3.6.0)
165
+ rspec-support (3.6.0)
166
+ rubocop (0.49.1)
167
+ parallel (~> 1.10)
168
+ parser (>= 2.3.3.1, < 3.0)
169
+ powerpack (~> 0.1)
170
+ rainbow (>= 1.99.1, < 3.0)
171
+ ruby-progressbar (~> 1.7)
172
+ unicode-display_width (~> 1.0, >= 1.0.1)
173
+ ruby-progressbar (1.8.1)
174
+ simplecov (0.13.0)
175
+ docile (~> 1.1.0)
176
+ json (>= 1.8, < 3)
177
+ simplecov-html (~> 0.10.0)
178
+ simplecov-html (0.10.2)
179
+ slop (3.6.0)
180
+ sprockets (3.7.1)
181
+ concurrent-ruby (~> 1.0)
182
+ rack (> 1, < 3)
183
+ sprockets-rails (3.2.1)
184
+ actionpack (>= 4.0)
185
+ activesupport (>= 4.0)
186
+ sprockets (>= 3.0.0)
187
+ sqlite3 (1.3.13)
188
+ thor (0.20.0)
189
+ thread_safe (0.3.6)
190
+ tzinfo (1.2.3)
191
+ thread_safe (~> 0.1)
192
+ unicode-display_width (1.3.0)
193
+ warden (1.2.7)
194
+ rack (>= 1.0)
195
+ websocket-driver (0.6.5)
196
+ websocket-extensions (>= 0.1.0)
197
+ websocket-extensions (0.1.2)
198
+ xpath (2.1.0)
199
+ nokogiri (~> 1.3)
200
+
201
+ PLATFORMS
202
+ ruby
203
+
204
+ DEPENDENCIES
205
+ appraisal (~> 2.2)
206
+ bundler (~> 1.15)
207
+ capybara (~> 2.15)
208
+ codeclimate-test-reporter (= 1.0.8)
209
+ devise (~> 4.3)
210
+ pry-byebug
211
+ rails (~> 5.0.5)
212
+ rails-session_cookie!
213
+ rake (~> 10.0)
214
+ rspec (~> 3.0)
215
+ rspec-benchmark (~> 0.3)
216
+ rspec-rails (~> 3.6.1)
217
+ rubocop (~> 0.49)
218
+ simplecov (= 0.13.0)
219
+ sqlite3 (~> 1.3)
220
+ warden (>= 1.2)
221
+
222
+ BUNDLED WITH
223
+ 1.15.4
@@ -44,14 +44,24 @@ GEM
44
44
  i18n (~> 0.7)
45
45
  minitest (~> 5.1)
46
46
  tzinfo (~> 1.1)
47
+ addressable (2.5.2)
48
+ public_suffix (>= 2.0.2, < 4.0)
47
49
  appraisal (2.2.0)
48
50
  bundler
49
51
  rake
50
52
  thor (>= 0.14.0)
51
53
  arel (8.0.0)
52
54
  ast (2.3.0)
55
+ benchmark-perf (0.2.1)
53
56
  builder (3.2.3)
54
57
  byebug (9.0.6)
58
+ capybara (2.15.1)
59
+ addressable
60
+ mini_mime (>= 0.1.3)
61
+ nokogiri (>= 1.3.3)
62
+ rack (>= 1.0.0)
63
+ rack-test (>= 0.5.4)
64
+ xpath (~> 2.0)
55
65
  codeclimate-test-reporter (1.0.8)
56
66
  simplecov (<= 0.13)
57
67
  coderay (1.1.1)
@@ -71,6 +81,7 @@ GEM
71
81
  mime-types (3.1)
72
82
  mime-types-data (~> 3.2015)
73
83
  mime-types-data (3.2016.0521)
84
+ mini_mime (0.1.4)
74
85
  mini_portile2 (2.2.0)
75
86
  minitest (5.10.3)
76
87
  nio4r (2.1.0)
@@ -87,6 +98,7 @@ GEM
87
98
  pry-byebug (3.4.2)
88
99
  byebug (~> 9.0)
89
100
  pry (~> 0.10)
101
+ public_suffix (3.0.0)
90
102
  rack (2.0.3)
91
103
  rack-test (0.6.3)
92
104
  rack (>= 1.0)
@@ -120,6 +132,9 @@ GEM
120
132
  rspec-core (~> 3.6.0)
121
133
  rspec-expectations (~> 3.6.0)
122
134
  rspec-mocks (~> 3.6.0)
135
+ rspec-benchmark (0.3.0)
136
+ benchmark-perf (~> 0.2.0)
137
+ rspec (>= 3.0.0, < 4.0.0)
123
138
  rspec-core (3.6.0)
124
139
  rspec-support (~> 3.6.0)
125
140
  rspec-expectations (3.6.0)
@@ -158,6 +173,7 @@ GEM
158
173
  actionpack (>= 4.0)
159
174
  activesupport (>= 4.0)
160
175
  sprockets (>= 3.0.0)
176
+ sqlite3 (1.3.13)
161
177
  thor (0.20.0)
162
178
  thread_safe (0.3.6)
163
179
  tzinfo (1.2.3)
@@ -166,6 +182,8 @@ GEM
166
182
  websocket-driver (0.6.5)
167
183
  websocket-extensions (>= 0.1.0)
168
184
  websocket-extensions (0.1.2)
185
+ xpath (2.1.0)
186
+ nokogiri (~> 1.3)
169
187
 
170
188
  PLATFORMS
171
189
  ruby
@@ -173,15 +191,18 @@ PLATFORMS
173
191
  DEPENDENCIES
174
192
  appraisal (~> 2.2)
175
193
  bundler (~> 1.15)
194
+ capybara (~> 2.15)
176
195
  codeclimate-test-reporter (= 1.0.8)
177
196
  pry-byebug
178
197
  rails (~> 5.1.3)
179
198
  rails-session_cookie!
180
199
  rake (~> 10.0)
181
200
  rspec (~> 3.0)
201
+ rspec-benchmark (~> 0.3)
182
202
  rspec-rails (~> 3.6.1)
183
203
  rubocop (~> 0.49)
184
204
  simplecov (= 0.13.0)
205
+ sqlite3 (~> 1.3)
185
206
 
186
207
  BUNDLED WITH
187
208
  1.15.4
@@ -0,0 +1,10 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "pry-byebug"
6
+ gem "rails", "~> 5.1.3"
7
+ gem "warden", ">= 1.2"
8
+ gem "devise", "~> 4.3"
9
+
10
+ gemspec path: "../"
@@ -0,0 +1,223 @@
1
+ PATH
2
+ remote: ..
3
+ specs:
4
+ rails-session_cookie (0.1.0)
5
+ rails (>= 4.0)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ actioncable (5.1.3)
11
+ actionpack (= 5.1.3)
12
+ nio4r (~> 2.0)
13
+ websocket-driver (~> 0.6.1)
14
+ actionmailer (5.1.3)
15
+ actionpack (= 5.1.3)
16
+ actionview (= 5.1.3)
17
+ activejob (= 5.1.3)
18
+ mail (~> 2.5, >= 2.5.4)
19
+ rails-dom-testing (~> 2.0)
20
+ actionpack (5.1.3)
21
+ actionview (= 5.1.3)
22
+ activesupport (= 5.1.3)
23
+ rack (~> 2.0)
24
+ rack-test (~> 0.6.3)
25
+ rails-dom-testing (~> 2.0)
26
+ rails-html-sanitizer (~> 1.0, >= 1.0.2)
27
+ actionview (5.1.3)
28
+ activesupport (= 5.1.3)
29
+ builder (~> 3.1)
30
+ erubi (~> 1.4)
31
+ rails-dom-testing (~> 2.0)
32
+ rails-html-sanitizer (~> 1.0, >= 1.0.3)
33
+ activejob (5.1.3)
34
+ activesupport (= 5.1.3)
35
+ globalid (>= 0.3.6)
36
+ activemodel (5.1.3)
37
+ activesupport (= 5.1.3)
38
+ activerecord (5.1.3)
39
+ activemodel (= 5.1.3)
40
+ activesupport (= 5.1.3)
41
+ arel (~> 8.0)
42
+ activesupport (5.1.3)
43
+ concurrent-ruby (~> 1.0, >= 1.0.2)
44
+ i18n (~> 0.7)
45
+ minitest (~> 5.1)
46
+ tzinfo (~> 1.1)
47
+ addressable (2.5.2)
48
+ public_suffix (>= 2.0.2, < 4.0)
49
+ appraisal (2.2.0)
50
+ bundler
51
+ rake
52
+ thor (>= 0.14.0)
53
+ arel (8.0.0)
54
+ ast (2.3.0)
55
+ bcrypt (3.1.11)
56
+ benchmark-perf (0.2.1)
57
+ builder (3.2.3)
58
+ byebug (9.1.0)
59
+ capybara (2.15.1)
60
+ addressable
61
+ mini_mime (>= 0.1.3)
62
+ nokogiri (>= 1.3.3)
63
+ rack (>= 1.0.0)
64
+ rack-test (>= 0.5.4)
65
+ xpath (~> 2.0)
66
+ codeclimate-test-reporter (1.0.8)
67
+ simplecov (<= 0.13)
68
+ coderay (1.1.2)
69
+ concurrent-ruby (1.0.5)
70
+ devise (4.3.0)
71
+ bcrypt (~> 3.0)
72
+ orm_adapter (~> 0.1)
73
+ railties (>= 4.1.0, < 5.2)
74
+ responders
75
+ warden (~> 1.2.3)
76
+ diff-lcs (1.3)
77
+ docile (1.1.5)
78
+ erubi (1.6.1)
79
+ globalid (0.4.0)
80
+ activesupport (>= 4.2.0)
81
+ i18n (0.8.6)
82
+ json (2.1.0)
83
+ loofah (2.0.3)
84
+ nokogiri (>= 1.5.9)
85
+ mail (2.6.6)
86
+ mime-types (>= 1.16, < 4)
87
+ method_source (0.8.2)
88
+ mime-types (3.1)
89
+ mime-types-data (~> 3.2015)
90
+ mime-types-data (3.2016.0521)
91
+ mini_mime (0.1.4)
92
+ mini_portile2 (2.2.0)
93
+ minitest (5.10.3)
94
+ nio4r (2.1.0)
95
+ nokogiri (1.8.0)
96
+ mini_portile2 (~> 2.2.0)
97
+ orm_adapter (0.5.0)
98
+ parallel (1.12.0)
99
+ parser (2.4.0.0)
100
+ ast (~> 2.2)
101
+ powerpack (0.1.1)
102
+ pry (0.10.4)
103
+ coderay (~> 1.1.0)
104
+ method_source (~> 0.8.1)
105
+ slop (~> 3.4)
106
+ pry-byebug (3.5.0)
107
+ byebug (~> 9.1)
108
+ pry (~> 0.10)
109
+ public_suffix (3.0.0)
110
+ rack (2.0.3)
111
+ rack-test (0.6.3)
112
+ rack (>= 1.0)
113
+ rails (5.1.3)
114
+ actioncable (= 5.1.3)
115
+ actionmailer (= 5.1.3)
116
+ actionpack (= 5.1.3)
117
+ actionview (= 5.1.3)
118
+ activejob (= 5.1.3)
119
+ activemodel (= 5.1.3)
120
+ activerecord (= 5.1.3)
121
+ activesupport (= 5.1.3)
122
+ bundler (>= 1.3.0)
123
+ railties (= 5.1.3)
124
+ sprockets-rails (>= 2.0.0)
125
+ rails-dom-testing (2.0.3)
126
+ activesupport (>= 4.2.0)
127
+ nokogiri (>= 1.6)
128
+ rails-html-sanitizer (1.0.3)
129
+ loofah (~> 2.0)
130
+ railties (5.1.3)
131
+ actionpack (= 5.1.3)
132
+ activesupport (= 5.1.3)
133
+ method_source
134
+ rake (>= 0.8.7)
135
+ thor (>= 0.18.1, < 2.0)
136
+ rainbow (2.2.2)
137
+ rake
138
+ rake (10.5.0)
139
+ responders (2.4.0)
140
+ actionpack (>= 4.2.0, < 5.3)
141
+ railties (>= 4.2.0, < 5.3)
142
+ rspec (3.6.0)
143
+ rspec-core (~> 3.6.0)
144
+ rspec-expectations (~> 3.6.0)
145
+ rspec-mocks (~> 3.6.0)
146
+ rspec-benchmark (0.3.0)
147
+ benchmark-perf (~> 0.2.0)
148
+ rspec (>= 3.0.0, < 4.0.0)
149
+ rspec-core (3.6.0)
150
+ rspec-support (~> 3.6.0)
151
+ rspec-expectations (3.6.0)
152
+ diff-lcs (>= 1.2.0, < 2.0)
153
+ rspec-support (~> 3.6.0)
154
+ rspec-mocks (3.6.0)
155
+ diff-lcs (>= 1.2.0, < 2.0)
156
+ rspec-support (~> 3.6.0)
157
+ rspec-rails (3.6.1)
158
+ actionpack (>= 3.0)
159
+ activesupport (>= 3.0)
160
+ railties (>= 3.0)
161
+ rspec-core (~> 3.6.0)
162
+ rspec-expectations (~> 3.6.0)
163
+ rspec-mocks (~> 3.6.0)
164
+ rspec-support (~> 3.6.0)
165
+ rspec-support (3.6.0)
166
+ rubocop (0.49.1)
167
+ parallel (~> 1.10)
168
+ parser (>= 2.3.3.1, < 3.0)
169
+ powerpack (~> 0.1)
170
+ rainbow (>= 1.99.1, < 3.0)
171
+ ruby-progressbar (~> 1.7)
172
+ unicode-display_width (~> 1.0, >= 1.0.1)
173
+ ruby-progressbar (1.8.1)
174
+ simplecov (0.13.0)
175
+ docile (~> 1.1.0)
176
+ json (>= 1.8, < 3)
177
+ simplecov-html (~> 0.10.0)
178
+ simplecov-html (0.10.2)
179
+ slop (3.6.0)
180
+ sprockets (3.7.1)
181
+ concurrent-ruby (~> 1.0)
182
+ rack (> 1, < 3)
183
+ sprockets-rails (3.2.1)
184
+ actionpack (>= 4.0)
185
+ activesupport (>= 4.0)
186
+ sprockets (>= 3.0.0)
187
+ sqlite3 (1.3.13)
188
+ thor (0.20.0)
189
+ thread_safe (0.3.6)
190
+ tzinfo (1.2.3)
191
+ thread_safe (~> 0.1)
192
+ unicode-display_width (1.3.0)
193
+ warden (1.2.7)
194
+ rack (>= 1.0)
195
+ websocket-driver (0.6.5)
196
+ websocket-extensions (>= 0.1.0)
197
+ websocket-extensions (0.1.2)
198
+ xpath (2.1.0)
199
+ nokogiri (~> 1.3)
200
+
201
+ PLATFORMS
202
+ ruby
203
+
204
+ DEPENDENCIES
205
+ appraisal (~> 2.2)
206
+ bundler (~> 1.15)
207
+ capybara (~> 2.15)
208
+ codeclimate-test-reporter (= 1.0.8)
209
+ devise (~> 4.3)
210
+ pry-byebug
211
+ rails (~> 5.1.3)
212
+ rails-session_cookie!
213
+ rake (~> 10.0)
214
+ rspec (~> 3.0)
215
+ rspec-benchmark (~> 0.3)
216
+ rspec-rails (~> 3.6.1)
217
+ rubocop (~> 0.49)
218
+ simplecov (= 0.13.0)
219
+ sqlite3 (~> 1.3)
220
+ warden (>= 1.2)
221
+
222
+ BUNDLED WITH
223
+ 1.15.4
@@ -1,8 +1,11 @@
1
1
  require 'rails/session_cookie/app'
2
+ require 'rails/session_cookie/warden_app' if defined? Warden
2
3
  require 'rails/session_cookie/version'
3
4
 
4
5
  module Rails
5
6
  # :nodoc:
6
7
  module SessionCookie
8
+ NoRailsApplication = Class.new(StandardError)
9
+ RACK_SESSION = 'rack.session'.freeze # upstream constant name is changing
7
10
  end
8
11
  end
@@ -1,12 +1,7 @@
1
- require 'rack'
2
- require 'active_support'
3
1
  require 'action_dispatch'
4
2
 
5
3
  module Rails
6
4
  module SessionCookie
7
- NoRailsApplication = Class.new(StandardError)
8
- RACK_SESSION = 'rack.session'.freeze # upstream constant name is changing
9
-
10
5
  # This mini rack app allows easily get rails session cookie
11
6
  class App
12
7
  def self.simple_app_from_session_hash(session = {})
@@ -18,12 +13,25 @@ module Rails
18
13
  }
19
14
  end
20
15
 
16
+ def self.simple_app_returning_rack(app)
17
+ proc { |env|
18
+ result = app.call(env)
19
+ result.is_a?(Hash) ? [200, result, []] : result
20
+ }
21
+ end
22
+
21
23
  attr_reader :app, :rails_app
22
24
 
23
25
  def initialize(app, session_options = nil)
24
26
  auth_session_options = session_options || rails_app.config.session_options
25
- auth_app = app.respond_to?(:call) ? app : self.class.simple_app_from_session_hash(app)
26
- @app = with_session_cookie_middlewares(auth_app, auth_session_options)
27
+
28
+ auth_app = if app.respond_to?(:call)
29
+ self.class.simple_app_returning_rack(app)
30
+ else
31
+ self.class.simple_app_from_session_hash(app)
32
+ end
33
+
34
+ @app = with_middlewares(auth_app, auth_session_options)
27
35
  end
28
36
 
29
37
  def call(env = {})
@@ -37,7 +45,7 @@ module Rails
37
45
 
38
46
  private
39
47
 
40
- def with_session_cookie_middlewares(app, session_options)
48
+ def with_middlewares(app, session_options)
41
49
  ActionDispatch::Cookies.new(
42
50
  ActionDispatch::Session::CookieStore.new(
43
51
  app, session_options
@@ -1,5 +1,5 @@
1
1
  module Rails
2
2
  module SessionCookie
3
- VERSION = '0.1.0'.freeze
3
+ VERSION = '0.2.0'.freeze
4
4
  end
5
5
  end
@@ -0,0 +1,24 @@
1
+ require 'warden'
2
+ require 'rails/session_cookie/app'
3
+
4
+ module Rails
5
+ module SessionCookie
6
+ # This mini rack app helps setting warden session cookie
7
+ class WardenApp < App
8
+ def initialize(user, session_options = nil, scope = :user)
9
+ auth_session_options = session_options || rails_app.config.session_options
10
+ serializer = Warden::SessionSerializer.new({})
11
+
12
+ key = serializer.key_for(scope)
13
+ value = serializer.store(user, scope)
14
+
15
+ auth_app = proc { |env|
16
+ env[Rails::SessionCookie::RACK_SESSION][key] = value
17
+ [200, {}, []]
18
+ }
19
+
20
+ @app = with_middlewares(auth_app, auth_session_options)
21
+ end
22
+ end
23
+ end
24
+ end
@@ -31,4 +31,9 @@ Gem::Specification.new do |spec|
31
31
  spec.add_development_dependency 'rspec-rails', '~> 3.6.1'
32
32
  spec.add_development_dependency 'codeclimate-test-reporter', '= 1.0.8'
33
33
  spec.add_development_dependency 'simplecov', '= 0.13.0'
34
+ spec.add_development_dependency 'sqlite3', '~> 1.3'
35
+
36
+ # bench
37
+ spec.add_development_dependency 'rspec-benchmark', '~> 0.3'
38
+ spec.add_development_dependency 'capybara', '~> 2.15'
34
39
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails-session_cookie
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
  - Vlad Bokov
@@ -136,6 +136,48 @@ dependencies:
136
136
  - - '='
137
137
  - !ruby/object:Gem::Version
138
138
  version: 0.13.0
139
+ - !ruby/object:Gem::Dependency
140
+ name: sqlite3
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - "~>"
144
+ - !ruby/object:Gem::Version
145
+ version: '1.3'
146
+ type: :development
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - "~>"
151
+ - !ruby/object:Gem::Version
152
+ version: '1.3'
153
+ - !ruby/object:Gem::Dependency
154
+ name: rspec-benchmark
155
+ requirement: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - "~>"
158
+ - !ruby/object:Gem::Version
159
+ version: '0.3'
160
+ type: :development
161
+ prerelease: false
162
+ version_requirements: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - "~>"
165
+ - !ruby/object:Gem::Version
166
+ version: '0.3'
167
+ - !ruby/object:Gem::Dependency
168
+ name: capybara
169
+ requirement: !ruby/object:Gem::Requirement
170
+ requirements:
171
+ - - "~>"
172
+ - !ruby/object:Gem::Version
173
+ version: '2.15'
174
+ type: :development
175
+ prerelease: false
176
+ version_requirements: !ruby/object:Gem::Requirement
177
+ requirements:
178
+ - - "~>"
179
+ - !ruby/object:Gem::Version
180
+ version: '2.15'
139
181
  description: Helps to get proper integration tests run faster
140
182
  email:
141
183
  - razum2um@mail.ru
@@ -157,13 +199,20 @@ files:
157
199
  - gemfiles/.bundle/config
158
200
  - gemfiles/rails_4.2.gemfile
159
201
  - gemfiles/rails_4.2.gemfile.lock
202
+ - gemfiles/rails_4.2_warden.gemfile
203
+ - gemfiles/rails_4.2_warden.gemfile.lock
160
204
  - gemfiles/rails_5.0.gemfile
161
205
  - gemfiles/rails_5.0.gemfile.lock
206
+ - gemfiles/rails_5.0_warden.gemfile
207
+ - gemfiles/rails_5.0_warden.gemfile.lock
162
208
  - gemfiles/rails_5.1.gemfile
163
209
  - gemfiles/rails_5.1.gemfile.lock
210
+ - gemfiles/rails_5.1_warden.gemfile
211
+ - gemfiles/rails_5.1_warden.gemfile.lock
164
212
  - lib/rails/session_cookie.rb
165
213
  - lib/rails/session_cookie/app.rb
166
214
  - lib/rails/session_cookie/version.rb
215
+ - lib/rails/session_cookie/warden_app.rb
167
216
  - rails-session_cookie.gemspec
168
217
  homepage: https://github.com/razum2um/rails/session_cookie
169
218
  licenses: []