Remove TouchFollowerJob and do user update inline (#5391) [deploy]
This commit is contained in:
parent
1003f71c8f
commit
7c939dc2c5
4 changed files with 3 additions and 49 deletions
|
|
@ -1,12 +0,0 @@
|
|||
module Follows
|
||||
class TouchFollowerJob < ApplicationJob
|
||||
queue_as :touch_follower
|
||||
|
||||
def perform(follow_id)
|
||||
follow = Follow.find_by(id: follow_id)
|
||||
return unless follow
|
||||
|
||||
follow.follower.touch(:updated_at, :last_followed_at)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -34,7 +34,7 @@ class Follow < ApplicationRecord
|
|||
private
|
||||
|
||||
def touch_follower
|
||||
Follows::TouchFollowerJob.perform_later(id)
|
||||
follower.touch(:updated_at, :last_followed_at)
|
||||
end
|
||||
|
||||
def create_chat_channel
|
||||
|
|
|
|||
|
|
@ -1,27 +0,0 @@
|
|||
require "rails_helper"
|
||||
|
||||
RSpec.describe Follows::TouchFollowerJob, type: :job do
|
||||
include_examples "#enqueues_job", "touch_follower", 3
|
||||
|
||||
describe "#perform_now" do
|
||||
context "with follow" do
|
||||
it "touches a follower" do
|
||||
timestamp = 1.day.ago
|
||||
user = create(:user, updated_at: timestamp, last_followed_at: timestamp)
|
||||
follow = create(:follow, follower: user)
|
||||
|
||||
described_class.perform_now(follow.id)
|
||||
|
||||
user.reload
|
||||
expect(user.updated_at).to be > timestamp
|
||||
expect(user.last_followed_at).to be > timestamp
|
||||
end
|
||||
end
|
||||
|
||||
context "without follow" do
|
||||
it "does not break" do
|
||||
expect { described_class.perform_now(nil) }.not_to raise_error
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -14,12 +14,6 @@ RSpec.describe Follow, type: :model do
|
|||
end
|
||||
|
||||
context "when enqueuing jobs" do
|
||||
it "enqueues touch follower job on creation" do
|
||||
expect do
|
||||
described_class.create(follower: user, followable: user_2)
|
||||
end.to have_enqueued_job(Follows::TouchFollowerJob)
|
||||
end
|
||||
|
||||
it "enqueues create channel job" do
|
||||
expect do
|
||||
described_class.create(follower: user, followable: user_2)
|
||||
|
|
@ -37,9 +31,8 @@ RSpec.describe Follow, type: :model do
|
|||
it "touches the follower user while creating" do
|
||||
timestamp = 1.day.ago
|
||||
user.update_columns(updated_at: timestamp, last_followed_at: timestamp)
|
||||
perform_enqueued_jobs do
|
||||
described_class.create!(follower: user, followable: user_2)
|
||||
end
|
||||
described_class.create!(follower: user, followable: user_2)
|
||||
|
||||
user.reload
|
||||
expect(user.updated_at).to be > timestamp
|
||||
expect(user.last_followed_at).to be > timestamp
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue