2022-11-20 15:43:33 -05:00
|
|
|
require "test_helper"
|
|
|
|
|
|
|
|
class ExpensesControllerTest < ActionDispatch::IntegrationTest
|
|
|
|
setup do
|
|
|
|
@expense = expenses(:one)
|
|
|
|
end
|
|
|
|
|
|
|
|
test "should get index" do
|
|
|
|
get expenses_url
|
|
|
|
assert_response :success
|
|
|
|
end
|
|
|
|
|
|
|
|
test "should get new" do
|
|
|
|
get new_expense_url
|
|
|
|
assert_response :success
|
|
|
|
end
|
|
|
|
|
|
|
|
test "should create expense" do
|
|
|
|
assert_difference("Expense.count") do
|
2023-03-08 19:25:24 -05:00
|
|
|
post expenses_url, params: {expense: {credit_card: @expense.credit_card, description: @expense.description, estimated: @expense.estimated, payment: @expense.payment, period: @expense.period}}
|
2022-11-20 15:43:33 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
assert_redirected_to expense_url(Expense.last)
|
|
|
|
end
|
|
|
|
|
|
|
|
test "should show expense" do
|
|
|
|
get expense_url(@expense)
|
|
|
|
assert_response :success
|
|
|
|
end
|
|
|
|
|
|
|
|
test "should get edit" do
|
|
|
|
get edit_expense_url(@expense)
|
|
|
|
assert_response :success
|
|
|
|
end
|
|
|
|
|
|
|
|
test "should update expense" do
|
2023-03-08 19:25:24 -05:00
|
|
|
patch expense_url(@expense), params: {expense: {credit_card: @expense.credit_card, description: @expense.description, estimated: @expense.estimated, payment: @expense.payment, period: @expense.period}}
|
2022-11-20 15:43:33 -05:00
|
|
|
assert_redirected_to expense_url(@expense)
|
|
|
|
end
|
|
|
|
|
|
|
|
test "should destroy expense" do
|
|
|
|
assert_difference("Expense.count", -1) do
|
|
|
|
delete expense_url(@expense)
|
|
|
|
end
|
|
|
|
|
|
|
|
assert_redirected_to expenses_url
|
|
|
|
end
|
|
|
|
end
|