Change the way that id_code was created (#5348) [deploy]
The column id_code was created with a job in an after create callback, that was replaced by an inline creation of the attribute
This commit is contained in:
parent
e09e46ec99
commit
f5d3593d4f
2 changed files with 9 additions and 1 deletions
|
|
@ -247,7 +247,7 @@ class Comment < ApplicationRecord
|
|||
end
|
||||
|
||||
def create_id_code
|
||||
Comments::CreateIdCodeJob.perform_later(id)
|
||||
update_column(:id_code, id.to_s(26))
|
||||
end
|
||||
|
||||
def touch_user
|
||||
|
|
|
|||
|
|
@ -248,6 +248,14 @@ RSpec.describe Comment, type: :model do
|
|||
end
|
||||
|
||||
context "when callbacks are triggered after create" do
|
||||
it "creates an id code" do
|
||||
comment = build(:comment, user: user, commentable: article)
|
||||
|
||||
comment.save
|
||||
|
||||
expect(comment.reload.id_code).to eq(comment.id.to_s(26))
|
||||
end
|
||||
|
||||
it "enqueue a worker to create the first reaction" do
|
||||
comment = build(:comment, user: user, commentable: article)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue