clearance 2.0.0.beta1 → 2.0.0.beta2

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of clearance might be problematic. Click here for more details.

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4f79f5aa24e81ddb8b9fc746a557db5bcf7770e17ee52f758c070656afda4434
4
- data.tar.gz: c8bfc11a5c5b3e4035aaa4fb118dd24f45a72e148499ed935a15c2a5fb4764dd
3
+ metadata.gz: 6c7eb11d597ee18d41e6655e608bb82c9e774baa30e0e4f05dbcd7cc99c553e5
4
+ data.tar.gz: c221f519c1191b0d8487d302db40a3c69724e6a59df5b67efd9bbaffbf2f10cf
5
5
  SHA512:
6
- metadata.gz: af3771ef9f0981c1666f01b8dad6271e61cd1ed7a13d8268f9214827682c6ba1da9e6c0fac1c81cfa89f71b44dde927d3f71b829324a6c3794b0c90e66f6c8f1
7
- data.tar.gz: 8f69cf0a50f4064a120f8e63a9c80e0ebdf5aa69be0fc68998bbe6e4e73b14ba78789c1bdd28c3f7c3c02623135036189c764d7bd6c93a8125767cebd09cf458
6
+ metadata.gz: 586d54d09d31cbdae4caf13a1aa3920559806feb92701e6e9bb73d5dcf9001790c5e73e7d0f4af9a9e2e5b4cf72ae7865e1b7013bbe8ab18235353842449ca9c
7
+ data.tar.gz: 2df91d418506ba30981dec2b0139074f543193e389b1b00a79163a61c48de714ce1b480a215e98e1c13a95076d09dc271ce7f4bdb34539c822d83fc2f46d61e2
data/.travis.yml CHANGED
@@ -4,16 +4,15 @@ language:
4
4
  - ruby
5
5
 
6
6
  rvm:
7
- - 2.3.8
8
7
  - 2.4.6
9
8
  - 2.5.5
10
9
  - 2.6.2
11
10
 
12
11
  gemfile:
13
- - gemfiles/rails_4.2.gemfile
14
12
  - gemfiles/rails_5.0.gemfile
15
13
  - gemfiles/rails_5.1.gemfile
16
14
  - gemfiles/rails_5.2.gemfile
15
+ - gemfiles/rails_6.0.gemfile
17
16
 
18
17
  before_install:
19
18
  - gem update --system
@@ -24,11 +23,10 @@ install:
24
23
  branches:
25
24
  only:
26
25
  - master
27
- - 2.0
28
26
 
29
27
  matrix:
30
- allow_failures:
31
- - gemfile: gemfiles/rails_4.2.gemfile
32
- rvm: 2.6.2
28
+ exclude:
29
+ - rvm: 2.4.6
30
+ gemfile: gemfiles/rails_6.0.gemfile
33
31
 
34
32
  sudo: false
data/Appraisals CHANGED
@@ -1,15 +1,23 @@
1
1
  rails_versions = %w(
2
- 4.2
3
2
  5.0
4
3
  5.1
5
4
  5.2
5
+ 6.0
6
6
  )
7
7
 
8
8
  rails_versions.each do |version|
9
9
  appraise "rails_#{version}" do
10
10
  gem "railties", "~> #{version}.0"
11
- if Gem::Version.new(version) >= Gem::Version.new("5.0")
12
- gem "rails-controller-testing"
11
+ gem "rails-controller-testing"
12
+
13
+ if Gem::Version.new(version) >= Gem::Version.new("6.0")
14
+ # TODO - Switch to 4.0 gem once release is made
15
+ gem 'rspec-rails', '~> 4.0.0.beta2'
16
+ gem 'sqlite3', '~> 1.4.0'
17
+ else
18
+ gem 'sqlite3', '~> 1.3.13'
19
+ gem 'rspec-rails', '~> 3.1'
13
20
  end
21
+
14
22
  end
15
23
  end
data/Gemfile CHANGED
@@ -10,7 +10,5 @@ gem 'database_cleaner', '~> 1.0'
10
10
  gem 'factory_bot_rails', '~> 5.0'
11
11
  gem 'nokogiri', '~> 1.10.0'
12
12
  gem 'pry', require: false
13
- gem 'rspec-rails', '~> 3.5'
14
- gem 'shoulda-matchers', '~> 4.0'
15
- gem 'sqlite3', '~> 1.3.13'
13
+ gem 'shoulda-matchers', '~> 4.1'
16
14
  gem 'timecop', '~> 0.6'
data/Gemfile.lock CHANGED
@@ -1,50 +1,50 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- clearance (2.0.0.beta1)
5
- actionmailer (>= 4.2)
6
- activemodel (>= 4.2)
7
- activerecord (>= 4.2)
4
+ clearance (2.0.0.beta2)
5
+ actionmailer (>= 5.0)
6
+ activemodel (>= 5.0)
7
+ activerecord (>= 5.0)
8
8
  bcrypt
9
9
  email_validator (~> 1.4)
10
- railties (>= 4.2)
10
+ railties (>= 5.0)
11
11
 
12
12
  GEM
13
13
  remote: https://rubygems.org/
14
14
  specs:
15
- actionmailer (5.2.3)
16
- actionpack (= 5.2.3)
17
- actionview (= 5.2.3)
18
- activejob (= 5.2.3)
15
+ actionmailer (6.0.0)
16
+ actionpack (= 6.0.0)
17
+ actionview (= 6.0.0)
18
+ activejob (= 6.0.0)
19
19
  mail (~> 2.5, >= 2.5.4)
20
20
  rails-dom-testing (~> 2.0)
21
- actionpack (5.2.3)
22
- actionview (= 5.2.3)
23
- activesupport (= 5.2.3)
21
+ actionpack (6.0.0)
22
+ actionview (= 6.0.0)
23
+ activesupport (= 6.0.0)
24
24
  rack (~> 2.0)
25
25
  rack-test (>= 0.6.3)
26
26
  rails-dom-testing (~> 2.0)
27
- rails-html-sanitizer (~> 1.0, >= 1.0.2)
28
- actionview (5.2.3)
29
- activesupport (= 5.2.3)
27
+ rails-html-sanitizer (~> 1.0, >= 1.2.0)
28
+ actionview (6.0.0)
29
+ activesupport (= 6.0.0)
30
30
  builder (~> 3.1)
31
31
  erubi (~> 1.4)
32
32
  rails-dom-testing (~> 2.0)
33
- rails-html-sanitizer (~> 1.0, >= 1.0.3)
34
- activejob (5.2.3)
35
- activesupport (= 5.2.3)
33
+ rails-html-sanitizer (~> 1.1, >= 1.2.0)
34
+ activejob (6.0.0)
35
+ activesupport (= 6.0.0)
36
36
  globalid (>= 0.3.6)
37
- activemodel (5.2.3)
38
- activesupport (= 5.2.3)
39
- activerecord (5.2.3)
40
- activemodel (= 5.2.3)
41
- activesupport (= 5.2.3)
42
- arel (>= 9.0)
43
- activesupport (5.2.3)
37
+ activemodel (6.0.0)
38
+ activesupport (= 6.0.0)
39
+ activerecord (6.0.0)
40
+ activemodel (= 6.0.0)
41
+ activesupport (= 6.0.0)
42
+ activesupport (6.0.0)
44
43
  concurrent-ruby (~> 1.0, >= 1.0.2)
45
44
  i18n (>= 0.7, < 2)
46
45
  minitest (~> 5.1)
47
46
  tzinfo (~> 1.1)
47
+ zeitwerk (~> 2.1, >= 2.1.8)
48
48
  addressable (2.6.0)
49
49
  public_suffix (>= 2.0.2, < 4.0)
50
50
  ammeter (1.1.4)
@@ -55,16 +55,15 @@ GEM
55
55
  bundler
56
56
  rake
57
57
  thor (>= 0.14.0)
58
- arel (9.0.0)
59
- bcrypt (3.1.12)
58
+ bcrypt (3.1.13)
60
59
  builder (3.2.3)
61
- capybara (3.16.2)
60
+ capybara (3.29.0)
62
61
  addressable
63
62
  mini_mime (>= 0.1.3)
64
63
  nokogiri (~> 1.8)
65
64
  rack (>= 1.6.0)
66
65
  rack-test (>= 0.6.3)
67
- regexp_parser (~> 1.2)
66
+ regexp_parser (~> 1.5)
68
67
  xpath (~> 3.2)
69
68
  coderay (1.1.2)
70
69
  concurrent-ruby (1.1.5)
@@ -76,8 +75,8 @@ GEM
76
75
  erubi (1.8.0)
77
76
  factory_bot (5.0.2)
78
77
  activesupport (>= 4.2.0)
79
- factory_bot_rails (5.0.1)
80
- factory_bot (~> 5.0.0)
78
+ factory_bot_rails (5.0.2)
79
+ factory_bot (~> 5.0.2)
81
80
  railties (>= 4.2.0)
82
81
  globalid (0.4.2)
83
82
  activesupport (>= 4.2.0)
@@ -89,37 +88,37 @@ GEM
89
88
  mail (2.7.1)
90
89
  mini_mime (>= 0.1.1)
91
90
  method_source (0.9.2)
92
- mini_mime (1.0.1)
91
+ mini_mime (1.0.2)
93
92
  mini_portile2 (2.4.0)
94
93
  minitest (5.11.3)
95
- nokogiri (1.10.2)
94
+ nokogiri (1.10.4)
96
95
  mini_portile2 (~> 2.4.0)
97
96
  pry (0.12.2)
98
97
  coderay (~> 1.1.0)
99
98
  method_source (~> 0.9.0)
100
- public_suffix (3.0.3)
99
+ public_suffix (3.1.1)
101
100
  rack (2.0.7)
102
101
  rack-test (1.1.0)
103
102
  rack (>= 1.0, < 3)
104
103
  rails-dom-testing (2.0.3)
105
104
  activesupport (>= 4.2.0)
106
105
  nokogiri (>= 1.6)
107
- rails-html-sanitizer (1.0.4)
106
+ rails-html-sanitizer (1.2.0)
108
107
  loofah (~> 2.2, >= 2.2.2)
109
- railties (5.2.3)
110
- actionpack (= 5.2.3)
111
- activesupport (= 5.2.3)
108
+ railties (6.0.0)
109
+ actionpack (= 6.0.0)
110
+ activesupport (= 6.0.0)
112
111
  method_source
113
112
  rake (>= 0.8.7)
114
- thor (>= 0.19.0, < 2.0)
115
- rake (12.3.2)
116
- regexp_parser (1.4.0)
117
- rspec-core (3.8.0)
113
+ thor (>= 0.20.3, < 2.0)
114
+ rake (12.3.3)
115
+ regexp_parser (1.6.0)
116
+ rspec-core (3.8.2)
118
117
  rspec-support (~> 3.8.0)
119
- rspec-expectations (3.8.2)
118
+ rspec-expectations (3.8.4)
120
119
  diff-lcs (>= 1.2.0, < 2.0)
121
120
  rspec-support (~> 3.8.0)
122
- rspec-mocks (3.8.0)
121
+ rspec-mocks (3.8.1)
123
122
  diff-lcs (>= 1.2.0, < 2.0)
124
123
  rspec-support (~> 3.8.0)
125
124
  rspec-rails (3.8.2)
@@ -130,10 +129,9 @@ GEM
130
129
  rspec-expectations (~> 3.8.0)
131
130
  rspec-mocks (~> 3.8.0)
132
131
  rspec-support (~> 3.8.0)
133
- rspec-support (3.8.0)
134
- shoulda-matchers (4.0.1)
132
+ rspec-support (3.8.2)
133
+ shoulda-matchers (4.1.2)
135
134
  activesupport (>= 4.2.0)
136
- sqlite3 (1.3.13)
137
135
  thor (0.20.3)
138
136
  thread_safe (0.3.6)
139
137
  timecop (0.9.1)
@@ -141,6 +139,7 @@ GEM
141
139
  thread_safe (~> 0.1)
142
140
  xpath (3.2.0)
143
141
  nokogiri (~> 1.8)
142
+ zeitwerk (2.1.10)
144
143
 
145
144
  PLATFORMS
146
145
  ruby
@@ -155,9 +154,7 @@ DEPENDENCIES
155
154
  factory_bot_rails (~> 5.0)
156
155
  nokogiri (~> 1.10.0)
157
156
  pry
158
- rspec-rails (~> 3.5)
159
- shoulda-matchers (~> 4.0)
160
- sqlite3 (~> 1.3.13)
157
+ shoulda-matchers (~> 4.1)
161
158
  timecop (~> 0.6)
162
159
 
163
160
  BUNDLED WITH
data/NEWS.md CHANGED
@@ -3,6 +3,25 @@
3
3
  The noteworthy changes for each Clearance version are included here. For a
4
4
  complete changelog, see the git history for each version via the version links.
5
5
 
6
+ ## [2.0.0.beta2] - September 17, 2019
7
+
8
+ ### Added
9
+
10
+ - Add support for Rails version 6
11
+ - Allow `cookie_domain` to be configured with a lambda for custom configuration
12
+
13
+ ### Fixed
14
+
15
+ - The backdoor auth mechanism now supports scenarios where `Rails.env` has been
16
+ configured via env variables other than `RAILS_ENV` (`RACK_ENV` for example).
17
+
18
+ ### Removed
19
+
20
+ - Removed support for Ruby versions older than 2.4
21
+ - Removed support for Rails versions older than 5.0
22
+
23
+ [2.0.0.beta2]: https://github.com/thoughtbot/clearance/compare/v2.0.0.beta1...v2.0.0.beta2
24
+
6
25
  ## [2.0.0.beta1] - April 12, 2019
7
26
 
8
27
  ### Removed
data/README.md CHANGED
@@ -31,8 +31,8 @@ Run the bundle command to install it.
31
31
 
32
32
  After you install Clearance, you need to run the generator:
33
33
 
34
- ```sh
35
- $ rails generate clearance:install
34
+ ```shell
35
+ rails generate clearance:install
36
36
  ```
37
37
 
38
38
  The Clearance install generator:
@@ -62,7 +62,7 @@ Clearance.configure do |config|
62
62
  config.rotate_csrf_on_sign_in = false
63
63
  config.secure_cookie = false
64
64
  config.sign_in_guards = []
65
- config.user_model = User
65
+ config.user_model = "User"
66
66
  end
67
67
  ```
68
68
 
@@ -130,6 +130,18 @@ Clearance.configure do |config|
130
130
  end
131
131
  ```
132
132
 
133
+ ### Multiple Domain Support
134
+
135
+ You can support multiple domains, or other special domain configurations by
136
+ optionally setting `cookie_domain` as a callable object. The first argument
137
+ passed to the method is an ActionDispatch::Request object.
138
+
139
+ ```ruby
140
+ Clearance.configure do |config|
141
+ config.cookie_domain = lambda { |request| request.host }
142
+ end
143
+ ```
144
+
133
145
  ### Integrating with Rack Applications
134
146
 
135
147
  Clearance adds its session to the Rack environment hash so middleware and other
@@ -161,15 +173,16 @@ As of Clearance 1.5 it is recommended that you disable Clearance routes and take
161
173
  full control over routing and URL design. This ensures that your app's URL design
162
174
  won't be affected if the gem's routes and URL design are changed.
163
175
 
164
- To disable the routes, change the `routes` configuration option to false:
176
+ To disable the routes, change the `routes` configuration option to false:
165
177
 
166
178
  ```ruby
167
179
  Clearance.configure do |config|
168
180
  config.routes = false
169
181
  end
170
182
  ```
171
- You can optionally run `rails generate clearance:routes` to dump a copy of the default routes into your
172
- application for modification.
183
+
184
+ You can optionally run `rails generate clearance:routes` to dump a copy of the
185
+ default routes into your application for modification.
173
186
 
174
187
  ### Controllers
175
188
 
@@ -188,22 +201,29 @@ class UsersController < Clearance::UsersController
188
201
 
189
202
  ### Redirects
190
203
 
191
- All of these controller methods redirect to
204
+ The post-action redirects in Clearance are simple methods which can be
205
+ overridden one by one, or configured globally.
206
+
207
+ These "success" methods are called for signed in users, and redirect to
192
208
  `Clearance.configuration.redirect_url` (which is `/` by default):
193
209
 
194
- ```
195
- passwords#url_after_update
196
- sessions#url_after_create
197
- sessions#url_for_signed_in_users
198
- users#url_after_create
199
- application#url_after_denied_access_when_signed_in
200
- ```
210
+ - `passwords#url_after_update`
211
+ - `sessions#url_after_create`
212
+ - `sessions#url_for_signed_in_users`
213
+ - `users#url_after_create`
214
+ - `application#url_after_denied_access_when_signed_in`
201
215
 
202
216
  To override them all at once, change the global configuration of `redirect_url`.
203
- To change individual URLs, override the appropriate method.
217
+ To change individual URLs, override the appropriate method in your subclassed
218
+ controller.
219
+
220
+ These "failure" methods are called for signed out sessions:
204
221
 
205
- `application#url_after_denied_access_when_signed_out` defaults to `sign_in_url`.
206
- Override this method to change this.
222
+ - `application#url_after_denied_access_when_signed_out`
223
+ - `sessions#url_after_destroy`
224
+
225
+ They both default to `sign_in_url`. Override this method to change both of their
226
+ behavior, or override them individually to just change one.
207
227
 
208
228
  ### Views
209
229
 
@@ -226,7 +246,7 @@ You can use the Clearance views generator to copy the default views to your
226
246
  application for modification.
227
247
 
228
248
  ```shell
229
- $ rails generate clearance:views
249
+ rails generate clearance:views
230
250
  ```
231
251
 
232
252
  ### Layouts
@@ -245,8 +265,10 @@ end
245
265
 
246
266
  ### Translations
247
267
 
248
- All flash messages and email subject lines are stored in [i18n translations](http://guides.rubyonrails.org/i18n.html). Override them like any other
249
- translation.
268
+ All flash messages and email subject lines are stored in [i18n translations].
269
+ Override them like any other translation.
270
+
271
+ [i18n translations]: http://guides.rubyonrails.org/i18n.html
250
272
 
251
273
  See [config/locales/clearance.en.yml](/config/locales/clearance.en.yml) for the
252
274
  default behavior.
@@ -377,7 +399,7 @@ feature specs, will also require `factory_bot_rails`.
377
399
  To Generate the clearance specs, run:
378
400
 
379
401
  ```shell
380
- $ rails generate clearance:specs
402
+ rails generate clearance:specs
381
403
  ```
382
404
 
383
405
  ### Controller Test Helpers
data/clearance.gemspec CHANGED
@@ -1,14 +1,13 @@
1
1
  $LOAD_PATH.push File.expand_path('../lib', __FILE__)
2
2
  require 'clearance/version'
3
- require 'date'
4
3
 
5
4
  Gem::Specification.new do |s|
6
5
  s.add_dependency 'bcrypt'
7
6
  s.add_dependency 'email_validator', '~> 1.4'
8
- s.add_dependency 'railties', '>= 4.2'
9
- s.add_dependency 'activemodel', '>= 4.2'
10
- s.add_dependency 'activerecord', '>= 4.2'
11
- s.add_dependency 'actionmailer', '>= 4.2'
7
+ s.add_dependency 'railties', '>= 5.0'
8
+ s.add_dependency 'activemodel', '>= 5.0'
9
+ s.add_dependency 'activerecord', '>= 5.0'
10
+ s.add_dependency 'actionmailer', '>= 5.0'
12
11
  s.authors = [
13
12
  'Dan Croak',
14
13
  'Eugene Bolshakov',
@@ -38,7 +37,7 @@ Gem::Specification.new do |s|
38
37
  s.name = %q{clearance}
39
38
  s.rdoc_options = ['--charset=UTF-8']
40
39
  s.require_paths = ['lib']
41
- s.required_ruby_version = Gem::Requirement.new('>= 2.3.0')
40
+ s.required_ruby_version = Gem::Requirement.new('>= 2.4.0')
42
41
  s.summary = 'Rails authentication & authorization with email & password.'
43
42
  s.test_files = `git ls-files -- {spec}/*`.split("\n")
44
43
  s.version = Clearance::VERSION
@@ -10,11 +10,11 @@ gem "database_cleaner", "~> 1.0"
10
10
  gem "factory_bot_rails", "~> 5.0"
11
11
  gem "nokogiri", "~> 1.10.0"
12
12
  gem "pry", require: false
13
- gem "rspec-rails", "~> 3.5"
14
- gem "shoulda-matchers", "~> 4.0"
15
- gem "sqlite3", "~> 1.3.13"
13
+ gem "shoulda-matchers", "~> 4.1"
16
14
  gem "timecop", "~> 0.6"
17
15
  gem "railties", "~> 5.0.0"
18
16
  gem "rails-controller-testing"
17
+ gem "sqlite3", "~> 1.3.13"
18
+ gem "rspec-rails", "~> 3.1"
19
19
 
20
20
  gemspec path: "../"
@@ -10,11 +10,11 @@ gem "database_cleaner", "~> 1.0"
10
10
  gem "factory_bot_rails", "~> 5.0"
11
11
  gem "nokogiri", "~> 1.10.0"
12
12
  gem "pry", require: false
13
- gem "rspec-rails", "~> 3.5"
14
- gem "shoulda-matchers", "~> 4.0"
15
- gem "sqlite3", "~> 1.3.13"
13
+ gem "shoulda-matchers", "~> 4.1"
16
14
  gem "timecop", "~> 0.6"
17
15
  gem "railties", "~> 5.1.0"
18
16
  gem "rails-controller-testing"
17
+ gem "sqlite3", "~> 1.3.13"
18
+ gem "rspec-rails", "~> 3.1"
19
19
 
20
20
  gemspec path: "../"
@@ -10,11 +10,11 @@ gem "database_cleaner", "~> 1.0"
10
10
  gem "factory_bot_rails", "~> 5.0"
11
11
  gem "nokogiri", "~> 1.10.0"
12
12
  gem "pry", require: false
13
- gem "rspec-rails", "~> 3.5"
14
- gem "shoulda-matchers", "~> 4.0"
15
- gem "sqlite3", "~> 1.3.13"
13
+ gem "shoulda-matchers", "~> 4.1"
16
14
  gem "timecop", "~> 0.6"
17
15
  gem "railties", "~> 5.2.0"
18
16
  gem "rails-controller-testing"
17
+ gem "sqlite3", "~> 1.3.13"
18
+ gem "rspec-rails", "~> 3.1"
19
19
 
20
20
  gemspec path: "../"
@@ -10,10 +10,11 @@ gem "database_cleaner", "~> 1.0"
10
10
  gem "factory_bot_rails", "~> 5.0"
11
11
  gem "nokogiri", "~> 1.10.0"
12
12
  gem "pry", require: false
13
- gem "rspec-rails", "~> 3.5"
14
- gem "shoulda-matchers", "~> 4.0"
15
- gem "sqlite3", "~> 1.3.13"
13
+ gem "shoulda-matchers", "~> 4.1"
16
14
  gem "timecop", "~> 0.6"
17
- gem "railties", "~> 4.2.0"
15
+ gem "railties", "~> 6.0.0"
16
+ gem "rails-controller-testing"
17
+ gem "rspec-rails", "~> 4.0.0.beta2"
18
+ gem "sqlite3", "~> 1.4.0"
18
19
 
19
20
  gemspec path: "../"
@@ -68,7 +68,7 @@ module Clearance
68
68
 
69
69
  # @api private
70
70
  def environment_is_allowed?
71
- allowed_environments.include? ENV["RAILS_ENV"]
71
+ allowed_environments.include? Rails.env
72
72
  end
73
73
 
74
74
  # @api private
@@ -112,7 +112,7 @@ module Clearance
112
112
  end
113
113
 
114
114
  def user_model
115
- @user_model ||= ::User
115
+ (@user_model || "User").to_s.constantize
116
116
  end
117
117
 
118
118
  # Is the user sign up route enabled?
@@ -154,7 +154,7 @@ module Clearance
154
154
  # @api private
155
155
  def cookie_options
156
156
  {
157
- domain: Clearance.configuration.cookie_domain,
157
+ domain: domain,
158
158
  expires: remember_token_expires,
159
159
  httponly: Clearance.configuration.httponly,
160
160
  path: Clearance.configuration.cookie_path,
@@ -162,5 +162,24 @@ module Clearance
162
162
  value: remember_token,
163
163
  }
164
164
  end
165
+
166
+ # @api private
167
+ def domain
168
+ if configured_cookie_domain.respond_to?(:call)
169
+ configured_cookie_domain.call(request_with_env)
170
+ else
171
+ configured_cookie_domain
172
+ end
173
+ end
174
+
175
+ # @api private
176
+ def configured_cookie_domain
177
+ Clearance.configuration.cookie_domain
178
+ end
179
+
180
+ # @api private
181
+ def request_with_env
182
+ ActionDispatch::Request.new(@env)
183
+ end
165
184
  end
166
185
  end
@@ -1,3 +1,3 @@
1
1
  module Clearance
2
- VERSION = "2.0.0.beta1".freeze
2
+ VERSION = "2.0.0.beta2".freeze
3
3
  end
@@ -119,17 +119,11 @@ module Clearance
119
119
  end
120
120
 
121
121
  def migration_version
122
- if Rails.version >= "5.0.0"
123
- "[#{Rails::VERSION::MAJOR}.#{Rails::VERSION::MINOR}]"
124
- end
122
+ "[#{Rails::VERSION::MAJOR}.#{Rails::VERSION::MINOR}]"
125
123
  end
126
124
 
127
125
  def models_inherit_from
128
- if Rails.version >= "5.0.0"
129
- "ApplicationRecord"
130
- else
131
- "ActiveRecord::Base"
132
- end
126
+ "ApplicationRecord"
133
127
  end
134
128
  end
135
129
  end
@@ -1,9 +1,5 @@
1
1
  class HomeController < ApplicationController
2
2
  def show
3
- if Rails::VERSION::MAJOR >= 5
4
- render html: "", layout: "application"
5
- else
6
- render text: "", layout: "application"
7
- end
3
+ render html: "", layout: "application"
8
4
  end
9
5
  end
@@ -1,9 +1,6 @@
1
1
  require "spec_helper"
2
- require "support/environment"
3
2
 
4
3
  describe Clearance::BackDoor do
5
- include EnvironmentSupport
6
-
7
4
  it "signs in as a given user" do
8
5
  user_id = "123"
9
6
  user = double("user")
@@ -42,7 +39,7 @@ describe Clearance::BackDoor do
42
39
  end
43
40
 
44
41
  it "can't be used outside the allowed environments" do
45
- with_environment("RAILS_ENV" => "production") do
42
+ with_environment("production") do
46
43
  expect { Clearance::BackDoor.new(mock_app) }.
47
44
  to raise_exception "Can't use auth backdoor outside of configured \
48
45
  environments (test, ci, development).".squish
@@ -55,7 +52,7 @@ describe Clearance::BackDoor do
55
52
  end
56
53
 
57
54
  it "raises an error for a default allowed env" do
58
- with_environment("RAILS_ENV" => "test") do
55
+ with_environment("test") do
59
56
  expect { Clearance::BackDoor.new(mock_app) }.
60
57
  to raise_exception "BackDoor auth is disabled."
61
58
  end
@@ -68,7 +65,7 @@ describe Clearance::BackDoor do
68
65
  end
69
66
 
70
67
  it "can be used with configured allowed environments" do
71
- with_environment("RAILS_ENV" => "demo") do
68
+ with_environment("demo") do
72
69
  user_id = "123"
73
70
  user = double("user")
74
71
  allow(User).to receive(:find).with(user_id).and_return(user)
@@ -100,4 +97,13 @@ describe Clearance::BackDoor do
100
97
  def mock_app
101
98
  lambda { |env| [200, {}, ["okay"]] }
102
99
  end
100
+
101
+ def with_environment(environment)
102
+ original_env = Rails.env
103
+ Rails.env = environment
104
+
105
+ yield
106
+ ensure
107
+ Rails.env = original_env
108
+ end
103
109
  end
@@ -238,17 +238,31 @@ describe Clearance::Session do
238
238
  end
239
239
  end
240
240
 
241
- describe 'cookie domain option' do
242
- context 'when set' do
241
+ describe "cookie domain option" do
242
+ context "when set" do
243
243
  before do
244
- Clearance.configuration.cookie_domain = '.example.com'
244
+ Clearance.configuration.cookie_domain = cookie_domain
245
245
  session.sign_in(user)
246
246
  end
247
247
 
248
- it 'sets a standard cookie' do
249
- session.add_cookie_to_headers(headers)
248
+ context "with string" do
249
+ let(:cookie_domain) { ".example.com" }
250
+
251
+ it "sets a standard cookie" do
252
+ session.add_cookie_to_headers(headers)
253
+
254
+ expect(headers['Set-Cookie']).to match(/domain=\.example\.com; path/)
255
+ end
256
+ end
257
+
258
+ context "with lambda" do
259
+ let(:cookie_domain) { lambda { |_r| ".example.com" } }
250
260
 
251
- expect(headers['Set-Cookie']).to match(/domain=\.example\.com; path/)
261
+ it "sets a standard cookie" do
262
+ session.add_cookie_to_headers(headers)
263
+
264
+ expect(headers['Set-Cookie']).to match(/domain=\.example\.com; path/)
265
+ end
252
266
  end
253
267
  end
254
268
 
@@ -258,7 +272,7 @@ describe Clearance::Session do
258
272
  it 'sets a standard cookie' do
259
273
  session.add_cookie_to_headers(headers)
260
274
 
261
- expect(headers['Set-Cookie']).not_to match(/domain=.+; path/)
275
+ expect(headers["Set-Cookie"]).not_to match(/domain=.+; path/)
262
276
  end
263
277
  end
264
278
  end
@@ -270,7 +284,7 @@ describe Clearance::Session do
270
284
  it 'sets a standard cookie' do
271
285
  session.add_cookie_to_headers(headers)
272
286
 
273
- expect(headers['Set-Cookie']).to_not match(/domain=.+; path/)
287
+ expect(headers["Set-Cookie"]).to_not match(/domain=.+; path/)
274
288
  end
275
289
  end
276
290
 
@@ -8,12 +8,25 @@ describe Clearance::Configuration do
8
8
  end
9
9
 
10
10
  context "when a custom user_model_name is specified" do
11
- it "is used instead of User" do
11
+ before(:each) do
12
12
  MyUser = Class.new
13
+ end
14
+
15
+ after(:each) do
16
+ Object.send(:remove_const, :MyUser)
17
+ end
18
+
19
+ it "is used instead of User" do
13
20
  Clearance.configure { |config| config.user_model = MyUser }
14
21
 
15
22
  expect(Clearance.configuration.user_model).to eq ::MyUser
16
23
  end
24
+
25
+ it "can be specified as a string to avoid triggering autoloading" do
26
+ Clearance.configure { |config| config.user_model = "MyUser" }
27
+
28
+ expect(Clearance.configuration.user_model).to eq ::MyUser
29
+ end
17
30
  end
18
31
 
19
32
  context "when secure_cookie is set to true" do
@@ -65,7 +65,7 @@ describe PermissionsController do
65
65
  context 'when remember_token is blank' do
66
66
  it 'denies acess to show' do
67
67
  user = create(:user)
68
- user.update_attributes(remember_token: '')
68
+ user.update(remember_token: '')
69
69
  cookies[:remember_token] = ''
70
70
 
71
71
  get :show
@@ -2,10 +2,6 @@ class ApplicationController < ActionController::Base
2
2
  include Clearance::Controller
3
3
 
4
4
  def show
5
- if Rails::VERSION::MAJOR >= 5
6
- render html: "", layout: "application"
7
- else
8
- render text: "", layout: "application"
9
- end
5
+ render html: "", layout: "application"
10
6
  end
11
7
  end
@@ -28,7 +28,13 @@ module Dummy
28
28
  config.secret_key_base = "SECRET_KEY_BASE"
29
29
 
30
30
  if config.active_record.sqlite3.respond_to?(:represent_boolean_as_integer)
31
- config.active_record.sqlite3.represent_boolean_as_integer = true
31
+ if Rails::VERSION::MAJOR < 6
32
+ config.active_record.sqlite3.represent_boolean_as_integer = true
33
+ end
34
+ end
35
+
36
+ if Rails::VERSION::MAJOR >= 6
37
+ config.action_mailer.delivery_job = "ActionMailer::MailDeliveryJob"
32
38
  end
33
39
 
34
40
  config.active_job.queue_adapter = :inline
@@ -128,10 +128,6 @@ describe Clearance::Generators::InstallGenerator, :generator do
128
128
  end
129
129
 
130
130
  def models_inherit_from
131
- if Rails.version >= "5.0.0"
132
- "ApplicationRecord"
133
- else
134
- "ActiveRecord::Base"
135
- end
131
+ "ApplicationRecord"
136
132
  end
137
133
  end
@@ -22,7 +22,6 @@ describe Clearance::Generators::ViewsGenerator, :generator do
22
22
 
23
23
  view_files.each do |each|
24
24
  expect(each).to exist
25
- expect(each).to have_correct_syntax
26
25
  end
27
26
  end
28
27
 
@@ -3,10 +3,15 @@ require "spec_helper"
3
3
  describe "Token expiration" do
4
4
  describe "after signing in" do
5
5
  before do
6
+ Timecop.freeze
6
7
  create_user_and_sign_in
7
8
  @initial_cookies = remember_token_cookies
8
9
  end
9
10
 
11
+ after do
12
+ Timecop.return
13
+ end
14
+
10
15
  it "should have a remember_token cookie with a future expiration" do
11
16
  expect(first_cookie.expires).to be_between(
12
17
  1.years.from_now - 1.second,
data/spec/spec_helper.rb CHANGED
@@ -29,12 +29,10 @@ RSpec.configure do |config|
29
29
 
30
30
  config.before { restore_default_warning_free_config }
31
31
 
32
- if Rails::VERSION::MAJOR >= 5
33
- require 'rails-controller-testing'
34
- config.include Rails::Controller::Testing::TestProcess
35
- config.include Rails::Controller::Testing::TemplateAssertions
36
- config.include Rails::Controller::Testing::Integration
37
- end
32
+ require 'rails-controller-testing'
33
+ config.include Rails::Controller::Testing::TestProcess
34
+ config.include Rails::Controller::Testing::TemplateAssertions
35
+ config.include Rails::Controller::Testing::Integration
38
36
  end
39
37
 
40
38
  Shoulda::Matchers.configure do |config|
@@ -34,11 +34,7 @@ module GeneratorSpecHelpers
34
34
  end
35
35
 
36
36
  def versionize_template(template_file)
37
- if Rails.version >= "5.0.0"
38
- template_file = ["rails5", template_file].join("/")
39
- end
40
-
41
- template_file
37
+ ["rails5", template_file].join("/")
42
38
  end
43
39
  end
44
40
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: clearance
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0.beta1
4
+ version: 2.0.0.beta2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dan Croak
@@ -25,7 +25,7 @@ authors:
25
25
  autorequire:
26
26
  bindir: bin
27
27
  cert_chain: []
28
- date: 2019-04-12 00:00:00.000000000 Z
28
+ date: 2019-09-17 00:00:00.000000000 Z
29
29
  dependencies:
30
30
  - !ruby/object:Gem::Dependency
31
31
  name: bcrypt
@@ -61,56 +61,56 @@ dependencies:
61
61
  requirements:
62
62
  - - ">="
63
63
  - !ruby/object:Gem::Version
64
- version: '4.2'
64
+ version: '5.0'
65
65
  type: :runtime
66
66
  prerelease: false
67
67
  version_requirements: !ruby/object:Gem::Requirement
68
68
  requirements:
69
69
  - - ">="
70
70
  - !ruby/object:Gem::Version
71
- version: '4.2'
71
+ version: '5.0'
72
72
  - !ruby/object:Gem::Dependency
73
73
  name: activemodel
74
74
  requirement: !ruby/object:Gem::Requirement
75
75
  requirements:
76
76
  - - ">="
77
77
  - !ruby/object:Gem::Version
78
- version: '4.2'
78
+ version: '5.0'
79
79
  type: :runtime
80
80
  prerelease: false
81
81
  version_requirements: !ruby/object:Gem::Requirement
82
82
  requirements:
83
83
  - - ">="
84
84
  - !ruby/object:Gem::Version
85
- version: '4.2'
85
+ version: '5.0'
86
86
  - !ruby/object:Gem::Dependency
87
87
  name: activerecord
88
88
  requirement: !ruby/object:Gem::Requirement
89
89
  requirements:
90
90
  - - ">="
91
91
  - !ruby/object:Gem::Version
92
- version: '4.2'
92
+ version: '5.0'
93
93
  type: :runtime
94
94
  prerelease: false
95
95
  version_requirements: !ruby/object:Gem::Requirement
96
96
  requirements:
97
97
  - - ">="
98
98
  - !ruby/object:Gem::Version
99
- version: '4.2'
99
+ version: '5.0'
100
100
  - !ruby/object:Gem::Dependency
101
101
  name: actionmailer
102
102
  requirement: !ruby/object:Gem::Requirement
103
103
  requirements:
104
104
  - - ">="
105
105
  - !ruby/object:Gem::Version
106
- version: '4.2'
106
+ version: '5.0'
107
107
  type: :runtime
108
108
  prerelease: false
109
109
  version_requirements: !ruby/object:Gem::Requirement
110
110
  requirements:
111
111
  - - ">="
112
112
  - !ruby/object:Gem::Version
113
- version: '4.2'
113
+ version: '5.0'
114
114
  description: Rails authentication & authorization with email & password.
115
115
  email: support@thoughtbot.com
116
116
  executables: []
@@ -154,10 +154,10 @@ files:
154
154
  - config/routes.rb
155
155
  - db/migrate/20110111224543_create_clearance_users.rb
156
156
  - db/schema.rb
157
- - gemfiles/rails_4.2.gemfile
158
157
  - gemfiles/rails_5.0.gemfile
159
158
  - gemfiles/rails_5.1.gemfile
160
159
  - gemfiles/rails_5.2.gemfile
160
+ - gemfiles/rails_6.0.gemfile
161
161
  - lib/clearance.rb
162
162
  - lib/clearance/authentication.rb
163
163
  - lib/clearance/authorization.rb
@@ -255,11 +255,9 @@ files:
255
255
  - spec/spec_helper.rb
256
256
  - spec/support/clearance.rb
257
257
  - spec/support/cookies.rb
258
- - spec/support/environment.rb
259
258
  - spec/support/fake_model_with_password_strategy.rb
260
259
  - spec/support/fake_model_without_password_strategy.rb
261
260
  - spec/support/generator_spec_helpers.rb
262
- - spec/support/http_method_shim.rb
263
261
  - spec/support/request_with_remember_token.rb
264
262
  - spec/views/view_helpers_spec.rb
265
263
  homepage: https://github.com/thoughtbot/clearance
@@ -275,7 +273,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
275
273
  requirements:
276
274
  - - ">="
277
275
  - !ruby/object:Gem::Version
278
- version: 2.3.0
276
+ version: 2.4.0
279
277
  required_rubygems_version: !ruby/object:Gem::Requirement
280
278
  requirements:
281
279
  - - ">"
@@ -1,12 +0,0 @@
1
- module EnvironmentSupport
2
- def with_environment(replacement_env)
3
- original_env = ENV.to_hash
4
- ENV.update(replacement_env)
5
-
6
- begin
7
- yield
8
- ensure
9
- ENV.replace(original_env)
10
- end
11
- end
12
- end
@@ -1,25 +0,0 @@
1
- # Rails 5 deprecates calling HTTP action methods with positional arguments
2
- # in favor of keyword arguments. However, the keyword argument form is only
3
- # supported in Rails 5+. Since we support 4.2, we must give it a shim to massage
4
- # the params into the previous style!
5
-
6
- module PreRailsFiveHTTPMethodShim
7
- def get(path, params: {}, headers: {}, format: :html)
8
- super(path, params.merge(format: format), headers)
9
- end
10
-
11
- def put(path, params: {}, headers: {}, format: :html)
12
- super(path, params.merge(format: format), headers)
13
- end
14
-
15
- def post(path, params: {}, headers: {}, format: :html)
16
- super(path, params.merge(format: format), headers)
17
- end
18
- end
19
-
20
- if Rails::VERSION::MAJOR < 5
21
- RSpec.configure do |config|
22
- config.include PreRailsFiveHTTPMethodShim, type: :controller
23
- config.include PreRailsFiveHTTPMethodShim, type: :request
24
- end
25
- end