DEV: Clean up topics_controller_spec (#30553)

This commit is contained in:
Jarek Radosz 2025-01-05 01:09:23 +01:00 committed by GitHub
parent 53b51e0d56
commit 8be29694ec
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -32,8 +32,7 @@ RSpec.describe TopicsController do
end
end
fab!(:group_user) { Fabricate(:group_user, user: Fabricate(:user, refresh_auto_groups: true)) }
fab!(:group_user) { Fabricate(:group_user, user:) }
fab!(:tag)
before { SiteSetting.personal_message_enabled_groups = Group::AUTO_GROUPS[:everyone] }
@ -253,9 +252,8 @@ RSpec.describe TopicsController do
Fabricate(:category_moderation_group, category:, group: group_user.group)
end
fab!(:topic) { Fabricate(:topic, category: category) }
fab!(:p1) { Fabricate(:post, user: group_user.user, post_number: 1, topic: topic) }
fab!(:p2) { Fabricate(:post, user: group_user.user, post_number: 2, topic: topic) }
let!(:user) { group_user.user }
fab!(:p1) { Fabricate(:post, user: user, post_number: 1, topic: topic) }
fab!(:p2) { Fabricate(:post, user: user, post_number: 2, topic: topic) }
before do
sign_in(user)
@ -427,10 +425,8 @@ RSpec.describe TopicsController do
Fabricate(:category_moderation_group, category:, group: group_user.group)
end
fab!(:topic) { Fabricate(:topic, category: category) }
fab!(:p1) { Fabricate(:post, user: group_user.user, post_number: 1, topic: topic) }
fab!(:p2) { Fabricate(:post, user: group_user.user, post_number: 2, topic: topic) }
let!(:user) { group_user.user }
fab!(:p1) { Fabricate(:post, user: user, post_number: 1, topic: topic) }
fab!(:p2) { Fabricate(:post, user: user, post_number: 2, topic: topic) }
before do
sign_in(user)
@ -482,16 +478,9 @@ RSpec.describe TopicsController do
end
fab!(:topic) { Fabricate(:topic, category: category) }
fab!(:p1) do
Fabricate(
:post,
user: group_user.user,
topic: topic,
created_at: dest_topic.created_at - 1.hour,
)
Fabricate(:post, user: user, topic: topic, created_at: dest_topic.created_at - 1.hour)
end
let!(:user) { group_user.user }
before do
sign_in(user)
SiteSetting.enable_category_group_moderation = true
@ -764,7 +753,7 @@ RSpec.describe TopicsController do
fab!(:p2) { Fabricate(:post, user: post_author2, post_number: 2, topic: topic) }
before do
sign_in(group_user.user)
sign_in(user)
SiteSetting.enable_category_group_moderation = true
end
@ -820,7 +809,7 @@ RSpec.describe TopicsController do
end
before do
sign_in(group_user.user)
sign_in(user)
SiteSetting.enable_category_group_moderation = true
end
@ -984,6 +973,7 @@ RSpec.describe TopicsController do
expect(response.status).to eq(403)
end
end
describe "admin signed in" do
let!(:editor) { sign_in(admin) }
@ -1205,7 +1195,7 @@ RSpec.describe TopicsController do
fab!(:topic) { Fabricate(:topic, category: category) }
before do
sign_in(group_user.user)
sign_in(user)
SiteSetting.enable_category_group_moderation = true
end