Skip to content

Commit

Permalink
Hide last activities on breadcrumb dropdown when organization is conf…
Browse files Browse the repository at this point in the history
…igured to force authentication (decidim#12685)

* Do not display latest activities cell for not signed in users and forced authentication

* Add test

* Use safe navigation operator

* Update decidim-core/spec/system/homepage_spec.rb

Co-authored-by: Andrés Pereira de Lucena <[email protected]>

* Hide promoted space from menu dropdown if not signed in user and forced authentication

* Update decidim-core/spec/system/homepage_spec.rb

Co-authored-by: Andrés Pereira de Lucena <[email protected]>

---------

Co-authored-by: Andrés Pereira de Lucena <[email protected]>
  • Loading branch information
entantoencuanto and andreslucena authored Apr 17, 2024
1 parent 11c6d6b commit 2c396dc
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ module ContentBlocks
# A cell to be rendered as a content block with the latest activities performed
# in a Decidim Organization.
class MenuBreadcrumbLastActivityCell < LastActivityCell
def show
return if current_user.blank? && current_organization&.force_users_to_authenticate_before_access_organization

super
end

private

def activities
Expand Down
2 changes: 2 additions & 0 deletions decidim-core/app/helpers/decidim/menu_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ def footer_menu
end

def menu_highlighted_participatory_process
return if current_user.blank? && current_organization&.force_users_to_authenticate_before_access_organization

@menu_highlighted_participatory_process ||= (
# The queries already include the order by weight
Decidim::ParticipatoryProcesses::OrganizationParticipatoryProcesses.new(current_organization) |
Expand Down
47 changes: 47 additions & 0 deletions decidim-core/spec/system/homepage_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,53 @@
end
end

context "when organization forces users to authenticate before access" do
let(:organization) do
create(
:organization,
official_url:,
force_users_to_authenticate_before_access_organization: true
)
end

context "when there are site activities and user is not authenticated" do
let(:participatory_space) { create(:participatory_process, organization:) }
let(:component) do
create(:component, :published, participatory_space:)
end
let(:commentable) { create(:dummy_resource, component:) }
let(:comment) { create(:comment, commentable:) }
let!(:action_log) do
create(:action_log, created_at: 1.day.ago, action: "create", visibility: "public-only", resource: comment, organization:, participatory_space:)
end

before do
visit current_path
find_by_id("main-dropdown-summary").hover
end

it "does not show last activity section on menu bar main dropdown" do
expect(page).to have_no_content(translated(comment.body))
expect(page).to have_no_link("New comment")
expect(page).to have_no_link("Last activity")
end
end

context "when there is a promoted participatory space and user is not authenticated" do
let!(:participatory_space) { create(:participatory_process, :promoted, title:, organization:) }
let(:title) { { en: "Promoted, promoted, promoted!!!" } }

before do
visit current_path
find_by_id("main-dropdown-summary").hover
end

it "does not show last activity section on menu bar main dropdown" do
expect(page).to have_no_content(title[:en])
end
end
end

describe "includes statistics" do
let!(:users) { create_list(:user, 4, :confirmed, organization:) }
let!(:participatory_process) do
Expand Down

0 comments on commit 2c396dc

Please sign in to comment.