FIX: 'disable_edit_notifications' will only disable revisions made by the system user
This commit is contained in:
parent
eb34ecfc0c
commit
598a3f3e10
|
@ -41,10 +41,10 @@ class PostAlertObserver < ActiveRecord::Observer
|
|||
post = post_revision.post
|
||||
|
||||
return unless post
|
||||
return if SiteSetting.disable_edit_notifications
|
||||
return if post_revision.user.blank?
|
||||
return if post_revision.user_id == post.user_id
|
||||
return if post.topic.private_message?
|
||||
return if SiteSetting.disable_edit_notifications && post_revision.user_id == Discourse::SYSTEM_USER_ID
|
||||
|
||||
alerter.create_notification(post.user, Notification.types[:edited], post, display_username: post_revision.user.username)
|
||||
end
|
||||
|
|
|
@ -40,11 +40,23 @@ describe PostAlertObserver do
|
|||
}.should change(post.user.notifications, :count).by(1)
|
||||
end
|
||||
|
||||
it 'does not notifiy a user of the revision when edit notifications are disabled' do
|
||||
SiteSetting.stubs(:disable_edit_notifications).returns(true)
|
||||
context "edit notifications are disabled" do
|
||||
|
||||
before { SiteSetting.stubs(:disable_edit_notifications).returns(true) }
|
||||
|
||||
|
||||
it 'notifies a user of the revision made by another user' do
|
||||
lambda {
|
||||
post.revise(evil_trout, "world is the new body of the message")
|
||||
}.should_not change(post.user.notifications, :count).by(1)
|
||||
}.should change(post.user.notifications, :count).by(1)
|
||||
end
|
||||
|
||||
it 'does not notifiy a user of the revision made by the system user' do
|
||||
lambda {
|
||||
post.revise(Discourse.system_user, "world is the new body of the message")
|
||||
}.should_not change(post.user.notifications, :count)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue