Skip to content

Commit

Permalink
Add factories for specs.
Browse files Browse the repository at this point in the history
  • Loading branch information
neb417 committed Nov 5, 2024
1 parent 24d2c31 commit c13bf90
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 1 deletion.
3 changes: 3 additions & 0 deletions spec/factories/federal_tax_brackets.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,12 @@
# fk_rails_... (federal_tax_table_type_id => federal_tax_table_types.id)
#
FactoryBot.define do

# tax_brackets = 10% on first $1,000, 15% from $1,001 to $100,000, 25% from $100,001 to $500,000

factory :federal_tax_bracket do
federal_tax_table_type

tier { "Tier 1" }
bottom_range_cents { 0 }
top_range_cents { 100_000 } # $1,000.00
Expand Down
21 changes: 21 additions & 0 deletions spec/factories/federal_tax_table_types.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,26 @@
#
FactoryBot.define do
factory :federal_tax_table_type do
filing_status { "single" }

trait :married_filing_jointly do
filing_status { "married_filing_jointly" }
end

trait :married_filing_separately do
filing_status { "married_filing_separately" }
end

trait :head_of_household do
filing_status { "head_of_household" }
end

trait :with_all_statuses do
after :create do |_record|
create(:federal_tax_table_type, :married_filing_jointly)
create(:federal_tax_table_type, :married_filing_separately)
create(:federal_tax_table_type, :head_of_household)
end
end
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
bottom_range: 1,
top_range: 1,
rate: 1.5,
cumulative: 1
cumulative: 1,
federal_tax_table_type: create(:federal_tax_table_type)
)
}

Expand Down

0 comments on commit c13bf90

Please sign in to comment.