fix: department manager policy test

parent e5789ae4
......@@ -116,7 +116,7 @@ class User < ApplicationRecord
has_many :semester_feedbacks, inverse_of: 'author', foreign_key: 'author_id', dependent: :destroy
has_and_belongs_to_many :department
has_and_belongs_to_many :department, -> { order(created_at: :desc) }
# Roles definition
SUPERADMIN = 'superadmin'.freeze
......
......@@ -3,8 +3,14 @@ class DepartmentPolicyTest < PolicyAssertions::Test
def setup
@superadmin = create :user, :with_clients, :with_department, role: 'superadmin'
@social_worker = create :user, :with_clients, role: 'social_worker'
@department_manager = create :department_manager
@department = create :department
@dep_managers_department = create :department
@department_manager = create :department_manager_without_department
@department_manager.department = [@dep_managers_department]
@department_manager.save
@department_manager.reload
@dep_managers_department.reload
end
test 'only superadmin can create department' do
......@@ -32,7 +38,7 @@ class DepartmentPolicyTest < PolicyAssertions::Test
'index?', 'show?', 'new?', 'edit?', 'create?', 'update?', 'destroy?'
)
assert_permit(
@department_manager, @department_manager.department.first,
@department_manager, @dep_managers_department,
'show?', 'edit?', 'update?'
)
end
......
Markdown is supported
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