mirror of
https://github.com/discourse/discourse.git
synced 2025-02-05 19:11:13 +00:00
DEV: Fix spec for post menu (#25100)
Followup to b92993fceea107c6f1cbc04eac6008827a61a000 I ran out of time to get this working for that fix, also here I am making the post.url method have parity with post.shareUrl in JS, which omits the post number for the first post.
This commit is contained in:
parent
69383e9afd
commit
4e6d4193ea
@ -645,12 +645,12 @@ class Post < ActiveRecord::Base
|
|||||||
publish_change_to_clients!(:acted)
|
publish_change_to_clients!(:acted)
|
||||||
end
|
end
|
||||||
|
|
||||||
def full_url
|
def full_url(opts = {})
|
||||||
"#{Discourse.base_url}#{url}"
|
"#{Discourse.base_url}#{url(opts)}"
|
||||||
end
|
end
|
||||||
|
|
||||||
def relative_url
|
def relative_url(opts = {})
|
||||||
"#{Discourse.base_path}#{url}"
|
"#{Discourse.base_path}#{url(opts)}"
|
||||||
end
|
end
|
||||||
|
|
||||||
def url(opts = nil)
|
def url(opts = nil)
|
||||||
@ -685,8 +685,12 @@ class Post < ActiveRecord::Base
|
|||||||
result = +"/t/"
|
result = +"/t/"
|
||||||
result << "#{slug}/" if !opts[:without_slug]
|
result << "#{slug}/" if !opts[:without_slug]
|
||||||
|
|
||||||
|
if post_number == 1 && opts[:share_url]
|
||||||
|
"#{result}#{topic_id}"
|
||||||
|
else
|
||||||
"#{result}#{topic_id}/#{post_number}"
|
"#{result}#{topic_id}/#{post_number}"
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def self.urls(post_ids)
|
def self.urls(post_ids)
|
||||||
ids = post_ids.map { |u| u }
|
ids = post_ids.map { |u| u }
|
||||||
|
@ -2,7 +2,8 @@
|
|||||||
|
|
||||||
describe "Post menu", type: :system, js: true do
|
describe "Post menu", type: :system, js: true do
|
||||||
fab!(:current_user) { Fabricate(:user) }
|
fab!(:current_user) { Fabricate(:user) }
|
||||||
fab!(:post)
|
fab!(:topic)
|
||||||
|
fab!(:post) { Fabricate(:post, topic: topic) }
|
||||||
|
|
||||||
let(:topic_page) { PageObjects::Pages::Topic.new }
|
let(:topic_page) { PageObjects::Pages::Topic.new }
|
||||||
|
|
||||||
@ -13,10 +14,12 @@ describe "Post menu", type: :system, js: true do
|
|||||||
|
|
||||||
before { cdp.allow_clipboard }
|
before { cdp.allow_clipboard }
|
||||||
|
|
||||||
xit "copies the absolute link to the post when clicked" do
|
it "copies the absolute link to the post when clicked" do
|
||||||
topic_page.visit_topic(post.topic)
|
topic_page.visit_topic(post.topic)
|
||||||
topic_page.click_post_action_button(post, :copy_link)
|
topic_page.click_post_action_button(post, :copy_link)
|
||||||
expect(cdp.read_clipboard).to eq(post.full_url + "?u=#{current_user.username}")
|
expect(cdp.read_clipboard).to eq(
|
||||||
|
post.full_url(share_url: true) + "?u=#{current_user.username}",
|
||||||
|
)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user