Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion app/controllers/sign_up/passwords_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,11 @@ def process_unsuccessful_password_creation

def sign_in_and_redirect_user
sign_in @user
redirect_to authentication_methods_setup_url
if current_user.accepted_rules_of_use_still_valid?
redirect_to authentication_methods_setup_url
else
redirect_to rules_of_use_url
end
end
end
end
28 changes: 28 additions & 0 deletions spec/features/users/sign_up_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,34 @@ def clipboard_text
end
end

context 'user finishes sign up after rules of use change' do
it 'validates terms checkbox and signs in successfully' do
user = create(
:user,
:unconfirmed,
accepted_terms_at: IdentityConfig.store.rules_of_use_updated_at - 1.year,
confirmation_token: 'foo',
)

visit sign_up_enter_password_path(confirmation_token: 'foo')
fill_in t('forms.password'), with: Features::SessionHelper::VALID_PASSWORD
fill_in(
t('components.password_confirmation.confirm_label'),
with: Features::SessionHelper::VALID_PASSWORD,
)
click_button t('forms.buttons.continue')

expect(current_path).to eq rules_of_use_path
check 'rules_of_use_form[terms_accepted]'

freeze_time do
click_button t('forms.buttons.continue')
expect(current_path).to eq authentication_methods_setup_path
expect(user.reload.accepted_terms_at).to eq Time.zone.now
end
end
end

it 'does not regenerate a confirmation token if the token is not expired' do
email = 'test@test.com'

Expand Down