mirror of
https://github.com/discourse/discourse.git
synced 2024-11-26 20:26:28 +08:00
FIX: Use saved_change_to_value?
in site_setting_saved event
Since Rails 5.2, the behavior of `attribute_changed?` inside `after_save` callbacks has changed, so we need to use `saved_change_to_attribute` instead. The site setting local_process_provider in test mode was covering up the issue.
This commit is contained in:
parent
a58091e352
commit
c687e2b921
|
@ -2,7 +2,7 @@
|
||||||
# existing users are approved.
|
# existing users are approved.
|
||||||
DiscourseEvent.on(:site_setting_saved) do |site_setting|
|
DiscourseEvent.on(:site_setting_saved) do |site_setting|
|
||||||
name = site_setting.name.to_sym
|
name = site_setting.name.to_sym
|
||||||
next unless site_setting.value_changed?
|
next unless site_setting.saved_change_to_value?
|
||||||
|
|
||||||
if name == :must_approve_users && site_setting.value == 't'
|
if name == :must_approve_users && site_setting.value == 't'
|
||||||
User.where(approved: false).update_all(approved: true)
|
User.where(approved: false).update_all(approved: true)
|
||||||
|
|
|
@ -8,7 +8,7 @@ class SiteSettings::LocalProcessProvider
|
||||||
attr_accessor :name, :data_type, :value
|
attr_accessor :name, :data_type, :value
|
||||||
|
|
||||||
def value_changed?
|
def value_changed?
|
||||||
true
|
false
|
||||||
end
|
end
|
||||||
|
|
||||||
def saved_change_to_value?
|
def saved_change_to_value?
|
||||||
|
|
Loading…
Reference in New Issue
Block a user