mirror of
https://github.com/internetee/registry.git
synced 2025-07-02 01:03:35 +02:00
Registrar: fixed login flash message
This commit is contained in:
parent
8df6b3bdd1
commit
bcb283e2f1
2 changed files with 82 additions and 78 deletions
|
@ -1,4 +1,4 @@
|
||||||
- if flash[:notice].present? || flash[:alert].present?
|
- display = (flash.empty?) ? 'none' : 'block'
|
||||||
#flash
|
#flash{style: "display: #{display};"}
|
||||||
- type = (flash[:notice]) ? 'bg-success' : 'bg-danger'
|
- type = (flash[:notice]) ? 'bg-success' : 'bg-danger'
|
||||||
.alert{class: type}= flash[:notice] || flash[:alert]
|
.alert{class: type}= flash[:notice] || flash[:alert]
|
||||||
|
|
|
@ -6,104 +6,108 @@ feature 'Sessions', type: :feature do
|
||||||
Fabricate(:api_user)
|
Fabricate(:api_user)
|
||||||
end
|
end
|
||||||
|
|
||||||
scenario 'Api user should not get in when external service fails' do
|
context 'as unknown user' do
|
||||||
client = instance_double("Digidoc::Client")
|
it 'should not get in' do
|
||||||
allow(client).to receive(:authenticate).and_return(
|
client = instance_double("Digidoc::Client")
|
||||||
OpenStruct.new(
|
allow(client).to receive(:authenticate).and_return(
|
||||||
faultcode: 'Fault',
|
OpenStruct.new(
|
||||||
detail: OpenStruct.new(
|
user_id_code: '123'
|
||||||
message: 'Something is wrong'
|
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
)
|
|
||||||
|
|
||||||
allow(Digidoc::Client).to receive(:new) { client }
|
allow(Digidoc::Client).to receive(:new) { client }
|
||||||
|
|
||||||
visit registrar_login_path
|
visit registrar_login_path
|
||||||
page.should have_css('a[href="/registrar/login/mid"]')
|
page.should have_css('a[href="/registrar/login/mid"]')
|
||||||
|
|
||||||
page.find('a[href="/registrar/login/mid"]').click
|
page.find('a[href="/registrar/login/mid"]').click
|
||||||
|
|
||||||
fill_in 'user_phone', with: '00007'
|
fill_in 'user_phone', with: '00007'
|
||||||
click_button 'Log in'
|
click_button 'Log in'
|
||||||
page.should have_text('Something is wrong')
|
page.should have_text('No such user')
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
scenario 'Api user should not get in when there is not such user' do
|
context 'as known api user' do
|
||||||
client = instance_double("Digidoc::Client")
|
it 'should not get in when external service fails' do
|
||||||
allow(client).to receive(:authenticate).and_return(
|
client = instance_double("Digidoc::Client")
|
||||||
OpenStruct.new(
|
allow(client).to receive(:authenticate).and_return(
|
||||||
user_id_code: '123'
|
OpenStruct.new(
|
||||||
|
faultcode: 'Fault',
|
||||||
|
detail: OpenStruct.new(
|
||||||
|
message: 'Something is wrong'
|
||||||
|
)
|
||||||
|
)
|
||||||
)
|
)
|
||||||
)
|
|
||||||
|
|
||||||
allow(Digidoc::Client).to receive(:new) { client }
|
allow(Digidoc::Client).to receive(:new) { client }
|
||||||
|
|
||||||
visit registrar_login_path
|
visit registrar_login_path
|
||||||
page.should have_css('a[href="/registrar/login/mid"]')
|
page.should have_css('a[href="/registrar/login/mid"]')
|
||||||
|
|
||||||
page.find('a[href="/registrar/login/mid"]').click
|
page.find('a[href="/registrar/login/mid"]').click
|
||||||
|
|
||||||
fill_in 'user_phone', with: '00007'
|
fill_in 'user_phone', with: '00007'
|
||||||
click_button 'Log in'
|
click_button 'Log in'
|
||||||
page.should have_text('No such user')
|
page.should have_text('Something is wrong')
|
||||||
end
|
end
|
||||||
|
|
||||||
scenario 'Api user should when there is a sim error', js: true do
|
it 'should not get in when there is a sim error', js: true do
|
||||||
client = instance_double("Digidoc::Client", session_code: '123')
|
client = instance_double("Digidoc::Client", session_code: '123')
|
||||||
|
|
||||||
allow(client).to receive('session_code=')
|
allow(client).to receive('session_code=')
|
||||||
|
|
||||||
allow(client).to receive(:authenticate).and_return(
|
allow(client).to receive(:authenticate).and_return(
|
||||||
OpenStruct.new(
|
OpenStruct.new(
|
||||||
user_id_code: '14212128025'
|
user_id_code: '14212128025'
|
||||||
|
)
|
||||||
)
|
)
|
||||||
)
|
|
||||||
|
|
||||||
allow(client).to receive('authentication_status').and_return(
|
allow(client).to receive('authentication_status').and_return(
|
||||||
OpenStruct.new(status: 'SIM_ERROR')
|
OpenStruct.new(status: 'SIM_ERROR')
|
||||||
)
|
|
||||||
|
|
||||||
allow(Digidoc::Client).to receive(:new) { client }
|
|
||||||
|
|
||||||
visit registrar_login_path
|
|
||||||
page.should have_css('a[href="/registrar/login/mid"]')
|
|
||||||
|
|
||||||
page.find('a[href="/registrar/login/mid"]').click
|
|
||||||
|
|
||||||
fill_in 'user_phone', with: '00007'
|
|
||||||
click_button 'Log in'
|
|
||||||
|
|
||||||
page.should have_text('Check your phone for confirmation code')
|
|
||||||
page.should have_text('SIM application error')
|
|
||||||
end
|
|
||||||
|
|
||||||
scenario 'Api user should log in', js: true do
|
|
||||||
client = instance_double("Digidoc::Client", session_code: '123')
|
|
||||||
|
|
||||||
allow(client).to receive('session_code=')
|
|
||||||
|
|
||||||
allow(client).to receive(:authenticate).and_return(
|
|
||||||
OpenStruct.new(
|
|
||||||
user_id_code: '14212128025'
|
|
||||||
)
|
)
|
||||||
)
|
|
||||||
|
|
||||||
allow(client).to receive('authentication_status').and_return(
|
allow(Digidoc::Client).to receive(:new) { client }
|
||||||
OpenStruct.new(status: 'USER_AUTHENTICATED')
|
|
||||||
)
|
|
||||||
|
|
||||||
allow(Digidoc::Client).to receive(:new) { client }
|
visit registrar_login_path
|
||||||
|
page.should have_css('a[href="/registrar/login/mid"]')
|
||||||
|
|
||||||
visit registrar_login_path
|
page.find('a[href="/registrar/login/mid"]').click
|
||||||
page.should have_css('a[href="/registrar/login/mid"]')
|
|
||||||
|
|
||||||
page.find('a[href="/registrar/login/mid"]').click
|
fill_in 'user_phone', with: '00007'
|
||||||
|
click_button 'Log in'
|
||||||
|
|
||||||
fill_in 'user_phone', with: '00007'
|
page.should have_text('Check your phone for confirmation code')
|
||||||
click_button 'Log in'
|
page.should have_text('SIM application error')
|
||||||
|
end
|
||||||
|
|
||||||
page.should have_text('Check your phone for confirmation code')
|
it 'should log in successfully', js: true do
|
||||||
page.should have_text('Welcome!')
|
client = instance_double("Digidoc::Client", session_code: '123')
|
||||||
|
|
||||||
|
allow(client).to receive('session_code=')
|
||||||
|
|
||||||
|
allow(client).to receive(:authenticate).and_return(
|
||||||
|
OpenStruct.new(
|
||||||
|
user_id_code: '14212128025'
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
allow(client).to receive('authentication_status').and_return(
|
||||||
|
OpenStruct.new(status: 'USER_AUTHENTICATED')
|
||||||
|
)
|
||||||
|
|
||||||
|
allow(Digidoc::Client).to receive(:new) { client }
|
||||||
|
|
||||||
|
visit registrar_login_path
|
||||||
|
page.should have_css('a[href="/registrar/login/mid"]')
|
||||||
|
|
||||||
|
page.find('a[href="/registrar/login/mid"]').click
|
||||||
|
|
||||||
|
fill_in 'user_phone', with: '00007'
|
||||||
|
click_button 'Log in'
|
||||||
|
|
||||||
|
page.should have_text('Check your phone for confirmation code')
|
||||||
|
page.should have_text('Welcome!')
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue