Skip to content

Commit

Permalink
fixing up controller + adding testts
Browse files Browse the repository at this point in the history
  • Loading branch information
one-m1nd committed Mar 8, 2024
1 parent 7ad44b0 commit 39915b2
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/controllers/fertilizer_trackers_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,6 @@ def set_fertilizer_tracker

# Only allow a list of trusted parameters through.
def fertilizer_tracker_params
params.fetch(:fertilizer_tracker, {})
params.require(:fertilizer_tracker).permit([:name, :date])
end
end
47 changes: 47 additions & 0 deletions test/controllers/fertilizer_trackers_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
require "test_helper"
class FertilizerTrackersControllerTest < ActionDispatch::IntegrationTest
setup do
@fertilizer_tracker = fertilizer_trackers(:one)
end

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

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

test "should create fertilizer_tracker" do
assert_difference("FertilizerTracker.count") do
post fertilizer_trackers_url, params: { fertilizer_tracker: { date: '2006-6-6', name: 'giga' } }
end

assert_redirected_to fertilizer_tracker_url(FertilizerTracker.last)
end

test "should show fertilizer_tracker" do
get fertilizer_tracker_url(@fertilizer_tracker)
assert_response :success
end

test "should get edit" do
get edit_fertilizer_tracker_url(@fertilizer_tracker)
assert_response :success
end

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

test "should destroy fertilizer_tracker" do
assert_difference("FertilizerTracker.count", -1) do
delete fertilizer_tracker_url(@fertilizer_tracker)
end

assert_redirected_to fertilizer_trackers_url
end
end

0 comments on commit 39915b2

Please sign in to comment.