diff --git a/app/controllers/fertilizer_trackers_controller.rb b/app/controllers/fertilizer_trackers_controller.rb index 0d05d8f..f72c059 100644 --- a/app/controllers/fertilizer_trackers_controller.rb +++ b/app/controllers/fertilizer_trackers_controller.rb @@ -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 diff --git a/test/controllers/fertilizer_trackers_test.rb b/test/controllers/fertilizer_trackers_test.rb new file mode 100644 index 0000000..b1785d5 --- /dev/null +++ b/test/controllers/fertilizer_trackers_test.rb @@ -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