Skip to content

Commit

Permalink
Don't add default filter if param is provided
Browse files Browse the repository at this point in the history
  • Loading branch information
oliverguenther committed Dec 18, 2024
1 parent 1f58c3b commit 9c3953d
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 13 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
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

0 comments on commit 9c3953d

Please sign in to comment.