diff --git a/app/policies/section_policy.rb b/app/policies/section_policy.rb index 6effdbe..627d66a 100644 --- a/app/policies/section_policy.rb +++ b/app/policies/section_policy.rb @@ -18,6 +18,10 @@ end def admin_update? + +puts "MODIFIER? #{user.can_modify_templates?} ORGS MATCH? #{(section.phase.template.org_id == user.org_id)}" +puts "MODIFIER? #{@user.can_modify_templates?} ORGS MATCH? #{(@section.phase.template.org_id == @user.org_id)}" + user.can_modify_templates? && (section.phase.template.org_id == user.org_id) end diff --git a/test/test_helper.rb b/test/test_helper.rb index ff0125b..3843548 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -41,7 +41,7 @@ usr = User.create!(email: "admin-#{org.abbreviation.downcase}@example.com", firstname: "Org", surname: "Admin", language: Language.find_by(abbreviation: FastGettext.locale), password: "password123", password_confirmation: "password123", - perms: Perm.where.not(name: ['admin', 'add_organisations', 'change_org_affiliation', 'grant_api_to_orgs']), + perms: Perm.where(name: ['grant_permissions', 'modify_guidance', 'modify_templates', 'modify_org_details']), org: org, accept_terms: true, confirmed_at: Time.zone.now) end usr