mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
Prefabricated admin at the top level
This commit is contained in:
parent
cef14d81ac
commit
1d0565eca2
@ -6,6 +6,7 @@ RSpec.describe TopicsController do
|
|||||||
fab!(:topic) { Fabricate(:topic) }
|
fab!(:topic) { Fabricate(:topic) }
|
||||||
fab!(:user) { Fabricate(:user) }
|
fab!(:user) { Fabricate(:user) }
|
||||||
fab!(:moderator) { Fabricate(:moderator) }
|
fab!(:moderator) { Fabricate(:moderator) }
|
||||||
|
fab!(:admin) { Fabricate(:admin) }
|
||||||
|
|
||||||
describe '#wordpress' do
|
describe '#wordpress' do
|
||||||
let!(:user) { sign_in(moderator) }
|
let!(:user) { sign_in(moderator) }
|
||||||
@ -96,7 +97,7 @@ RSpec.describe TopicsController do
|
|||||||
end
|
end
|
||||||
|
|
||||||
context 'success' do
|
context 'success' do
|
||||||
before { sign_in(Fabricate(:admin)) }
|
before { sign_in(admin) }
|
||||||
|
|
||||||
it "returns success" do
|
it "returns success" do
|
||||||
expect do
|
expect do
|
||||||
@ -119,7 +120,7 @@ RSpec.describe TopicsController do
|
|||||||
|
|
||||||
describe 'when topic has been deleted' do
|
describe 'when topic has been deleted' do
|
||||||
it 'should still be able to move posts' do
|
it 'should still be able to move posts' do
|
||||||
PostDestroyer.new(Fabricate(:admin), topic.first_post).destroy
|
PostDestroyer.new(admin, topic.first_post).destroy
|
||||||
|
|
||||||
expect(topic.reload.deleted_at).to_not be_nil
|
expect(topic.reload.deleted_at).to_not be_nil
|
||||||
|
|
||||||
@ -268,7 +269,7 @@ RSpec.describe TopicsController do
|
|||||||
end
|
end
|
||||||
|
|
||||||
context 'success' do
|
context 'success' do
|
||||||
before { sign_in(Fabricate(:admin)) }
|
before { sign_in(admin) }
|
||||||
|
|
||||||
it "returns success" do
|
it "returns success" do
|
||||||
SiteSetting.allow_staff_to_tag_pms = true
|
SiteSetting.allow_staff_to_tag_pms = true
|
||||||
@ -293,7 +294,7 @@ RSpec.describe TopicsController do
|
|||||||
|
|
||||||
describe 'when message has been deleted' do
|
describe 'when message has been deleted' do
|
||||||
it 'should still be able to move posts' do
|
it 'should still be able to move posts' do
|
||||||
PostDestroyer.new(Fabricate(:admin), message.first_post).destroy
|
PostDestroyer.new(admin, message.first_post).destroy
|
||||||
|
|
||||||
expect(message.reload.deleted_at).to_not be_nil
|
expect(message.reload.deleted_at).to_not be_nil
|
||||||
|
|
||||||
@ -331,7 +332,7 @@ RSpec.describe TopicsController do
|
|||||||
end
|
end
|
||||||
|
|
||||||
describe 'moving to an existing message' do
|
describe 'moving to an existing message' do
|
||||||
let!(:user) { sign_in(Fabricate(:admin)) }
|
let!(:user) { sign_in(admin) }
|
||||||
fab!(:trust_level_4) { Fabricate(:trust_level_4) }
|
fab!(:trust_level_4) { Fabricate(:trust_level_4) }
|
||||||
fab!(:evil_trout) { Fabricate(:evil_trout) }
|
fab!(:evil_trout) { Fabricate(:evil_trout) }
|
||||||
let(:message) { Fabricate(:private_message_topic) }
|
let(:message) { Fabricate(:private_message_topic) }
|
||||||
@ -497,7 +498,7 @@ RSpec.describe TopicsController do
|
|||||||
end
|
end
|
||||||
|
|
||||||
describe 'changing ownership' do
|
describe 'changing ownership' do
|
||||||
let!(:editor) { sign_in(Fabricate(:admin)) }
|
let!(:editor) { sign_in(admin) }
|
||||||
let(:topic) { Fabricate(:topic) }
|
let(:topic) { Fabricate(:topic) }
|
||||||
fab!(:user_a) { Fabricate(:user) }
|
fab!(:user_a) { Fabricate(:user) }
|
||||||
let(:p1) { Fabricate(:post, topic: topic) }
|
let(:p1) { Fabricate(:post, topic: topic) }
|
||||||
@ -770,7 +771,7 @@ RSpec.describe TopicsController do
|
|||||||
expect(first_notification.read).to eq(true)
|
expect(first_notification.read).to eq(true)
|
||||||
expect(second_notification.read).to eq(false)
|
expect(second_notification.read).to eq(false)
|
||||||
|
|
||||||
PostDestroyer.new(Fabricate(:admin), post2).destroy
|
PostDestroyer.new(admin, post2).destroy
|
||||||
|
|
||||||
delete "/t/#{topic.id}/timings.json?last=1"
|
delete "/t/#{topic.id}/timings.json?last=1"
|
||||||
|
|
||||||
@ -1345,7 +1346,7 @@ RSpec.describe TopicsController do
|
|||||||
|
|
||||||
context 'admin' do
|
context 'admin' do
|
||||||
before do
|
before do
|
||||||
sign_in(Fabricate(:admin))
|
sign_in(admin)
|
||||||
end
|
end
|
||||||
|
|
||||||
expected = {
|
expected = {
|
||||||
@ -1892,9 +1893,8 @@ RSpec.describe TopicsController do
|
|||||||
describe '#invite_group' do
|
describe '#invite_group' do
|
||||||
let(:admins) { Group[:admins] }
|
let(:admins) { Group[:admins] }
|
||||||
|
|
||||||
let!(:admin) { sign_in(Fabricate(:admin)) }
|
|
||||||
|
|
||||||
before do
|
before do
|
||||||
|
sign_in(admin)
|
||||||
admins.messageable_level = Group::ALIAS_LEVELS[:everyone]
|
admins.messageable_level = Group::ALIAS_LEVELS[:everyone]
|
||||||
admins.save!
|
admins.save!
|
||||||
end
|
end
|
||||||
@ -1928,7 +1928,7 @@ RSpec.describe TopicsController do
|
|||||||
|
|
||||||
describe 'when logged in' do
|
describe 'when logged in' do
|
||||||
it "changes the topic archetype to 'banner'" do
|
it "changes the topic archetype to 'banner'" do
|
||||||
topic = Fabricate(:topic, user: sign_in(Fabricate(:admin)))
|
topic = Fabricate(:topic, user: sign_in(admin))
|
||||||
|
|
||||||
put "/t/#{topic.id}/make-banner.json"
|
put "/t/#{topic.id}/make-banner.json"
|
||||||
expect(response.status).to eq(200)
|
expect(response.status).to eq(200)
|
||||||
@ -1947,7 +1947,7 @@ RSpec.describe TopicsController do
|
|||||||
|
|
||||||
describe 'when logged in' do
|
describe 'when logged in' do
|
||||||
it "resets the topic archetype" do
|
it "resets the topic archetype" do
|
||||||
topic = Fabricate(:topic, user: sign_in(Fabricate(:admin)), archetype: Archetype.banner)
|
topic = Fabricate(:topic, user: sign_in(admin), archetype: Archetype.banner)
|
||||||
|
|
||||||
put "/t/#{topic.id}/remove-banner.json"
|
put "/t/#{topic.id}/remove-banner.json"
|
||||||
expect(response.status).to eq(200)
|
expect(response.status).to eq(200)
|
||||||
@ -1959,7 +1959,7 @@ RSpec.describe TopicsController do
|
|||||||
|
|
||||||
describe '#remove_allowed_user' do
|
describe '#remove_allowed_user' do
|
||||||
it 'admin can be removed from a pm' do
|
it 'admin can be removed from a pm' do
|
||||||
admin = sign_in(Fabricate(:admin))
|
sign_in(admin)
|
||||||
pm = create_post(user: user, archetype: 'private_message', target_usernames: [user.username, admin.username])
|
pm = create_post(user: user, archetype: 'private_message', target_usernames: [user.username, admin.username])
|
||||||
|
|
||||||
put "/t/#{pm.topic_id}/remove-allowed-user.json", params: {
|
put "/t/#{pm.topic_id}/remove-allowed-user.json", params: {
|
||||||
@ -2128,7 +2128,7 @@ RSpec.describe TopicsController do
|
|||||||
|
|
||||||
context "success" do
|
context "success" do
|
||||||
it "returns success" do
|
it "returns success" do
|
||||||
sign_in(Fabricate(:admin))
|
sign_in(admin)
|
||||||
put "/t/#{topic.id}/convert-topic/private.json"
|
put "/t/#{topic.id}/convert-topic/private.json"
|
||||||
|
|
||||||
topic.reload
|
topic.reload
|
||||||
@ -2154,7 +2154,7 @@ RSpec.describe TopicsController do
|
|||||||
|
|
||||||
context "success" do
|
context "success" do
|
||||||
it "returns success" do
|
it "returns success" do
|
||||||
sign_in(Fabricate(:admin))
|
sign_in(admin)
|
||||||
put "/t/#{topic.id}/convert-topic/public.json"
|
put "/t/#{topic.id}/convert-topic/public.json"
|
||||||
|
|
||||||
topic.reload
|
topic.reload
|
||||||
@ -2217,8 +2217,6 @@ RSpec.describe TopicsController do
|
|||||||
end
|
end
|
||||||
|
|
||||||
context 'when logged in as an admin' do
|
context 'when logged in as an admin' do
|
||||||
let(:admin) { Fabricate(:admin) }
|
|
||||||
|
|
||||||
before do
|
before do
|
||||||
sign_in(admin)
|
sign_in(admin)
|
||||||
end
|
end
|
||||||
@ -2451,7 +2449,7 @@ RSpec.describe TopicsController do
|
|||||||
let(:group) { Fabricate(:group) }
|
let(:group) { Fabricate(:group) }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
sign_in(Fabricate(:admin))
|
sign_in(admin)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should work correctly" do
|
it "should work correctly" do
|
||||||
@ -2511,7 +2509,9 @@ RSpec.describe TopicsController do
|
|||||||
end
|
end
|
||||||
|
|
||||||
describe 'as an admin user' do
|
describe 'as an admin user' do
|
||||||
let!(:admin) { sign_in(Fabricate(:admin)) }
|
before do
|
||||||
|
sign_in(admin)
|
||||||
|
end
|
||||||
|
|
||||||
it "disallows inviting a group to a topic" do
|
it "disallows inviting a group to a topic" do
|
||||||
topic = Fabricate(:topic)
|
topic = Fabricate(:topic)
|
||||||
@ -2720,7 +2720,7 @@ RSpec.describe TopicsController do
|
|||||||
|
|
||||||
it "should fail for non-existend topic" do
|
it "should fail for non-existend topic" do
|
||||||
max_id = Topic.maximum(:id)
|
max_id = Topic.maximum(:id)
|
||||||
sign_in(Fabricate(:admin))
|
sign_in(admin)
|
||||||
put "/t/#{max_id + 1}/reset-bump-date.json"
|
put "/t/#{max_id + 1}/reset-bump-date.json"
|
||||||
expect(response.status).to eq(404)
|
expect(response.status).to eq(404)
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user