blob: 3d3ea8de60909ebaaf25a1a36766de65f7db9a83 (
plain) (
tree)
|
|
require "test_helper"
class ResourceTypesControllerTest < ActionDispatch::IntegrationTest
setup do
@resource_type = resource_types(:one)
@user = users(:one)
post session_url, params: { email_address: @user.email_address, password: "password" }
follow_redirect! # After login
end
test "should get index" do
get resource_types_url
assert_response :success
end
test "should get new" do
get new_resource_type_url
assert_response :success
end
test "should create resource_type" do
# 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 :success
end
test "should get edit" do
get edit_resource_type_url(@resource_type)
assert_response :success
end
test "should update resource_type" do
patch resource_type_url(@resource_type), params: { resource_type: { name: @resource_type.name } }
assert_redirected_to resource_type_url(@resource_type)
end
test "should destroy resource_type" do
assert_difference("ResourceType.count", -1) do
delete resource_type_url(@resource_type)
end
assert_redirected_to resource_types_url
end
end
|