OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
add bulk read/unread enpoint for notifications
ulferts261b0fa5c3a8
diff --git a/app/models/queries/notifications.rb b/app/models/queries/notifications.rbindex 47c5689d622..40143482e51 100644--- a/app/models/queries/notifications.rb+++ b/app/models/queries/notifications.rb@@ -32,6 +32,9 @@ module Queries::NotificationsQueries::Register.filter Queries::Notifications::NotificationQuery,Queries::Notifications::Filters::ReadIanFilter+ Queries::Register.filter Queries::Notifications::NotificationQuery,+ Queries::Notifications::Filters::IdFilter+Queries::Register.order Queries::Notifications::NotificationQuery,Queries::Notifications::Orders::DefaultOrderdiff --git a/app/models/queries/notifications/filters/id_filter.rb b/app/models/queries/notifications/filters/id_filter.rbnew file mode 100644index 00000000000..ba0dccf4834--- /dev/null+++ b/app/models/queries/notifications/filters/id_filter.rb@@ -0,0 +1,45 @@+#-- encoding: UTF-8++#-- copyright+# OpenProject is an open source project management software.+# Copyright (C) 2012-2021 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 docs/COPYRIGHT.rdoc for more details.+#++++class Queries::Notifications::Filters::IdFilter < Queries::Notifications::Filters::NotificationFilter+ def allowed_values+ Notification+ .recipient(User.current)+ .pluck(:id, :id)+ end++ def type+ :list+ end++ def self.key+ :id+ end+enddiff --git a/frontend/src/app/core/apiv3/endpoints/notifications/apiv3-notification-paths.ts b/frontend/src/app/core/apiv3/endpoints/notifications/apiv3-notification-paths.tsindex 8330794dd58..83fe5303c65 100644--- a/frontend/src/app/core/apiv3/endpoints/notifications/apiv3-notification-paths.ts+++ b/frontend/src/app/core/apiv3/endpoints/notifications/apiv3-notification-paths.ts@@ -39,7 +39,7 @@ export class Apiv3NotificationPaths extends APIv3GettableResource<InAppNotificatreturn this.http.post(- this.path + '/readIAN',+ this.path + '/read_ian',{},{withCredentials: true,@@ -52,7 +52,7 @@ export class Apiv3NotificationPaths extends APIv3GettableResource<InAppNotificatreturn this.http.post(- this.path + '/unreadIAN',+ this.path + '/unread_ian',{},{withCredentials: true,diff --git a/lib/api/v3/notifications/notifications_api.rb b/lib/api/v3/notifications/notifications_api.rbindex 776b924fa95..21462216fc6 100644--- a/lib/api/v3/notifications/notifications_api.rb+++ b/lib/api/v3/notifications/notifications_api.rb@@ -35,35 +35,71 @@ module APIauthorize_by_with_raise current_user.logged?end+ helpers do+ def notification_query+ @notification_query ||= ParamsToQueryService+ .new(Notification, current_user)+ .call(params)+ end++ def bulk_update_status(attributes)+ if notification_query.valid?+ notification_query.results.update_all({ updated_at: Time.zone.now }.merge(attributes))+ status 204+ else+ raise ::API::Errors::InvalidQuery.new(notification_query.errors.full_messages)+ end+ end+ end+get &::API::V3::Utilities::Endpoints::Index.new(model: Notification, scope: -> { Notification.recipient(current_user) }).mount+ post :read_ian do+ bulk_update_status(read_ian: true)+ end++ post :unread_ian do+ bulk_update_status(read_ian: false)+ end++ post :read_email do+ bulk_update_status(read_email: true)+ end++ post :unread_email do+ bulk_update_status(read_email: false)+ end+route_param :id, type: Integer, desc: 'Notification ID' doafter_validation do@notification = Notification.recipient(current_user).find(params[:id])end+ helpers do+ def update_status(attributes)+ @notification.update_columns({ updated_at: Time.zone.now }.merge(attributes))+ status 204+ end+ end+get &::API::V3::Utilities::Endpoints::Show.new(model: Notification).mount- post :readIAN do- @notification.update_column(:read_ian, true)- status 204+ post :read_ian do+ update_status(read_ian: true)end- post :unreadIAN do- @notification.update_column(:read_ian, false)- status 204+ post :unread_ian do+ update_status(read_ian: false)end- post :readEmail do- @notification.update_column(:read_email, true)- status 204+ post :read_email do+ update_status(read_email: true)end- post :unreadEmail do- @notification.update_column(:read_email, false)- status 204+ post :unread_email do+ update_status(read_email: false)endendenddiff --git a/lib/api/v3/utilities/path_helper.rb b/lib/api/v3/utilities/path_helper.rbindex 6900707cab7..d153c067e94 100644--- a/lib/api/v3/utilities/path_helper.rb+++ b/lib/api/v3/utilities/path_helper.rb@@ -221,20 +221,36 @@ module APIindex :notificationshow :notification+ def self.notification_bulk_read_ian+ "#{notifications}/read_ian"+ end++ def self.notification_bulk_unread_ian+ "#{notifications}/unread_ian"+ end++ def self.notification_bulk_read_email+ "#{notifications}/read_email"+ end++ def self.notification_bulk_unread_email+ "#{notifications}/unread_email"+ end+def self.notification_read_ian(id)- "#{notification(id)}/readIAN"+ "#{notification(id)}/read_ian"enddef self.notification_unread_ian(id)- "#{notification(id)}/unreadIAN"+ "#{notification(id)}/unread_ian"enddef self.notification_read_email(id)- "#{notification(id)}/readEmail"+ "#{notification(id)}/read_email"enddef self.notification_unread_email(id)- "#{notification(id)}/unreadEmail"+ "#{notification(id)}/unread_email"endindex :placeholder_userdiff --git a/spec/lib/api/v3/utilities/path_helper_spec.rb b/spec/lib/api/v3/utilities/path_helper_spec.rbindex 55add70602f..142ff97040a 100644--- a/spec/lib/api/v3/utilities/path_helper_spec.rb+++ b/spec/lib/api/v3/utilities/path_helper_spec.rb@@ -218,6 +218,59 @@ describe ::API::V3::Utilities::PathHelper doit_behaves_like 'show', :newsend+ describe 'notifications paths' do+ it_behaves_like 'index', :notifications+ it_behaves_like 'show', :notification++ describe '#notification_bulk_read_ian' do+ subject { helper.notification_bulk_read_ian }++ it_behaves_like 'api v3 path', '/notifications/read_ian'+ end++ describe '#notification_bulk_unread_ian' do+ subject { helper.notification_bulk_unread_ian }++ it_behaves_like 'api v3 path', '/notifications/unread_ian'+ end++ describe '#notification_bulk_read_email' do+ subject { helper.notification_bulk_read_email }++ it_behaves_like 'api v3 path', '/notifications/read_email'+ end++ describe '#notification_bulk_unread_email' do+ subject { helper.notification_bulk_unread_email }++ it_behaves_like 'api v3 path', '/notifications/unread_email'+ end++ describe '#notification_read_ian' do+ subject { helper.notification_read_ian(42) }++ it_behaves_like 'api v3 path', '/notifications/42/read_ian'+ end++ describe '#notification_unread_ian' do+ subject { helper.notification_unread_ian(42) }++ it_behaves_like 'api v3 path', '/notifications/42/unread_ian'+ end++ describe '#notification_read_email' do+ subject { helper.notification_read_email(42) }++ it_behaves_like 'api v3 path', '/notifications/42/read_email'+ end++ describe '#notification_unread_email' do+ subject { helper.notification_unread_email(42) }++ it_behaves_like 'api v3 path', '/notifications/42/unread_email'+ end+ end+describe 'markup paths' dodescribe '#render_markup' dosubject { helper.render_markup(link: 'link-ish') }diff --git a/spec/models/queries/notifications/filters/id_filter_spec.rb b/spec/models/queries/notifications/filters/id_filter_spec.rbnew file mode 100644index 00000000000..01075e5c97e--- /dev/null+++ b/spec/models/queries/notifications/filters/id_filter_spec.rb@@ -0,0 +1,41 @@+#-- encoding: UTF-8++#-- copyright+# OpenProject is an open source project management software.+# Copyright (C) 2012-2021 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 docs/COPYRIGHT.rdoc for more details.+#++++require 'spec_helper'++describe Queries::Notifications::Filters::IdFilter, type: :model do+ it_behaves_like 'basic query filter' do+ let(:class_key) { :id }+ let(:type) { :list }+ let(:model) { Notification }+ let(:attribute) { :id }+ let(:values) { ['5'] }+ end+enddiff --git a/spec/requests/api/v3/notifications/bulk_read_email_resource_spec.rb b/spec/requests/api/v3/notifications/bulk_read_email_resource_spec.rbnew file mode 100644index 00000000000..0f343768277--- /dev/null+++ b/spec/requests/api/v3/notifications/bulk_read_email_resource_spec.rb@@ -0,0 +1,116 @@+#-- encoding: UTF-8++#-- copyright+# OpenProject is an open source project management software.+# Copyright (C) 2012-2020 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 docs/COPYRIGHT.rdoc for more details.++require 'spec_helper'++describe ::API::V3::Notifications::NotificationsAPI,+ 'bulk set read status',+ type: :request,+ content_type: :json do+ include API::V3::Utilities::PathHelper++ shared_let(:recipient) { FactoryBot.create :user }+ shared_let(:other_recipient) { FactoryBot.create :user }+ shared_let(:notification1) { FactoryBot.create :notification, recipient: recipient }+ shared_let(:notification2) { FactoryBot.create :notification, recipient: recipient }+ shared_let(:notification3) { FactoryBot.create :notification, recipient: recipient }+ shared_let(:other_user_notification) { FactoryBot.create :notification, recipient: other_recipient }++ let(:filters) { nil }++ let(:read_path) do+ api_v3_paths.path_for :notification_bulk_read_email, filters: filters+ end++ let(:parsed_response) { JSON.parse(last_response.body) }++ before do+ login_as current_user++ post read_path+ end++ describe 'POST /api/v3/notifications/read_email' do+ let(:current_user) { recipient }++ it 'returns 204' do+ expect(last_response.status)+ .to eql(204)+ end++ it 'sets all the current users`s notifications to read' do+ expect(::Notification.where(id: [notification1.id, notification2.id, notification3.id]).pluck(:read_email))+ .to all(be_truthy)++ expect(::Notification.where(id: [other_user_notification]).pluck(:read_email))+ .to all(be_falsey)+ end++ context 'with a filter for id' do+ let(:filters) do+ [+ {+ 'id' => {+ 'operator' => '=',+ 'values' => [notification1.id.to_s, notification2.id.to_s]++ }+ }+ ]+ end++ it 'sets the current users`s notifications matching the filter to read' do+ expect(::Notification.where(id: [notification1.id, notification2.id]).pluck(:read_email))+ .to all(be_truthy)++ expect(::Notification.where(id: [other_user_notification, notification3.id]).pluck(:read_email))+ .to all(be_falsey)+ end+ end++ context 'with an invalid filter' do+ let(:filters) do+ [+ {+ 'bogus' => {+ 'operator' => '=',+ 'values' => []++ }+ }+ ]+ end++ it 'returns 400' do+ expect(last_response.status)+ .to eql(400)+ end+ end+ end+enddiff --git a/spec/requests/api/v3/notifications/bulk_read_ian_resource_spec.rb b/spec/requests/api/v3/notifications/bulk_read_ian_resource_spec.rbnew file mode 100644index 00000000000..97c4ae73f02--- /dev/null+++ b/spec/requests/api/v3/notifications/bulk_read_ian_resource_spec.rb@@ -0,0 +1,116 @@+#-- encoding: UTF-8++#-- copyright+# OpenProject is an open source project management software.+# Copyright (C) 2012-2020 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 docs/COPYRIGHT.rdoc for more details.++require 'spec_helper'++describe ::API::V3::Notifications::NotificationsAPI,+ 'bulk set read status',+ type: :request,+ content_type: :json do+ include API::V3::Utilities::PathHelper++ shared_let(:recipient) { FactoryBot.create :user }+ shared_let(:other_recipient) { FactoryBot.create :user }+ shared_let(:notification1) { FactoryBot.create :notification, recipient: recipient }+ shared_let(:notification2) { FactoryBot.create :notification, recipient: recipient }+ shared_let(:notification3) { FactoryBot.create :notification, recipient: recipient }+ shared_let(:other_user_notification) { FactoryBot.create :notification, recipient: other_recipient }++ let(:filters) { nil }++ let(:read_path) do+ api_v3_paths.path_for :notification_bulk_read_ian, filters: filters+ end++ let(:parsed_response) { JSON.parse(last_response.body) }++ before do+ login_as current_user++ post read_path+ end++ describe 'POST /api/v3/notifications/read_ian' do+ let(:current_user) { recipient }++ it 'returns 204' do+ expect(last_response.status)+ .to eql(204)+ end++ it 'sets all the current users`s notifications to read' do+ expect(::Notification.where(id: [notification1.id, notification2.id, notification3.id]).pluck(:read_ian))+ .to all(be_truthy)++ expect(::Notification.where(id: [other_user_notification]).pluck(:read_ian))+ .to all(be_falsey)+ end++ context 'with a filter for id' do+ let(:filters) do+ [+ {+ 'id' => {+ 'operator' => '=',+ 'values' => [notification1.id.to_s, notification2.id.to_s]++ }+ }+ ]+ end++ it 'sets the current users`s notifications matching the filter to read' do+ expect(::Notification.where(id: [notification1.id, notification2.id]).pluck(:read_ian))+ .to all(be_truthy)++ expect(::Notification.where(id: [other_user_notification, notification3.id]).pluck(:read_ian))+ .to all(be_falsey)+ end+ end++ context 'with an invalid filter' do+ let(:filters) do+ [+ {+ 'bogus' => {+ 'operator' => '=',+ 'values' => []++ }+ }+ ]+ end++ it 'returns 400' do+ expect(last_response.status)+ .to eql(400)+ end+ end+ end+enddiff --git a/spec/requests/api/v3/notifications/bulk_unread_email_resource_spec.rb b/spec/requests/api/v3/notifications/bulk_unread_email_resource_spec.rbnew file mode 100644index 00000000000..16d67399b1c--- /dev/null+++ b/spec/requests/api/v3/notifications/bulk_unread_email_resource_spec.rb@@ -0,0 +1,116 @@+#-- encoding: UTF-8++#-- copyright+# OpenProject is an open source project management software.+# Copyright (C) 2012-2020 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 docs/COPYRIGHT.rdoc for more details.++require 'spec_helper'++describe ::API::V3::Notifications::NotificationsAPI,+ 'bulk unset read status',+ type: :request,+ content_type: :json do+ include API::V3::Utilities::PathHelper++ shared_let(:recipient) { FactoryBot.create :user }+ shared_let(:other_recipient) { FactoryBot.create :user }+ shared_let(:notification1) { FactoryBot.create :notification, recipient: recipient, read_email: true }+ shared_let(:notification2) { FactoryBot.create :notification, recipient: recipient, read_email: true }+ shared_let(:notification3) { FactoryBot.create :notification, recipient: recipient, read_email: true }+ shared_let(:other_user_notification) { FactoryBot.create :notification, recipient: other_recipient, read_email: true }++ let(:filters) { nil }++ let(:read_path) do+ api_v3_paths.path_for :notification_bulk_unread_email, filters: filters+ end++ let(:parsed_response) { JSON.parse(last_response.body) }++ before do+ login_as current_user++ post read_path+ end++ describe 'POST /api/v3/notifications/unread_email' do+ let(:current_user) { recipient }++ it 'returns 204' do+ expect(last_response.status)+ .to eql(204)+ end++ it 'sets all the current users`s notifications to read' do+ expect(::Notification.where(id: [notification1.id, notification2.id, notification3.id]).pluck(:read_email))+ .to all(be_falsey)++ expect(::Notification.where(id: [other_user_notification]).pluck(:read_email))+ .to all(be_truthy)+ end++ context 'with a filter for id' do+ let(:filters) do+ [+ {+ 'id' => {+ 'operator' => '=',+ 'values' => [notification1.id.to_s, notification2.id.to_s]++ }+ }+ ]+ end++ it 'sets the current users`s notifications matching the filter to read' do+ expect(::Notification.where(id: [notification1.id, notification2.id]).pluck(:read_email))+ .to all(be_falsey)++ expect(::Notification.where(id: [other_user_notification, notification3.id]).pluck(:read_email))+ .to all(be_truthy)+ end+ end++ context 'with an invalid filter' do+ let(:filters) do+ [+ {+ 'bogus' => {+ 'operator' => '=',+ 'values' => []++ }+ }+ ]+ end++ it 'returns 400' do+ expect(last_response.status)+ .to eql(400)+ end+ end+ end+enddiff --git a/spec/requests/api/v3/notifications/bulk_unread_ian_resource_spec.rb b/spec/requests/api/v3/notifications/bulk_unread_ian_resource_spec.rbnew file mode 100644index 00000000000..20d2eb337b6--- /dev/null+++ b/spec/requests/api/v3/notifications/bulk_unread_ian_resource_spec.rb@@ -0,0 +1,116 @@+#-- encoding: UTF-8++#-- copyright+# OpenProject is an open source project management software.+# Copyright (C) 2012-2020 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 docs/COPYRIGHT.rdoc for more details.++require 'spec_helper'++describe ::API::V3::Notifications::NotificationsAPI,+ 'bulk unset read status',+ type: :request,+ content_type: :json do+ include API::V3::Utilities::PathHelper++ shared_let(:recipient) { FactoryBot.create :user }+ shared_let(:other_recipient) { FactoryBot.create :user }+ shared_let(:notification1) { FactoryBot.create :notification, recipient: recipient, read_ian: true }+ shared_let(:notification2) { FactoryBot.create :notification, recipient: recipient, read_ian: true }+ shared_let(:notification3) { FactoryBot.create :notification, recipient: recipient, read_ian: true }+ shared_let(:other_user_notification) { FactoryBot.create :notification, recipient: other_recipient, read_ian: true }++ let(:filters) { nil }++ let(:read_path) do+ api_v3_paths.path_for :notification_bulk_unread_ian, filters: filters+ end++ let(:parsed_response) { JSON.parse(last_response.body) }++ before do+ login_as current_user++ post read_path+ end++ describe 'POST /api/v3/notifications/unread_ian' do+ let(:current_user) { recipient }++ it 'returns 204' do+ expect(last_response.status)+ .to eql(204)+ end++ it 'sets all the current users`s notifications to read' do+ expect(::Notification.where(id: [notification1.id, notification2.id, notification3.id]).pluck(:read_ian))+ .to all(be_falsey)++ expect(::Notification.where(id: [other_user_notification]).pluck(:read_ian))+ .to all(be_truthy)+ end++ context 'with a filter for id' do+ let(:filters) do+ [+ {+ 'id' => {+ 'operator' => '=',+ 'values' => [notification1.id.to_s, notification2.id.to_s]++ }+ }+ ]+ end++ it 'sets the current users`s notifications matching the filter to read' do+ expect(::Notification.where(id: [notification1.id, notification2.id]).pluck(:read_ian))+ .to all(be_falsey)++ expect(::Notification.where(id: [other_user_notification, notification3.id]).pluck(:read_ian))+ .to all(be_truthy)+ end+ end++ context 'with an invalid filter' do+ let(:filters) do+ [+ {+ 'bogus' => {+ 'operator' => '=',+ 'values' => []++ }+ }+ ]+ end++ it 'returns 400' do+ expect(last_response.status)+ .to eql(400)+ end+ end+ end+enddiff --git a/spec/requests/api/v3/notifications/read_email_resource_spec.rb b/spec/requests/api/v3/notifications/read_email_resource_spec.rbindex 6a980a6bb1e..89b822d807d 100644--- a/spec/requests/api/v3/notifications/read_email_resource_spec.rb+++ b/spec/requests/api/v3/notifications/read_email_resource_spec.rb@@ -31,19 +31,18 @@ require 'spec_helper'describe ::API::V3::Notifications::NotificationsAPI,'update email read status',- type: :request do+ type: :request,+ content_type: :json doinclude API::V3::Utilities::PathHelpershared_let(:recipient) { FactoryBot.create :user }shared_let(:notification) { FactoryBot.create :notification, recipient: recipient }let(:send_read) do- header "Content-Type", "application/json"post api_v3_paths.notification_read_email(notification.id)endlet(:send_unread) do- header "Content-Type", "application/json"post api_v3_paths.notification_unread_email(notification.id)enddiff --git a/spec/requests/api/v3/notifications/read_iam_resource_spec.rb b/spec/requests/api/v3/notifications/read_ian_resource_spec.rbsimilarity index 95%rename from spec/requests/api/v3/notifications/read_iam_resource_spec.rbrename to spec/requests/api/v3/notifications/read_ian_resource_spec.rbindex a04a48fc6e0..821e7d1e175 100644--- a/spec/requests/api/v3/notifications/read_iam_resource_spec.rb+++ b/spec/requests/api/v3/notifications/read_ian_resource_spec.rb@@ -31,19 +31,18 @@ require 'spec_helper'describe ::API::V3::Notifications::NotificationsAPI,'update read status',- type: :request do+ type: :request,+ content_type: :json doinclude API::V3::Utilities::PathHelpershared_let(:recipient) { FactoryBot.create :user }shared_let(:notification) { FactoryBot.create :notification, recipient: recipient }let(:send_read) do- header "Content-Type", "application/json"post api_v3_paths.notification_read_ian(notification.id)endlet(:send_unread) do- header "Content-Type", "application/json"post api_v3_paths.notification_unread_ian(notification.id)end