diff --git a/app/controllers/sections_controller.rb b/app/controllers/sections_controller.rb index 6107ccf..13ff18d 100644 --- a/app/controllers/sections_controller.rb +++ b/app/controllers/sections_controller.rb @@ -23,7 +23,8 @@ @section = Section.includes(phase: :template).find(params[:id]) puts "CONTROLLER: #{current_user.inspect}" - +puts "PERMS: #{current_user.perms.inspect}" unless current_user.nil? + authorize @section @section.description = params["section-desc-#{params[:id]}"] @phase = @section.phase diff --git a/app/policies/section_policy.rb b/app/policies/section_policy.rb index 815173a..df552c9 100644 --- a/app/policies/section_policy.rb +++ b/app/policies/section_policy.rb @@ -19,6 +19,7 @@ def admin_update? puts "POLICY: #{user.inspect}" +puts "PERMS: #{user.perms.inspect}" unless user.nil? user.can_modify_templates? && (section.phase.template.org_id == user.org_id) end diff --git a/test/functional/sections_controller_test.rb b/test/functional/sections_controller_test.rb index 893aced..846cd31 100644 --- a/test/functional/sections_controller_test.rb +++ b/test/functional/sections_controller_test.rb @@ -64,14 +64,14 @@ test "update the section" do params = {title: 'Phase - UPDATE'} - puts "TEST USER (#{@user.can_org_admin?}) - #{@user.inspect}" - puts "TEST PERMS: #{@user.perms.inspect}" - # Should redirect user to the root path if they are not logged in! put admin_update_section_path(@phase.sections.first), {section: params} assert_unauthorized_redirect_to_root_path sign_in @user + +puts "TEST USER (#{@user.can_org_admin?}) - #{@user.inspect}" +puts "TEST PERMS: #{@user.perms.inspect}" # Valid save put admin_update_section_path(@phase.sections.first), {section: params}