adds specs for managed user session
This commit is contained in:
@@ -6,7 +6,7 @@ describe Management::SessionsController do
|
|||||||
create(:manager, username: "supermanager" , password: "secret")
|
create(:manager, username: "supermanager" , password: "secret")
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'Sign up' do
|
describe 'Sign in' do
|
||||||
it "should return 404 if not username/password" do
|
it "should return 404 if not username/password" do
|
||||||
expect { get :create }.to raise_error "Not Found"
|
expect { get :create }.to raise_error "Not Found"
|
||||||
end
|
end
|
||||||
@@ -25,4 +25,17 @@ describe Management::SessionsController do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe 'Sign out' do
|
||||||
|
it "should destroy the session and redirect" do
|
||||||
|
session[:manager_id] = 1
|
||||||
|
session[:managed_user_id] = 1
|
||||||
|
|
||||||
|
delete :destroy
|
||||||
|
|
||||||
|
expect(session[:manager_id]).to be_nil
|
||||||
|
expect(session[:managed_user_id]).to be_nil
|
||||||
|
expect(response).to be_redirect
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
121
spec/features/management/managed_users_spec.rb
Normal file
121
spec/features/management/managed_users_spec.rb
Normal file
@@ -0,0 +1,121 @@
|
|||||||
|
require 'rails_helper'
|
||||||
|
|
||||||
|
feature 'Managed User' do
|
||||||
|
|
||||||
|
background do
|
||||||
|
login_as_manager(create(:manager))
|
||||||
|
end
|
||||||
|
|
||||||
|
context "Currently managed user" do
|
||||||
|
|
||||||
|
scenario "User is already level three verified" do
|
||||||
|
user = create(:user, :level_three)
|
||||||
|
|
||||||
|
visit management_document_verifications_path
|
||||||
|
fill_in 'document_verification_document_number', with: user.document_number
|
||||||
|
click_button 'Check'
|
||||||
|
|
||||||
|
expect(page).to have_content "already verified"
|
||||||
|
|
||||||
|
within(".account-info") do
|
||||||
|
expect(page).to have_content "Identified as"
|
||||||
|
expect(page).to have_content "#{user.username}"
|
||||||
|
expect(page).to have_content "#{user.email}"
|
||||||
|
expect(page).to have_content "#{user.document_number}"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
scenario "User is verified as level three" do
|
||||||
|
user = create(:user, :level_two)
|
||||||
|
|
||||||
|
visit management_document_verifications_path
|
||||||
|
fill_in 'document_verification_document_number', with: user.document_number
|
||||||
|
click_button 'Check'
|
||||||
|
|
||||||
|
expect(page).to have_content "Vote proposals"
|
||||||
|
|
||||||
|
click_button 'Verify'
|
||||||
|
|
||||||
|
expect(page).to have_content "already verified"
|
||||||
|
|
||||||
|
within(".account-info") do
|
||||||
|
expect(page).to have_content "Identified as"
|
||||||
|
expect(page).to have_content "#{user.username}"
|
||||||
|
expect(page).to have_content "#{user.email}"
|
||||||
|
expect(page).to have_content "#{user.document_number}"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
scenario "User is verified as level two (pending email confirmation for level three)" do
|
||||||
|
login_as_manager(create(:manager))
|
||||||
|
|
||||||
|
user = create(:user)
|
||||||
|
|
||||||
|
visit management_document_verifications_path
|
||||||
|
fill_in 'document_verification_document_number', with: '1234'
|
||||||
|
click_button 'Check'
|
||||||
|
|
||||||
|
expect(page).to have_content "Please introduce the email used on the account"
|
||||||
|
|
||||||
|
fill_in 'email_verification_email', with: user.email
|
||||||
|
click_button 'Send verification email'
|
||||||
|
|
||||||
|
expect(page).to have_content("In order to completely verify this user, it is necessary that the user clicks on a link")
|
||||||
|
|
||||||
|
within(".account-info") do
|
||||||
|
expect(page).to have_content "Identified as"
|
||||||
|
expect(page).to have_content "#{user.username}"
|
||||||
|
expect(page).to have_content "#{user.email}"
|
||||||
|
expect(page).to have_content "#{user.document_number}"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
scenario "User is creating as level 3 from scratch" do
|
||||||
|
login_as_manager(create(:manager))
|
||||||
|
|
||||||
|
visit management_document_verifications_path
|
||||||
|
fill_in 'document_verification_document_number', with: '1234'
|
||||||
|
click_button 'Check'
|
||||||
|
|
||||||
|
expect(page).to have_content "Please introduce the email used on the account"
|
||||||
|
|
||||||
|
click_link 'Create a new account'
|
||||||
|
|
||||||
|
fill_in 'user_username', with: 'pepe'
|
||||||
|
fill_in 'user_email', with: 'pepe@gmail.com'
|
||||||
|
|
||||||
|
click_button 'Create user'
|
||||||
|
|
||||||
|
expect(page).to have_content "We have sent an email"
|
||||||
|
|
||||||
|
user = User.last
|
||||||
|
within(".account-info") do
|
||||||
|
expect(page).to have_content "Identified as"
|
||||||
|
expect(page).to have_content "#{user.username}"
|
||||||
|
expect(page).to have_content "#{user.email}"
|
||||||
|
expect(page).to have_content "#{user.document_number}"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
scenario "Close the currently managed user session" do
|
||||||
|
user = create(:user, :level_three)
|
||||||
|
|
||||||
|
visit management_document_verifications_path
|
||||||
|
fill_in 'document_verification_document_number', with: user.document_number
|
||||||
|
click_button 'Check'
|
||||||
|
|
||||||
|
expect(page).to have_content "already verified"
|
||||||
|
|
||||||
|
within(".account-info") do
|
||||||
|
expect(page).to have_content "Identified as"
|
||||||
|
expect(page).to have_content "#{user.username}"
|
||||||
|
|
||||||
|
click_link "Logout"
|
||||||
|
end
|
||||||
|
|
||||||
|
expect(page).to have_content "Signed out successfully."
|
||||||
|
expect(current_path).to eq(root_path)
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
@@ -14,10 +14,6 @@ module CommonActions
|
|||||||
click_button 'Sign up'
|
click_button 'Sign up'
|
||||||
end
|
end
|
||||||
|
|
||||||
def login_as_manager(manager)
|
|
||||||
visit management_sign_in_path(login: manager.username, clave_usuario: manager.password)
|
|
||||||
end
|
|
||||||
|
|
||||||
def login_through_form_as(user)
|
def login_through_form_as(user)
|
||||||
visit root_path
|
visit root_path
|
||||||
click_link 'Log in'
|
click_link 'Log in'
|
||||||
@@ -33,10 +29,7 @@ module CommonActions
|
|||||||
end
|
end
|
||||||
|
|
||||||
def login_managed_user(user)
|
def login_managed_user(user)
|
||||||
####
|
allow_any_instance_of(Management::BaseController).to receive(:current_user).and_return(user)
|
||||||
# CHANGE ME
|
|
||||||
# Should identify the user being managed
|
|
||||||
####
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def confirm_email
|
def confirm_email
|
||||||
|
|||||||
Reference in New Issue
Block a user