Skip to content

Commit

Permalink
add tests for water trckers controller
Browse files Browse the repository at this point in the history
  • Loading branch information
one-m1nd committed Mar 4, 2024
1 parent 8ce166f commit a90cebc
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 0 deletions.
48 changes: 48 additions & 0 deletions test/controllers/water_trackers_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
require "test_helper"

class WaterTrackersControllerTest < ActionDispatch::IntegrationTest
setup do
@watertracker = watertrackers(:one)
end

test "should get index" do
get watertrackers_url
assert_response :success
end

test "should get new" do
get new_watertracker_url
assert_response :success
end

test "should create watertracker" do
assert_difference("Watertracker.count") do
post watertrackers_url, params: { watertracker: { date: '2006-6-6' } }
end

assert_redirected_to watertracker_url(Watertracker.last)
end

test "should show watertracker" do
get watertracker_url(@watertracker)
assert_response :success
end

test "should get edit" do
get edit_watertracker_url(@watertracker)
assert_response :success
end

test "should update watertracker" do
patch watertracker_url(@watertracker), params: { watertracker: { date: '2006-06-06' } }
assert_redirected_to watertracker_url(@watertracker)
end

test "should destroy watertracker" do
assert_difference("Watertracker.count", -1) do
delete watertracker_url(@watertracker)
end

assert_redirected_to watertracker_url
end
end
2 changes: 2 additions & 0 deletions test/fixtures/watertrackers.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
# Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html

one:
id: 1
date: 2024-02-24

two:
id: 2
date: 2024-03-02

0 comments on commit a90cebc

Please sign in to comment.