mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
DEV: Move admin config pages out of /customize/ sub-route (#30511)
The customize routes add CSS classes that make these admin config pages look different from the ones under /admin/config. We want all config routes to be under /admin/config as well. This commit moves the emoji, user fields, and permalinks pages out of customize and into config, updating all references and adding more rails routes as needed. Also renames admin emojis route to emoji, emoji is singular and plural.
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
RSpec.describe Admin::EmojisController do
|
||||
RSpec.describe Admin::EmojiController do
|
||||
fab!(:admin)
|
||||
fab!(:moderator)
|
||||
fab!(:user)
|
||||
@@ -10,11 +10,11 @@ RSpec.describe Admin::EmojisController do
|
||||
context "when logged in as an admin" do
|
||||
before { sign_in(admin) }
|
||||
|
||||
it "returns a list of custom emojis" do
|
||||
it "returns a list of custom emoji" do
|
||||
CustomEmoji.create!(name: "osama-test-emoji", upload: upload, user: admin)
|
||||
Emoji.clear_cache
|
||||
|
||||
get "/admin/customize/emojis.json"
|
||||
get "/admin/config/emoji.json"
|
||||
expect(response.status).to eq(200)
|
||||
|
||||
json = response.parsed_body
|
||||
@@ -24,9 +24,9 @@ RSpec.describe Admin::EmojisController do
|
||||
end
|
||||
end
|
||||
|
||||
shared_examples "custom emojis inaccessible" do
|
||||
shared_examples "custom emoji inaccessible" do
|
||||
it "denies access with a 404 response" do
|
||||
get "/admin/customize/emojis.json"
|
||||
get "/admin/config/emoji.json"
|
||||
|
||||
expect(response.status).to eq(404)
|
||||
expect(response.parsed_body["errors"]).to include(I18n.t("not_found"))
|
||||
@@ -36,13 +36,13 @@ RSpec.describe Admin::EmojisController do
|
||||
context "when logged in as a moderator" do
|
||||
before { sign_in(moderator) }
|
||||
|
||||
include_examples "custom emojis inaccessible"
|
||||
include_examples "custom emoji inaccessible"
|
||||
end
|
||||
|
||||
context "when logged in as a non-staff user" do
|
||||
before { sign_in(user) }
|
||||
|
||||
include_examples "custom emojis inaccessible"
|
||||
include_examples "custom emoji inaccessible"
|
||||
end
|
||||
end
|
||||
|
||||
@@ -52,7 +52,7 @@ RSpec.describe Admin::EmojisController do
|
||||
|
||||
context "when upload is invalid" do
|
||||
it "should publish the right error" do
|
||||
post "/admin/customize/emojis.json",
|
||||
post "/admin/config/emoji.json",
|
||||
params: {
|
||||
name: "test",
|
||||
file: fixture_file_upload("#{Rails.root}/spec/fixtures/images/fake.jpg"),
|
||||
@@ -68,7 +68,7 @@ RSpec.describe Admin::EmojisController do
|
||||
it "should publish the right error" do
|
||||
CustomEmoji.create!(name: "test", upload: upload)
|
||||
|
||||
post "/admin/customize/emojis.json",
|
||||
post "/admin/config/emoji.json",
|
||||
params: {
|
||||
name: "test",
|
||||
file: fixture_file_upload("#{Rails.root}/spec/fixtures/images/logo.png"),
|
||||
@@ -85,7 +85,7 @@ RSpec.describe Admin::EmojisController do
|
||||
it "should allow an admin to add a custom emoji" do
|
||||
Emoji.expects(:clear_cache)
|
||||
|
||||
post "/admin/customize/emojis.json",
|
||||
post "/admin/config/emoji.json",
|
||||
params: {
|
||||
name: "test",
|
||||
file: fixture_file_upload("#{Rails.root}/spec/fixtures/images/logo.png"),
|
||||
@@ -108,7 +108,7 @@ RSpec.describe Admin::EmojisController do
|
||||
it "should log the action" do
|
||||
Emoji.expects(:clear_cache)
|
||||
|
||||
post "/admin/customize/emojis.json",
|
||||
post "/admin/config/emoji.json",
|
||||
params: {
|
||||
name: "test",
|
||||
file: fixture_file_upload("#{Rails.root}/spec/fixtures/images/logo.png"),
|
||||
@@ -124,7 +124,7 @@ RSpec.describe Admin::EmojisController do
|
||||
it "should allow an admin to add a custom emoji with a custom group" do
|
||||
Emoji.expects(:clear_cache)
|
||||
|
||||
post "/admin/customize/emojis.json",
|
||||
post "/admin/config/emoji.json",
|
||||
params: {
|
||||
name: "test",
|
||||
group: "Foo",
|
||||
@@ -141,7 +141,7 @@ RSpec.describe Admin::EmojisController do
|
||||
it "should fix up the emoji name" do
|
||||
Emoji.expects(:clear_cache).times(3)
|
||||
|
||||
post "/admin/customize/emojis.json",
|
||||
post "/admin/config/emoji.json",
|
||||
params: {
|
||||
name: "test.png",
|
||||
file: fixture_file_upload("#{Rails.root}/spec/fixtures/images/logo.png"),
|
||||
@@ -154,7 +154,7 @@ RSpec.describe Admin::EmojisController do
|
||||
expect(custom_emoji.name).to eq("test")
|
||||
expect(response.status).to eq(200)
|
||||
|
||||
post "/admin/customize/emojis.json",
|
||||
post "/admin/config/emoji.json",
|
||||
params: {
|
||||
name: "st&#* onk$",
|
||||
file: fixture_file_upload("#{Rails.root}/spec/fixtures/images/logo.png"),
|
||||
@@ -164,7 +164,7 @@ RSpec.describe Admin::EmojisController do
|
||||
expect(custom_emoji.name).to eq("st_onk_")
|
||||
expect(response.status).to eq(200)
|
||||
|
||||
post "/admin/customize/emojis.json",
|
||||
post "/admin/config/emoji.json",
|
||||
params: {
|
||||
name: "PaRTYpaRrot",
|
||||
file: fixture_file_upload("#{Rails.root}/spec/fixtures/images/logo.png"),
|
||||
@@ -178,7 +178,7 @@ RSpec.describe Admin::EmojisController do
|
||||
|
||||
shared_examples "custom emoji creation not allowed" do
|
||||
it "prevents creation with a 404 response" do
|
||||
post "/admin/customize/emojis.json",
|
||||
post "/admin/config/emoji.json",
|
||||
params: {
|
||||
name: "test",
|
||||
file: fixture_file_upload("#{Rails.root}/spec/fixtures/images/logo.png"),
|
||||
@@ -211,7 +211,7 @@ RSpec.describe Admin::EmojisController do
|
||||
Emoji.clear_cache
|
||||
|
||||
expect do
|
||||
delete "/admin/customize/emojis/#{custom_emoji.name}.json", params: { name: "test" }
|
||||
delete "/admin/config/emoji/#{custom_emoji.name}.json", params: { name: "test" }
|
||||
end.to change { CustomEmoji.count }.by(-1)
|
||||
end
|
||||
|
||||
@@ -219,7 +219,7 @@ RSpec.describe Admin::EmojisController do
|
||||
custom_emoji = CustomEmoji.create!(name: "test", upload: upload)
|
||||
Emoji.clear_cache
|
||||
|
||||
delete "/admin/customize/emojis/#{custom_emoji.name}.json", params: { name: "test" }
|
||||
delete "/admin/config/emoji/#{custom_emoji.name}.json", params: { name: "test" }
|
||||
|
||||
last_log = UserHistory.last
|
||||
|
||||
@@ -234,7 +234,7 @@ RSpec.describe Admin::EmojisController do
|
||||
custom_emoji = CustomEmoji.create!(name: "test", upload: upload)
|
||||
Emoji.clear_cache
|
||||
|
||||
delete "/admin/customize/emojis/#{custom_emoji.name}.json", params: { name: "test" }
|
||||
delete "/admin/config/emoji/#{custom_emoji.name}.json", params: { name: "test" }
|
||||
|
||||
expect(response.status).to eq(404)
|
||||
expect(response.parsed_body["errors"]).to include(I18n.t("not_found"))
|
||||
|
||||
@@ -11,7 +11,7 @@ RSpec.describe Admin::UserFieldsController do
|
||||
|
||||
it "creates a user field" do
|
||||
expect {
|
||||
post "/admin/customize/user_fields.json",
|
||||
post "/admin/config/user_fields.json",
|
||||
params: {
|
||||
user_field: {
|
||||
name: "hello",
|
||||
@@ -27,7 +27,7 @@ RSpec.describe Admin::UserFieldsController do
|
||||
|
||||
it "creates a user field with options" do
|
||||
expect do
|
||||
post "/admin/customize/user_fields.json",
|
||||
post "/admin/config/user_fields.json",
|
||||
params: {
|
||||
user_field: {
|
||||
name: "hello",
|
||||
@@ -48,7 +48,7 @@ RSpec.describe Admin::UserFieldsController do
|
||||
shared_examples "user field creation not allowed" do
|
||||
it "prevents creation with a 404 response" do
|
||||
expect do
|
||||
post "/admin/customize/user_fields.json",
|
||||
post "/admin/config/user_fields.json",
|
||||
params: {
|
||||
user_field: {
|
||||
name: "hello",
|
||||
@@ -83,7 +83,7 @@ RSpec.describe Admin::UserFieldsController do
|
||||
before { sign_in(admin) }
|
||||
|
||||
it "returns a list of user fields" do
|
||||
get "/admin/customize/user_fields.json"
|
||||
get "/admin/config/user_fields.json"
|
||||
expect(response.status).to eq(200)
|
||||
json = response.parsed_body
|
||||
expect(json["user_fields"]).to be_present
|
||||
@@ -92,7 +92,7 @@ RSpec.describe Admin::UserFieldsController do
|
||||
|
||||
shared_examples "user fields inaccessible" do
|
||||
it "denies access with a 404 response" do
|
||||
get "/admin/customize/user_fields.json"
|
||||
get "/admin/config/user_fields.json"
|
||||
|
||||
expect(response.status).to eq(404)
|
||||
expect(response.parsed_body["errors"]).to include(I18n.t("not_found"))
|
||||
@@ -121,7 +121,7 @@ RSpec.describe Admin::UserFieldsController do
|
||||
|
||||
it "deletes the user field" do
|
||||
expect {
|
||||
delete "/admin/customize/user_fields/#{user_field.id}.json"
|
||||
delete "/admin/config/user_fields/#{user_field.id}.json"
|
||||
expect(response.status).to eq(200)
|
||||
}.to change(UserField, :count).by(-1)
|
||||
end
|
||||
@@ -129,7 +129,7 @@ RSpec.describe Admin::UserFieldsController do
|
||||
|
||||
shared_examples "user field deletion not allowed" do
|
||||
it "prevents deletion with a 404 response" do
|
||||
expect do delete "/admin/customize/user_fields/#{user_field.id}.json" end.not_to change {
|
||||
expect do delete "/admin/config/user_fields/#{user_field.id}.json" end.not_to change {
|
||||
UserField.count
|
||||
}
|
||||
|
||||
@@ -158,7 +158,7 @@ RSpec.describe Admin::UserFieldsController do
|
||||
before { sign_in(admin) }
|
||||
|
||||
it "updates the user field" do
|
||||
put "/admin/customize/user_fields/#{user_field.id}.json",
|
||||
put "/admin/config/user_fields/#{user_field.id}.json",
|
||||
params: {
|
||||
user_field: {
|
||||
name: "fraggle",
|
||||
@@ -177,7 +177,7 @@ RSpec.describe Admin::UserFieldsController do
|
||||
end
|
||||
|
||||
it "updates the user field options" do
|
||||
put "/admin/customize/user_fields/#{user_field.id}.json",
|
||||
put "/admin/config/user_fields/#{user_field.id}.json",
|
||||
params: {
|
||||
user_field: {
|
||||
name: "fraggle",
|
||||
@@ -195,7 +195,7 @@ RSpec.describe Admin::UserFieldsController do
|
||||
end
|
||||
|
||||
it "keeps options when updating the user field" do
|
||||
put "/admin/customize/user_fields/#{user_field.id}.json",
|
||||
put "/admin/config/user_fields/#{user_field.id}.json",
|
||||
params: {
|
||||
user_field: {
|
||||
name: "fraggle",
|
||||
@@ -210,7 +210,7 @@ RSpec.describe Admin::UserFieldsController do
|
||||
user_field.reload
|
||||
expect(user_field.user_field_options.size).to eq(2)
|
||||
|
||||
put "/admin/customize/user_fields/#{user_field.id}.json",
|
||||
put "/admin/config/user_fields/#{user_field.id}.json",
|
||||
params: {
|
||||
user_field: {
|
||||
name: "fraggle",
|
||||
@@ -234,7 +234,7 @@ RSpec.describe Admin::UserFieldsController do
|
||||
position: next_position,
|
||||
)
|
||||
expect {
|
||||
put "/admin/customize/user_fields/#{user_field.id}.json",
|
||||
put "/admin/config/user_fields/#{user_field.id}.json",
|
||||
params: {
|
||||
user_field: {
|
||||
show_on_profile: false,
|
||||
@@ -251,7 +251,7 @@ RSpec.describe Admin::UserFieldsController do
|
||||
user_field.reload
|
||||
original_name = user_field.name
|
||||
|
||||
put "/admin/customize/user_fields/#{user_field.id}.json",
|
||||
put "/admin/config/user_fields/#{user_field.id}.json",
|
||||
params: {
|
||||
user_field: {
|
||||
name: "fraggle",
|
||||
|
||||
Reference in New Issue
Block a user