Add some model tests (#9)
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
Reviewed-on: #9
This commit is contained in:
parent
dd881ee41c
commit
e1a7f4fbbd
11 changed files with 113 additions and 37 deletions
|
@ -2,7 +2,7 @@ require "test_helper"
|
||||||
|
|
||||||
class ExpensesControllerTest < ActionDispatch::IntegrationTest
|
class ExpensesControllerTest < ActionDispatch::IntegrationTest
|
||||||
setup do
|
setup do
|
||||||
@expense = expenses(:one)
|
@expense = expenses(:monthly_expense)
|
||||||
end
|
end
|
||||||
|
|
||||||
test "should get index" do
|
test "should get index" do
|
||||||
|
|
|
@ -2,7 +2,7 @@ require "test_helper"
|
||||||
|
|
||||||
class IncomesControllerTest < ActionDispatch::IntegrationTest
|
class IncomesControllerTest < ActionDispatch::IntegrationTest
|
||||||
setup do
|
setup do
|
||||||
@income = incomes(:one)
|
@income = incomes(:included_1)
|
||||||
end
|
end
|
||||||
|
|
||||||
test "should get index" do
|
test "should get index" do
|
||||||
|
|
8
test/fixtures/credit_card_bills.yml
vendored
8
test/fixtures/credit_card_bills.yml
vendored
|
@ -1,9 +1,5 @@
|
||||||
# Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
|
# Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
|
||||||
|
|
||||||
one:
|
one:
|
||||||
description: MyString
|
description: Credit Card Bill One
|
||||||
amount: 9.99
|
amount: 1_000.00
|
||||||
|
|
||||||
two:
|
|
||||||
description: MyString
|
|
||||||
amount: 9.99
|
|
||||||
|
|
30
test/fixtures/expenses.yml
vendored
30
test/fixtures/expenses.yml
vendored
|
@ -1,15 +1,29 @@
|
||||||
# Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
|
# Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
|
||||||
|
|
||||||
one:
|
monthly_expense:
|
||||||
description: MyString
|
description: Monthly Expense
|
||||||
payment: 9.99
|
payment: 120.00
|
||||||
period: 1
|
period: monthly
|
||||||
|
credit_card: true
|
||||||
|
estimated: false
|
||||||
|
|
||||||
|
annual_expense:
|
||||||
|
description: Annual Expense
|
||||||
|
payment: 120.00
|
||||||
|
period: annually
|
||||||
|
credit_card: true
|
||||||
|
estimated: false
|
||||||
|
|
||||||
|
weekly_expense:
|
||||||
|
description: Weekly Expense
|
||||||
|
payment: 120.00
|
||||||
|
period: weekly
|
||||||
credit_card: false
|
credit_card: false
|
||||||
estimated: false
|
estimated: false
|
||||||
|
|
||||||
two:
|
quarterly_expense:
|
||||||
description: MyString
|
description: Quarterly Expense
|
||||||
payment: 9.99
|
payment: 120.00
|
||||||
period: 1
|
period: quarterly
|
||||||
credit_card: false
|
credit_card: false
|
||||||
estimated: false
|
estimated: false
|
||||||
|
|
26
test/fixtures/incomes.yml
vendored
26
test/fixtures/incomes.yml
vendored
|
@ -1,13 +1,25 @@
|
||||||
# Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
|
# Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
|
||||||
|
|
||||||
one:
|
included_1:
|
||||||
description: MyString
|
description: Salary
|
||||||
included: false
|
included: true
|
||||||
amount: 9.99
|
amount: 85_000.00
|
||||||
member: one
|
member: one
|
||||||
|
|
||||||
two:
|
included_2:
|
||||||
description: MyString
|
description: Salary
|
||||||
|
included: true
|
||||||
|
amount: 15_000.00
|
||||||
|
member: one
|
||||||
|
|
||||||
|
excluded:
|
||||||
|
description: Bonus
|
||||||
included: false
|
included: false
|
||||||
amount: 9.99
|
amount: 10_000
|
||||||
|
member: one
|
||||||
|
|
||||||
|
another_included:
|
||||||
|
description: Salary
|
||||||
|
included: true
|
||||||
|
amount: 10_000.00
|
||||||
member: two
|
member: two
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
require "test_helper"
|
require "test_helper"
|
||||||
|
|
||||||
class CreditCardBillTest < ActiveSupport::TestCase
|
class CreditCardBillTest < ActiveSupport::TestCase
|
||||||
# test "the truth" do
|
def test_unpaid
|
||||||
# assert true
|
credit_card_bill = credit_card_bills(:one)
|
||||||
# end
|
|
||||||
|
assert_equal 870.00, credit_card_bill.unpaid
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,7 +1,39 @@
|
||||||
require "test_helper"
|
require "test_helper"
|
||||||
|
|
||||||
class ExpenseTest < ActiveSupport::TestCase
|
class ExpenseTest < ActiveSupport::TestCase
|
||||||
# test "the truth" do
|
def test_monthly_converts_period_for_monthly
|
||||||
# assert true
|
expense = expenses(:monthly_expense)
|
||||||
# end
|
|
||||||
|
assert_equal 120.00, expense.monthly
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_monthly_converts_period_for_annually
|
||||||
|
expense = expenses(:annual_expense)
|
||||||
|
|
||||||
|
assert_equal 10.00, expense.monthly
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_monthly_converts_period_for_weekly
|
||||||
|
expense = expenses(:weekly_expense)
|
||||||
|
|
||||||
|
assert_equal 520.00, expense.monthly
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_monthly_converts_period_for_quarterly
|
||||||
|
expense = expenses(:quarterly_expense)
|
||||||
|
|
||||||
|
assert_equal 40.00, expense.monthly
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_total_calculates_total_of_expenses
|
||||||
|
assert_equal 480.00, Expense.total
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_total_calculates_monthly_total
|
||||||
|
assert_equal 690.00, Expense.monthly_total
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_total_calculates_credit_card_monthly_total
|
||||||
|
assert_equal 130.00, Expense.credit_card_monthly_total
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
require "test_helper"
|
require "test_helper"
|
||||||
|
|
||||||
class IncomeTest < ActiveSupport::TestCase
|
class IncomeTest < ActiveSupport::TestCase
|
||||||
# test "the truth" do
|
def test_total
|
||||||
# assert true
|
assert_equal 110_000.00, Income.total
|
||||||
# end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,7 +1,27 @@
|
||||||
require "test_helper"
|
require "test_helper"
|
||||||
|
|
||||||
class MemberTest < ActiveSupport::TestCase
|
class MemberTest < ActiveSupport::TestCase
|
||||||
# test "the truth" do
|
def member
|
||||||
# assert true
|
members(:one)
|
||||||
# end
|
end
|
||||||
|
|
||||||
|
def test_income
|
||||||
|
assert_equal 110_000.00, member.income
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_included_income
|
||||||
|
assert_equal 100_000.00, member.included_income
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_others_included_income
|
||||||
|
assert_equal 10_000.00, member.others_included_income
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_burden_percent
|
||||||
|
assert_equal 0.91, member.burden_percent
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_burden_amount
|
||||||
|
assert_equal 627.90, member.burden_amount
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -2,7 +2,7 @@ require "application_system_test_case"
|
||||||
|
|
||||||
class ExpensesTest < ApplicationSystemTestCase
|
class ExpensesTest < ApplicationSystemTestCase
|
||||||
setup do
|
setup do
|
||||||
@expense = expenses(:one)
|
@expense = expenses(:monthly_expense)
|
||||||
end
|
end
|
||||||
|
|
||||||
test "visiting the index" do
|
test "visiting the index" do
|
||||||
|
|
|
@ -2,7 +2,7 @@ require "application_system_test_case"
|
||||||
|
|
||||||
class IncomesTest < ApplicationSystemTestCase
|
class IncomesTest < ApplicationSystemTestCase
|
||||||
setup do
|
setup do
|
||||||
@income = incomes(:one)
|
@income = incomes(:included_1)
|
||||||
end
|
end
|
||||||
|
|
||||||
test "visiting the index" do
|
test "visiting the index" do
|
||||||
|
|
Loading…
Reference in a new issue