Skip to content

Commit

Permalink
Merge pull request #17493 from opf/fix/meeting-participant-invite
Browse files Browse the repository at this point in the history
Fix invited user in meetings
  • Loading branch information
dombesz authored Dec 18, 2024
2 parents 82480b4 + 27bedfb commit a8fc3ad
Show file tree
Hide file tree
Showing 5 changed files with 123 additions and 16 deletions.
2 changes: 1 addition & 1 deletion modules/meeting/app/controllers/meetings_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ def apply_time_filter_and_sort(query)
end

def apply_default_filter_if_none_given(query)
return if query.filters.any?
return if params.key?(:filters)

query.where("invited_user_id", "=", [User.current.id.to_s])
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def set_attributes(params)

super

set_participants(participants) if participants
set_participants(participants) if participants.present?
end

def set_default_attributes(_params)
Expand Down
42 changes: 30 additions & 12 deletions modules/meeting/spec/features/meetings_index_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,47 +49,47 @@
end
end

let(:meeting) do
shared_let(:meeting) do
create(:meeting,
project:,
title: "Awesome meeting today!",
start_time: Time.current)
end
let(:tomorrows_meeting) do
shared_let(:tomorrows_meeting) do
create(:meeting,
project:,
title: "Awesome meeting tomorrow!",
start_time: 1.day.from_now,
duration: 2.0,
location: "no-protocol.com")
end
let(:meeting_with_no_location) do
shared_let(:meeting_with_no_location) do
create(:meeting,
project:,
title: "Boring meeting without a location!",
start_time: 1.day.from_now,
location: "")
end
let(:meeting_with_malicious_location) do
shared_let(:meeting_with_malicious_location) do
create(:meeting,
project:,
title: "Sneaky meeting!",
start_time: 1.day.from_now,
location: "<script>alert('Description');</script>")
end
let(:yesterdays_meeting) do
shared_let(:yesterdays_meeting) do
create(:meeting, project:, title: "Awesome meeting yesterday!", start_time: 1.day.ago)
end

let(:other_project_meeting) do
shared_let(:other_project_meeting) do
create(:meeting,
project: other_project,
title: "Awesome other project meeting!",
start_time: 2.days.from_now,
duration: 2.0,
location: "not-a-url")
end
let(:ongoing_meeting) do
shared_let(:ongoing_meeting) do
create(:meeting, project:, title: "Awesome ongoing meeting!", start_time: 30.minutes.ago)
end

Expand All @@ -109,6 +109,22 @@ def invite_to_meeting(meeting)
end

shared_examples "sidebar filtering" do |context:|
context "when showing all meetings without invitations" do
it "does not show under My meetings, but in All meetings" do
meetings_page.visit!
expect(page).to have_content "There is currently nothing to display."

meetings_page.set_sidebar_filter "All meetings"

# It now includes the ongoing meeting I'm not invited to
if context == :global
[ongoing_meeting, meeting, tomorrows_meeting, other_project_meeting]
else
[ongoing_meeting, meeting, tomorrows_meeting]
end
end
end

context "when showing all meetings with the sidebar" do
before do
ongoing_meeting
Expand All @@ -124,11 +140,13 @@ def invite_to_meeting(meeting)
end

it "shows all upcoming and ongoing meetings", :aggregate_failures do
expected_upcoming_meetings = if context == :global
[ongoing_meeting, meeting, tomorrows_meeting, other_project_meeting]
else
[ongoing_meeting, meeting, tomorrows_meeting]
end
expected_upcoming_meetings =
if context == :global
[ongoing_meeting, meeting, tomorrows_meeting, meeting_with_no_location,
meeting_with_malicious_location, other_project_meeting]
else
[ongoing_meeting, meeting, tomorrows_meeting, meeting_with_no_location, meeting_with_malicious_location]
end

meetings_page.expect_meetings_listed_in_order(*expected_upcoming_meetings)
meetings_page.expect_meetings_not_listed(yesterdays_meeting)
Expand Down
2 changes: 0 additions & 2 deletions modules/meeting/spec/requests/meetings_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,6 @@
let(:send_notifications) { "1" }

before do
meeting.participants.create!(user:, invited: true)

subject
perform_enqueued_jobs
end
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
#-- copyright
# OpenProject is an open source project management software.
# Copyright (C) the OpenProject GmbH
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License version 3.
#
# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
# Copyright (C) 2006-2013 Jean-Philippe Lang
# Copyright (C) 2010-2013 the ChiliProject Team
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
# See COPYRIGHT and LICENSE files for more details.
#++

require "spec_helper"

RSpec.describe Meetings::CreateService, "integration", type: :model do
shared_let(:project) { create(:project, enabled_module_names: %i[meetings]) }
shared_let(:user) do
create(:user, member_with_permissions: { project => %i(view_meetings create_meetings) })
end
shared_let(:other_user) do
create(:user, member_with_permissions: { project => %i(view_meetings) })
end
let(:instance) { described_class.new(user:) }
let(:service_result) { subject }
let(:series) { service_result.result }
let(:params) { {} }
let(:default_params) do
{
project:,
title: "My test meeting"
}
end

subject { instance.call(**params, **default_params) }

describe "participants" do
context "when passed" do
let(:params) do
{
participants_attributes: [
{ user_id: other_user.id, invited: true, attended: true }
]
}
end

it "creates that meeting with that one participant" do
expect(subject).to be_success
expect(subject.result.participants.count).to eq(1)
expect(subject.result.participants.first.user).to eq(other_user)
end
end

context "when passed as empty" do
let(:params) do
{
participants_attributes: {}
}
end

it "creates the meeting with default" do
expect(subject).to be_success
expect(subject.result.participants.count).to eq(1)
expect(subject.result.participants.first.user).to eq(user)
end
end

context "when not passed" do
it "creates the meeting with default" do
expect(subject).to be_success
expect(subject.result.participants.count).to eq(1)
expect(subject.result.participants.first.user).to eq(user)
end
end
end
end

0 comments on commit a8fc3ad

Please sign in to comment.