mark dataexported notifications as read when visiting export page
This commit is contained in:
parent
3e143954e3
commit
d52529c840
|
@ -2,6 +2,7 @@
|
|||
|
||||
class Settings::ExportController < ApplicationController
|
||||
before_action :authenticate_user!
|
||||
before_action :mark_notifications_as_read, only: %i[index]
|
||||
|
||||
def index
|
||||
flash[:info] = t(".info") if current_user.export_processing
|
||||
|
@ -17,4 +18,12 @@ class Settings::ExportController < ApplicationController
|
|||
|
||||
redirect_to settings_export_path
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def mark_notifications_as_read
|
||||
Notification::DataExported
|
||||
.where(recipient: current_user, new: true)
|
||||
.update_all(new: false) # rubocop:disable Rails/SkipsModelValidations
|
||||
end
|
||||
end
|
||||
|
|
|
@ -15,6 +15,21 @@ describe Settings::ExportController, type: :controller do
|
|||
subject
|
||||
expect(response).to render_template(:index)
|
||||
end
|
||||
|
||||
context "when user has a new DataExported notification" do
|
||||
let(:notification) do
|
||||
Notification::DataExported.create(
|
||||
target_id: user.id,
|
||||
target_type: "User::DataExport",
|
||||
recipient: user,
|
||||
new: true
|
||||
)
|
||||
end
|
||||
|
||||
it "marks the notification as read" do
|
||||
expect { subject }.to change { notification.reload.new }.from(true).to(false)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in New Issue