Fix lint errors
This commit is contained in:
parent
620121341e
commit
d39f37072d
|
@ -28,15 +28,18 @@ class Subscription < ApplicationRecord
|
|||
def notify(source, target)
|
||||
return nil if source.nil? || target.nil?
|
||||
|
||||
muted_by = Relationships::Mute.where(target: source.user).pluck(&:source_id)
|
||||
|
||||
# As we will need to notify for each person subscribed,
|
||||
# it's much faster to bulk insert than to use +Notification.notify+
|
||||
notifications = Subscription.where(answer: target)
|
||||
.where.not(user: source.user)
|
||||
.where.not(user_id: muted_by)
|
||||
.map do |s|
|
||||
{ target_id: source.id, target_type: Comment, recipient_id: s.user_id, new: true, type: Notification::Commented, created_at: source.created_at, updated_at: source.created_at }
|
||||
notifications = Subscription.for(source, target).pluck(:user_id).map do |recipient_id|
|
||||
{
|
||||
target_id: source.id,
|
||||
target_type: Comment,
|
||||
recipient_id:,
|
||||
new: true,
|
||||
type: Notification::Commented,
|
||||
created_at: source.created_at,
|
||||
updated_at: source.created_at,
|
||||
}
|
||||
end
|
||||
|
||||
return if notifications.empty?
|
||||
|
@ -53,5 +56,13 @@ class Subscription < ApplicationRecord
|
|||
subs = Subscription.where(answer: target)
|
||||
Notification.where(target:, recipient: subs.map(&:user)).delete_all
|
||||
end
|
||||
|
||||
def for(source, target)
|
||||
muted_by = Relationships::Mute.where(target: source.user).pluck(&:source_id)
|
||||
|
||||
Subscription.where(answer: target)
|
||||
.where.not(user: source.user)
|
||||
.where.not(user_id: muted_by)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -35,7 +35,6 @@ describe Ajax::CommentController, :ajax_controller, type: :controller do
|
|||
expect { subject }.to change { subscribed_user.reload.notifications_updated_at }.to(DateTime.now)
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
include_examples "returns the expected response"
|
||||
|
|
|
@ -43,10 +43,10 @@ describe BootstrapHelper, :type => :helper do
|
|||
)
|
||||
end
|
||||
|
||||
it 'should put an ID on the entry an id if given' do
|
||||
it "should put an ID on the entry an id if given" do
|
||||
allow(self).to receive(:current_page?).and_return(false)
|
||||
expect(nav_entry('Example', '/example', id: "testing")).to(
|
||||
eq('<li class="nav-item " id="testing"><a class="nav-link" href="/example">Example</a></li>')
|
||||
expect(nav_entry("Example", "/example", id: "testing")).to(
|
||||
eq("<li class=\"nav-item \" id=\"testing\"><a class=\"nav-link\" href=\"/example\">Example</a></li>"),
|
||||
)
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue