From 3588780ac379b30e2eefbd3375111857618bc80c Mon Sep 17 00:00:00 2001 From: James Kiesel Date: Tue, 5 Jul 2016 11:33:08 -0400 Subject: [PATCH] Don't reject likes by email for closed topics (#4311) --- lib/email/receiver.rb | 2 +- spec/components/email/receiver_spec.rb | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/email/receiver.rb b/lib/email/receiver.rb index 0a2d250a5..d44a13135 100644 --- a/lib/email/receiver.rb +++ b/lib/email/receiver.rb @@ -404,11 +404,11 @@ module Email def create_reply(options={}) raise TopicNotFoundError if options[:topic].nil? || options[:topic].trashed? - raise TopicClosedError if options[:topic].closed? if post_action_type = post_action_for(options[:raw]) create_post_action(options[:user], options[:post], post_action_type) else + raise TopicClosedError if options[:topic].closed? options[:topic_id] = options[:post].try(:topic_id) options[:reply_to_post_number] = options[:post].try(:post_number) options[:is_group_message] = options[:topic].private_message? && options[:topic].allowed_groups.exists? diff --git a/spec/components/email/receiver_spec.rb b/spec/components/email/receiver_spec.rb index 66301c811..29ba74adf 100644 --- a/spec/components/email/receiver_spec.rb +++ b/spec/components/email/receiver_spec.rb @@ -129,6 +129,11 @@ describe Email::Receiver do expect { process(:reply_user_matching) }.to raise_error(Email::Receiver::TopicClosedError) end + it "does not raise TopicClosedError when performing a like action" do + topic.update_columns(closed: true) + expect { process(:like) }.to change(PostAction, :count) + end + it "raises an InvalidPost when there was an error while creating the post" do expect { process(:too_small) }.to raise_error(Email::Receiver::InvalidPost) end