clearance 2.3.1 → 2.6.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 +4 -4
- data/.github/workflows/tests.yml +5 -13
- data/Appraisals +9 -13
- data/{NEWS.md → CHANGELOG.md} +42 -1
- data/Gemfile.lock +122 -94
- data/README.md +34 -4
- data/app/controllers/clearance/passwords_controller.rb +6 -6
- data/app/controllers/clearance/sessions_controller.rb +1 -1
- data/app/controllers/clearance/users_controller.rb +1 -1
- data/app/views/passwords/new.html.erb +1 -1
- data/app/views/sessions/_form.html.erb +1 -1
- data/app/views/users/_form.html.erb +1 -1
- data/clearance.gemspec +2 -1
- data/db/schema.rb +2 -2
- data/gemfiles/rails_6.0.gemfile +2 -0
- data/gemfiles/rails_6.1.gemfile +1 -0
- data/gemfiles/rails_7.0.gemfile +21 -0
- data/lib/clearance/authentication.rb +3 -1
- data/lib/clearance/authorization.rb +9 -3
- data/lib/clearance/configuration.rb +18 -1
- data/lib/clearance/sign_in_guard.rb +2 -2
- data/lib/clearance/user.rb +2 -2
- data/lib/clearance/version.rb +1 -1
- data/lib/generators/clearance/install/install_generator.rb +10 -6
- data/lib/generators/clearance/install/templates/db/migrate/add_clearance_to_users.rb.erb +15 -12
- data/lib/generators/clearance/install/templates/db/migrate/create_users.rb.erb +2 -1
- data/lib/generators/clearance/specs/templates/support/features/clearance_helpers.rb +1 -0
- data/spec/acceptance/clearance_installation_spec.rb +1 -0
- data/spec/app_templates/testapp/Gemfile +2 -0
- data/spec/configuration_spec.rb +8 -1
- data/spec/controllers/passwords_controller_spec.rb +86 -3
- data/spec/controllers/sessions_controller_spec.rb +22 -0
- data/spec/controllers/users_controller_spec.rb +14 -0
- data/spec/dummy/application.rb +6 -21
- data/spec/dummy/db/.keep +0 -0
- data/spec/generators/clearance/install/install_generator_spec.rb +6 -0
- data/spec/requests/password_maintenance_spec.rb +1 -0
- data/spec/spec_helper.rb +1 -5
- metadata +7 -4
@@ -0,0 +1,21 @@
|
|
1
|
+
# This file was generated by Appraisal
|
2
|
+
|
3
|
+
source "https://rubygems.org"
|
4
|
+
|
5
|
+
gem "addressable"
|
6
|
+
gem "ammeter"
|
7
|
+
gem "appraisal"
|
8
|
+
gem "capybara"
|
9
|
+
gem "database_cleaner"
|
10
|
+
gem "erb_lint", require: false
|
11
|
+
gem "factory_bot_rails"
|
12
|
+
gem "nokogiri"
|
13
|
+
gem "pry", require: false
|
14
|
+
gem "rails-controller-testing"
|
15
|
+
gem "rspec-rails"
|
16
|
+
gem "shoulda-matchers"
|
17
|
+
gem "sqlite3"
|
18
|
+
gem "timecop"
|
19
|
+
gem "railties", "~> 7.0"
|
20
|
+
|
21
|
+
gemspec path: "../"
|
@@ -24,8 +24,10 @@ module Clearance
|
|
24
24
|
# `params[:session][:password]` are required.
|
25
25
|
# @return [User, nil] The user or nil if authentication fails.
|
26
26
|
def authenticate(params)
|
27
|
+
session_params = params.require(:session)
|
28
|
+
|
27
29
|
Clearance.configuration.user_model.authenticate(
|
28
|
-
|
30
|
+
session_params[:email], session_params[:password]
|
29
31
|
)
|
30
32
|
end
|
31
33
|
|
@@ -77,8 +77,8 @@ module Clearance
|
|
77
77
|
end
|
78
78
|
|
79
79
|
# @api private
|
80
|
-
def redirect_back_or(default)
|
81
|
-
redirect_to(return_to || default)
|
80
|
+
def redirect_back_or(default, **options)
|
81
|
+
redirect_to(return_to || default, **options)
|
82
82
|
clear_return_to
|
83
83
|
end
|
84
84
|
|
@@ -86,10 +86,16 @@ module Clearance
|
|
86
86
|
def return_to
|
87
87
|
if return_to_url
|
88
88
|
uri = URI.parse(return_to_url)
|
89
|
-
|
89
|
+
path = path_without_leading_slashes(uri)
|
90
|
+
"#{path}?#{uri.query}".chomp("?") + "##{uri.fragment}".chomp("#")
|
90
91
|
end
|
91
92
|
end
|
92
93
|
|
94
|
+
# @api private
|
95
|
+
def path_without_leading_slashes(uri)
|
96
|
+
uri.path.sub(/\A\/+/, "/")
|
97
|
+
end
|
98
|
+
|
93
99
|
# @api private
|
94
100
|
def return_to_url
|
95
101
|
session[:return_to]
|
@@ -118,6 +118,17 @@ module Clearance
|
|
118
118
|
# @return [Array<String>]
|
119
119
|
attr_accessor :allowed_backdoor_environments
|
120
120
|
|
121
|
+
# The parameter for user routes. By default this is derived from the user
|
122
|
+
# model.
|
123
|
+
# @return [Symbol]
|
124
|
+
attr_accessor :user_parameter
|
125
|
+
|
126
|
+
# Controls wether users are automatically signed in after successfully
|
127
|
+
# resetting their password.
|
128
|
+
# Defaults to `true`.
|
129
|
+
# @return [Boolean]
|
130
|
+
attr_writer :sign_in_on_password_reset
|
131
|
+
|
121
132
|
def initialize
|
122
133
|
@allow_sign_up = true
|
123
134
|
@allowed_backdoor_environments = ["test", "ci", "development"]
|
@@ -134,6 +145,8 @@ module Clearance
|
|
134
145
|
@secure_cookie = false
|
135
146
|
@signed_cookie = false
|
136
147
|
@sign_in_guards = []
|
148
|
+
@user_parameter = nil
|
149
|
+
@sign_in_on_password_reset = true
|
137
150
|
end
|
138
151
|
|
139
152
|
def signed_cookie=(value)
|
@@ -183,7 +196,7 @@ module Clearance
|
|
183
196
|
# In the default configuration, this is `user`.
|
184
197
|
# @return [Symbol]
|
185
198
|
def user_parameter
|
186
|
-
user_model.model_name.singular.to_sym
|
199
|
+
@user_parameter ||= user_model.model_name.singular.to_sym
|
187
200
|
end
|
188
201
|
|
189
202
|
# The name of foreign key parameter for the configured user model.
|
@@ -214,6 +227,10 @@ module Clearance
|
|
214
227
|
def rotate_csrf_on_sign_in?
|
215
228
|
!!rotate_csrf_on_sign_in
|
216
229
|
end
|
230
|
+
|
231
|
+
def sign_in_on_password_reset?
|
232
|
+
@sign_in_on_password_reset
|
233
|
+
end
|
217
234
|
end
|
218
235
|
|
219
236
|
# @return [Clearance::Configuration] Clearance's current configuration
|
@@ -16,10 +16,10 @@ module Clearance
|
|
16
16
|
#
|
17
17
|
# # in config/initializers/clearance.rb
|
18
18
|
# Clearance.configure do |config|
|
19
|
-
# config.sign_in_guards = [ConfirmationGuard]
|
19
|
+
# config.sign_in_guards = ["ConfirmationGuard"]
|
20
20
|
# end
|
21
21
|
#
|
22
|
-
# # in
|
22
|
+
# # in app/guards/confirmation_guard.rb
|
23
23
|
# class ConfirmationGuard < Clearance::SignInGuard
|
24
24
|
# def call
|
25
25
|
# if signed_in? && current_user.email_confirmed?
|
data/lib/clearance/user.rb
CHANGED
@@ -234,7 +234,7 @@ module Clearance
|
|
234
234
|
# Always false. Override this method in your user model to allow for other
|
235
235
|
# forms of user authentication (username, Facebook, etc).
|
236
236
|
#
|
237
|
-
# @return [
|
237
|
+
# @return [Boolean]
|
238
238
|
def email_optional?
|
239
239
|
false
|
240
240
|
end
|
@@ -242,7 +242,7 @@ module Clearance
|
|
242
242
|
# Always false. Override this method in your user model to allow for other
|
243
243
|
# forms of user authentication (username, Facebook, etc).
|
244
244
|
#
|
245
|
-
# @return [
|
245
|
+
# @return [Boolean]
|
246
246
|
def password_optional?
|
247
247
|
false
|
248
248
|
end
|
data/lib/clearance/version.rb
CHANGED
@@ -73,17 +73,21 @@ module Clearance
|
|
73
73
|
|
74
74
|
def new_columns
|
75
75
|
@new_columns ||= {
|
76
|
-
email:
|
77
|
-
encrypted_password:
|
78
|
-
confirmation_token:
|
79
|
-
remember_token:
|
76
|
+
email: "t.string :email",
|
77
|
+
encrypted_password: "t.string :encrypted_password, limit: 128",
|
78
|
+
confirmation_token: "t.string :confirmation_token, limit: 128",
|
79
|
+
remember_token: "t.string :remember_token, limit: 128",
|
80
80
|
}.reject { |column| existing_users_columns.include?(column.to_s) }
|
81
81
|
end
|
82
82
|
|
83
83
|
def new_indexes
|
84
84
|
@new_indexes ||= {
|
85
|
-
index_users_on_email:
|
86
|
-
|
85
|
+
index_users_on_email:
|
86
|
+
"add_index :users, :email",
|
87
|
+
index_users_on_confirmation_token:
|
88
|
+
"add_index :users, :confirmation_token, unique: true",
|
89
|
+
index_users_on_remember_token:
|
90
|
+
"add_index :users, :remember_token, unique: true",
|
87
91
|
}.reject { |index| existing_users_indexes.include?(index.to_s) }
|
88
92
|
end
|
89
93
|
|
@@ -1,31 +1,34 @@
|
|
1
1
|
class AddClearanceToUsers < ActiveRecord::Migration<%= migration_version %>
|
2
2
|
def self.up
|
3
|
+
<% if config[:new_columns].any? -%>
|
3
4
|
change_table :users do |t|
|
4
5
|
<% config[:new_columns].values.each do |column| -%>
|
5
6
|
<%= column %>
|
6
7
|
<% end -%>
|
7
8
|
end
|
8
|
-
|
9
|
+
<% end -%>
|
10
|
+
<% if config[:new_indexes].any? -%>
|
9
11
|
<% config[:new_indexes].values.each do |index| -%>
|
10
12
|
<%= index %>
|
11
13
|
<% end -%>
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
update <<-SQL.squish
|
17
|
-
UPDATE users
|
18
|
-
SET remember_token = '#{Clearance::Token.new}'
|
19
|
-
WHERE id = '#{user['id']}'
|
20
|
-
SQL
|
14
|
+
<% end -%>
|
15
|
+
<% if config[:new_columns].keys.include?(:remember_token) -%>
|
16
|
+
Clearance.configuration.user_model.where(remember_token: nil).each do |user|
|
17
|
+
user.update_columns(remember_token: Clearance::Token.new)
|
21
18
|
end
|
19
|
+
<% end -%>
|
22
20
|
end
|
23
21
|
|
24
22
|
def self.down
|
25
|
-
|
23
|
+
<% config[:new_indexes].values.each do |index| -%>
|
24
|
+
<%= index.sub("add_index", "remove_index") %>
|
25
|
+
<% end -%>
|
26
26
|
<% if config[:new_columns].any? -%>
|
27
|
-
|
27
|
+
change_table :users do |t|
|
28
|
+
<% config[:new_columns].keys.each do |key| -%>
|
29
|
+
t.remove <%= key.inspect %>
|
28
30
|
<% end -%>
|
29
31
|
end
|
32
|
+
<% end -%>
|
30
33
|
end
|
31
34
|
end
|
data/spec/configuration_spec.rb
CHANGED
@@ -167,7 +167,14 @@ describe Clearance::Configuration do
|
|
167
167
|
end
|
168
168
|
|
169
169
|
describe "#user_parameter" do
|
170
|
-
|
170
|
+
context "when user_parameter is configured" do
|
171
|
+
it "returns the configured parameter" do
|
172
|
+
Clearance.configure { |config| config.user_parameter = :custom_param }
|
173
|
+
expect(Clearance.configuration.user_parameter).to eq :custom_param
|
174
|
+
end
|
175
|
+
end
|
176
|
+
|
177
|
+
it "returns the parameter key to use based on the user_model by default" do
|
171
178
|
Account = Class.new(ActiveRecord::Base)
|
172
179
|
Clearance.configure { |config| config.user_model = Account }
|
173
180
|
|
@@ -35,6 +35,16 @@ describe Clearance::PasswordsController do
|
|
35
35
|
email = ActionMailer::Base.deliveries.last
|
36
36
|
expect(email.subject).to match(/change your password/i)
|
37
37
|
end
|
38
|
+
|
39
|
+
it "re-renders the page when turbo is enabled" do
|
40
|
+
user = create(:user)
|
41
|
+
|
42
|
+
post :create, params: {
|
43
|
+
password: { email: user.email.upcase },
|
44
|
+
}
|
45
|
+
|
46
|
+
expect(response).to have_http_status(:accepted)
|
47
|
+
end
|
38
48
|
end
|
39
49
|
|
40
50
|
context "email param is missing" do
|
@@ -46,6 +56,14 @@ describe Clearance::PasswordsController do
|
|
46
56
|
expect(flash.now[:alert]).to match(/email can't be blank/i)
|
47
57
|
expect(response).to render_template(:new)
|
48
58
|
end
|
59
|
+
|
60
|
+
it "re-renders the page when turbo is enabled" do
|
61
|
+
post :create, params: {
|
62
|
+
password: {},
|
63
|
+
}
|
64
|
+
|
65
|
+
expect(response).to have_http_status(:unprocessable_entity)
|
66
|
+
end
|
49
67
|
end
|
50
68
|
|
51
69
|
context "email param is blank" do
|
@@ -53,12 +71,22 @@ describe Clearance::PasswordsController do
|
|
53
71
|
post :create, params: {
|
54
72
|
password: {
|
55
73
|
email: "",
|
56
|
-
}
|
74
|
+
},
|
57
75
|
}
|
58
76
|
|
59
77
|
expect(flash.now[:alert]).to match(/email can't be blank/i)
|
60
78
|
expect(response).to render_template(:new)
|
61
79
|
end
|
80
|
+
|
81
|
+
it "re-renders the page when turbo is enabled" do
|
82
|
+
post :create, params: {
|
83
|
+
password: {
|
84
|
+
email: "",
|
85
|
+
},
|
86
|
+
}
|
87
|
+
|
88
|
+
expect(response).to have_http_status(:unprocessable_entity)
|
89
|
+
end
|
62
90
|
end
|
63
91
|
|
64
92
|
context "email does not belong to an existing user" do
|
@@ -73,7 +101,7 @@ describe Clearance::PasswordsController do
|
|
73
101
|
expect(ActionMailer::Base.deliveries).to be_empty
|
74
102
|
end
|
75
103
|
|
76
|
-
it "still responds with
|
104
|
+
it "still responds with error so as not to leak registered users" do
|
77
105
|
email = "this_user_does_not_exist@non_existent_domain.com"
|
78
106
|
|
79
107
|
post :create, params: {
|
@@ -83,6 +111,16 @@ describe Clearance::PasswordsController do
|
|
83
111
|
expect(response).to be_successful
|
84
112
|
expect(response).to render_template "passwords/create"
|
85
113
|
end
|
114
|
+
|
115
|
+
it "has the same status code as a successful request" do
|
116
|
+
email = "this_user_does_not_exist@non_existent_domain.com"
|
117
|
+
|
118
|
+
post :create, params: {
|
119
|
+
password: { email: email },
|
120
|
+
}
|
121
|
+
|
122
|
+
expect(response).to have_http_status(:accepted)
|
123
|
+
end
|
86
124
|
end
|
87
125
|
end
|
88
126
|
|
@@ -97,6 +135,7 @@ describe Clearance::PasswordsController do
|
|
97
135
|
}
|
98
136
|
|
99
137
|
expect(response).to be_redirect
|
138
|
+
expect(response).to have_http_status(:found)
|
100
139
|
expect(response).to redirect_to edit_user_password_url(user)
|
101
140
|
expect(session[:password_reset_token]).to eq user.confirmation_token
|
102
141
|
end
|
@@ -172,6 +211,35 @@ describe Clearance::PasswordsController do
|
|
172
211
|
)
|
173
212
|
|
174
213
|
expect(user.reload.encrypted_password).not_to eq old_encrypted_password
|
214
|
+
expect(response).to have_http_status(:see_other)
|
215
|
+
end
|
216
|
+
|
217
|
+
it "signs in the user" do
|
218
|
+
user = create(:user, :with_forgotten_password)
|
219
|
+
|
220
|
+
put :update, params: update_parameters(
|
221
|
+
user,
|
222
|
+
new_password: "my_new_password",
|
223
|
+
)
|
224
|
+
|
225
|
+
expect(current_user).to eq(user)
|
226
|
+
end
|
227
|
+
|
228
|
+
context "when Clearance is configured to not sign in the user" do
|
229
|
+
it "doesn't sign in the user" do
|
230
|
+
Clearance.configure do |config|
|
231
|
+
config.sign_in_on_password_reset = false
|
232
|
+
end
|
233
|
+
|
234
|
+
user = create(:user, :with_forgotten_password)
|
235
|
+
|
236
|
+
put :update, params: update_parameters(
|
237
|
+
user,
|
238
|
+
new_password: "my_new_password",
|
239
|
+
)
|
240
|
+
|
241
|
+
expect(current_user).to be_nil
|
242
|
+
end
|
175
243
|
end
|
176
244
|
end
|
177
245
|
|
@@ -211,8 +279,19 @@ describe Clearance::PasswordsController do
|
|
211
279
|
)
|
212
280
|
|
213
281
|
expect(flash.now[:alert]).to match(/password can't be blank/i)
|
282
|
+
expect(response).to have_http_status(:unprocessable_entity)
|
214
283
|
expect(response).to render_template(:edit)
|
215
|
-
|
284
|
+
end
|
285
|
+
|
286
|
+
it "doesn't sign in the user" do
|
287
|
+
user = create(:user, :with_forgotten_password)
|
288
|
+
|
289
|
+
put :update, params: update_parameters(
|
290
|
+
user,
|
291
|
+
new_password: "",
|
292
|
+
)
|
293
|
+
|
294
|
+
expect(current_user).to be_nil
|
216
295
|
end
|
217
296
|
end
|
218
297
|
end
|
@@ -226,4 +305,8 @@ describe Clearance::PasswordsController do
|
|
226
305
|
password_reset: { password: new_password }
|
227
306
|
}
|
228
307
|
end
|
308
|
+
|
309
|
+
def current_user
|
310
|
+
request.env[:clearance].current_user
|
311
|
+
end
|
229
312
|
end
|
@@ -24,6 +24,14 @@ describe Clearance::SessionsController do
|
|
24
24
|
end
|
25
25
|
|
26
26
|
describe "on POST to #create" do
|
27
|
+
context "when missing parameters" do
|
28
|
+
it "raises an error" do
|
29
|
+
expect do
|
30
|
+
post :create
|
31
|
+
end.to raise_error(ActionController::ParameterMissing)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
27
35
|
context "when password is optional" do
|
28
36
|
it "renders the page with error" do
|
29
37
|
user = create(:user_with_optional_password)
|
@@ -58,6 +66,19 @@ describe Clearance::SessionsController do
|
|
58
66
|
end
|
59
67
|
|
60
68
|
context "with good credentials and a session return url" do
|
69
|
+
it "redirects to the return URL removing leading slashes" do
|
70
|
+
user = create(:user)
|
71
|
+
url = "/url_in_the_session?foo=bar#baz"
|
72
|
+
return_url = "//////#{url}"
|
73
|
+
request.session[:return_to] = return_url
|
74
|
+
|
75
|
+
post :create, params: {
|
76
|
+
session: { email: user.email, password: user.password },
|
77
|
+
}
|
78
|
+
|
79
|
+
should redirect_to(url)
|
80
|
+
end
|
81
|
+
|
61
82
|
it "redirects to the return URL maintaining query and fragment" do
|
62
83
|
user = create(:user)
|
63
84
|
return_url = "/url_in_the_session?foo=bar#baz"
|
@@ -104,6 +125,7 @@ describe Clearance::SessionsController do
|
|
104
125
|
end
|
105
126
|
|
106
127
|
it { should redirect_to_url_after_destroy }
|
128
|
+
it { expect(response).to have_http_status(:see_other) }
|
107
129
|
end
|
108
130
|
|
109
131
|
context "with a cookie" do
|
@@ -67,6 +67,20 @@ describe Clearance::UsersController do
|
|
67
67
|
expect(response).to redirect_to(return_url)
|
68
68
|
end
|
69
69
|
end
|
70
|
+
|
71
|
+
context "with invalid attributes" do
|
72
|
+
it "renders the page with error" do
|
73
|
+
user_attributes = FactoryBot.attributes_for(:user, email: nil)
|
74
|
+
old_user_count = User.count
|
75
|
+
|
76
|
+
post :create, params: {
|
77
|
+
user: user_attributes,
|
78
|
+
}
|
79
|
+
|
80
|
+
expect(User.count).to eq old_user_count
|
81
|
+
expect(response).to have_http_status(:unprocessable_entity)
|
82
|
+
end
|
83
|
+
end
|
70
84
|
end
|
71
85
|
|
72
86
|
context "when signed in" do
|
data/spec/dummy/application.rb
CHANGED
@@ -1,50 +1,35 @@
|
|
1
1
|
require "rails/all"
|
2
|
+
|
2
3
|
require "clearance"
|
3
4
|
|
4
5
|
module Dummy
|
5
6
|
APP_ROOT = File.expand_path("..", __FILE__).freeze
|
6
7
|
|
7
|
-
I18n.enforce_available_locales = true
|
8
|
-
|
9
8
|
class Application < Rails::Application
|
10
|
-
config.action_controller.allow_forgery_protection = false
|
11
9
|
config.action_controller.perform_caching = false
|
12
|
-
config.action_dispatch.show_exceptions = false
|
13
10
|
config.action_mailer.default_url_options = { host: "dummy.example.com" }
|
14
11
|
config.action_mailer.delivery_method = :test
|
15
12
|
config.active_support.deprecation = :stderr
|
16
|
-
config.active_support.test_order = :random
|
17
|
-
config.cache_classes = true
|
18
|
-
config.consider_all_requests_local = true
|
19
13
|
config.eager_load = false
|
20
|
-
|
14
|
+
|
21
15
|
config.paths["app/controllers"] << "#{APP_ROOT}/app/controllers"
|
22
16
|
config.paths["app/models"] << "#{APP_ROOT}/app/models"
|
23
17
|
config.paths["app/views"] << "#{APP_ROOT}/app/views"
|
24
18
|
config.paths["config/database"] = "#{APP_ROOT}/config/database.yml"
|
25
19
|
config.paths["log"] = "tmp/log/development.log"
|
26
|
-
|
27
20
|
config.paths.add "config/routes.rb", with: "#{APP_ROOT}/config/routes.rb"
|
28
|
-
config.secret_key_base = "SECRET_KEY_BASE"
|
29
21
|
|
30
|
-
if
|
31
|
-
|
32
|
-
|
33
|
-
|
22
|
+
if Rails.version.match?(/^6.0/)
|
23
|
+
config.active_record.sqlite3.represent_boolean_as_integer = true
|
24
|
+
else
|
25
|
+
config.active_record.legacy_connection_handling = false
|
34
26
|
end
|
35
27
|
|
36
|
-
if Rails::VERSION::MAJOR >= 6
|
37
|
-
config.action_mailer.delivery_job = "ActionMailer::MailDeliveryJob"
|
38
|
-
end
|
39
|
-
|
40
|
-
config.active_job.queue_adapter = :inline
|
41
|
-
|
42
28
|
def require_environment!
|
43
29
|
initialize!
|
44
30
|
end
|
45
31
|
|
46
32
|
def initialize!(&block)
|
47
|
-
FileUtils.mkdir_p(Rails.root.join("db").to_s)
|
48
33
|
super unless @initialized
|
49
34
|
end
|
50
35
|
end
|
data/spec/dummy/db/.keep
ADDED
File without changes
|
@@ -135,6 +135,12 @@ describe Clearance::Generators::InstallGenerator, :generator do
|
|
135
135
|
expect(migration).to contain("add_index :users, :email")
|
136
136
|
expect(migration).not_to contain("t.string :remember_token")
|
137
137
|
expect(migration).not_to contain("add_index :users, :remember_token")
|
138
|
+
expect(migration).to(
|
139
|
+
contain("add_index :users, :confirmation_token, unique: true"),
|
140
|
+
)
|
141
|
+
expect(migration).to(
|
142
|
+
contain("remove_index :users, :confirmation_token, unique: true"),
|
143
|
+
)
|
138
144
|
end
|
139
145
|
end
|
140
146
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -5,6 +5,7 @@ require "dummy/application"
|
|
5
5
|
|
6
6
|
require "clearance/rspec"
|
7
7
|
require "factory_bot_rails"
|
8
|
+
require "rails-controller-testing"
|
8
9
|
require "rspec/rails"
|
9
10
|
require "shoulda-matchers"
|
10
11
|
require "timecop"
|
@@ -28,11 +29,6 @@ RSpec.configure do |config|
|
|
28
29
|
end
|
29
30
|
|
30
31
|
config.before { restore_default_warning_free_config }
|
31
|
-
|
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
|
36
32
|
end
|
37
33
|
|
38
34
|
Shoulda::Matchers.configure do |config|
|
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.
|
4
|
+
version: 2.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dan Croak
|
@@ -22,10 +22,11 @@ authors:
|
|
22
22
|
- Jason Morrison
|
23
23
|
- Galen Frechette
|
24
24
|
- Josh Steiner
|
25
|
+
- Dorian Marié
|
25
26
|
autorequire:
|
26
27
|
bindir: bin
|
27
28
|
cert_chain: []
|
28
|
-
date:
|
29
|
+
date: 2022-06-12 00:00:00.000000000 Z
|
29
30
|
dependencies:
|
30
31
|
- !ruby/object:Gem::Dependency
|
31
32
|
name: bcrypt
|
@@ -149,11 +150,11 @@ files:
|
|
149
150
|
- ".gitignore"
|
150
151
|
- ".yardopts"
|
151
152
|
- Appraisals
|
153
|
+
- CHANGELOG.md
|
152
154
|
- CONTRIBUTING.md
|
153
155
|
- Gemfile
|
154
156
|
- Gemfile.lock
|
155
157
|
- LICENSE
|
156
|
-
- NEWS.md
|
157
158
|
- README.md
|
158
159
|
- RELEASING.md
|
159
160
|
- Rakefile
|
@@ -185,6 +186,7 @@ files:
|
|
185
186
|
- gemfiles/rails_5.2.gemfile
|
186
187
|
- gemfiles/rails_6.0.gemfile
|
187
188
|
- gemfiles/rails_6.1.gemfile
|
189
|
+
- gemfiles/rails_7.0.gemfile
|
188
190
|
- lib/clearance.rb
|
189
191
|
- lib/clearance/authentication.rb
|
190
192
|
- lib/clearance/authorization.rb
|
@@ -266,6 +268,7 @@ files:
|
|
266
268
|
- spec/dummy/application.rb
|
267
269
|
- spec/dummy/config/database.yml
|
268
270
|
- spec/dummy/config/routes.rb
|
271
|
+
- spec/dummy/db/.keep
|
269
272
|
- spec/factories.rb
|
270
273
|
- spec/generators/clearance/install/install_generator_spec.rb
|
271
274
|
- spec/generators/clearance/routes/routes_generator_spec.rb
|
@@ -311,7 +314,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
311
314
|
- !ruby/object:Gem::Version
|
312
315
|
version: '0'
|
313
316
|
requirements: []
|
314
|
-
rubygems_version: 3.1.
|
317
|
+
rubygems_version: 3.1.6
|
315
318
|
signing_key:
|
316
319
|
specification_version: 4
|
317
320
|
summary: Rails authentication & authorization with email & password.
|