mirror of
https://github.com/discourse/discourse.git
synced 2025-05-31 17:17:17 +08:00
FIX: Permalink.create
didn't work as expected anymore (#29895)
This moves the logic of setting the correct permalink values back into the controller. And it replaces the validation with a simpler one, that always works, even when the model is loaded from the DB. Follow-up to #29634 which broke import scripts and lots of documentation on Meta.
This commit is contained in:
@ -10,20 +10,10 @@ RSpec.describe Admin::PermalinksController do
|
||||
before { sign_in(admin) }
|
||||
|
||||
it "filters url" do
|
||||
Fabricate(:permalink, url: "/forum/23", permalink_type_value: "1", permalink_type: "topic")
|
||||
Fabricate(:permalink, url: "/forum/98", permalink_type_value: "1", permalink_type: "topic")
|
||||
Fabricate(
|
||||
:permalink,
|
||||
url: "/discuss/topic/45",
|
||||
permalink_type_value: "1",
|
||||
permalink_type: "topic",
|
||||
)
|
||||
Fabricate(
|
||||
:permalink,
|
||||
url: "/discuss/topic/76",
|
||||
permalink_type_value: "1",
|
||||
permalink_type: "topic",
|
||||
)
|
||||
Fabricate(:permalink, url: "/forum/23", topic_id: 1)
|
||||
Fabricate(:permalink, url: "/forum/98", topic_id: 1)
|
||||
Fabricate(:permalink, url: "/discuss/topic/45", topic_id: 1)
|
||||
Fabricate(:permalink, url: "/discuss/topic/76", topic_id: 1)
|
||||
|
||||
get "/admin/permalinks.json", params: { filter: "topic" }
|
||||
|
||||
@ -33,26 +23,10 @@ RSpec.describe Admin::PermalinksController do
|
||||
end
|
||||
|
||||
it "filters external url" do
|
||||
Fabricate(
|
||||
:permalink,
|
||||
permalink_type_value: "http://google.com",
|
||||
permalink_type: "external_url",
|
||||
)
|
||||
Fabricate(
|
||||
:permalink,
|
||||
permalink_type_value: "http://wikipedia.org",
|
||||
permalink_type: "external_url",
|
||||
)
|
||||
Fabricate(
|
||||
:permalink,
|
||||
permalink_type_value: "http://www.discourse.org",
|
||||
permalink_type: "external_url",
|
||||
)
|
||||
Fabricate(
|
||||
:permalink,
|
||||
permalink_type_value: "http://try.discourse.org",
|
||||
permalink_type: "external_url",
|
||||
)
|
||||
Fabricate(:permalink, external_url: "http://google.com")
|
||||
Fabricate(:permalink, external_url: "http://wikipedia.org")
|
||||
Fabricate(:permalink, external_url: "http://www.discourse.org")
|
||||
Fabricate(:permalink, external_url: "http://try.discourse.org")
|
||||
|
||||
get "/admin/permalinks.json", params: { filter: "discourse" }
|
||||
|
||||
@ -62,30 +36,10 @@ RSpec.describe Admin::PermalinksController do
|
||||
end
|
||||
|
||||
it "filters url and external url both" do
|
||||
Fabricate(
|
||||
:permalink,
|
||||
url: "/forum/23",
|
||||
permalink_type_value: "http://google.com",
|
||||
permalink_type: "external_url",
|
||||
)
|
||||
Fabricate(
|
||||
:permalink,
|
||||
url: "/discourse/98",
|
||||
permalink_type_value: "http://wikipedia.org",
|
||||
permalink_type: "external_url",
|
||||
)
|
||||
Fabricate(
|
||||
:permalink,
|
||||
url: "/discuss/topic/45",
|
||||
permalink_type_value: "http://discourse.org",
|
||||
permalink_type: "external_url",
|
||||
)
|
||||
Fabricate(
|
||||
:permalink,
|
||||
url: "/discuss/topic/76",
|
||||
permalink_type_value: "http://try.discourse.org",
|
||||
permalink_type: "external_url",
|
||||
)
|
||||
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")
|
||||
Fabricate(:permalink, url: "/discuss/topic/76", external_url: "http://try.discourse.org")
|
||||
|
||||
get "/admin/permalinks.json", params: { filter: "discourse" }
|
||||
|
||||
|
Reference in New Issue
Block a user