From 124ba84a83ff57aba8178968b2aec029fd4d25ae Mon Sep 17 00:00:00 2001 From: Marcela Ribeiro de Oliveira <mro15@inf.ufpr.br> Date: Thu, 6 Jul 2017 10:49:01 -0300 Subject: [PATCH] change moderator polices to curator and fix upload tests --- app/models/user.rb | 7 +++++++ app/policies/application_policy.rb | 4 ++-- app/policies/learning_object_policy.rb | 2 +- app/policies/submission_policy.rb | 4 ++-- spec/acceptance/learning_objects_spec.rb | 2 +- 5 files changed, 13 insertions(+), 6 deletions(-) diff --git a/app/models/user.rb b/app/models/user.rb index 118478ac..1c00819a 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -108,6 +108,13 @@ class User < ApplicationRecord false end + def is_curator? + roles.each do |role| + return true if role.name == 'curator' + end + false + end + def is_supervisor? roles.each do |role| return true if role.name == 'supervisor' diff --git a/app/policies/application_policy.rb b/app/policies/application_policy.rb index 0f351485..dddccc94 100644 --- a/app/policies/application_policy.rb +++ b/app/policies/application_policy.rb @@ -59,8 +59,8 @@ class ApplicationPolicy user.is_admin? || user.is_editor? end - def user_can_moderate? - user.is_moderator? + def user_can_curate? + user.is_curator? end class Scope < ApplicationPolicy diff --git a/app/policies/learning_object_policy.rb b/app/policies/learning_object_policy.rb index 8e217762..2bceb6b7 100644 --- a/app/policies/learning_object_policy.rb +++ b/app/policies/learning_object_policy.rb @@ -27,7 +27,7 @@ class LearningObjectPolicy < ApplicationPolicy end def publish? - record if user_can_moderate? && record.submitted? + record if user_can_curate? && record.submitted? end def destroy? diff --git a/app/policies/submission_policy.rb b/app/policies/submission_policy.rb index 345ec5e5..c4c03d41 100644 --- a/app/policies/submission_policy.rb +++ b/app/policies/submission_policy.rb @@ -6,12 +6,12 @@ module SubmissionPolicy def submissions? return false if user.nil? - record if user_can_moderate? + record if user_can_curate? end def show_submission? return false if user.nil? - record if user_can_moderate? + record if user_can_curate? end end diff --git a/spec/acceptance/learning_objects_spec.rb b/spec/acceptance/learning_objects_spec.rb index fc2de13f..126991df 100644 --- a/spec/acceptance/learning_objects_spec.rb +++ b/spec/acceptance/learning_objects_spec.rb @@ -159,7 +159,7 @@ resource 'Learning Objects' do end post '/v1/learning_objects/:id/publish' do - include_context "authenticate_user_moderator" + include_context "authenticate_user_curator" let(:id) { @learning_object.id } -- GitLab