FIX: Bot should only respond to regular posts.

This commit is contained in:
Guo Xiang Tan 2017-06-05 15:21:19 +09:00
parent 5cd9236f17
commit c7108e077e
2 changed files with 13 additions and 1 deletions

View File

@ -28,7 +28,7 @@ module DiscourseNarrativeBot
def select
data = Store.get(@user.id)
if @post && !is_topic_action?
if @post && @post.post_type == Post.types[:regular] && !is_topic_action?
is_reply = @input == :reply
return if is_reply && reset_track

View File

@ -104,6 +104,18 @@ describe DiscourseNarrativeBot::TrackSelector do
end
end
context 'when a non regular post is created' do
it 'should not do anything' do
moderator_post = Fabricate(:moderator_post, user: user, topic: topic)
expect do
described_class.new(
:reply, user, post_id: moderator_post.id
).select
end.to_not change { Post.count }
end
end
describe 'when user thank the bot' do
it 'should like the post' do
post.update!(raw: 'thanks!')