Refactor Devise integration

- Use scoped users
- Use the named route helpers instead of hardcoded paths
This commit is contained in:
Artur Beljajev 2018-06-20 12:21:22 +03:00
parent c31f507c25
commit 9684c8e59f
52 changed files with 313 additions and 280 deletions

View file

@ -2,7 +2,7 @@ require 'rails_helper'
RSpec.feature 'Registrar area home link', db: true do
scenario 'is visible' do
visit registrar_login_url
visit new_registrar_user_session_url
expect(page).to have_link('registrar-home-btn', href: registrar_root_path)
end
end

View file

@ -9,7 +9,7 @@ RSpec.feature 'Mobile ID login', db: true do
end
scenario 'login with phone number' do
visit registrar_login_path
visit new_registrar_user_session_url
click_on 'login-with-mobile-id-btn'
fill_in 'user[phone]', with: '1234'

View file

@ -1,39 +0,0 @@
require 'rails_helper'
RSpec.feature 'Registrar area password sign-in' do
scenario 'signs in the user with valid credentials' do
create(:api_user_with_unlimited_balance,
active: true,
login: 'test',
password: 'testtest')
visit registrar_login_path
sign_in_with 'test', 'testtest'
expect(page).to have_text(t('registrar.base.current_user.sign_out'))
end
scenario 'notifies the user with invalid credentials' do
create(:api_user, login: 'test', password: 'testtest')
visit registrar_login_path
sign_in_with 'test', 'invalid'
expect(page).to have_text('No such user')
end
scenario 'notifies the user with inactive account' do
create(:api_user, active: false, login: 'test', password: 'testtest')
visit registrar_login_path
sign_in_with 'test', 'testtest'
expect(page).to have_text('User is not active')
end
def sign_in_with(username, password)
fill_in 'depp_user_tag', with: username
fill_in 'depp_user_password', with: password
click_button 'Login'
end
end

View file

@ -1,14 +0,0 @@
require 'rails_helper'
RSpec.feature 'Registrar area sign-out', settings: false do
background do
sign_in_to_registrar_area(user: create(:api_user_with_unlimited_balance))
end
scenario 'signs the user out' do
visit registrar_root_path
click_on t('registrar.base.current_user.sign_out')
expect(page).to have_text('Signed out successfully.')
end
end