Skip to content

Commit

Permalink
Correctly use the project filter when marking all notifications as read
Browse files Browse the repository at this point in the history
  • Loading branch information
HDinger authored and oliverguenther committed Aug 12, 2024
1 parent 70141f2 commit 3ee1834
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 5 deletions.
2 changes: 1 addition & 1 deletion app/controllers/notifications_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ def filtered_query
case params[:filter]
when "project"
id = params[:name].to_i
query.where(:project, "=", [id])
query.where(:project_id, "=", [id])
when "reason"
query.where(:reason, "=", [params[:name]])
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,13 @@
context "with more the 100 notifications" do
let(:notifications) do
attributes = { recipient:, project: project1, resource: work_package }
attributes_project2 = { recipient:, project: project2, resource: work_package2 }

# rubocop:disable FactoryBot/ExcessiveCreateList
create_list(:notification, 100, attributes.merge(reason: :mentioned)) +
create_list(:notification, 105, attributes.merge(reason: :watched))
create_list(:notification, 105, attributes.merge(reason: :watched)) +
create_list(:notification, 50, attributes_project2.merge(reason: :assigned))
# rubocop:enable FactoryBot/ExcessiveCreateList
end

it "can dismiss all notifications of the currently selected filter" do
Expand All @@ -112,8 +117,8 @@
center.expect_bell_count "99+"
center.open

# side menu items show full count of notifications (inbox has one more due to the "Created" notification)
side_menu.expect_item_with_count "Inbox", 206
# side menu items show full count of notifications (inbox has two more due to the "Created" notification)
side_menu.expect_item_with_count "Inbox", 257
side_menu.expect_item_with_count "Mentioned", 100
side_menu.expect_item_with_count "Watcher", 105

Expand All @@ -124,10 +129,21 @@
wait_for_network_idle

center.expect_bell_count "99+"
side_menu.expect_item_with_count "Inbox", 101
side_menu.expect_item_with_count "Inbox", 152
side_menu.expect_item_with_count "Mentioned", 100
side_menu.expect_item_with_no_count "Watcher"

# select a project and mark all as read
side_menu.click_item project2.name
side_menu.finished_loading
center.mark_all_read
wait_for_network_idle

center.expect_bell_count "99+"
side_menu.expect_item_with_count "Inbox", 101
side_menu.expect_item_with_count "Mentioned", 100
side_menu.expect_no_item project2.name

# select inbox and mark all as read
side_menu.click_item "Inbox"
side_menu.finished_loading
Expand Down

0 comments on commit 3ee1834

Please sign in to comment.