diff --git a/app/components/users/public_activity_component.rb b/app/components/users/public_activity_component.rb index 653bf89c7..61c1fbb8e 100644 --- a/app/components/users/public_activity_component.rb +++ b/app/components/users/public_activity_component.rb @@ -73,7 +73,12 @@ class Users::PublicActivityComponent < ApplicationComponent def disabled_commentables [ ("Debate" unless feature?(:debates)), - ("Budget::Investment" unless feature?(:budgets)) - ].compact + ("Budget::Investment" unless feature?(:budgets)), + (["Legislation::Question", + "Legislation::Proposal", + "Legislation::Annotation"] unless feature?(:legislation)), + (["Poll", "Poll::Question"] unless feature?(:polls)), + ("Proposal" unless feature?(:proposals)) + ].flatten.compact end end diff --git a/spec/components/users/public_activity_component_spec.rb b/spec/components/users/public_activity_component_spec.rb index 39ae4010d..2f72c8495 100644 --- a/spec/components/users/public_activity_component_spec.rb +++ b/spec/components/users/public_activity_component_spec.rb @@ -79,4 +79,29 @@ describe Users::PublicActivityComponent, controller: UsersController do end end end + + describe "comments" do + let(:user) { create(:user) } + let(:component) { Users::PublicActivityComponent.new(user) } + + it "doesn't show comments for disabled features" do + Setting["process.budgets"] = false + Setting["process.debates"] = false + Setting["process.legislation"] = false + Setting["process.polls"] = false + Setting["process.proposals"] = false + + create(:budget_investment_comment, user: user) + create(:debate_comment, user: user) + create(:legislation_annotation_comment, user: user) + create(:legislation_question_comment, user: user) + create(:legislation_proposal_comment, user: user) + create(:poll_comment, user: user) + create(:proposal_comment, user: user) + + render_inline component + + expect(page).not_to have_content "Comments" + end + end end diff --git a/spec/factories/comments.rb b/spec/factories/comments.rb index 79402c448..f55581f88 100644 --- a/spec/factories/comments.rb +++ b/spec/factories/comments.rb @@ -4,7 +4,8 @@ FactoryBot.define do user sequence(:body) { |n| "Comment body #{n}" } - %i[budget_investment debate legislation_annotation legislation_question proposal topic_with_community].each do |model| + %i[budget_investment debate legislation_annotation legislation_question legislation_proposal + poll proposal topic_with_community].each do |model| factory :"#{model}_comment" do association :commentable, factory: model end