diff --git a/app/views/registrar/shared/_flash.haml b/app/views/registrar/shared/_flash.haml index d4c817fe7..b1d850a0c 100644 --- a/app/views/registrar/shared/_flash.haml +++ b/app/views/registrar/shared/_flash.haml @@ -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] diff --git a/spec/features/registrar/sessions_spec.rb b/spec/features/registrar/sessions_spec.rb index d157e4ec7..8bfba8555 100644 --- a/spec/features/registrar/sessions_spec.rb +++ b/spec/features/registrar/sessions_spec.rb @@ -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