clearance 2.10.0 → 2.11.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.
Files changed (79) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/codeql.yml +39 -0
  3. data/.github/workflows/standardrb.yml +19 -0
  4. data/.github/workflows/tests.yml +4 -3
  5. data/Appraisals +1 -1
  6. data/CHANGELOG.md +21 -1
  7. data/CODEOWNERS +2 -0
  8. data/Gemfile +17 -14
  9. data/Gemfile.lock +117 -85
  10. data/README.md +1 -2
  11. data/Rakefile +1 -1
  12. data/app/controllers/clearance/passwords_controller.rb +6 -6
  13. data/app/mailers/clearance_mailer.rb +1 -1
  14. data/clearance.gemspec +38 -38
  15. data/config/routes.rb +7 -7
  16. data/gemfiles/rails_7.1.gemfile +3 -0
  17. data/gemfiles/rails_7.2.gemfile +3 -0
  18. data/gemfiles/rails_8.0.gemfile +5 -1
  19. data/lib/clearance/authentication.rb +4 -0
  20. data/lib/clearance/back_door.rb +3 -3
  21. data/lib/clearance/configuration.rb +6 -6
  22. data/lib/clearance/constraints.rb +2 -2
  23. data/lib/clearance/controller.rb +2 -2
  24. data/lib/clearance/default_sign_in_guard.rb +1 -1
  25. data/lib/clearance/password_strategies/bcrypt.rb +2 -2
  26. data/lib/clearance/session.rb +4 -6
  27. data/lib/clearance/sign_in_guard.rb +1 -1
  28. data/lib/clearance/testing/deny_access_matcher.rb +4 -4
  29. data/lib/clearance/token.rb +1 -1
  30. data/lib/clearance/user.rb +7 -7
  31. data/lib/clearance/version.rb +1 -1
  32. data/lib/clearance.rb +10 -10
  33. data/lib/generators/clearance/install/install_generator.rb +15 -15
  34. data/lib/generators/clearance/routes/routes_generator.rb +5 -5
  35. data/lib/generators/clearance/routes/templates/routes.rb +10 -10
  36. data/lib/generators/clearance/specs/specs_generator.rb +4 -4
  37. data/lib/generators/clearance/views/views_generator.rb +4 -4
  38. data/spec/acceptance/clearance_installation_spec.rb +3 -3
  39. data/spec/clearance/back_door_spec.rb +5 -5
  40. data/spec/clearance/constraints/signed_in_spec.rb +14 -14
  41. data/spec/clearance/constraints/signed_out_spec.rb +4 -4
  42. data/spec/clearance/default_sign_in_guard_spec.rb +6 -6
  43. data/spec/clearance/rack_session_spec.rb +9 -9
  44. data/spec/clearance/session_spec.rb +60 -62
  45. data/spec/clearance/sign_in_guard_spec.rb +7 -7
  46. data/spec/clearance/testing/controller_helpers_spec.rb +15 -14
  47. data/spec/clearance/testing/deny_access_matcher_spec.rb +1 -1
  48. data/spec/clearance/testing/view_helpers_spec.rb +2 -2
  49. data/spec/clearance/token_spec.rb +3 -3
  50. data/spec/configuration_spec.rb +8 -21
  51. data/spec/controllers/apis_controller_spec.rb +2 -2
  52. data/spec/controllers/forgeries_controller_spec.rb +12 -12
  53. data/spec/controllers/passwords_controller_spec.rb +25 -25
  54. data/spec/controllers/permissions_controller_spec.rb +12 -12
  55. data/spec/controllers/sessions_controller_spec.rb +6 -6
  56. data/spec/controllers/users_controller_spec.rb +5 -5
  57. data/spec/dummy/config/environments/test.rb +3 -3
  58. data/spec/factories/users.rb +3 -3
  59. data/spec/generators/clearance/install/install_generator_spec.rb +11 -11
  60. data/spec/generators/clearance/routes/routes_generator_spec.rb +1 -1
  61. data/spec/generators/clearance/specs/specs_generator_spec.rb +2 -2
  62. data/spec/generators/clearance/views/views_generator_spec.rb +2 -2
  63. data/spec/mailers/clearance_mailer_spec.rb +3 -2
  64. data/spec/models/user_spec.rb +2 -2
  65. data/spec/password_strategies/argon2_spec.rb +3 -3
  66. data/spec/password_strategies/bcrypt_spec.rb +4 -4
  67. data/spec/password_strategies/password_strategies_spec.rb +1 -1
  68. data/spec/requests/authentication_cookie_spec.rb +3 -3
  69. data/spec/requests/backdoor_spec.rb +1 -1
  70. data/spec/requests/cookie_options_spec.rb +2 -2
  71. data/spec/requests/csrf_rotation_spec.rb +1 -1
  72. data/spec/requests/password_maintenance_spec.rb +1 -1
  73. data/spec/requests/token_expiration_spec.rb +2 -2
  74. data/spec/routing/clearance_routes_spec.rb +36 -36
  75. data/spec/support/clearance.rb +1 -1
  76. data/spec/support/fake_model_without_password_strategy.rb +5 -2
  77. data/spec/support/generator_spec_helpers.rb +2 -2
  78. data/spec/support/request_with_remember_token.rb +1 -1
  79. metadata +5 -3
@@ -1,5 +1,12 @@
1
1
  require "spec_helper"
2
2
 
3
+ MyController = Class.new
4
+ DummyGuard = Class.new
5
+ Account = Class.new(ActiveRecord::Base)
6
+ CustomUser = Class.new(ActiveRecord::Base)
7
+ ConfiguredUser = Class.new
8
+ MyUser = Class.new
9
+
3
10
  describe Clearance::Configuration do
4
11
  let(:config) { Clearance.configuration }
5
12
 
@@ -10,14 +17,6 @@ describe Clearance::Configuration do
10
17
  end
11
18
 
12
19
  context "when a custom user_model_name is specified" do
13
- before(:each) do
14
- MyUser = Class.new
15
- end
16
-
17
- after(:each) do
18
- Object.send(:remove_const, :MyUser)
19
- end
20
-
21
20
  it "is used instead of User" do
22
21
  Clearance.configure { |config| config.user_model = MyUser }
23
22
 
@@ -38,14 +37,6 @@ describe Clearance::Configuration do
38
37
  end
39
38
 
40
39
  context "when a custom parent_controller is specified" do
41
- before(:each) do
42
- MyController = Class.new
43
- end
44
-
45
- after(:each) do
46
- Object.send(:remove_const, :MyController)
47
- end
48
-
49
40
  it "is used instead of ApplicationController" do
50
41
  Clearance.configure { |config| config.parent_controller = MyController }
51
42
 
@@ -139,7 +130,6 @@ describe Clearance::Configuration do
139
130
 
140
131
  context "when specifying sign in guards" do
141
132
  it "returns the stack with added guards" do
142
- DummyGuard = Class.new
143
133
  Clearance.configure { |config| config.sign_in_guards = [DummyGuard] }
144
134
 
145
135
  expect(Clearance.configuration.sign_in_guards).to eq [DummyGuard]
@@ -192,7 +182,7 @@ describe Clearance::Configuration do
192
182
  expect(Clearance.configuration.allow_password_reset?).to eq true
193
183
  end
194
184
  end
195
- end
185
+ end
196
186
 
197
187
  describe "#user_actions" do
198
188
  context "when allow_sign_up is configured to false" do
@@ -218,7 +208,6 @@ describe Clearance::Configuration do
218
208
  end
219
209
 
220
210
  it "returns the parameter key to use based on the user_model by default" do
221
- Account = Class.new(ActiveRecord::Base)
222
211
  Clearance.configure { |config| config.user_model = Account }
223
212
 
224
213
  expect(Clearance.configuration.user_parameter).to eq :account
@@ -227,7 +216,6 @@ describe Clearance::Configuration do
227
216
 
228
217
  describe "#user_id_parameter" do
229
218
  it "returns the parameter key to use based on the user_model" do
230
- CustomUser = Class.new(ActiveRecord::Base)
231
219
  Clearance.configure { |config| config.user_model = CustomUser }
232
220
 
233
221
  expect(Clearance.configuration.user_id_parameter).to eq :custom_user_id
@@ -247,7 +235,6 @@ describe Clearance::Configuration do
247
235
 
248
236
  describe "#reload_user_model" do
249
237
  it "returns the user model class if one has already been configured" do
250
- ConfiguredUser = Class.new
251
238
  Clearance.configure { |config| config.user_model = ConfiguredUser }
252
239
 
253
240
  expect(Clearance.configuration.reload_user_model).to eq ConfiguredUser
@@ -1,4 +1,4 @@
1
- require 'spec_helper'
1
+ require "spec_helper"
2
2
 
3
3
  class ApisController < ActionController::Base
4
4
  include Clearance::Controller
@@ -21,7 +21,7 @@ describe ApisController do
21
21
  Rails.application.reload_routes!
22
22
  end
23
23
 
24
- it 'responds with HTTP status code 401 when denied' do
24
+ it "responds with HTTP status code 401 when denied" do
25
25
  get :show, format: :js
26
26
  expect(subject).to respond_with(:unauthorized)
27
27
  end
@@ -1,4 +1,4 @@
1
- require 'spec_helper'
1
+ require "spec_helper"
2
2
 
3
3
  class ForgeriesController < ActionController::Base
4
4
  include Clearance::Controller
@@ -11,43 +11,43 @@ class ForgeriesController < ActionController::Base
11
11
  self.allow_forgery_protection = true
12
12
 
13
13
  def create
14
- redirect_to action: 'index'
14
+ redirect_to action: "index"
15
15
  end
16
16
  end
17
17
 
18
18
  describe ForgeriesController do
19
- context 'signed in user' do
19
+ context "signed in user" do
20
20
  before do
21
21
  Rails.application.routes.draw do
22
22
  resources :forgeries
23
- get '/sign_in' => 'clearance/sessions#new', as: 'sign_in'
23
+ get "/sign_in" => "clearance/sessions#new", :as => "sign_in"
24
24
  end
25
25
 
26
26
  @user = create(:user)
27
- @user.update_attribute(:remember_token, 'old-token')
28
- @request.cookies['remember_token'] = 'old-token'
27
+ @user.update_attribute(:remember_token, "old-token")
28
+ @request.cookies["remember_token"] = "old-token"
29
29
  end
30
30
 
31
31
  after do
32
32
  Rails.application.reload_routes!
33
33
  end
34
34
 
35
- it 'succeeds with authentic token' do
35
+ it "succeeds with authentic token" do
36
36
  token = controller.send(:form_authenticity_token)
37
37
  post :create, params: {
38
- authenticity_token: token,
38
+ authenticity_token: token
39
39
  }
40
- expect(subject).to redirect_to(action: 'index')
40
+ expect(subject).to redirect_to(action: "index")
41
41
  end
42
42
 
43
- it 'fails with invalid token' do
43
+ it "fails with invalid token" do
44
44
  post :create, params: {
45
- authenticity_token: "hax0r",
45
+ authenticity_token: "hax0r"
46
46
  }
47
47
  expect(subject).to deny_access
48
48
  end
49
49
 
50
- it 'fails with no token' do
50
+ it "fails with no token" do
51
51
  post :create
52
52
  expect(subject).to deny_access
53
53
  end
@@ -18,7 +18,7 @@ describe Clearance::PasswordsController do
18
18
  user = create(:user)
19
19
 
20
20
  post :create, params: {
21
- password: { email: user.email.upcase },
21
+ password: {email: user.email.upcase}
22
22
  }
23
23
 
24
24
  expect(user.reload.confirmation_token).not_to be_nil
@@ -29,7 +29,7 @@ describe Clearance::PasswordsController do
29
29
  user = create(:user)
30
30
 
31
31
  post :create, params: {
32
- password: { email: user.email },
32
+ password: {email: user.email}
33
33
  }
34
34
 
35
35
  email = ActionMailer::Base.deliveries.last
@@ -40,7 +40,7 @@ describe Clearance::PasswordsController do
40
40
  user = create(:user)
41
41
 
42
42
  post :create, params: {
43
- password: { email: user.email.upcase },
43
+ password: {email: user.email.upcase}
44
44
  }
45
45
 
46
46
  expect(response).to have_http_status(:accepted)
@@ -50,7 +50,7 @@ describe Clearance::PasswordsController do
50
50
  context "email param is missing" do
51
51
  it "displays flash error on new page" do
52
52
  post :create, params: {
53
- password: {},
53
+ password: {}
54
54
  }
55
55
 
56
56
  expect(flash.now[:alert]).to match(I18n.t("flashes.failure_when_missing_email"))
@@ -59,7 +59,7 @@ describe Clearance::PasswordsController do
59
59
 
60
60
  it "re-renders the page when turbo is enabled" do
61
61
  post :create, params: {
62
- password: {},
62
+ password: {}
63
63
  }
64
64
 
65
65
  expect(response).to have_http_status(:unprocessable_entity)
@@ -70,8 +70,8 @@ describe Clearance::PasswordsController do
70
70
  it "displays flash error on new page" do
71
71
  post :create, params: {
72
72
  password: {
73
- email: "",
74
- },
73
+ email: ""
74
+ }
75
75
  }
76
76
 
77
77
  expect(flash.now[:alert]).to match(I18n.t("flashes.failure_when_missing_email"))
@@ -81,8 +81,8 @@ describe Clearance::PasswordsController do
81
81
  it "re-renders the page when turbo is enabled" do
82
82
  post :create, params: {
83
83
  password: {
84
- email: "",
85
- },
84
+ email: ""
85
+ }
86
86
  }
87
87
 
88
88
  expect(response).to have_http_status(:unprocessable_entity)
@@ -95,7 +95,7 @@ describe Clearance::PasswordsController do
95
95
  email = "this_user_does_not_exist@non_existent_domain.com"
96
96
 
97
97
  post :create, params: {
98
- password: { email: email },
98
+ password: {email: email}
99
99
  }
100
100
 
101
101
  expect(ActionMailer::Base.deliveries).to be_empty
@@ -105,7 +105,7 @@ describe Clearance::PasswordsController do
105
105
  email = "this_user_does_not_exist@non_existent_domain.com"
106
106
 
107
107
  post :create, params: {
108
- password: { email: email },
108
+ password: {email: email}
109
109
  }
110
110
 
111
111
  expect(response).to be_successful
@@ -116,7 +116,7 @@ describe Clearance::PasswordsController do
116
116
  email = "this_user_does_not_exist@non_existent_domain.com"
117
117
 
118
118
  post :create, params: {
119
- password: { email: email },
119
+ password: {email: email}
120
120
  }
121
121
 
122
122
  expect(response).to have_http_status(:accepted)
@@ -131,7 +131,7 @@ describe Clearance::PasswordsController do
131
131
 
132
132
  get :edit, params: {
133
133
  user_id: user,
134
- token: user.confirmation_token,
134
+ token: user.confirmation_token
135
135
  }
136
136
 
137
137
  expect(response).to be_redirect
@@ -147,7 +147,7 @@ describe Clearance::PasswordsController do
147
147
 
148
148
  request.session[:password_reset_token] = user.confirmation_token
149
149
  get :edit, params: {
150
- user_id: user,
150
+ user_id: user
151
151
  }
152
152
 
153
153
  expect(response).to be_successful
@@ -160,7 +160,7 @@ describe Clearance::PasswordsController do
160
160
  it "renders the new password reset form with a flash alert" do
161
161
  get :edit, params: {
162
162
  user_id: 1,
163
- token: "",
163
+ token: ""
164
164
  }
165
165
 
166
166
  expect(response).to render_template(:new)
@@ -174,7 +174,7 @@ describe Clearance::PasswordsController do
174
174
 
175
175
  get :edit, params: {
176
176
  user_id: 1,
177
- token: user.confirmation_token + "a",
177
+ token: user.confirmation_token + "a"
178
178
  }
179
179
 
180
180
  expect(response).to render_template(:new)
@@ -190,7 +190,7 @@ describe Clearance::PasswordsController do
190
190
  user.forgot_password!
191
191
  get :edit, params: {
192
192
  user_id: user.id,
193
- token: user.reload.confirmation_token,
193
+ token: user.reload.confirmation_token
194
194
  }
195
195
 
196
196
  expect(response).to redirect_to(edit_user_password_url(user))
@@ -207,7 +207,7 @@ describe Clearance::PasswordsController do
207
207
 
208
208
  put :update, params: update_parameters(
209
209
  user,
210
- new_password: "my_new_password",
210
+ new_password: "my_new_password"
211
211
  )
212
212
 
213
213
  expect(user.reload.encrypted_password).not_to eq old_encrypted_password
@@ -219,7 +219,7 @@ describe Clearance::PasswordsController do
219
219
 
220
220
  put :update, params: update_parameters(
221
221
  user,
222
- new_password: "my_new_password",
222
+ new_password: "my_new_password"
223
223
  )
224
224
 
225
225
  expect(current_user).to eq(user)
@@ -235,7 +235,7 @@ describe Clearance::PasswordsController do
235
235
 
236
236
  put :update, params: update_parameters(
237
237
  user,
238
- new_password: "my_new_password",
238
+ new_password: "my_new_password"
239
239
  )
240
240
 
241
241
  expect(current_user).to be_nil
@@ -250,7 +250,7 @@ describe Clearance::PasswordsController do
250
250
 
251
251
  put :update, params: update_parameters(
252
252
  user,
253
- new_password: "",
253
+ new_password: ""
254
254
  )
255
255
 
256
256
  user.reload
@@ -265,7 +265,7 @@ describe Clearance::PasswordsController do
265
265
  put :update, params: {
266
266
  user_id: user,
267
267
  token: user.confirmation_token,
268
- password_reset: {},
268
+ password_reset: {}
269
269
  }
270
270
  end.not_to raise_error
271
271
  end
@@ -275,7 +275,7 @@ describe Clearance::PasswordsController do
275
275
 
276
276
  put :update, params: update_parameters(
277
277
  user,
278
- new_password: "",
278
+ new_password: ""
279
279
  )
280
280
 
281
281
  expect(flash.now[:alert]).to match(I18n.t("flashes.failure_after_update"))
@@ -288,7 +288,7 @@ describe Clearance::PasswordsController do
288
288
 
289
289
  put :update, params: update_parameters(
290
290
  user,
291
- new_password: "",
291
+ new_password: ""
292
292
  )
293
293
 
294
294
  expect(current_user).to be_nil
@@ -302,7 +302,7 @@ describe Clearance::PasswordsController do
302
302
  {
303
303
  user_id: user,
304
304
  token: user.confirmation_token,
305
- password_reset: { password: new_password }
305
+ password_reset: {password: new_password}
306
306
  }
307
307
  end
308
308
 
@@ -1,4 +1,4 @@
1
- require 'spec_helper'
1
+ require "spec_helper"
2
2
 
3
3
  class PermissionsController < ActionController::Base
4
4
  include Clearance::Controller
@@ -18,7 +18,7 @@ describe PermissionsController do
18
18
  before do
19
19
  Rails.application.routes.draw do
20
20
  resource :permission, only: [:new, :show]
21
- get '/sign_in' => 'clearance/sessions#new', as: 'sign_in'
21
+ get "/sign_in" => "clearance/sessions#new", :as => "sign_in"
22
22
  end
23
23
  end
24
24
 
@@ -26,30 +26,30 @@ describe PermissionsController do
26
26
  Rails.application.reload_routes!
27
27
  end
28
28
 
29
- context 'with signed in user' do
29
+ context "with signed in user" do
30
30
  before { sign_in }
31
31
 
32
- it 'allows access to new' do
32
+ it "allows access to new" do
33
33
  get :new
34
34
 
35
35
  expect(subject).not_to deny_access
36
36
  end
37
37
 
38
- it 'allows access to show' do
38
+ it "allows access to show" do
39
39
  get :show
40
40
 
41
41
  expect(subject).not_to deny_access
42
42
  end
43
43
  end
44
44
 
45
- context 'with visitor' do
46
- it 'allows access to new' do
45
+ context "with visitor" do
46
+ it "allows access to new" do
47
47
  get :new
48
48
 
49
49
  expect(subject).not_to deny_access
50
50
  end
51
51
 
52
- it 'denies access to show' do
52
+ it "denies access to show" do
53
53
  get :show
54
54
 
55
55
  expect(subject).to deny_access(redirect: sign_in_url)
@@ -62,11 +62,11 @@ describe PermissionsController do
62
62
  end
63
63
  end
64
64
 
65
- context 'when remember_token is blank' do
66
- it 'denies acess to show' do
65
+ context "when remember_token is blank" do
66
+ it "denies acess to show" do
67
67
  user = create(:user)
68
- user.update(remember_token: '')
69
- cookies[:remember_token] = ''
68
+ user.update(remember_token: "")
69
+ cookies[:remember_token] = ""
70
70
 
71
71
  get :show
72
72
 
@@ -37,7 +37,7 @@ describe Clearance::SessionsController do
37
37
  user = create(:user_with_optional_password)
38
38
 
39
39
  post :create, params: {
40
- session: { email: user.email, password: user.password },
40
+ session: {email: user.email, password: user.password}
41
41
  }
42
42
 
43
43
  expect(response).to render_template(:new)
@@ -50,7 +50,7 @@ describe Clearance::SessionsController do
50
50
  @user = create(:user)
51
51
  @user.update_attribute :remember_token, "old-token"
52
52
  post :create, params: {
53
- session: { email: @user.email, password: @user.password },
53
+ session: {email: @user.email, password: @user.password}
54
54
  }
55
55
  end
56
56
 
@@ -73,7 +73,7 @@ describe Clearance::SessionsController do
73
73
  request.session[:return_to] = return_url
74
74
 
75
75
  post :create, params: {
76
- session: { email: user.email, password: user.password },
76
+ session: {email: user.email, password: user.password}
77
77
  }
78
78
 
79
79
  should redirect_to(url)
@@ -85,7 +85,7 @@ describe Clearance::SessionsController do
85
85
  request.session[:return_to] = return_url
86
86
 
87
87
  post :create, params: {
88
- session: { email: user.email, password: user.password },
88
+ session: {email: user.email, password: user.password}
89
89
  }
90
90
 
91
91
  should redirect_to(return_url)
@@ -97,7 +97,7 @@ describe Clearance::SessionsController do
97
97
  request.session[:return_to] = return_url
98
98
 
99
99
  post :create, params: {
100
- session: { email: user.email, password: user.password },
100
+ session: {email: user.email, password: user.password}
101
101
  }
102
102
 
103
103
  should redirect_to(return_url)
@@ -109,7 +109,7 @@ describe Clearance::SessionsController do
109
109
  request.session[:return_to] = return_url
110
110
 
111
111
  post :create, params: {
112
- session: { email: user.email, password: user.password },
112
+ session: {email: user.email, password: user.password}
113
113
  }
114
114
 
115
115
  should redirect_to(return_url)
@@ -14,7 +14,7 @@ describe Clearance::UsersController do
14
14
 
15
15
  it "defaults email field to the value provided in the query string" do
16
16
  get :new, params: {
17
- user: { email: "a@example.com" },
17
+ user: {email: "a@example.com"}
18
18
  }
19
19
 
20
20
  expect(assigns(:user).email).to eq "a@example.com"
@@ -42,7 +42,7 @@ describe Clearance::UsersController do
42
42
  old_user_count = User.count
43
43
 
44
44
  post :create, params: {
45
- user: user_attributes,
45
+ user: user_attributes
46
46
  }
47
47
 
48
48
  expect(assigns(:user)).to be_present
@@ -59,7 +59,7 @@ describe Clearance::UsersController do
59
59
  @request.session[:return_to] = return_url
60
60
 
61
61
  post :create, params: {
62
- user: user_attributes,
62
+ user: user_attributes
63
63
  }
64
64
 
65
65
  expect(assigns(:user)).to be_present
@@ -74,7 +74,7 @@ describe Clearance::UsersController do
74
74
  old_user_count = User.count
75
75
 
76
76
  post :create, params: {
77
- user: user_attributes,
77
+ user: user_attributes
78
78
  }
79
79
 
80
80
  expect(User.count).to eq old_user_count
@@ -88,7 +88,7 @@ describe Clearance::UsersController do
88
88
  sign_in
89
89
 
90
90
  post :create, params: {
91
- user: {},
91
+ user: {}
92
92
  }
93
93
 
94
94
  expect(response).to redirect_to(Clearance.configuration.redirect_url)
@@ -5,7 +5,7 @@ Rails.application.configure do
5
5
 
6
6
  config.eager_load = ENV["CI"].present?
7
7
 
8
- config.public_file_server.headers = { "Cache-Control" => "public, max-age=#{1.hour.to_i}" }
8
+ config.public_file_server.headers = {"Cache-Control" => "public, max-age=#{1.hour.to_i}"}
9
9
 
10
10
  # Show full error reports and disable caching.
11
11
  config.consider_all_requests_local = true
@@ -19,13 +19,13 @@ Rails.application.configure do
19
19
  config.action_mailer.perform_caching = false
20
20
  config.action_mailer.delivery_method = :test
21
21
 
22
- config.action_mailer.default_url_options = { host: "www.example.com" }
22
+ config.action_mailer.default_url_options = {host: "www.example.com"}
23
23
 
24
24
  config.active_support.deprecation = :stderr
25
25
  config.active_support.disallowed_deprecation = :raise
26
26
  config.active_support.disallowed_deprecation_warnings = []
27
27
 
28
- config.factory_bot.definition_file_paths = [File.expand_path('../../../factories', __dir__)]
28
+ config.factory_bot.definition_file_paths = [File.expand_path("../../../factories", __dir__)]
29
29
 
30
30
  config.middleware.use Clearance::BackDoor
31
31
  end
@@ -5,15 +5,15 @@ FactoryBot.define do
5
5
 
6
6
  factory :user do
7
7
  email
8
- password { 'password' }
8
+ password { "password" }
9
9
 
10
10
  trait :with_forgotten_password do
11
11
  confirmation_token { Clearance::Token.new }
12
12
  end
13
13
 
14
- factory :user_with_optional_password, class: 'UserWithOptionalPassword' do
14
+ factory :user_with_optional_password, class: "UserWithOptionalPassword" do
15
15
  password { nil }
16
- encrypted_password { '' }
16
+ encrypted_password { "" }
17
17
  end
18
18
  end
19
19
  end
@@ -117,13 +117,13 @@ describe Clearance::Generators::InstallGenerator, :generator do
117
117
  existing_columns = [Struct::Named.new("remember_token")]
118
118
  existing_indexes = [Struct::Named.new("index_users_on_remember_token")]
119
119
 
120
- allow(ActiveRecord::Base.connection).to receive(:columns).
121
- with(:users).
122
- and_return(existing_columns)
120
+ allow(ActiveRecord::Base.connection).to receive(:columns)
121
+ .with(:users)
122
+ .and_return(existing_columns)
123
123
 
124
- allow(ActiveRecord::Base.connection).to receive(:indexes).
125
- with(:users).
126
- and_return(existing_indexes)
124
+ allow(ActiveRecord::Base.connection).to receive(:indexes)
125
+ .with(:users)
126
+ .and_return(existing_indexes)
127
127
 
128
128
  run_generator
129
129
  migration = migration_file("db/migrate/add_clearance_to_users.rb")
@@ -136,10 +136,10 @@ describe Clearance::Generators::InstallGenerator, :generator do
136
136
  expect(migration).not_to contain("t.string :remember_token")
137
137
  expect(migration).not_to contain("add_index :users, :remember_token")
138
138
  expect(migration).to(
139
- contain("add_index :users, :confirmation_token, unique: true"),
139
+ contain("add_index :users, :confirmation_token, unique: true")
140
140
  )
141
141
  expect(migration).to(
142
- contain("remove_index :users, :confirmation_token, unique: true"),
142
+ contain("remove_index :users, :confirmation_token, unique: true")
143
143
  )
144
144
  end
145
145
  end
@@ -147,9 +147,9 @@ describe Clearance::Generators::InstallGenerator, :generator do
147
147
 
148
148
  def table_does_not_exist(name)
149
149
  connection = ActiveRecord::Base.connection
150
- allow(connection).to receive(:data_source_exists?).
151
- with(name).
152
- and_return(false)
150
+ allow(connection).to receive(:data_source_exists?)
151
+ .with(name)
152
+ .and_return(false)
153
153
  end
154
154
 
155
155
  def preserve_original_primary_key_type_setting
@@ -15,7 +15,7 @@ describe Clearance::Generators::RoutesGenerator, :generator do
15
15
  expect(initializer).to contain("config.routes = false")
16
16
  expect(routes).to have_correct_syntax
17
17
  expect(routes).to contain(
18
- 'get "/sign_in" => "clearance/sessions#new", as: "sign_in"'
18
+ 'get "/sign_in" => "clearance/sessions#new", :as => "sign_in"'
19
19
  )
20
20
  end
21
21
  end
@@ -5,7 +5,7 @@ describe Clearance::Generators::SpecsGenerator, :generator do
5
5
  it "copies specs to host app" do
6
6
  run_generator
7
7
 
8
- specs = %w(
8
+ specs = %w[
9
9
  factories/clearance
10
10
  features/clearance/user_signs_out_spec
11
11
  features/clearance/visitor_resets_password_spec
@@ -14,7 +14,7 @@ describe Clearance::Generators::SpecsGenerator, :generator do
14
14
  features/clearance/visitor_updates_password_spec
15
15
  support/clearance
16
16
  support/features/clearance_helpers
17
- )
17
+ ]
18
18
 
19
19
  spec_files = specs.map { |spec| file("spec/#{spec}.rb") }
20
20
 
@@ -5,7 +5,7 @@ describe Clearance::Generators::ViewsGenerator, :generator do
5
5
  it "copies clearance views to the host application" do
6
6
  run_generator
7
7
 
8
- views = %w(
8
+ views = %w[
9
9
  clearance_mailer/change_password.html.erb
10
10
  clearance_mailer/change_password.text.erb
11
11
  passwords/create.html.erb
@@ -15,7 +15,7 @@ describe Clearance::Generators::ViewsGenerator, :generator do
15
15
  sessions/new.html.erb
16
16
  users/_form.html.erb
17
17
  users/new.html.erb
18
- )
18
+ ]
19
19
 
20
20
  view_files = views.map { |view| file("app/views/#{view}") }
21
21