From 6f197cf2fda6ef1888deafb2acffa095cc0906c7 Mon Sep 17 00:00:00 2001 From: Matthew Lemon Date: Sun, 15 Dec 2024 20:21:28 +0000 Subject: ResourceType tests now pass --- test/controllers/resource_types_controller_test.rb | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/test/controllers/resource_types_controller_test.rb b/test/controllers/resource_types_controller_test.rb index c04a258..3d3ea8d 100644 --- a/test/controllers/resource_types_controller_test.rb +++ b/test/controllers/resource_types_controller_test.rb @@ -19,16 +19,21 @@ class ResourceTypesControllerTest < ActionDispatch::IntegrationTest end test "should create resource_type" do - assert_difference("ResourceType.count") do - post resource_types_url, params: { resource_type: { name: @resource_type.name } } + # Use a unique name to avoid validation conflicts. + unique_name = "UniqueResourceTypeName#{SecureRandom.hex(8)}" + + # POST request to create a new resource type. + assert_difference("ResourceType.count", 1) do + post resource_types_url, params: { resource_type: { name: unique_name } } end + # Assert redirection to the newly created resource. assert_redirected_to resource_type_url(ResourceType.last) end test "should show resource_type" do get resource_type_url(@resource_type) - assert_response :redirect + assert_response :success end test "should get edit" do -- cgit v1.2.3