Track incomes
This commit is contained in:
parent
ab00344de0
commit
e098ab48ca
19 changed files with 337 additions and 1 deletions
48
test/controllers/incomes_controller_test.rb
Normal file
48
test/controllers/incomes_controller_test.rb
Normal file
|
@ -0,0 +1,48 @@
|
|||
require "test_helper"
|
||||
|
||||
class IncomesControllerTest < ActionDispatch::IntegrationTest
|
||||
setup do
|
||||
@income = incomes(:one)
|
||||
end
|
||||
|
||||
test "should get index" do
|
||||
get incomes_url
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
test "should get new" do
|
||||
get new_income_url
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
test "should create income" do
|
||||
assert_difference("Income.count") do
|
||||
post incomes_url, params: { income: { amount: @income.amount, description: @income.description, included: @income.included, member_id: @income.member_id } }
|
||||
end
|
||||
|
||||
assert_redirected_to income_url(Income.last)
|
||||
end
|
||||
|
||||
test "should show income" do
|
||||
get income_url(@income)
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
test "should get edit" do
|
||||
get edit_income_url(@income)
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
test "should update income" do
|
||||
patch income_url(@income), params: { income: { amount: @income.amount, description: @income.description, included: @income.included, member_id: @income.member_id } }
|
||||
assert_redirected_to income_url(@income)
|
||||
end
|
||||
|
||||
test "should destroy income" do
|
||||
assert_difference("Income.count", -1) do
|
||||
delete income_url(@income)
|
||||
end
|
||||
|
||||
assert_redirected_to incomes_url
|
||||
end
|
||||
end
|
13
test/fixtures/incomes.yml
vendored
Normal file
13
test/fixtures/incomes.yml
vendored
Normal file
|
@ -0,0 +1,13 @@
|
|||
# Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
|
||||
|
||||
one:
|
||||
description: MyString
|
||||
included: false
|
||||
amount: 9.99
|
||||
member: one
|
||||
|
||||
two:
|
||||
description: MyString
|
||||
included: false
|
||||
amount: 9.99
|
||||
member: two
|
7
test/models/income_test.rb
Normal file
7
test/models/income_test.rb
Normal file
|
@ -0,0 +1,7 @@
|
|||
require "test_helper"
|
||||
|
||||
class IncomeTest < ActiveSupport::TestCase
|
||||
# test "the truth" do
|
||||
# assert true
|
||||
# end
|
||||
end
|
47
test/system/incomes_test.rb
Normal file
47
test/system/incomes_test.rb
Normal file
|
@ -0,0 +1,47 @@
|
|||
require "application_system_test_case"
|
||||
|
||||
class IncomesTest < ApplicationSystemTestCase
|
||||
setup do
|
||||
@income = incomes(:one)
|
||||
end
|
||||
|
||||
test "visiting the index" do
|
||||
visit incomes_url
|
||||
assert_selector "h1", text: "Incomes"
|
||||
end
|
||||
|
||||
test "should create income" do
|
||||
visit incomes_url
|
||||
click_on "New income"
|
||||
|
||||
fill_in "Amount", with: @income.amount
|
||||
fill_in "Description", with: @income.description
|
||||
check "Included" if @income.included
|
||||
fill_in "Member", with: @income.member_id
|
||||
click_on "Create Income"
|
||||
|
||||
assert_text "Income was successfully created"
|
||||
click_on "Back"
|
||||
end
|
||||
|
||||
test "should update Income" do
|
||||
visit income_url(@income)
|
||||
click_on "Edit this income", match: :first
|
||||
|
||||
fill_in "Amount", with: @income.amount
|
||||
fill_in "Description", with: @income.description
|
||||
check "Included" if @income.included
|
||||
fill_in "Member", with: @income.member_id
|
||||
click_on "Update Income"
|
||||
|
||||
assert_text "Income was successfully updated"
|
||||
click_on "Back"
|
||||
end
|
||||
|
||||
test "should destroy Income" do
|
||||
visit income_url(@income)
|
||||
click_on "Destroy this income", match: :first
|
||||
|
||||
assert_text "Income was successfully destroyed"
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue