From 53bf7e209d7bf21f7c075e8e0129fc43d7146df2 Mon Sep 17 00:00:00 2001 From: Martin Lensment Date: Tue, 24 Mar 2015 17:09:08 +0200 Subject: [PATCH] MID login success test --- spec/features/registrar/sessions_spec.rb | 31 ++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/spec/features/registrar/sessions_spec.rb b/spec/features/registrar/sessions_spec.rb index 2ca445b15..eef3ec6bb 100644 --- a/spec/features/registrar/sessions_spec.rb +++ b/spec/features/registrar/sessions_spec.rb @@ -48,4 +48,35 @@ feature 'Sessions', type: :feature do click_button 'Log in' page.should have_text('No such user') end + + scenario 'Api user should 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(: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