add the default enrollment term on root acct creation
fixes #3730 Change-Id: I912f1381eeb0e8eba0ac4869f37e655e3f25b4bb Reviewed-on: https://gerrit.instructure.com/2186 Reviewed-by: Bracken Mosbacker <bracken@instructure.com> Reviewed-by: Zach Wily <zach@instructure.com> Tested-by: Hudson <hudson@instructure.com>
This commit is contained in:
parent
0f08e32df2
commit
ad438b6234
|
@ -72,6 +72,7 @@ class Account < ActiveRecord::Base
|
|||
before_save :ensure_defaults
|
||||
before_save :set_update_account_associations_if_changed
|
||||
after_save :update_account_associations_if_changed
|
||||
after_create :default_enrollment_term
|
||||
|
||||
serialize :settings, Hash
|
||||
|
||||
|
@ -474,7 +475,9 @@ class Account < ActiveRecord::Base
|
|||
end
|
||||
|
||||
def default_enrollment_term
|
||||
self.enrollment_terms.active.find_or_create_by_name("Default Term")
|
||||
unless self.root_account_id
|
||||
self.enrollment_terms.active.find_or_create_by_name("Default Term")
|
||||
end
|
||||
end
|
||||
|
||||
def add_admin(args)
|
||||
|
|
|
@ -109,5 +109,15 @@ describe Account do
|
|||
a.turnitin_shared_secret.should eql("2t87aot72gho8a37gh4g[awg'waegawe-,v-3o7fya23oya2o3")
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
it "should make a default enrollment term if necessary" do
|
||||
a = Account.create!(:name => "nada")
|
||||
a.enrollment_terms.size.should == 1
|
||||
a.enrollment_terms.first.name.should == "Default Term"
|
||||
|
||||
# don't create a new default term for sub-accounts
|
||||
a2 = a.all_accounts.create!(:name => "sub")
|
||||
a2.enrollment_terms.size.should == 0
|
||||
end
|
||||
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue