Use prefabricated admin instead of creating new ones

This commit is contained in:
Daniel Waterworth 2019-05-06 11:14:35 +01:00 committed by Robin Ward
parent 2f706be43a
commit 2c7ed7b848

View File

@ -202,7 +202,7 @@ describe Guardian do
end end
it "returns true for a new user flagging a private message as spam" do it "returns true for a new user flagging a private message as spam" do
post = Fabricate(:private_message_post, user: Fabricate(:admin)) post = Fabricate(:private_message_post, user: admin)
user.trust_level = TrustLevel[0] user.trust_level = TrustLevel[0]
post.topic.allowed_users << user post.topic.allowed_users << user
expect(Guardian.new(user).post_can_act?(post, :spam)).to be_truthy expect(Guardian.new(user).post_can_act?(post, :spam)).to be_truthy
@ -340,8 +340,6 @@ describe Guardian do
expect(Guardian.new(user).can_send_private_message?(group)).to eq(output) expect(Guardian.new(user).can_send_private_message?(group)).to eq(output)
end end
admin = Fabricate(:admin)
Group::ALIAS_LEVELS.each do |level, _| Group::ALIAS_LEVELS.each do |level, _|
group.update!(messageable_level: Group::ALIAS_LEVELS[level]) group.update!(messageable_level: Group::ALIAS_LEVELS[level])
expect(Guardian.new(admin).can_send_private_message?(group)).to eq(true) expect(Guardian.new(admin).can_send_private_message?(group)).to eq(true)
@ -490,7 +488,7 @@ describe Guardian do
it 'returns false when user is not allowed to edit a group' do it 'returns false when user is not allowed to edit a group' do
expect(Guardian.new(user).can_invite_to_forum?(groups)).to eq(false) expect(Guardian.new(user).can_invite_to_forum?(groups)).to eq(false)
expect(Guardian.new(Fabricate(:admin)).can_invite_to_forum?(groups)) expect(Guardian.new(admin).can_invite_to_forum?(groups))
.to eq(true) .to eq(true)
end end
@ -862,7 +860,7 @@ describe Guardian do
before { SiteSetting.edit_history_visible_to_public = false } before { SiteSetting.edit_history_visible_to_public = false }
it 'is true for staff' do it 'is true for staff' do
expect(Guardian.new(Fabricate(:admin)).can_see?(post_revision)).to be_truthy expect(Guardian.new(admin).can_see?(post_revision)).to be_truthy
expect(Guardian.new(moderator).can_see?(post_revision)).to be_truthy expect(Guardian.new(moderator).can_see?(post_revision)).to be_truthy
end end