mirror of
https://github.com/diaspora/diaspora.git
synced 2026-01-10 07:38:10 -05:00
Fix specs for factory_bot 6
This commit is contained in:
@@ -179,6 +179,10 @@ FactoryBot.define do
|
||||
p.poll_answers << FactoryBot.build(:poll_answer, poll: p)
|
||||
p.poll_answers << FactoryBot.build(:poll_answer, poll: p)
|
||||
end
|
||||
|
||||
trait(:with_author) {
|
||||
association :author
|
||||
}
|
||||
end
|
||||
|
||||
factory(:poll_answer) do
|
||||
@@ -189,6 +193,11 @@ FactoryBot.define do
|
||||
factory :poll_participation do
|
||||
association :author, factory: :person
|
||||
association :poll_answer
|
||||
|
||||
trait(:with_poll_author) do
|
||||
after(:build) {|p| p.poll.author ||= p.author }
|
||||
end
|
||||
|
||||
after(:build) {|p| p.poll = p.poll_answer.poll }
|
||||
end
|
||||
|
||||
|
||||
@@ -4,9 +4,9 @@ describe GonHelper, type: :helper do
|
||||
include_context :gon
|
||||
|
||||
describe "#gon_load_contact" do
|
||||
let(:contact) { FactoryBot.build(:contact) }
|
||||
let(:contact) { FactoryBot.build(:contact, person: FactoryBot.create(:person)) }
|
||||
let(:current_user) { contact.user }
|
||||
let(:another_contact) { FactoryBot.build(:contact, user: current_user) }
|
||||
let(:another_contact) { FactoryBot.build(:contact, user: current_user, person: FactoryBot.create(:person)) }
|
||||
|
||||
before do
|
||||
RequestStore.store[:gon] = Gon::Request.new(controller.request.env)
|
||||
|
||||
@@ -190,7 +190,7 @@ describe Diaspora::Federation::Entities do
|
||||
end
|
||||
|
||||
it "builds a poll participation" do
|
||||
diaspora_entity = FactoryBot.build(:poll_participation)
|
||||
diaspora_entity = FactoryBot.build(:poll_participation, :with_poll_author)
|
||||
federation_entity = described_class.build(diaspora_entity)
|
||||
|
||||
expect(federation_entity).to be_instance_of(DiasporaFederation::Entities::PollParticipation)
|
||||
@@ -204,7 +204,7 @@ describe Diaspora::Federation::Entities do
|
||||
|
||||
it "builds a poll participation with signature" do
|
||||
signature = FactoryBot.build(:poll_participation_signature)
|
||||
diaspora_entity = FactoryBot.build(:poll_participation, signature: signature)
|
||||
diaspora_entity = FactoryBot.build(:poll_participation, :with_poll_author, signature: signature)
|
||||
federation_entity = described_class.build(diaspora_entity)
|
||||
|
||||
expect(federation_entity).to be_instance_of(DiasporaFederation::Entities::PollParticipation)
|
||||
|
||||
Reference in New Issue
Block a user