fix db:initial_setup for creating admin account

refs #CNVS-26056

Change-Id: Ie39dc69cf742865de89ebafcb026a7b522ce4ca0
Reviewed-on: https://gerrit.instructure.com/84187
Tested-by: Jenkins
Reviewed-by: Cody Cutrer <cody@instructure.com>
Product-Review: James Williams  <jamesw@instructure.com>
QA-Review: James Williams  <jamesw@instructure.com>
This commit is contained in:
James Williams 2016-07-01 13:04:57 -06:00
parent 9559fa7509
commit 61eb8e3d33
2 changed files with 5 additions and 0 deletions

View File

@ -131,6 +131,10 @@ class Role < ActiveRecord::Base
@built_in_roles_by_id[shard.id] ||= built_in_roles(reload, shard).index_by(&:id)
end
def self.clear_built_in_roles!
@built_in_roles.clear if @built_in_roles
end
def self.built_in_course_roles
built_in_roles.select{|role| role.course_role?}
end

View File

@ -129,6 +129,7 @@ namespace :db do
raise pseudonym.errors.full_messages.first if pseudonym.errors.size > 0
raise "unknown error saving password"
end
Role.clear_built_in_roles!
Account.site_admin.account_users.where(user_id: user, role_id: Role.get_built_in_role('AccountAdmin')).first_or_create!
Account.default.account_users.where(user_id: user, role_id: Role.get_built_in_role('AccountAdmin')).first_or_create!
user