mirror of
https://github.com/discourse/discourse.git
synced 2025-06-03 19:03:34 +08:00
DEV: Apply syntax_tree formatting to spec/*
This commit is contained in:
@ -1,8 +1,7 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
RSpec.describe DestroyTask do
|
||||
|
||||
describe 'destroy topics' do
|
||||
describe "destroy topics" do
|
||||
fab!(:c) { Fabricate(:category_with_definition) }
|
||||
fab!(:t) { Fabricate(:topic, category: c) }
|
||||
let!(:p) { Fabricate(:post, topic: t) }
|
||||
@ -13,16 +12,18 @@ RSpec.describe DestroyTask do
|
||||
fab!(:t3) { Fabricate(:topic, category: sc) }
|
||||
let!(:p3) { Fabricate(:post, topic: t3) }
|
||||
|
||||
it 'destroys all topics in a category' do
|
||||
it "destroys all topics in a category" do
|
||||
destroy_task = DestroyTask.new(StringIO.new)
|
||||
expect { destroy_task.destroy_topics(c.slug) }
|
||||
.to change { Topic.where(category_id: c.id).count }.by (-1)
|
||||
expect { destroy_task.destroy_topics(c.slug) }.to change {
|
||||
Topic.where(category_id: c.id).count
|
||||
}.by (-1)
|
||||
end
|
||||
|
||||
it 'destroys all topics in a sub category' do
|
||||
it "destroys all topics in a sub category" do
|
||||
destroy_task = DestroyTask.new(StringIO.new)
|
||||
expect { destroy_task.destroy_topics(sc.slug, c2.slug) }
|
||||
.to change { Topic.where(category_id: sc.id).count }.by(-1)
|
||||
expect { destroy_task.destroy_topics(sc.slug, c2.slug) }.to change {
|
||||
Topic.where(category_id: sc.id).count
|
||||
}.by(-1)
|
||||
end
|
||||
|
||||
it "doesn't destroy system topics" do
|
||||
@ -31,14 +32,14 @@ RSpec.describe DestroyTask do
|
||||
expect(Topic.where(category_id: c2.id).count).to eq 1
|
||||
end
|
||||
|
||||
it 'destroys topics in all categories' do
|
||||
it "destroys topics in all categories" do
|
||||
destroy_task = DestroyTask.new(StringIO.new)
|
||||
destroy_task.destroy_topics_all_categories
|
||||
expect(Post.where(topic_id: [t.id, t2.id, t3.id]).count).to eq 0
|
||||
end
|
||||
end
|
||||
|
||||
describe 'destroy categories' do
|
||||
describe "destroy categories" do
|
||||
fab!(:c) { Fabricate(:category_with_definition) }
|
||||
fab!(:t) { Fabricate(:topic, category: c) }
|
||||
let!(:p) { Fabricate(:post, topic: t) }
|
||||
@ -49,37 +50,39 @@ RSpec.describe DestroyTask do
|
||||
fab!(:t3) { Fabricate(:topic, category: sc) }
|
||||
let!(:p3) { Fabricate(:post, topic: t3) }
|
||||
|
||||
it 'destroys specified category' do
|
||||
it "destroys specified category" do
|
||||
destroy_task = DestroyTask.new(StringIO.new)
|
||||
|
||||
expect { destroy_task.destroy_category(c.id) }
|
||||
.to change { Category.where(id: c.id).count }.by (-1)
|
||||
expect { destroy_task.destroy_category(c.id) }.to change {
|
||||
Category.where(id: c.id).count
|
||||
}.by (-1)
|
||||
end
|
||||
|
||||
it 'destroys sub-categories when destroying parent category' do
|
||||
it "destroys sub-categories when destroying parent category" do
|
||||
destroy_task = DestroyTask.new(StringIO.new)
|
||||
|
||||
expect { destroy_task.destroy_category(c2.id) }
|
||||
.to change { Category.where(id: sc.id).count }.by (-1)
|
||||
expect { destroy_task.destroy_category(c2.id) }.to change {
|
||||
Category.where(id: sc.id).count
|
||||
}.by (-1)
|
||||
end
|
||||
end
|
||||
|
||||
describe 'private messages' do
|
||||
describe "private messages" do
|
||||
let!(:pm) { Fabricate(:private_message_post) }
|
||||
let!(:pm2) { Fabricate(:private_message_post) }
|
||||
|
||||
it 'destroys all private messages' do
|
||||
it "destroys all private messages" do
|
||||
destroy_task = DestroyTask.new(StringIO.new)
|
||||
destroy_task.destroy_private_messages
|
||||
expect(Topic.where(archetype: "private_message").count).to eq 0
|
||||
end
|
||||
end
|
||||
|
||||
describe 'groups' do
|
||||
describe "groups" do
|
||||
let!(:g) { Fabricate(:group) }
|
||||
let!(:g2) { Fabricate(:group) }
|
||||
|
||||
it 'destroys all groups' do
|
||||
it "destroys all groups" do
|
||||
destroy_task = DestroyTask.new(StringIO.new)
|
||||
destroy_task.destroy_groups
|
||||
expect(Group.where(automatic: false).count).to eq 0
|
||||
@ -93,8 +96,8 @@ RSpec.describe DestroyTask do
|
||||
end
|
||||
end
|
||||
|
||||
describe 'users' do
|
||||
it 'destroys all non-admin users' do
|
||||
describe "users" do
|
||||
it "destroys all non-admin users" do
|
||||
before_count = User.count
|
||||
|
||||
Fabricate(:user)
|
||||
@ -109,8 +112,8 @@ RSpec.describe DestroyTask do
|
||||
end
|
||||
end
|
||||
|
||||
describe 'stats' do
|
||||
it 'destroys all site stats' do
|
||||
describe "stats" do
|
||||
it "destroys all site stats" do
|
||||
destroy_task = DestroyTask.new(StringIO.new)
|
||||
destroy_task.destroy_stats
|
||||
end
|
||||
|
Reference in New Issue
Block a user