DEV: Apply syntax_tree formatting to spec/*

This commit is contained in:
David Taylor
2023-01-09 11:18:21 +00:00
parent 0cf6421716
commit cb932d6ee1
907 changed files with 58693 additions and 45909 deletions

View File

@@ -5,11 +5,11 @@ RSpec.describe Admin::PermalinksController do
fab!(:moderator) { Fabricate(:moderator) }
fab!(:user) { Fabricate(:user) }
describe '#index' do
describe "#index" do
context "when logged in as an admin" do
before { sign_in(admin) }
it 'filters url' do
it "filters url" do
Fabricate(:permalink, url: "/forum/23")
Fabricate(:permalink, url: "/forum/98")
Fabricate(:permalink, url: "/discuss/topic/45")
@@ -22,7 +22,7 @@ RSpec.describe Admin::PermalinksController do
expect(result.length).to eq(2)
end
it 'filters external url' do
it "filters external url" do
Fabricate(:permalink, external_url: "http://google.com")
Fabricate(:permalink, external_url: "http://wikipedia.org")
Fabricate(:permalink, external_url: "http://www.discourse.org")
@@ -35,7 +35,7 @@ RSpec.describe Admin::PermalinksController do
expect(result.length).to eq(2)
end
it 'filters url and external url both' do
it "filters url and external url both" do
Fabricate(:permalink, url: "/forum/23", external_url: "http://google.com")
Fabricate(:permalink, url: "/discourse/98", external_url: "http://wikipedia.org")
Fabricate(:permalink, url: "/discuss/topic/45", external_url: "http://discourse.org")
@@ -65,7 +65,7 @@ RSpec.describe Admin::PermalinksController do
end
context "when logged in as a non-staff user" do
before { sign_in(user) }
before { sign_in(user) }
include_examples "permalinks inaccessible"
end
@@ -78,53 +78,81 @@ RSpec.describe Admin::PermalinksController do
it "works for topics" do
topic = Fabricate(:topic)
post "/admin/permalinks.json", params: {
url: "/topics/771",
permalink_type: "topic_id",
permalink_type_value: topic.id
}
post "/admin/permalinks.json",
params: {
url: "/topics/771",
permalink_type: "topic_id",
permalink_type_value: topic.id,
}
expect(response.status).to eq(200)
expect(Permalink.last).to have_attributes(url: "topics/771", topic_id: topic.id, post_id: nil, category_id: nil, tag_id: nil)
expect(Permalink.last).to have_attributes(
url: "topics/771",
topic_id: topic.id,
post_id: nil,
category_id: nil,
tag_id: nil,
)
end
it "works for posts" do
some_post = Fabricate(:post)
post "/admin/permalinks.json", params: {
url: "/topics/771/8291",
permalink_type: "post_id",
permalink_type_value: some_post.id
}
post "/admin/permalinks.json",
params: {
url: "/topics/771/8291",
permalink_type: "post_id",
permalink_type_value: some_post.id,
}
expect(response.status).to eq(200)
expect(Permalink.last).to have_attributes(url: "topics/771/8291", topic_id: nil, post_id: some_post.id, category_id: nil, tag_id: nil)
expect(Permalink.last).to have_attributes(
url: "topics/771/8291",
topic_id: nil,
post_id: some_post.id,
category_id: nil,
tag_id: nil,
)
end
it "works for categories" do
category = Fabricate(:category)
post "/admin/permalinks.json", params: {
url: "/forums/11",
permalink_type: "category_id",
permalink_type_value: category.id
}
post "/admin/permalinks.json",
params: {
url: "/forums/11",
permalink_type: "category_id",
permalink_type_value: category.id,
}
expect(response.status).to eq(200)
expect(Permalink.last).to have_attributes(url: "forums/11", topic_id: nil, post_id: nil, category_id: category.id, tag_id: nil)
expect(Permalink.last).to have_attributes(
url: "forums/11",
topic_id: nil,
post_id: nil,
category_id: category.id,
tag_id: nil,
)
end
it "works for tags" do
tag = Fabricate(:tag)
post "/admin/permalinks.json", params: {
url: "/forums/12",
permalink_type: "tag_name",
permalink_type_value: tag.name
}
post "/admin/permalinks.json",
params: {
url: "/forums/12",
permalink_type: "tag_name",
permalink_type_value: tag.name,
}
expect(response.status).to eq(200)
expect(Permalink.last).to have_attributes(url: "forums/12", topic_id: nil, post_id: nil, category_id: nil, tag_id: tag.id)
expect(Permalink.last).to have_attributes(
url: "forums/12",
topic_id: nil,
post_id: nil,
category_id: nil,
tag_id: tag.id,
)
end
end
@@ -133,11 +161,12 @@ RSpec.describe Admin::PermalinksController do
topic = Fabricate(:topic)
expect do
post "/admin/permalinks.json", params: {
url: "/topics/771",
permalink_type: "topic_id",
permalink_type_value: topic.id
}
post "/admin/permalinks.json",
params: {
url: "/topics/771",
permalink_type: "topic_id",
permalink_type_value: topic.id,
}
end.not_to change { Permalink.count }
expect(response.status).to eq(404)
@@ -152,7 +181,7 @@ RSpec.describe Admin::PermalinksController do
end
context "when logged in as a non-staff user" do
before { sign_in(user) }
before { sign_in(user) }
include_examples "permalink creation not allowed"
end