mirror of
https://github.com/discourse/discourse.git
synced 2024-11-22 17:06:31 -06:00
FIX: Do not show quote copy button to anon (#25471)
This was an oversight in 51016e56dd
,
anon doesn't have any need to copy quotes, just as they have
no need to open the composer with a quote prefilled.
This commit is contained in:
parent
38eef3306f
commit
304a7f3e1a
@ -260,7 +260,10 @@ export default class PostTextSelection extends Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
get canCopyQuote() {
|
get canCopyQuote() {
|
||||||
return this.siteSettings.enable_quote_copy;
|
return (
|
||||||
|
this.siteSettings.enable_quote_copy &&
|
||||||
|
this.currentUser?.get("user_option.enable_quoting")
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// on Desktop, shows the bar at the beginning of the selection
|
// on Desktop, shows the bar at the beginning of the selection
|
||||||
|
@ -8,27 +8,38 @@ describe "Post selection | Copy quote", type: :system do
|
|||||||
fab!(:post) { Fabricate(:post, topic: topic, raw: "Hello world it's time for quoting!") }
|
fab!(:post) { Fabricate(:post, topic: topic, raw: "Hello world it's time for quoting!") }
|
||||||
fab!(:current_user) { Fabricate(:admin) }
|
fab!(:current_user) { Fabricate(:admin) }
|
||||||
|
|
||||||
before do
|
context "when logged in" do
|
||||||
sign_in(current_user)
|
before do
|
||||||
cdp.allow_clipboard
|
sign_in(current_user)
|
||||||
end
|
cdp.allow_clipboard
|
||||||
|
end
|
||||||
|
|
||||||
it "copies the selection from the post the clipboard" do
|
it "copies the selection from the post the clipboard" do
|
||||||
topic_page.visit_topic(topic)
|
topic_page.visit_topic(topic)
|
||||||
|
|
||||||
select_text_range("#{topic_page.post_by_number_selector(1)} .cooked p", 0, 10)
|
select_text_range("#{topic_page.post_by_number_selector(1)} .cooked p", 0, 10)
|
||||||
topic_page.copy_quote_button.click
|
topic_page.copy_quote_button.click
|
||||||
|
|
||||||
expect(cdp.read_clipboard.chomp).to eq(<<~QUOTE.chomp)
|
expect(cdp.read_clipboard.chomp).to eq(<<~QUOTE.chomp)
|
||||||
[quote=\"#{post.user.username}, post:1, topic:#{topic.id}\"]\nHello worl\n[/quote]\n
|
[quote=\"#{post.user.username}, post:1, topic:#{topic.id}\"]\nHello worl\n[/quote]\n
|
||||||
QUOTE
|
QUOTE
|
||||||
|
end
|
||||||
|
|
||||||
|
it "does not show the copy quote button if it has been disabled" do
|
||||||
|
SiteSetting.enable_quote_copy = false
|
||||||
|
topic_page.visit_topic(topic)
|
||||||
|
|
||||||
|
select_text_range("#{topic_page.post_by_number_selector(1)} .cooked p", 0, 10)
|
||||||
|
expect(page).not_to have_css(topic_page.copy_quote_button_selector)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
it "does not show the copy quote button if it has been disabled" do
|
context "when anon" do
|
||||||
SiteSetting.enable_quote_copy = false
|
it "does not show the copy quote button to anon users" do
|
||||||
topic_page.visit_topic(topic)
|
topic_page.visit_topic(topic)
|
||||||
|
|
||||||
select_text_range("#{topic_page.post_by_number_selector(1)} .cooked p", 0, 10)
|
select_text_range("#{topic_page.post_by_number_selector(1)} .cooked p", 0, 10)
|
||||||
expect(page).not_to have_css(topic_page.copy_quote_button_selector)
|
expect(page).not_to have_css(topic_page.copy_quote_button_selector)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user