FIX: No longer educate users who are editing

A user editing a post will no longer get composer messages that are
meant for new users posting replies and threads. These messages don't
make sense in an edit context at all -- they're usually discussing
making salient replies or topics, or adding avatars. They make even less
sense when a user is an admin attempting to change the default topics
for the first time.

Since these messages actually do make sense for a user when they have a
low post count, though, they're still going to occur. They just occur
when a user is creating new content (and thus, more likely to read the
notice), not during edits.

This is in response to this issue:
https://meta.discourse.org/t/education-message-for-editing-wiki-topic/66682
This commit is contained in:
Lucas Nicodemus 2018-10-03 17:21:53 -07:00 committed by Guo Xiang Tan
parent ff47609141
commit 1907338834
2 changed files with 34 additions and 0 deletions

View File

@ -11,10 +11,13 @@ class ComposerMessagesFinder
end
def find
return if editing_post?
self.class.check_methods.each do |m|
msg = send(m)
return msg if msg.present?
end
nil
end
@ -210,4 +213,8 @@ class ComposerMessagesFinder
@details[:composer_action] == "reply"
end
def editing_post?
@details[:composer_action] == "edit"
end
end

View File

@ -467,4 +467,31 @@ describe ComposerMessagesFinder do
end
end
context 'when editing a post' do
let(:user) { Fabricate(:user) }
let(:topic) { Fabricate(:post).topic }
let!(:post) do
post = PostCreator.create!(
user,
topic_id: topic.id,
post_number: 1,
raw: 'omg my first post'
)
end
let(:edit_post_finder) do
ComposerMessagesFinder.new(user, composer_action: 'edit')
end
before do
SiteSetting.disable_avatar_education_message = true
SiteSetting.educate_until_posts = 2
end
it "returns nothing even if it normally would" do
expect(edit_post_finder.find).to eq(nil)
end
end
end