mirror of
https://github.com/discourse/discourse-solved.git
synced 2025-07-03 20:32:12 +00:00
DEV: Update tests to use topic_with_op
fabrication for topic consistency
This ensures tests work with topics that include an original post by default, improving test reliability and coverage. Adjustments were made to guardian_extensions_spec and solved_spec to reflect this.
This commit is contained in:
parent
5aed0b41c5
commit
ea194b1f4f
@ -3,7 +3,7 @@
|
|||||||
require "rails_helper"
|
require "rails_helper"
|
||||||
|
|
||||||
RSpec.describe "Managing Posts solved status" do
|
RSpec.describe "Managing Posts solved status" do
|
||||||
let(:topic) { Fabricate(:topic) }
|
let(:topic) { Fabricate(:topic_with_op) }
|
||||||
fab!(:user) { Fabricate(:trust_level_4) }
|
fab!(:user) { Fabricate(:trust_level_4) }
|
||||||
let(:p1) { Fabricate(:post, topic: topic) }
|
let(:p1) { Fabricate(:post, topic: topic) }
|
||||||
|
|
||||||
@ -238,7 +238,7 @@ RSpec.describe "Managing Posts solved status" do
|
|||||||
it "gives priority to category's solved_topics_auto_close_hours setting" do
|
it "gives priority to category's solved_topics_auto_close_hours setting" do
|
||||||
freeze_time
|
freeze_time
|
||||||
custom_auto_close_category = Fabricate(:category)
|
custom_auto_close_category = Fabricate(:category)
|
||||||
topic_2 = Fabricate(:topic, category: custom_auto_close_category)
|
topic_2 = Fabricate(:topic_with_op, category: custom_auto_close_category)
|
||||||
post_2 = Fabricate(:post, topic: topic_2)
|
post_2 = Fabricate(:post, topic: topic_2)
|
||||||
custom_auto_close_category.custom_fields["solved_topics_auto_close_hours"] = 4
|
custom_auto_close_category.custom_fields["solved_topics_auto_close_hours"] = 4
|
||||||
custom_auto_close_category.save_custom_fields
|
custom_auto_close_category.save_custom_fields
|
||||||
|
@ -5,7 +5,7 @@ require "rails_helper"
|
|||||||
describe DiscourseSolved::GuardianExtensions do
|
describe DiscourseSolved::GuardianExtensions do
|
||||||
fab!(:user) { Fabricate(:user, refresh_auto_groups: true) }
|
fab!(:user) { Fabricate(:user, refresh_auto_groups: true) }
|
||||||
fab!(:other_user) { Fabricate(:user, refresh_auto_groups: true) }
|
fab!(:other_user) { Fabricate(:user, refresh_auto_groups: true) }
|
||||||
fab!(:topic)
|
fab!(:topic) { Fabricate(:topic_with_op) }
|
||||||
fab!(:post) { Fabricate(:post, topic: topic, user: other_user) }
|
fab!(:post) { Fabricate(:post, topic: topic, user: other_user) }
|
||||||
|
|
||||||
let(:guardian) { user.guardian }
|
let(:guardian) { user.guardian }
|
||||||
@ -17,9 +17,10 @@ describe DiscourseSolved::GuardianExtensions do
|
|||||||
expect(Guardian.new.can_accept_answer?(topic, post)).to eq(false)
|
expect(Guardian.new.can_accept_answer?(topic, post)).to eq(false)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "returns false if the topic is nil, the post is nil, or for whispers" do
|
it "returns false if the topic is nil, the post is nil, for the first post or for whispers" do
|
||||||
expect(guardian.can_accept_answer?(nil, post)).to eq(false)
|
expect(guardian.can_accept_answer?(nil, post)).to eq(false)
|
||||||
expect(guardian.can_accept_answer?(topic, nil)).to eq(false)
|
expect(guardian.can_accept_answer?(topic, nil)).to eq(false)
|
||||||
|
expect(guardian.can_accept_answer?(topic, topic.first_post)).to eq(false)
|
||||||
|
|
||||||
post.update!(post_type: Post.types[:whisper])
|
post.update!(post_type: Post.types[:whisper])
|
||||||
expect(guardian.can_accept_answer?(topic, post)).to eq(false)
|
expect(guardian.can_accept_answer?(topic, post)).to eq(false)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user