File tree Expand file tree Collapse file tree 2 files changed +16
-14
lines changed Expand file tree Collapse file tree 2 files changed +16
-14
lines changed Original file line number Diff line number Diff line change 1
1
# frozen_string_literal: true
2
2
3
3
class Users ::ConfirmationsController < ApplicationController
4
- before_action :feature_enabled!
5
4
before_action :redirect_if_authenticated , only : [ :create , :new ]
6
5
7
6
def new
@@ -51,19 +50,15 @@ def update
51
50
end
52
51
53
52
if @user . confirm!
54
- warden . set_user ( @user , scope : :user )
53
+ if Flipper . enabled? ( :user_registration , @user )
54
+ warden . set_user ( @user , scope : :user )
55
+ end
55
56
56
57
WelcomeNotifier . deliver_to ( @user )
57
58
58
- redirect_to users_dashboard_path , notice : "Thank you for confirming your email address"
59
+ redirect_to users_thank_you_path , notice : "Thank you for confirming your email address"
59
60
else
60
61
redirect_to new_users_confirmation_path , alert : "Something went wrong"
61
62
end
62
63
end
63
-
64
- private
65
-
66
- def feature_enabled!
67
- redirect_to root_path , notice : "Coming soon!" unless Flipper . enabled? ( :user_registration , current_admin_user )
68
- end
69
64
end
Original file line number Diff line number Diff line change 5
5
RSpec . describe "Confirmations" , type : :request do
6
6
include ActiveSupport ::Testing ::TimeHelpers
7
7
8
- before do
9
- Flipper [ :user_registration ] . enable
10
- end
11
-
12
8
describe "POST create" do
13
9
it "succeeds for unconfirmed user" do
14
10
user = FactoryBot . create ( :user , :unconfirmed )
103
99
104
100
put users_confirmation_path ( user . generate_token_for ( :confirmation ) )
105
101
106
- expect ( response ) . to redirect_to ( users_dashboard_path )
102
+ expect ( response ) . to redirect_to ( users_thank_you_path )
103
+ expect ( flash [ :notice ] ) . to eq ( "Thank you for confirming your email address" )
104
+ end
105
+
106
+ it "works when user sessions are disabled" do
107
+ Flipper [ :user_registration ] . enable
108
+
109
+ user = FactoryBot . create ( :user , :unconfirmed )
110
+
111
+ put users_confirmation_path ( user . generate_token_for ( :confirmation ) )
112
+
113
+ expect ( response ) . to redirect_to ( users_thank_you_path )
107
114
expect ( flash [ :notice ] ) . to eq ( "Thank you for confirming your email address" )
108
115
end
109
116
You can’t perform that action at this time.
0 commit comments