Skip to content

Commit 3725e45

Browse files
committed
Remove feature gate on confirmation actions
1 parent 4736af2 commit 3725e45

File tree

2 files changed

+16
-14
lines changed

2 files changed

+16
-14
lines changed

app/controllers/users/confirmations_controller.rb

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
# frozen_string_literal: true
22

33
class Users::ConfirmationsController < ApplicationController
4-
before_action :feature_enabled!
54
before_action :redirect_if_authenticated, only: [:create, :new]
65

76
def new
@@ -51,19 +50,15 @@ def update
5150
end
5251

5352
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
5556

5657
WelcomeNotifier.deliver_to(@user)
5758

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"
5960
else
6061
redirect_to new_users_confirmation_path, alert: "Something went wrong"
6162
end
6263
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
6964
end

spec/requests/users/confirmations_spec.rb

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,6 @@
55
RSpec.describe "Confirmations", type: :request do
66
include ActiveSupport::Testing::TimeHelpers
77

8-
before do
9-
Flipper[:user_registration].enable
10-
end
11-
128
describe "POST create" do
139
it "succeeds for unconfirmed user" do
1410
user = FactoryBot.create(:user, :unconfirmed)
@@ -103,7 +99,18 @@
10399

104100
put users_confirmation_path(user.generate_token_for(:confirmation))
105101

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)
107114
expect(flash[:notice]).to eq("Thank you for confirming your email address")
108115
end
109116

0 commit comments

Comments
 (0)