A platform for community discussion. Free, open, simple.
DEV: Fix spec for post menu (#25100)
Martin Brennan4e6d4193ea22
diff --git a/app/models/post.rb b/app/models/post.rbindex 473e306911a..30dfb179862 100644--- a/app/models/post.rb+++ b/app/models/post.rb@@ -645,12 +645,12 @@ class Post < ActiveRecord::Basepublish_change_to_clients!(:acted)end- def full_url- "#{Discourse.base_url}#{url}"+ def full_url(opts = {})+ "#{Discourse.base_url}#{url(opts)}"end- def relative_url- "#{Discourse.base_path}#{url}"+ def relative_url(opts = {})+ "#{Discourse.base_path}#{url(opts)}"enddef url(opts = nil)@@ -685,7 +685,11 @@ class Post < ActiveRecord::Baseresult = +"/t/"result << "#{slug}/" if !opts[:without_slug]- "#{result}#{topic_id}/#{post_number}"+ if post_number == 1 && opts[:share_url]+ "#{result}#{topic_id}"+ else+ "#{result}#{topic_id}/#{post_number}"+ endenddef self.urls(post_ids)diff --git a/spec/system/post_menu_spec.rb b/spec/system/post_menu_spec.rbindex 2755df4775c..67fbb247129 100644--- a/spec/system/post_menu_spec.rb+++ b/spec/system/post_menu_spec.rb@@ -2,7 +2,8 @@describe "Post menu", type: :system, js: true dofab!(:current_user) { Fabricate(:user) }- fab!(:post)+ fab!(:topic)+ fab!(:post) { Fabricate(:post, topic: topic) }let(:topic_page) { PageObjects::Pages::Topic.new }@@ -13,10 +14,12 @@ describe "Post menu", type: :system, js: true dobefore { cdp.allow_clipboard }- xit "copies the absolute link to the post when clicked" do+ it "copies the absolute link to the post when clicked" dotopic_page.visit_topic(post.topic)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}",+ )endendend