Verify page content in `ChallengableConcern` spec (#33895)

pull/33914/head
Matt Jankowski 2 weeks ago committed by GitHub
parent 6df24b4bc2
commit fb0856458b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -3,6 +3,8 @@
require 'rails_helper'
RSpec.describe ChallengableConcern do
render_views
controller(ApplicationController) do
include ChallengableConcern # rubocop:disable RSpec/DescribedClass
@ -85,29 +87,35 @@ RSpec.describe ChallengableConcern do
before { get :foo }
it 'renders challenge' do
expect(response).to render_template('auth/challenges/new', layout: :auth)
expect(response.parsed_body)
.to have_title(I18n.t('challenge.prompt'))
end
# See Auth::ChallengesControllerSpec
end
context 'with POST requests' do
before { post :bar }
it 'renders challenge' do
expect(response).to render_template('auth/challenges/new', layout: :auth)
expect(response.parsed_body)
.to have_title(I18n.t('challenge.prompt'))
end
it 'accepts correct password' do
post :bar, params: { form_challenge: { current_password: password } }
expect(response.body).to eq 'bar'
expect(session[:challenge_passed_at]).to_not be_nil
expect(response.body)
.to eq 'bar'
expect(session[:challenge_passed_at])
.to_not be_nil
end
it 'rejects wrong password' do
post :bar, params: { form_challenge: { current_password: 'dddfff888123' } }
expect(response.body).to render_template('auth/challenges/new', layout: :auth)
expect(session[:challenge_passed_at]).to be_nil
expect(response.parsed_body)
.to have_title(I18n.t('challenge.prompt'))
expect(session[:challenge_passed_at])
.to be_nil
end
end
end

Loading…
Cancel
Save