diff --git a/app/controllers/notifications_controller.rb b/app/controllers/notifications_controller.rb index 9d167647..4ad39cce 100644 --- a/app/controllers/notifications_controller.rb +++ b/app/controllers/notifications_controller.rb @@ -1,9 +1,11 @@ +# frozen_string_literal: true + class NotificationsController < ApplicationController before_action :authenticate_user! TYPE_MAPPINGS = { - 'smile' => 'appendable::reaction', - 'reaction' => 'appendable::reaction', + "smile" => "appendable::reaction", + "reaction" => "appendable::reaction" }.freeze def index @@ -24,9 +26,9 @@ class NotificationsController < ApplicationController cursor_params = { last_id: last_id, size: size }.compact case type - when 'all' + when "all" Notification.cursored_for(current_user, **cursor_params) - when 'new' + when "new" Notification.cursored_for(current_user, new: true, **cursor_params) else Notification.cursored_for_type(current_user, type, **cursor_params) diff --git a/app/models/appendable/reaction.rb b/app/models/appendable/reaction.rb index fc253fc3..df498b18 100644 --- a/app/models/appendable/reaction.rb +++ b/app/models/appendable/reaction.rb @@ -1,6 +1,7 @@ # frozen_string_literal: true class Appendable::Reaction < Appendable + # rubocop:disable Rails/SkipsModelValidations after_create do Notification.notify parent.user, self unless parent.user == user user.increment! :smiled_count @@ -12,6 +13,7 @@ class Appendable::Reaction < Appendable user.decrement! :smiled_count parent.decrement! :smile_count end + # rubocop:enable Rails/SkipsModelValidations def notification_type(*_args) Notifications::Smiled diff --git a/db/migrate/20220216150127_move_smiles_to_appendables.rb b/db/migrate/20220216150127_move_smiles_to_appendables.rb index df3d9789..56479ad5 100644 --- a/db/migrate/20220216150127_move_smiles_to_appendables.rb +++ b/db/migrate/20220216150127_move_smiles_to_appendables.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class MoveSmilesToAppendables < ActiveRecord::Migration[6.1] def up execute "INSERT INTO appendables (type, user_id, parent_id, parent_type, content, created_at, updated_at)