Update usages of `Smile`/`CommentSmile` to `Appendable::Reaction` in tests

This commit is contained in:
Karina Kwiatek 2022-03-26 18:38:17 +01:00 committed by Karina Kwiatek
parent 5ba3fed56c
commit 1b22872002
3 changed files with 14 additions and 12 deletions

View File

@ -28,8 +28,8 @@ describe Ajax::SmileController, :ajax_controller, type: :controller do
end
it "creates a smile to the answer" do
expect { subject }.to(change { Smile.count }.by(1))
expect(answer.reload.smiles.ids).to include(Smile.last.id)
expect { subject }.to(change { Appendable::Reaction.count }.by(1))
expect(answer.reload.smiles.ids).to include(Appendable::Reaction.last.id)
end
include_examples "returns the expected response"
@ -133,7 +133,7 @@ describe Ajax::SmileController, :ajax_controller, type: :controller do
describe "#destroy" do
let(:answer) { FactoryBot.create(:answer, user: user) }
let(:smile) { FactoryBot.create(:smile, user: user, answer: answer) }
let(:smile) { FactoryBot.create(:smile, user: user, parent: answer) }
let(:answer_id) { answer.id }
let(:params) do
@ -160,7 +160,7 @@ describe Ajax::SmileController, :ajax_controller, type: :controller do
end
it "deletes the smile" do
expect { subject }.to(change { Smile.count }.by(-1))
expect { subject }.to(change { Appendable::Reaction.count }.by(-1))
end
include_examples "returns the expected response"
@ -219,8 +219,8 @@ describe Ajax::SmileController, :ajax_controller, type: :controller do
end
it "creates a smile to the comment" do
expect { subject }.to(change { CommentSmile.count }.by(1))
expect(comment.reload.smiles.ids).to include(CommentSmile.last.id)
expect { subject }.to(change { Appendable::Reaction.count }.by(1))
expect(comment.reload.smiles.ids).to include(Appendable::Reaction.last.id)
end
include_examples "returns the expected response"
@ -277,7 +277,7 @@ describe Ajax::SmileController, :ajax_controller, type: :controller do
describe "#destroy_comment" do
let(:answer) { FactoryBot.create(:answer, user: user) }
let(:comment) { FactoryBot.create(:comment, user: user, answer: answer) }
let(:comment_smile) { FactoryBot.create(:comment_smile, user: user, comment: comment) }
let(:comment_smile) { FactoryBot.create(:comment_smile, user: user, parent: comment) }
let(:comment_id) { comment.id }
let(:params) do
@ -304,7 +304,7 @@ describe Ajax::SmileController, :ajax_controller, type: :controller do
end
it "deletes the smile" do
expect { subject }.to(change { CommentSmile.count }.by(-1))
expect { subject }.to(change { Appendable::Reaction.count }.by(-1))
end
include_examples "returns the expected response"

View File

@ -1,8 +1,9 @@
# frozen_string_literal: true
FactoryBot.define do
factory :comment_smile do
factory :comment_smile, class: Appendable::Reaction do
user { FactoryBot.build(:user) }
comment { FactoryBot.build(:comment) }
parent { FactoryBot.build(:comment) }
content { "🙂" }
end
end

View File

@ -1,8 +1,9 @@
# frozen_string_literal: true
FactoryBot.define do
factory :smile do
factory :smile, class: Appendable::Reaction do
user { FactoryBot.build(:user) }
answer { FactoryBot.build(:answer) }
parent { FactoryBot.build(:answer) }
content { "🙂" }
end
end