Skip to content

Commit fb9a4d3

Browse files
committed
clear special account cache after editing
should fix problems with account settings and help links on local/single-account environments test plan: * should be able to edit help links and show changes right away for the default account closes #CNVS-31213 #CNVS-31218 Change-Id: Ifc6a2b208f0a0dae99579a0a0e229ed1307ed63c Reviewed-on: https://gerrit.instructure.com/88635 Tested-by: Jenkins Reviewed-by: Jeremy Stanley <jeremy@instructure.com> QA-Review: Heath Hales <hhales@instructure.com> Product-Review: James Williams <jamesw@instructure.com>
1 parent 96138b9 commit fb9a4d3

2 files changed

Lines changed: 17 additions & 0 deletions

File tree

app/models/account.rb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ def inherited_assessment_question_banks(include_self = false, *additional_contex
109109

110110
before_save :setup_cache_invalidation
111111
after_save :invalidate_caches_if_changed
112+
after_update :clear_special_account_cache_if_special
112113

113114
after_create :default_enrollment_term
114115
after_create :enable_canvas_authentication
@@ -1162,6 +1163,12 @@ def all_special_accounts
11621163
define_special_account(:default, 'Default Account') # Account.default
11631164
define_special_account(:site_admin) # Account.site_admin
11641165

1166+
def clear_special_account_cache_if_special
1167+
if self.shard == Shard.birth && Account.special_account_ids.values.map(&:to_i).include?(self.id)
1168+
Account.clear_special_account_cache!(true)
1169+
end
1170+
end
1171+
11651172
# an opportunity for plugins to load some other stuff up before caching the account
11661173
def precache
11671174
end

spec/models/account_spec.rb

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1540,4 +1540,14 @@ def account_with_admin_and_restricted_user(account, restricted_role)
15401540
end
15411541
end
15421542
end
1543+
1544+
it "should clear special account cache on updates to special accounts" do
1545+
expect(Account.default.settings[:blah]).to be_nil
1546+
1547+
non_cached = Account.find(Account.default.id)
1548+
non_cached.settings[:blah] = true
1549+
non_cached.save!
1550+
1551+
expect(Account.default.settings[:blah]).to eq true
1552+
end
15431553
end

0 commit comments

Comments
 (0)