2022-11-20 15:43:33 -05:00
|
|
|
require "application_system_test_case"
|
|
|
|
|
|
|
|
class ExpensesTest < ApplicationSystemTestCase
|
|
|
|
setup do
|
2023-11-22 21:41:03 -05:00
|
|
|
@expense = expenses(:monthly_expense)
|
2024-09-08 21:07:51 -04:00
|
|
|
login(users(:one).email)
|
2022-11-20 15:43:33 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
test "visiting the index" do
|
|
|
|
visit expenses_url
|
|
|
|
assert_selector "h1", text: "Expenses"
|
|
|
|
end
|
|
|
|
|
|
|
|
test "should create expense" do
|
|
|
|
visit expenses_url
|
|
|
|
click_on "New expense"
|
|
|
|
|
2023-03-03 18:12:59 -05:00
|
|
|
check "Credit card" if @expense.credit_card
|
2022-11-20 15:43:33 -05:00
|
|
|
fill_in "Description", with: @expense.description
|
|
|
|
check "Estimated" if @expense.estimated
|
|
|
|
fill_in "Payment", with: @expense.payment
|
2023-07-10 23:09:57 -04:00
|
|
|
select @expense.period.capitalize, from: "Period"
|
2022-11-20 15:43:33 -05:00
|
|
|
click_on "Create Expense"
|
|
|
|
|
|
|
|
assert_text "Expense was successfully created"
|
|
|
|
click_on "Back"
|
|
|
|
end
|
|
|
|
|
|
|
|
test "should update Expense" do
|
|
|
|
visit expense_url(@expense)
|
|
|
|
click_on "Edit this expense", match: :first
|
|
|
|
|
2023-03-03 18:12:59 -05:00
|
|
|
check "Credit card" if @expense.credit_card
|
2022-11-20 15:43:33 -05:00
|
|
|
fill_in "Description", with: @expense.description
|
|
|
|
check "Estimated" if @expense.estimated
|
|
|
|
fill_in "Payment", with: @expense.payment
|
2023-07-10 23:09:57 -04:00
|
|
|
select @expense.period.capitalize, from: "Period"
|
2022-11-20 15:43:33 -05:00
|
|
|
click_on "Update Expense"
|
|
|
|
|
|
|
|
assert_text "Expense was successfully updated"
|
|
|
|
click_on "Back"
|
|
|
|
end
|
|
|
|
|
|
|
|
test "should destroy Expense" do
|
|
|
|
visit expense_url(@expense)
|
|
|
|
click_on "Destroy this expense", match: :first
|
|
|
|
|
|
|
|
assert_text "Expense was successfully destroyed"
|
|
|
|
end
|
|
|
|
end
|