Remove TouchJob and do it Inline (#5410)
This commit is contained in:
parent
2a8b133d82
commit
a86371e772
4 changed files with 2 additions and 33 deletions
|
|
@ -1,12 +0,0 @@
|
|||
module Users
|
||||
class TouchJob < ApplicationJob
|
||||
queue_as :touch_user
|
||||
|
||||
def perform(user_id)
|
||||
user = User.find_by(id: user_id)
|
||||
return unless user
|
||||
|
||||
user.touch
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -81,7 +81,7 @@ class Reaction < ApplicationRecord
|
|||
private
|
||||
|
||||
def touch_user
|
||||
Users::TouchJob.perform_later(user_id)
|
||||
user.touch
|
||||
end
|
||||
|
||||
def update_reactable
|
||||
|
|
|
|||
|
|
@ -1,18 +0,0 @@
|
|||
require "rails_helper"
|
||||
|
||||
RSpec.describe Users::TouchJob, type: :job do
|
||||
describe "#perform_later" do
|
||||
it "enqueues the job" do
|
||||
expect do
|
||||
described_class.perform_later(3)
|
||||
end.to have_enqueued_job.with(3).on_queue("touch_user")
|
||||
end
|
||||
|
||||
it "touches a user" do
|
||||
timestamp = 1.day.ago
|
||||
user = create(:user, updated_at: timestamp, last_followed_at: timestamp)
|
||||
described_class.perform_now(user.id)
|
||||
expect(user.reload.updated_at).to be > timestamp
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -118,8 +118,7 @@ RSpec.describe Reaction, type: :model do
|
|||
expect do
|
||||
reaction.save
|
||||
end.to(
|
||||
have_enqueued_job(Users::TouchJob).with(user.id).exactly(:once).
|
||||
and(have_enqueued_job(Reactions::UpdateReactableJob).exactly(:once)).
|
||||
have_enqueued_job(Reactions::UpdateReactableJob).exactly(:once).
|
||||
and(have_enqueued_job(Reactions::BustReactableCacheJob).exactly(:once)).
|
||||
and(have_enqueued_job(Reactions::BustHomepageCacheJob).exactly(:once)),
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue