mirror of
https://github.com/Retrospring/retrospring.git
synced 2024-11-20 14:39:52 +01:00
Appease the dog overlords
This commit is contained in:
parent
7afff7884e
commit
6a03d3587a
4 changed files with 53 additions and 55 deletions
|
@ -11,11 +11,11 @@ class Notification < ApplicationRecord
|
|||
define_cursor_paginator :cursored_for_type, :for_type
|
||||
|
||||
def for(recipient, **kwargs)
|
||||
where(kwargs.merge!(recipient: recipient)).order(:created_at).reverse_order
|
||||
where(kwargs.merge!(recipient:)).order(:created_at).reverse_order
|
||||
end
|
||||
|
||||
def for_type(recipient, type, **kwargs)
|
||||
where(kwargs.merge!(recipient: recipient)).where(type: type).order(:created_at).reverse_order
|
||||
where(kwargs.merge!(recipient:)).where(type:).order(:created_at).reverse_order
|
||||
end
|
||||
|
||||
def notify(recipient, target)
|
||||
|
@ -34,7 +34,7 @@ class Notification < ApplicationRecord
|
|||
notif_type = target.notification_type
|
||||
return nil unless notif_type
|
||||
|
||||
notif = Notification.find_by(recipient: recipient, target: target)
|
||||
notif = Notification.find_by(recipient:, target:)
|
||||
notif&.destroy
|
||||
end
|
||||
|
||||
|
@ -43,8 +43,8 @@ class Notification < ApplicationRecord
|
|||
def make_notification(recipient, target, notification_type)
|
||||
return if get_notification_owner(target).present? && recipient.muting?(get_notification_owner(target))
|
||||
|
||||
n = notification_type.new(target: target,
|
||||
recipient: recipient,
|
||||
n = notification_type.new(target:,
|
||||
recipient:,
|
||||
new: true)
|
||||
n.save!
|
||||
n
|
||||
|
@ -57,8 +57,6 @@ class Notification < ApplicationRecord
|
|||
target.user
|
||||
elsif target.try(:source) && target.source.is_a?(User)
|
||||
target.source
|
||||
else
|
||||
nil
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -10,14 +10,14 @@ describe Ajax::AnswerController, :ajax_controller, type: :controller do
|
|||
describe "#create" do
|
||||
let(:params) do
|
||||
{
|
||||
id: id,
|
||||
answer: answer,
|
||||
id:,
|
||||
answer:,
|
||||
share: shared_services&.to_json,
|
||||
inbox: inbox
|
||||
inbox:
|
||||
}.compact
|
||||
end
|
||||
|
||||
subject { post(:create, params: params) }
|
||||
subject { post(:create, params:) }
|
||||
|
||||
context "when user is signed in" do
|
||||
shared_examples "creates the answer" do
|
||||
|
@ -73,7 +73,7 @@ describe Ajax::AnswerController, :ajax_controller, type: :controller do
|
|||
let(:shared_services) { %w[twitter] }
|
||||
|
||||
context "when inbox is true" do
|
||||
let(:id) { FactoryBot.create(:inbox, user: inbox_user, question: question).id }
|
||||
let(:id) { FactoryBot.create(:inbox, user: inbox_user, question:).id }
|
||||
let(:inbox) { true }
|
||||
|
||||
context "when the inbox entry belongs to the user" do
|
||||
|
@ -237,7 +237,7 @@ describe Ajax::AnswerController, :ajax_controller, type: :controller do
|
|||
describe "#destroy" do
|
||||
let(:answer_user) { user }
|
||||
let(:question) { FactoryBot.create(:question) }
|
||||
let(:answer) { FactoryBot.create(:answer, user: answer_user, question: question) }
|
||||
let(:answer) { FactoryBot.create(:answer, user: answer_user, question:) }
|
||||
let(:answer_id) { answer.id }
|
||||
|
||||
let(:params) do
|
||||
|
@ -246,7 +246,7 @@ describe Ajax::AnswerController, :ajax_controller, type: :controller do
|
|||
}
|
||||
end
|
||||
|
||||
subject { delete(:destroy, params: params) }
|
||||
subject { delete(:destroy, params:) }
|
||||
|
||||
context "when user is signed in" do
|
||||
shared_examples "deletes the answer" do
|
||||
|
|
|
@ -10,11 +10,11 @@ describe Ajax::CommentController, :ajax_controller, type: :controller do
|
|||
let(:params) do
|
||||
{
|
||||
answer: answer_id,
|
||||
comment: comment
|
||||
comment:
|
||||
}.compact
|
||||
end
|
||||
|
||||
subject { post(:create, params: params) }
|
||||
subject { post(:create, params:) }
|
||||
|
||||
context "when user is signed in" do
|
||||
shared_examples "creates the comment" do
|
||||
|
@ -175,7 +175,7 @@ describe Ajax::CommentController, :ajax_controller, type: :controller do
|
|||
let(:answer_user) { FactoryBot.create(:user) }
|
||||
let(:answer) { FactoryBot.create(:answer, user: answer_user) }
|
||||
let(:comment_user) { user }
|
||||
let(:comment) { FactoryBot.create(:comment, user: comment_user, answer: answer) }
|
||||
let(:comment) { FactoryBot.create(:comment, user: comment_user, answer:) }
|
||||
let(:comment_id) { comment.id }
|
||||
|
||||
let(:params) do
|
||||
|
@ -184,7 +184,7 @@ describe Ajax::CommentController, :ajax_controller, type: :controller do
|
|||
}
|
||||
end
|
||||
|
||||
subject { delete(:destroy, params: params) }
|
||||
subject { delete(:destroy, params:) }
|
||||
|
||||
context "when user is signed in" do
|
||||
shared_examples "deletes the comment" do
|
||||
|
|
Loading…
Reference in a new issue