Commit 06bfa11f authored by Chrysanthi Lagodimou's avatar Chrysanthi Lagodimou
Browse files

tests added and fixed

parent 460d2936
......@@ -82,11 +82,10 @@
td= t('registered_by')
td= @client.user.email
tr
td
- if policy(Client).destroy?
= t_attr(:comments)
td= @client.comments
- if policy(Client).destroy?
tr
td= t_attr(:comments)
td= @client.comments
.row
.col-xs-12
......
......@@ -3,7 +3,7 @@ require 'test_helper'
class UserTest < ActiveSupport::TestCase
def setup
@user = build :user
@user_as_superadmin = create :user, :with_profile, role: 'superadmin'
@user_as_superadmin = create :user, :with_profile
@user_as_social_worker = create :user, :with_profile, role: 'social_worker'
@user_as_department_manager = create :user, :with_profile, role: 'department_manager'
end
......
......@@ -2,7 +2,7 @@ require 'test_helper'
class ClientPolicyTest < ActiveSupport::TestCase
def setup
@user_as_superadmin = create :user, :with_clients, role: 'superadmin'
@user_as_superadmin = create :user, :with_clients
@user_as_social_worker = create :user, :with_clients, role: 'social_worker'
@user_as_department_manager = create :user, role: 'department_manager'
end
......
......@@ -2,7 +2,7 @@ require 'test_helper'
class ProfilePolicyTest < ActiveSupport::TestCase
def setup
@user_as_superadmin = create :user, :with_clients, :with_profile, role: 'superadmin'
@user_as_superadmin = create :user, :with_clients, :with_profile
@user_as_social_worker = create :user, :with_clients, :with_profile, role: 'social_worker'
@user_as_department_manager = create :user, :with_profile, role: 'department_manager'
@user_without_profile = create :user
......
......@@ -2,8 +2,8 @@ require 'test_helper'
class UserPolicyTest < ActiveSupport::TestCase
def setup
@user_as_superadmin = create :user, :with_clients, :with_profile, role: 'superadmin'
@user_as_other_superadmin = create :user, :with_profile, role: 'superadmin'
@user_as_superadmin = create :user, :with_clients, :with_profile
@user_as_other_superadmin = create :user, :with_profile
@user_as_social_worker = create :user, :with_clients, :with_profile, role: 'social_worker'
@user_as_department_manager = create :user, :with_profile, role: 'department_manager'
end
......
......@@ -3,29 +3,30 @@ require 'application_system_test_case'
class SocialworkerTest < ApplicationSystemTestCase
def setup
@socialworker = create :user, :with_profile, :with_clients, role: 'social_worker'
login_as @socialworker
end
test 'when logged in socialworker cannot see create user link' do
login_as @socialworker
visit root_path
assert_not page.has_link? 'Create user'
end
test 'when updates user login, cannot see role field' do
login_as @socialworker
visit edit_user_path(@socialworker)
assert_not page.has_field? 'Role'
end
test 'has a navbar link to clients page' do
login_as @socialworker
visit user_path(@socialworker.id)
assert page.has_link? 'Clients'
end
test 'does not have navbar link to users page' do
visit user_path(@socialworker.id)
assert_not page.has_link? 'Users'
end
test 'can see his clients' do
login_as @socialworker
visit clients_path
@socialworker.clients.each do |client|
assert page.has_text? client.first_name
......@@ -35,8 +36,14 @@ class SocialworkerTest < ApplicationSystemTestCase
end
end
test 'cannot see comment field' do
visit new_client_path
assert_not page.has_field? 'Comments'
visit client_path(@socialworker.clients.first)
assert_not page.has_content? 'Comments'
end
test 'can only see her own clients' do
login_as @socialworker
visit clients_path
other_socialworker = create :user, :with_profile, :with_clients, role: 'social_worker'
Client.where(user: other_socialworker) do |client|
......@@ -48,14 +55,7 @@ class SocialworkerTest < ApplicationSystemTestCase
end
test 'socialworkers has no client destroy link' do
login_as @socialworker
visit clients_path
Client.where(user: @socialworker) do |client|
assert_not page.has_link? 'Destroy', href: client_path(client)
end
end
test 'socialworker cannot destroy client' do
login_as @social_worker
assert_not page.has_link? 'Delete'
end
end
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment