Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Backport 'Fix conference venues meetings visibility' to v0.26 #11913

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
64 changes: 63 additions & 1 deletion decidim-conferences/spec/system/conferences_spec.rb
Expand Up @@ -125,7 +125,7 @@
describe "when going to the conference page" do
let!(:conference) { base_conference }
let!(:proposals_component) { create(:component, :published, participatory_space: conference, manifest_name: :proposals) }
let!(:meetings_component) { create(:component, :unpublished, participatory_space: conference, manifest_name: :meetings) }
let!(:meetings_component) { create(:meeting_component, :unpublished, participatory_space: conference) }

before do
create_list(:proposal, 3, component: proposals_component)
Expand All @@ -134,6 +134,68 @@
visit decidim_conferences.conference_path(conference)
end

describe "conference venues" do
before do
meetings.empty?
allow(Decidim).to receive(:address).and_return("foo bar")

visit decidim_conferences.conference_path(conference)
end

context "when the meeting component is not published" do
let!(:meetings_component) { create(:meeting_component, :unpublished, participatory_space: conference) }
let!(:meetings) { create_list(:meeting, 3, :published, component: meetings_component) }

it "does not show the venues" do
expect(page).not_to have_content("CONFERENCE VENUES")
end
end

context "when the meeting component is published" do
let!(:meetings_component) { create(:meeting_component, :published, participatory_space: conference) }

context "when there are published meetings" do
let!(:meetings) { create_list(:meeting, 3, :published, component: meetings_component) }

it "does show the venues" do
expect(page).to have_content("CONFERENCE VENUES")
end
end

context "when there are moderated meetings" do
let!(:meetings) { create_list(:meeting, 3, :moderated, :published, component: meetings_component) }

it "does not show the venues" do
expect(page).not_to have_content("CONFERENCE VENUES")
end
end

context "when there are no published meetings" do
let!(:meetings) { create_list(:meeting, 3, published_at: nil, component: meetings_component) }

it "does not show the venues" do
expect(page).not_to have_content("CONFERENCE VENUES")
end
end

context "when there are no visible meetings" do
let!(:meetings) { create_list(:meeting, 3, :published, private_meeting: true, transparent: false, component: meetings_component) }

it "does not show the venues" do
expect(page).not_to have_content("CONFERENCE VENUES")
end
end

context "when there are visible meetings" do
let!(:meetings) { create_list(:meeting, 3, :published, private_meeting: true, transparent: true, component: meetings_component) }

it "does not show the venues" do
expect(page).to have_content("CONFERENCE VENUES")
end
end
end
end

it "shows the details of the given conference" do
within "div.hero__container" do
expect(page).to have_content(translated(conference.title, locale: :en))
Expand Down
5 changes: 3 additions & 2 deletions decidim-meetings/lib/decidim/meetings/engine.rb
Expand Up @@ -71,8 +71,9 @@ class Engine < ::Rails::Engine

Decidim.view_hooks.register(:conference_venues, priority: Decidim::ViewHooks::HIGH_PRIORITY) do |view_context|
published_components = Decidim::Component.where(participatory_space: view_context.current_participatory_space).published
meetings = Decidim::Meetings::Meeting.where(component: published_components).group_by(&:address)
meetings_geocoded = Decidim::Meetings::Meeting.where(component: published_components).geocoded
meetings = Decidim::Meetings::Meeting.visible.not_hidden.published.where(component: published_components).group_by(&:address)
meetings_geocoded = Decidim::Meetings::Meeting.visible.not_hidden.published.where(component: published_components).geocoded

next unless meetings.any?

view_context.render(
Expand Down