Add some registrar session specs

This commit is contained in:
Martin Lensment 2015-03-24 16:15:41 +02:00
parent 63c9ed83ee
commit 61da96d18a
3 changed files with 52 additions and 0 deletions

BIN
app/assets/images/test.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.9 KiB

View file

@ -2,6 +2,7 @@
Fabricator(:api_user) do
username { sequence(:username) { |i| "username#{i}" } }
password 'ghyt9e4fu'
identity_code '14212128025'
registrar
active true
end

View file

@ -0,0 +1,51 @@
require 'rails_helper'
feature 'Sessions', type: :feature do
before :all do
create_settings
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'
)
)
)
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('Something is wrong')
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'
)
)
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('No such user')
end
end