From 1b2287200234870c996a4fd55d5c60e628b640b2 Mon Sep 17 00:00:00 2001 From: Karina Kwiatek Date: Sat, 26 Mar 2022 18:38:17 +0100 Subject: [PATCH] Update usages of `Smile`/`CommentSmile` to `Appendable::Reaction` in tests --- spec/controllers/ajax/smile_controller_spec.rb | 16 ++++++++-------- spec/factories/comment_smile.rb | 5 +++-- spec/factories/smile.rb | 5 +++-- 3 files changed, 14 insertions(+), 12 deletions(-) diff --git a/spec/controllers/ajax/smile_controller_spec.rb b/spec/controllers/ajax/smile_controller_spec.rb index 9385d5d6..b3371612 100644 --- a/spec/controllers/ajax/smile_controller_spec.rb +++ b/spec/controllers/ajax/smile_controller_spec.rb @@ -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" diff --git a/spec/factories/comment_smile.rb b/spec/factories/comment_smile.rb index 3a2b585e..6923e121 100644 --- a/spec/factories/comment_smile.rb +++ b/spec/factories/comment_smile.rb @@ -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 diff --git a/spec/factories/smile.rb b/spec/factories/smile.rb index 1ce23750..1970c8e4 100644 --- a/spec/factories/smile.rb +++ b/spec/factories/smile.rb @@ -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