fix reserved roles showing as 'deleted' in role api

test plan:

* call the 'index' api call for roles
* confirm that 'StudentEnrollment', etc. have
 a workflow state of 'active', not 'deleted'

Change-Id: Id8ae44b354ec989e20a31fcee6164dfc1195f5eb
Reviewed-on: https://gerrit.instructure.com/15656
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Jeremy Stanley <jeremy@instructure.com>
This commit is contained in:
James Williams 2012-11-28 10:53:22 -07:00
parent 44ab708501
commit bb30b27742
3 changed files with 3 additions and 2 deletions

View File

@ -225,7 +225,7 @@ class RoleOverridesController < ApplicationController
def add_role
return unless authorized_action(@context, @current_user, :manage_role_overrides)
if @context.has_role?(@role) || RoleOverride::RESERVED_ROLES.include?(@role)
if @context.has_role?(@role)
if api_request?
render :json => {:message => "role already exists"}, :status => :bad_request
else

View File

@ -528,7 +528,7 @@ class Account < ActiveRecord::Base
end
def has_role?(role_name)
self.account_membership_types.include?(role_name) || self.active_course_roles.include?(role_name)
self.account_membership_types.include?(role_name) || self.active_course_roles.include?(role_name) || RoleOverride::RESERVED_ROLES.include?(role_name)
end
def account_authorization_config

View File

@ -61,6 +61,7 @@ describe "Roles API", :type => :integration do
{ :controller => 'role_overrides', :action => 'index', :format => 'json', :account_id => @account.id.to_param })
json.collect{|role| role['role']}.sort.should == (["AccountAdmin", "NewRole"] + RoleOverride.base_role_types).sort
json.find{|role| role['role'] == "StudentEnrollment"}['workflow_state'].should == 'active'
end
it "should remove a role" do