mirror of
https://github.com/discourse/discourse.git
synced 2025-05-28 13:51:18 +08:00
UX: redesign admin permalinks page (#29634)
Redesign the permalinks page to follow the UX guide. In addition, the ability to edit permalinks was added. This change includes: - move to RestModel - added Validations - update endpoint and clear old values after the update - system specs and improvements for unit tests
This commit is contained in:

committed by
GitHub

parent
b37f6f1edb
commit
42b1ca8f78
@ -345,7 +345,11 @@ RSpec.describe ApplicationController do
|
||||
describe "topic not found" do
|
||||
it "should not redirect to permalink if topic/category does not exist" do
|
||||
topic = create_post.topic
|
||||
Permalink.create!(url: topic.relative_url, topic_id: topic.id + 1)
|
||||
Permalink.create!(
|
||||
url: topic.relative_url,
|
||||
permalink_type_value: topic.id + 1,
|
||||
permalink_type: "topic",
|
||||
)
|
||||
topic.trash!
|
||||
|
||||
SiteSetting.detailed_404 = false
|
||||
@ -360,7 +364,11 @@ RSpec.describe ApplicationController do
|
||||
it "should return permalink for deleted topics" do
|
||||
topic = create_post.topic
|
||||
external_url = "https://somewhere.over.rainbow"
|
||||
Permalink.create!(url: topic.relative_url, external_url: external_url)
|
||||
Permalink.create!(
|
||||
url: topic.relative_url,
|
||||
permalink_type_value: external_url,
|
||||
permalink_type: "external_url",
|
||||
)
|
||||
topic.trash!
|
||||
|
||||
get topic.relative_url
|
||||
@ -382,7 +390,12 @@ RSpec.describe ApplicationController do
|
||||
trashed_topic = create_post.topic
|
||||
trashed_topic.trash!
|
||||
new_topic = create_post.topic
|
||||
permalink = Permalink.create!(url: trashed_topic.relative_url, topic_id: new_topic.id)
|
||||
permalink =
|
||||
Permalink.create!(
|
||||
url: trashed_topic.relative_url,
|
||||
permalink_type_value: new_topic.id,
|
||||
permalink_type: "topic",
|
||||
)
|
||||
|
||||
# no subfolder because router doesn't know about subfolder in this test
|
||||
get "/t/#{trashed_topic.slug}/#{trashed_topic.id}"
|
||||
@ -391,14 +404,23 @@ RSpec.describe ApplicationController do
|
||||
|
||||
permalink.destroy
|
||||
category = Fabricate(:category)
|
||||
permalink = Permalink.create!(url: trashed_topic.relative_url, category_id: category.id)
|
||||
permalink =
|
||||
Permalink.create!(
|
||||
url: trashed_topic.relative_url,
|
||||
permalink_type_value: category.id,
|
||||
permalink_type: "category",
|
||||
)
|
||||
get "/t/#{trashed_topic.slug}/#{trashed_topic.id}"
|
||||
expect(response.status).to eq(301)
|
||||
expect(response).to redirect_to("/forum/c/#{category.slug}/#{category.id}")
|
||||
|
||||
permalink.destroy
|
||||
permalink =
|
||||
Permalink.create!(url: trashed_topic.relative_url, post_id: new_topic.posts.last.id)
|
||||
Permalink.create!(
|
||||
url: trashed_topic.relative_url,
|
||||
permalink_type_value: new_topic.posts.last.id,
|
||||
permalink_type: "post",
|
||||
)
|
||||
get "/t/#{trashed_topic.slug}/#{trashed_topic.id}"
|
||||
expect(response.status).to eq(301)
|
||||
expect(response).to redirect_to(
|
||||
|
Reference in New Issue
Block a user