Registrar: fixed login flash message

This commit is contained in:
Priit Tark 2015-04-13 11:43:22 +03:00
parent 8df6b3bdd1
commit bcb283e2f1
2 changed files with 82 additions and 78 deletions

View file

@ -1,4 +1,4 @@
- if flash[:notice].present? || flash[:alert].present?
#flash
- type = (flash[:notice]) ? 'bg-success' : 'bg-danger'
.alert{class: type}= flash[:notice] || flash[:alert]
- display = (flash.empty?) ? 'none' : 'block'
#flash{style: "display: #{display};"}
- type = (flash[:notice]) ? 'bg-success' : 'bg-danger'
.alert{class: type}= flash[:notice] || flash[:alert]

View file

@ -6,104 +6,108 @@ feature 'Sessions', type: :feature do
Fabricate(:api_user)
end
scenario 'Api user should not get in when external service fails' do
client = instance_double("Digidoc::Client")
allow(client).to receive(:authenticate).and_return(
OpenStruct.new(
faultcode: 'Fault',
detail: OpenStruct.new(
message: 'Something is wrong'
context 'as unknown user' do
it 'should not get in' do
client = instance_double("Digidoc::Client")
allow(client).to receive(:authenticate).and_return(
OpenStruct.new(
user_id_code: '123'
)
)
)
allow(Digidoc::Client).to receive(:new) { client }
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.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'
click_button 'Log in'
page.should have_text('Something is wrong')
fill_in 'user_phone', with: '00007'
click_button 'Log in'
page.should have_text('No such user')
end
end
scenario 'Api user should not get in when there is not such user' do
client = instance_double("Digidoc::Client")
allow(client).to receive(:authenticate).and_return(
OpenStruct.new(
user_id_code: '123'
context 'as known api user' do
it 'should not get in when external service fails' do
client = instance_double("Digidoc::Client")
allow(client).to receive(:authenticate).and_return(
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
page.should have_css('a[href="/registrar/login/mid"]')
visit registrar_login_path
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'
click_button 'Log in'
page.should have_text('No such user')
end
fill_in 'user_phone', with: '00007'
click_button 'Log in'
page.should have_text('Something is wrong')
end
scenario 'Api user should when there is a sim error', js: true do
client = instance_double("Digidoc::Client", session_code: '123')
it 'should not get in when there is a sim error', js: true do
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(
OpenStruct.new(
user_id_code: '14212128025'
allow(client).to receive(:authenticate).and_return(
OpenStruct.new(
user_id_code: '14212128025'
)
)
)
allow(client).to receive('authentication_status').and_return(
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(
OpenStruct.new(status: 'SIM_ERROR')
)
)
allow(client).to receive('authentication_status').and_return(
OpenStruct.new(status: 'USER_AUTHENTICATED')
)
allow(Digidoc::Client).to receive(:new) { client }
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.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'
click_button 'Log in'
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
page.should have_text('Check your phone for confirmation code')
page.should have_text('Welcome!')
it 'should log in successfully', 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(
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