mirror of
https://github.com/internetee/registry.git
synced 2025-08-04 17:01:44 +02:00
Refactor Devise integration
- Use scoped users - Use the named route helpers instead of hardcoded paths
This commit is contained in:
parent
c31f507c25
commit
9684c8e59f
52 changed files with 313 additions and 280 deletions
|
@ -22,7 +22,7 @@ RSpec.describe 'Registrar area IP restriction', settings: false do
|
|||
context 'when ip is allowed' do
|
||||
let!(:white_ip) { create(:white_ip,
|
||||
ipv4: '127.0.0.1',
|
||||
registrar: controller.current_user.registrar,
|
||||
registrar: controller.current_registrar_user.registrar,
|
||||
interfaces: [WhiteIp::REGISTRAR]) }
|
||||
|
||||
specify do
|
||||
|
@ -36,12 +36,12 @@ RSpec.describe 'Registrar area IP restriction', settings: false do
|
|||
it 'signs the user out' do
|
||||
get registrar_root_url
|
||||
follow_redirect!
|
||||
expect(controller.current_user).to be_nil
|
||||
expect(controller.current_registrar_user).to be_nil
|
||||
end
|
||||
|
||||
it 'redirects to login url' do
|
||||
get registrar_root_url
|
||||
expect(response).to redirect_to(registrar_login_url)
|
||||
expect(response).to redirect_to(new_registrar_user_session_url)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -67,14 +67,14 @@ RSpec.describe 'Registrar area IP restriction', settings: false do
|
|||
interfaces: [WhiteIp::REGISTRAR]) }
|
||||
|
||||
specify do
|
||||
get registrar_login_path
|
||||
get new_registrar_user_session_path
|
||||
expect(response).to be_success
|
||||
end
|
||||
end
|
||||
|
||||
context 'when ip is not allowed' do
|
||||
specify do
|
||||
get registrar_login_path
|
||||
get new_registrar_user_session_path
|
||||
expect(response.body).to match "Access denied"
|
||||
end
|
||||
end
|
||||
|
@ -82,7 +82,7 @@ RSpec.describe 'Registrar area IP restriction', settings: false do
|
|||
|
||||
context 'when IP restriction is disabled' do
|
||||
specify do
|
||||
get registrar_login_path
|
||||
get new_registrar_user_session_path
|
||||
expect(response).to be_success
|
||||
end
|
||||
end
|
||||
|
|
|
@ -6,7 +6,7 @@ RSpec.describe 'Registrar area linked users', db: false do
|
|||
let!(:current_user) { create(:api_user, id: 1, identity_code: 'code') }
|
||||
|
||||
before do
|
||||
sign_in_to_registrar_area(user: current_user)
|
||||
sign_in current_user
|
||||
end
|
||||
|
||||
context 'when ip is allowed' do
|
||||
|
@ -23,7 +23,7 @@ RSpec.describe 'Registrar area linked users', db: false do
|
|||
it 'signs in as a new user' do
|
||||
put '/registrar/current_user/switch/2', nil, { HTTP_REFERER: registrar_contacts_url }
|
||||
follow_redirect!
|
||||
expect(controller.current_user.id).to eq(2)
|
||||
expect(controller.current_registrar_user.id).to eq(2)
|
||||
end
|
||||
|
||||
it 'redirects back' do
|
||||
|
@ -46,7 +46,6 @@ RSpec.describe 'Registrar area linked users', db: false do
|
|||
put '/registrar/current_user/switch/2', nil, { HTTP_REFERER: registrar_contacts_path }
|
||||
end
|
||||
|
||||
follow_redirect!
|
||||
expect(controller.current_user.id).to eq(1)
|
||||
end
|
||||
end
|
||||
|
@ -62,7 +61,7 @@ RSpec.describe 'Registrar area linked users', db: false do
|
|||
|
||||
specify do
|
||||
put '/registrar/current_user/switch/2'
|
||||
expect(response).to redirect_to(registrar_login_url)
|
||||
expect(response).to redirect_to(new_registrar_user_session_url)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -70,7 +69,7 @@ RSpec.describe 'Registrar area linked users', db: false do
|
|||
context 'when user is not authenticated' do
|
||||
specify do
|
||||
put '/registrar/current_user/switch/2'
|
||||
expect(response).to redirect_to(registrar_login_url)
|
||||
expect(response).to redirect_to(new_registrar_user_session_url)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,16 +0,0 @@
|
|||
require 'rails_helper'
|
||||
|
||||
RSpec.describe 'Registrar area password sign-in', settings: false do
|
||||
let!(:user) { create(:api_user, active: true, login: 'test', password: 'testtest') }
|
||||
|
||||
it 'signs the user in' do
|
||||
post registrar_sessions_path, depp_user: { tag: 'test', password: 'testtest' }
|
||||
follow_redirect!
|
||||
expect(controller.current_user).to eq(user)
|
||||
end
|
||||
|
||||
it 'redirects to root url' do
|
||||
post registrar_sessions_path, depp_user: { tag: 'test', password: 'testtest' }
|
||||
expect(response).to redirect_to(registrar_root_url)
|
||||
end
|
||||
end
|
|
@ -1,18 +0,0 @@
|
|||
require 'rails_helper'
|
||||
|
||||
RSpec.describe 'Registrar area sign-out', settings: false do
|
||||
before do
|
||||
sign_in_to_registrar_area
|
||||
end
|
||||
|
||||
it 'signs the user out' do
|
||||
delete registrar_destroy_user_session_path
|
||||
follow_redirect!
|
||||
expect(controller.current_user).to be_nil
|
||||
end
|
||||
|
||||
it 'redirects to login url' do
|
||||
delete registrar_destroy_user_session_path
|
||||
expect(response).to redirect_to(registrar_login_url)
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue