FIX: Post moved small action links should respect subfolder installs (#24336)
This change fixes an issue with small action links (when post is moved) to add the subfolder path to the url.
This commit is contained in:
parent
1e1bb45b96
commit
4b78254065
|
@ -646,6 +646,10 @@ class Post < ActiveRecord::Base
|
|||
"#{Discourse.base_url}#{url}"
|
||||
end
|
||||
|
||||
def relative_url
|
||||
"#{Discourse.base_path}#{url}"
|
||||
end
|
||||
|
||||
def url(opts = nil)
|
||||
opts ||= {}
|
||||
|
||||
|
|
|
@ -591,7 +591,7 @@ class PostMover
|
|||
if posts.first.is_first_post?
|
||||
"[#{destination_topic.title}](#{destination_topic.relative_url})"
|
||||
else
|
||||
"[#{destination_topic.title}](#{posts.first.url})"
|
||||
"[#{destination_topic.title}](#{posts.first.relative_url})"
|
||||
end
|
||||
),
|
||||
)
|
||||
|
|
|
@ -887,6 +887,27 @@ RSpec.describe PostMover do
|
|||
expect(new_post.post_revisions.size).to eq(1)
|
||||
end
|
||||
|
||||
context "with subfolder installs" do
|
||||
before { set_subfolder "/forum" }
|
||||
|
||||
it "creates a small action with correct post url" do
|
||||
moved_to = topic.move_posts(user, [p2.id], destination_topic_id: destination_topic.id)
|
||||
small_action = topic.posts.last
|
||||
|
||||
expect(small_action.post_type).to eq(Post.types[:small_action])
|
||||
|
||||
expected_text =
|
||||
I18n.t(
|
||||
"move_posts.existing_topic_moderator_post",
|
||||
count: 1,
|
||||
topic_link: "[#{moved_to.title}](#{p2.reload.relative_url})",
|
||||
locale: :en,
|
||||
)
|
||||
|
||||
expect(small_action.raw).to eq(expected_text)
|
||||
end
|
||||
end
|
||||
|
||||
context "with read state and other stats per user" do
|
||||
def create_topic_user(user, topic, opts = {})
|
||||
notification_level = opts.delete(:notification_level) || :regular
|
||||
|
|
|
@ -2135,6 +2135,17 @@ RSpec.describe Post do
|
|||
end
|
||||
end
|
||||
|
||||
describe "relative_url" do
|
||||
it "returns the correct post url with subfolder install" do
|
||||
set_subfolder "/forum"
|
||||
post = Fabricate(:post)
|
||||
|
||||
expect(post.relative_url).to eq(
|
||||
"/forum/t/#{post.topic.slug}/#{post.topic.id}/#{post.post_number}",
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
describe "public_posts_count_per_day" do
|
||||
before do
|
||||
freeze_time DateTime.parse("2017-03-01 12:00")
|
||||
|
|
Loading…
Reference in New Issue