A platform for community discussion. Free, open, simple.
UX: don't show "me too" button on category description topics (#42444)
Krisac5e4ea747ee
diff --git a/plugins/discourse-solved/lib/discourse_solved/guardian_extensions.rb b/plugins/discourse-solved/lib/discourse_solved/guardian_extensions.rbindex 405aa4e4fe1..f8862acf4d5 100644--- a/plugins/discourse-solved/lib/discourse_solved/guardian_extensions.rb+++ b/plugins/discourse-solved/lib/discourse_solved/guardian_extensions.rb@@ -57,6 +57,7 @@ module DiscourseSolvedreturn false if topic.blank? || !authenticated?return false if topic.user_id == current_user.idreturn false if topic.private_message?+ return false if topic.is_category_topic?return false if topic.trashed? || topic.closed? || topic.archived?return false if topic.solved.present? && !SiteSetting.solved_allow_multiple_solutionsreturn false unless topic_in_support_category?(topic)@@ -68,6 +69,7 @@ module DiscourseSolveddef shared_issue_visible?(topic)return false if topic.blank?return false if topic.private_message?+ return false if topic.is_category_topic?return false if topic.trashed?return false unless topic_in_support_category?(topic)return false unless shared_issues_enabled_for_category?(topic)diff --git a/plugins/discourse-solved/spec/lib/guardian_extensions_spec.rb b/plugins/discourse-solved/spec/lib/guardian_extensions_spec.rbindex 28ca604593c..0025d12857f 100644--- a/plugins/discourse-solved/spec/lib/guardian_extensions_spec.rb+++ b/plugins/discourse-solved/spec/lib/guardian_extensions_spec.rb@@ -146,4 +146,38 @@ describe DiscourseSolved::GuardianExtensions doexpect(guardian.can_unaccept_answer?(restricted_topic, restricted_post)).to eq(false)endend++ describe "shared issues" do+ fab!(:support_category) do+ Fabricate(:category_with_definition).tap do |c|+ c.upsert_custom_fields(DiscourseSolved::ENABLE_ACCEPTED_ANSWERS_CUSTOM_FIELD => "true")+ end+ end+ fab!(:support_topic) { Fabricate(:topic_with_op, category: support_category, user: other_user) }++ before do+ SiteSetting.enable_solved_shared_issues = true+ DiscourseSolved::AcceptedAnswerCache.reset_accepted_answer_cache+ end++ describe ".can_create_shared_issue?" do+ it "returns true for a regular topic in a support category" do+ expect(guardian.can_create_shared_issue?(support_topic)).to eq(true)+ end++ it "returns false for the category definition topic" do+ expect(guardian.can_create_shared_issue?(support_category.topic)).to eq(false)+ end+ end++ describe ".shared_issue_visible?" do+ it "returns true for a regular topic in a support category" do+ expect(guardian.shared_issue_visible?(support_topic)).to eq(true)+ end++ it "returns false for the category definition topic" do+ expect(guardian.shared_issue_visible?(support_category.topic)).to eq(false)+ end+ end+ endend