DEV: Make all admins TL4 in tests (#25435)

Make admins TL4 by default in tests, foregoing the need to call refresh_auto_groups on them.
This commit is contained in:
Ted Johansson 2024-03-26 11:41:12 +08:00 committed by GitHub
parent d9179468e4
commit 5ee23fc394
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
17 changed files with 17 additions and 18 deletions

View File

@ -72,6 +72,7 @@ Fabricator(:admin, from: :user) do
username { sequence(:username) { |i| "anne#{i}" } }
email { sequence(:email) { |i| "anne#{i}@discourse.org" } }
admin true
trust_level TrustLevel[4]
after_create do |user|
user.group_users << Fabricate(:group_user, user: user, group: Group[:admins])

View File

@ -185,11 +185,9 @@ RSpec.describe CookedPostProcessor do
- #{url_with_query_param}
RAW
let(:staff_post) do
Fabricate(:post, user: Fabricate(:admin, refresh_auto_groups: true), raw: <<~RAW)
let(:staff_post) { Fabricate(:post, user: Fabricate(:admin), raw: <<~RAW) }
This is a #{url_with_path} topic
RAW
end
before do
urls.each do |url|

View File

@ -2,7 +2,7 @@
RSpec.describe TopicGuardian do
fab!(:user) { Fabricate(:user, refresh_auto_groups: true) }
fab!(:admin) { Fabricate(:admin, refresh_auto_groups: true) }
fab!(:admin)
fab!(:tl3_user) { Fabricate(:trust_level_3) }
fab!(:tl4_user) { Fabricate(:trust_level_4) }
fab!(:moderator)

View File

@ -6,7 +6,7 @@ RSpec.describe Guardian do
fab!(:member) { Fabricate(:user) }
fab!(:owner) { Fabricate(:user) }
fab!(:moderator) { Fabricate(:moderator, refresh_auto_groups: true) }
fab!(:admin) { Fabricate(:admin, refresh_auto_groups: true) }
fab!(:admin)
fab!(:anonymous_user) { Fabricate(:anonymous) }
fab!(:staff_post) { Fabricate(:post, user: moderator) }
fab!(:group)

View File

@ -1,7 +1,7 @@
# frozen_string_literal: true
RSpec.describe PostActionCreator do
fab!(:admin) { Fabricate(:admin, refresh_auto_groups: true) }
fab!(:admin)
fab!(:user) { Fabricate(:user, refresh_auto_groups: true) }
fab!(:post)
let(:like_type_id) { PostActionType.types[:like] }

View File

@ -5,7 +5,7 @@ require "topic_subtype"
RSpec.describe PostCreator do
fab!(:user) { Fabricate(:user, refresh_auto_groups: true) }
fab!(:admin) { Fabricate(:admin, refresh_auto_groups: true) }
fab!(:admin)
fab!(:coding_horror) { Fabricate(:coding_horror, refresh_auto_groups: true) }
fab!(:evil_trout) { Fabricate(:evil_trout, refresh_auto_groups: true) }
let(:topic) { Fabricate(:topic, user: user) }

View File

@ -4,7 +4,7 @@ RSpec.describe PostDestroyer do
before { UserActionManager.enable }
fab!(:moderator) { Fabricate(:moderator, refresh_auto_groups: true) }
fab!(:admin) { Fabricate(:admin, refresh_auto_groups: true) }
fab!(:admin)
fab!(:coding_horror) { Fabricate(:coding_horror, refresh_auto_groups: true) }
let(:post) { create_post }

View File

@ -854,7 +854,7 @@ RSpec.describe PostRevisor do
end
describe "admin editing a new user's post" do
fab!(:changed_by) { Fabricate(:admin, refresh_auto_groups: true) }
fab!(:changed_by) { Fabricate(:admin) }
before do
SiteSetting.newuser_max_embedded_media = 0

View File

@ -3,7 +3,7 @@
RSpec.describe TopicCreator do
fab!(:user) { Fabricate(:user, trust_level: TrustLevel[2]) }
fab!(:moderator)
fab!(:admin) { Fabricate(:admin, refresh_auto_groups: true) }
fab!(:admin)
let(:valid_attrs) { Fabricate.attributes_for(:topic) }
let(:pm_valid_attrs) do

View File

@ -507,7 +507,7 @@ RSpec.describe Group do
g = Group[:trust_level_2]
expect(g.human_users.count).to eq(g.user_count)
expect(g.human_users).to contain_exactly(user)
expect(g.human_users).to contain_exactly(admin, user)
end
it "can set members via usernames helper" do

View File

@ -22,7 +22,7 @@ RSpec.describe PostMover do
context "with topics" do
before { freeze_time }
fab!(:user) { Fabricate(:admin, refresh_auto_groups: true) }
fab!(:user) { Fabricate(:admin) }
fab!(:another_user) { evil_trout }
fab!(:category) { Fabricate(:category, user: user) }
fab!(:topic) { Fabricate(:topic, user: user, created_at: 4.hours.ago) }

View File

@ -17,7 +17,7 @@ RSpec.describe TopicsController do
fab!(:post_author5) { Fabricate(:user) }
fab!(:post_author6) { Fabricate(:user) }
fab!(:moderator)
fab!(:admin) { Fabricate(:admin, refresh_auto_groups: true) }
fab!(:admin)
fab!(:trust_level_0)
fab!(:trust_level_1)
fab!(:trust_level_4)

View File

@ -11,7 +11,7 @@ RSpec.describe UsersController do
fab!(:invitee) { Fabricate(:user) }
fab!(:inviter) { Fabricate(:user) }
fab!(:admin) { Fabricate(:admin, refresh_auto_groups: true) }
fab!(:admin)
fab!(:moderator)
fab!(:inactive_user)

View File

@ -36,7 +36,7 @@ RSpec.describe TopicViewDetailsSerializer do
before { SiteSetting.can_permanently_delete = true }
it "is true for admins" do
admin = Fabricate(:admin, refresh_auto_groups: true)
admin = Fabricate(:admin)
serializer = described_class.new(TopicView.new(post.topic, admin), scope: Guardian.new(admin))
expect(serializer.as_json.dig(:topic_view_details, :can_permanently_delete)).to eq(true)

View File

@ -14,7 +14,7 @@ RSpec.describe TopicViewSerializer do
fab!(:topic)
fab!(:user) { Fabricate(:user, refresh_auto_groups: true) }
fab!(:user_2) { Fabricate(:user) }
fab!(:admin) { Fabricate(:admin, refresh_auto_groups: true) }
fab!(:admin)
describe "#featured_link and #featured_link_root_domain" do
fab!(:featured_link) { "http://meta.discourse.org" }

View File

@ -2,7 +2,7 @@
RSpec.describe UserDestroyer do
fab!(:user) { Fabricate(:user_with_secondary_email, refresh_auto_groups: true) }
fab!(:admin) { Fabricate(:admin, refresh_auto_groups: true) }
fab!(:admin)
describe ".new" do
it "raises an error when user is nil" do

View File

@ -1,7 +1,7 @@
# frozen_string_literal: true
describe "Flagging post", type: :system do
fab!(:current_user) { Fabricate(:admin, refresh_auto_groups: true) }
fab!(:current_user) { Fabricate(:admin) }
fab!(:first_post) { Fabricate(:post) }
fab!(:post_to_flag) { Fabricate(:post, topic: first_post.topic) }