Skip to content

Commit

Permalink
Use canonical entry url prefix in permalink input
Browse files Browse the repository at this point in the history
REDMINE-20825
  • Loading branch information
tf committed Sep 20, 2024
1 parent b00b73c commit 853f65c
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 1 deletion.
3 changes: 2 additions & 1 deletion app/views/admin/entries/_permalink_inputs.html.erb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<%= form.input(:permalink,
as: :pageflow_permalink,
base_url: pretty_site_url(entry.site),
base_url: entry.site.canonical_entry_url_prefix.presence ||
pretty_site_url(entry.site),
site: entry.site,
slug_placeholder: entry.default_permalink_slug,
hint: entry.new_record? ? nil : t('pageflow.admin.entries.permalink_hint'))%>
34 changes: 34 additions & 0 deletions spec/controllers/admin/entries_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -579,6 +579,40 @@ def self.name
expect(response.body)
.not_to have_selector('input[name="entry[permalink_attributes][slug]"]')
end

it 'displays host of site in permalink input' do
user = create(:user)
account = create(:account, with_publisher: user)
account.default_site.update(cname: 'some.example.com')
create(
:permalink_directory,
path: '',
site: account.default_site
)

sign_in(user, scope: :user)
get :new

expect(response.body)
.to have_selector('.permalink_base_url', text: 'some.example.com/')
end

it 'prefers cononical entry url prefix in permalink input' do
user = create(:user)
account = create(:account, with_publisher: user)
account.default_site.update(canonical_entry_url_prefix: 'https://some.example.com/foo/')
create(
:permalink_directory,
path: '',
site: account.default_site
)

sign_in(user, scope: :user)
get :new

expect(response.body)
.to have_selector('.permalink_base_url', text: 'some.example.com/foo/')
end
end

describe '#create' do
Expand Down

0 comments on commit 853f65c

Please sign in to comment.