From 8be29694ecb8ecb93028ab4869d0f9d8834eb47e Mon Sep 17 00:00:00 2001 From: Jarek Radosz Date: Sun, 5 Jan 2025 01:09:23 +0100 Subject: [PATCH] DEV: Clean up topics_controller_spec (#30553) --- spec/requests/topics_controller_spec.rb | 30 +++++++++---------------- 1 file changed, 10 insertions(+), 20 deletions(-) diff --git a/spec/requests/topics_controller_spec.rb b/spec/requests/topics_controller_spec.rb index 04aaea156e8..30b611ad0b4 100644 --- a/spec/requests/topics_controller_spec.rb +++ b/spec/requests/topics_controller_spec.rb @@ -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