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:
parent
d9179468e4
commit
5ee23fc394
|
@ -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])
|
||||
|
|
|
@ -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|
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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] }
|
||||
|
|
|
@ -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) }
|
||||
|
|
|
@ -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 }
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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) }
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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" }
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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) }
|
||||
|
||||
|
|
Loading…
Reference in New Issue