forked from instructure/canvas-lms
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request instructure#226 from grahamb/account-settings
add a sfu rake task to reset account settings after a clone
- Loading branch information
Showing
4 changed files
with
48 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
require 'yaml' | ||
|
||
namespace :sfu do | ||
desc 'Reset the default Account name and lti_guid. These values need to be reset after a clone from production.' | ||
task :account_settings, [:stage] => :environment do |t, args| | ||
stage = args[:stage] | ||
raise "You must specify a Canvas Capistrano stage (e.g. testing, staging, etc). `rake sfu:account_settings[stage_name]`" if stage.nil? | ||
sfu = YAML.load_file './config/sfu.yml' | ||
raise "sfu.yml does not contain a `account_settings` block." if sfu['account_settings'].nil? | ||
raise "You specified `#{stage}` as the stage, but no such stage is defined in sfu.yml." unless sfu['account_settings'].include? stage | ||
|
||
account_settings = sfu['account_settings'][stage] | ||
a = Account.default | ||
puts "Current Account settings:" | ||
puts " name: #{a.name}" | ||
puts " lti_guid: #{a.lti_guid}" | ||
|
||
puts "Resetting account settings:" | ||
puts " name: #{account_settings['name']}" | ||
puts " lti_guid: #{account_settings['lti_guid']}" | ||
|
||
Account.transaction do | ||
a.name = account_settings['name'] | ||
a.lti_guid = account_settings['lti_guid'] | ||
a.save! | ||
end | ||
end | ||
end |