Move extra bills to credit cards

This commit is contained in:
Andrew Tomaka 2023-03-03 18:12:59 -05:00
parent c14a408f9a
commit 0887a5f6b9
Signed by: atomaka
GPG key ID: 61209BF70A5B18BE
38 changed files with 242 additions and 251 deletions

View file

@ -0,0 +1,48 @@
require "test_helper"
class CreditCardBillsControllerTest < ActionDispatch::IntegrationTest
setup do
@credit_card_bill = credit_card_bills(:one)
end
test "should get index" do
get credit_card_bills_url
assert_response :success
end
test "should get new" do
get new_credit_card_bill_url
assert_response :success
end
test "should create credit_card_bill" do
assert_difference("CreditCardBill.count") do
post credit_card_bills_url, params: { credit_card_bill: { amount: @credit_card_bill.amount, description: @credit_card_bill.description } }
end
assert_redirected_to credit_card_bill_url(CreditCardBill.last)
end
test "should show credit_card_bill" do
get credit_card_bill_url(@credit_card_bill)
assert_response :success
end
test "should get edit" do
get edit_credit_card_bill_url(@credit_card_bill)
assert_response :success
end
test "should update credit_card_bill" do
patch credit_card_bill_url(@credit_card_bill), params: { credit_card_bill: { amount: @credit_card_bill.amount, description: @credit_card_bill.description } }
assert_redirected_to credit_card_bill_url(@credit_card_bill)
end
test "should destroy credit_card_bill" do
assert_difference("CreditCardBill.count", -1) do
delete credit_card_bill_url(@credit_card_bill)
end
assert_redirected_to credit_card_bills_url
end
end

View file

@ -17,7 +17,7 @@ class ExpensesControllerTest < ActionDispatch::IntegrationTest
test "should create expense" do
assert_difference("Expense.count") do
post expenses_url, params: { expense: { autopaid: @expense.autopaid, description: @expense.description, estimated: @expense.estimated, payment: @expense.payment, period: @expense.period } }
post expenses_url, params: { expense: { credit_card: @expense.credit_card, description: @expense.description, estimated: @expense.estimated, payment: @expense.payment, period: @expense.period } }
end
assert_redirected_to expense_url(Expense.last)
@ -34,7 +34,7 @@ class ExpensesControllerTest < ActionDispatch::IntegrationTest
end
test "should update expense" do
patch expense_url(@expense), params: { expense: { autopaid: @expense.autopaid, description: @expense.description, estimated: @expense.estimated, payment: @expense.payment, period: @expense.period } }
patch expense_url(@expense), params: { expense: { credit_card: @expense.credit_card, description: @expense.description, estimated: @expense.estimated, payment: @expense.payment, period: @expense.period } }
assert_redirected_to expense_url(@expense)
end

View file

@ -1,48 +0,0 @@
require "test_helper"
class ExtraBillsControllerTest < ActionDispatch::IntegrationTest
setup do
@extra_bill = extra_bills(:one)
end
test "should get index" do
get extra_bills_url
assert_response :success
end
test "should get new" do
get new_extra_bill_url
assert_response :success
end
test "should create extra_bill" do
assert_difference("ExtraBill.count") do
post extra_bills_url, params: { extra_bill: { amount: @extra_bill.amount, deduct_autopaid: @extra_bill.deduct_autopaid, description: @extra_bill.description } }
end
assert_redirected_to extra_bill_url(ExtraBill.last)
end
test "should show extra_bill" do
get extra_bill_url(@extra_bill)
assert_response :success
end
test "should get edit" do
get edit_extra_bill_url(@extra_bill)
assert_response :success
end
test "should update extra_bill" do
patch extra_bill_url(@extra_bill), params: { extra_bill: { amount: @extra_bill.amount, deduct_autopaid: @extra_bill.deduct_autopaid, description: @extra_bill.description } }
assert_redirected_to extra_bill_url(@extra_bill)
end
test "should destroy extra_bill" do
assert_difference("ExtraBill.count", -1) do
delete extra_bill_url(@extra_bill)
end
assert_redirected_to extra_bills_url
end
end

View file

@ -3,9 +3,7 @@
one:
description: MyString
amount: 9.99
deduct_autopaid: false
two:
description: MyString
amount: 9.99
deduct_autopaid: false

View file

@ -4,12 +4,12 @@ one:
description: MyString
payment: 9.99
period: 1
autopaid: false
credit_card: false
estimated: false
two:
description: MyString
payment: 9.99
period: 1
autopaid: false
credit_card: false
estimated: false

View file

@ -1,6 +1,6 @@
require "test_helper"
class ExtraBillTest < ActiveSupport::TestCase
class CreditCardBillTest < ActiveSupport::TestCase
# test "the truth" do
# assert true
# end

View file

@ -14,7 +14,7 @@ class ExpensesTest < ApplicationSystemTestCase
visit expenses_url
click_on "New expense"
check "Autopaid" if @expense.autopaid
check "Credit card" if @expense.credit_card
fill_in "Description", with: @expense.description
check "Estimated" if @expense.estimated
fill_in "Payment", with: @expense.payment
@ -29,7 +29,7 @@ class ExpensesTest < ApplicationSystemTestCase
visit expense_url(@expense)
click_on "Edit this expense", match: :first
check "Autopaid" if @expense.autopaid
check "Credit card" if @expense.credit_card
fill_in "Description", with: @expense.description
check "Estimated" if @expense.estimated
fill_in "Payment", with: @expense.payment

View file

@ -1,45 +1,43 @@
require "application_system_test_case"
class ExtraBillsTest < ApplicationSystemTestCase
class CreditCardBillsTest < ApplicationSystemTestCase
setup do
@extra_bill = extra_bills(:one)
@credit_card_bill = credit_card_bills(:one)
end
test "visiting the index" do
visit extra_bills_url
assert_selector "h1", text: "Extra bills"
visit credit_card_bills_url
assert_selector "h1", text: "Credit card bills"
end
test "should create extra bill" do
visit extra_bills_url
click_on "New extra bill"
test "should create credit card bill" do
visit credit_card_bills_url
click_on "New credit card bill"
fill_in "Amount", with: @extra_bill.amount
check "Deduct autopaid" if @extra_bill.deduct_autopaid
fill_in "Description", with: @extra_bill.description
click_on "Create Extra bill"
fill_in "Amount", with: @credit_card_bill.amount
fill_in "Description", with: @credit_card_bill.description
click_on "Create Credit card bill"
assert_text "Extra bill was successfully created"
assert_text "Credit card bill was successfully created"
click_on "Back"
end
test "should update Extra bill" do
visit extra_bill_url(@extra_bill)
click_on "Edit this extra bill", match: :first
test "should update Credit card bill" do
visit credit_card_bill_url(@credit_card_bill)
click_on "Edit this credit card bill", match: :first
fill_in "Amount", with: @extra_bill.amount
check "Deduct autopaid" if @extra_bill.deduct_autopaid
fill_in "Description", with: @extra_bill.description
click_on "Update Extra bill"
fill_in "Amount", with: @credit_card_bill.amount
fill_in "Description", with: @credit_card_bill.description
click_on "Update Credit card bill"
assert_text "Extra bill was successfully updated"
assert_text "Credit card bill was successfully updated"
click_on "Back"
end
test "should destroy Extra bill" do
visit extra_bill_url(@extra_bill)
click_on "Destroy this extra bill", match: :first
test "should destroy Credit card bill" do
visit credit_card_bill_url(@credit_card_bill)
click_on "Destroy this credit card bill", match: :first
assert_text "Extra bill was successfully destroyed"
assert_text "Credit card bill was successfully destroyed"
end
end