Skip to content

A platform for community discussion. Free, open, simple.

FIX: Email Send post has already been taken error (#16992)

Blake Erickson35e17ce115f9
diff --git a/app/models/post_reply_key.rb b/app/models/post_reply_key.rb
index 996f18a66aa..83686df18ba 100644
--- a/app/models/post_reply_key.rb
+++ b/app/models/post_reply_key.rb
@@ -6,7 +6,7 @@ class PostReplyKey < ActiveRecord::Base
before_validation { self.reply_key ||= self.class.generate_reply_key }
- validates :post_id, presence: true, uniqueness: { scope: :user_id }
+ validates :post_id, presence: true
validates :user_id, presence: true
validates :reply_key, presence: true
diff --git a/spec/lib/email/sender_spec.rb b/spec/lib/email/sender_spec.rb
index 255753263ef..8045995edb9 100644
--- a/spec/lib/email/sender_spec.rb
+++ b/spec/lib/email/sender_spec.rb
@@ -767,6 +767,14 @@ describe Email::Sender do
expect(post_reply_key.post_id).to eq(post.id)
expect { email_sender.send }.to change { PostReplyKey.count }.by(0)
end
+
+ it 'should find existing key' do
+ existing_post_reply_key = PostReplyKey.create(post_id: post.id, user_id: user.id)
+ expect { email_sender.send }.to change { PostReplyKey.count }.by(0)
+ post_reply_key = PostReplyKey.last
+ expect(post_reply_key).to eq(existing_post_reply_key)
+ end
+
end
end
end