mirror of
https://github.com/discourse/discourse.git
synced 2024-11-23 11:13:22 +08:00
493d437e79
* Remove outdated option
04078317ba
* Use the non-globally exposed RSpec syntax
https://github.com/rspec/rspec-core/pull/2803
* Use the non-globally exposed RSpec syntax, cont
https://github.com/rspec/rspec-core/pull/2803
* Comply to strict predicate matchers
See:
- https://github.com/rspec/rspec-expectations/pull/1195
- https://github.com/rspec/rspec-expectations/pull/1196
- https://github.com/rspec/rspec-expectations/pull/1277
25 lines
739 B
Ruby
25 lines
739 B
Ruby
# frozen_string_literal: true
|
|
|
|
RSpec.describe PostReply do
|
|
fab!(:topic) { Fabricate(:topic) }
|
|
fab!(:post) { Fabricate(:post, topic: topic) }
|
|
fab!(:other_post) { Fabricate(:post, topic: topic) }
|
|
|
|
context "validation" do
|
|
it "should ensure that the posts belong in the same topic" do
|
|
expect(PostReply.new(post: post, reply: other_post)).to be_valid
|
|
|
|
other_topic = Fabricate(:topic)
|
|
other_post.update!(topic_id: other_topic.id)
|
|
other_post.reload
|
|
|
|
post_reply = PostReply.new(post: post, reply: other_post)
|
|
expect(post_reply).to_not be_valid
|
|
|
|
expect(post_reply.errors[:base]).to include(
|
|
I18n.t("activerecord.errors.models.post_reply.base.different_topic")
|
|
)
|
|
end
|
|
end
|
|
end
|