From 8429b3952be8c78331cce99ca3b5cf163892adf6 Mon Sep 17 00:00:00 2001 From: Manuel Bustillo Date: Sun, 1 Dec 2024 09:58:39 +0100 Subject: [PATCH] Adapt factories to use a wedding object --- spec/factories/expense.rb | 1 + spec/factories/groups.rb | 1 + spec/factories/guest.rb | 3 ++- spec/factories/table_arrangement.rb | 6 ++++++ spec/factories/users.rb | 2 +- spec/factories/weddings.rb | 1 + spec/models/tables_arrangement_spec.rb | 2 +- 7 files changed, 13 insertions(+), 3 deletions(-) create mode 100644 spec/factories/table_arrangement.rb diff --git a/spec/factories/expense.rb b/spec/factories/expense.rb index 9670768..726d94d 100644 --- a/spec/factories/expense.rb +++ b/spec/factories/expense.rb @@ -2,6 +2,7 @@ FactoryBot.define do factory :expense do + wedding sequence(:name) { |i| "Expense #{i}" } pricing_type { "fixed" } amount { 100 } diff --git a/spec/factories/groups.rb b/spec/factories/groups.rb index 4ebce4e..ccd1156 100644 --- a/spec/factories/groups.rb +++ b/spec/factories/groups.rb @@ -2,6 +2,7 @@ FactoryBot.define do factory :group do + wedding sequence(:name) { |i| "Group #{i}" } order { 1 } end diff --git a/spec/factories/guest.rb b/spec/factories/guest.rb index 4c9b58a..28f3b80 100644 --- a/spec/factories/guest.rb +++ b/spec/factories/guest.rb @@ -2,7 +2,8 @@ FactoryBot.define do factory :guest do - association :group + group + wedding name { Faker::Name.name } phone { Faker::PhoneNumber.cell_phone } diff --git a/spec/factories/table_arrangement.rb b/spec/factories/table_arrangement.rb new file mode 100644 index 0000000..5e914ce --- /dev/null +++ b/spec/factories/table_arrangement.rb @@ -0,0 +1,6 @@ +FactoryBot.define do + factory :tables_arrangement do + wedding + end +end + \ No newline at end of file diff --git a/spec/factories/users.rb b/spec/factories/users.rb index 7839fbe..2aa8a37 100644 --- a/spec/factories/users.rb +++ b/spec/factories/users.rb @@ -2,6 +2,6 @@ FactoryBot.define do factory :user do - + wedding end end diff --git a/spec/factories/weddings.rb b/spec/factories/weddings.rb index fe8e605..3680045 100644 --- a/spec/factories/weddings.rb +++ b/spec/factories/weddings.rb @@ -2,6 +2,7 @@ FactoryBot.define do factory :wedding do + sequence(:slug) { |i| "wedding-#{i}" } date { 1.year.from_now } end end diff --git a/spec/models/tables_arrangement_spec.rb b/spec/models/tables_arrangement_spec.rb index c15971a..4db0859 100644 --- a/spec/models/tables_arrangement_spec.rb +++ b/spec/models/tables_arrangement_spec.rb @@ -5,7 +5,7 @@ require 'rails_helper' RSpec.describe TablesArrangement, type: :model do describe 'callbacks' do it 'assigns a name before creation' do - expect(described_class.create!.name).to be_present + expect(create(:tables_arrangement).name).to be_present end end end