Reduce RSpec/MultipleExpectations in captcha feature spec (#29226)

This commit is contained in:
Matt Jankowski 2024-02-16 02:52:57 -05:00 committed by GitHub
parent 4b7f04e3ea
commit a9f9b0097b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -19,12 +19,10 @@ describe 'email confirmation flow when captcha is enabled' do
# It presents the user with a captcha form
expect(page).to have_title(I18n.t('auth.captcha_confirmation.title'))
# It does not confirm the user just yet
expect(user.reload.confirmed?).to be false
# It redirects to app and confirms user
click_on I18n.t('challenge.confirm')
expect(user.reload.confirmed?).to be true
expect { click_on I18n.t('challenge.confirm') }
.to change { user.reload.confirmed? }.from(false).to(true)
expect(page).to have_current_path(/\A#{client_app.confirmation_redirect_uri}/, url: true)
# Browsers will generally reload the original page upon redirection
@ -32,8 +30,9 @@ describe 'email confirmation flow when captcha is enabled' do
visit "/auth/confirmation?confirmation_token=#{user.confirmation_token}&redirect_to_app=true"
# It presents a page with a link to the app callback
expect(page).to have_content(I18n.t('auth.confirmations.registration_complete', domain: 'cb6e6126.ngrok.io'))
expect(page).to have_link(I18n.t('auth.confirmations.clicking_this_link'), href: client_app.confirmation_redirect_uri)
expect(page)
.to have_content(I18n.t('auth.confirmations.registration_complete', domain: 'cb6e6126.ngrok.io'))
.and have_link(I18n.t('auth.confirmations.clicking_this_link'), href: client_app.confirmation_redirect_uri)
end
end