From 6427b28c60c6ed0dfd637307d1ab4ffe65c1144d Mon Sep 17 00:00:00 2001 From: Matthew Lemon Date: Thu, 14 Nov 2024 15:47:43 +0000 Subject: Adds ResourceType model --- test/controllers/resource_types_controller_test.rb | 48 ++++++++++++++++++++++ test/fixtures/resource_types.yml | 7 ++++ test/models/resource_type_test.rb | 7 ++++ test/system/resource_types_test.rb | 41 ++++++++++++++++++ 4 files changed, 103 insertions(+) create mode 100644 test/controllers/resource_types_controller_test.rb create mode 100644 test/fixtures/resource_types.yml create mode 100644 test/models/resource_type_test.rb create mode 100644 test/system/resource_types_test.rb (limited to 'test') diff --git a/test/controllers/resource_types_controller_test.rb b/test/controllers/resource_types_controller_test.rb new file mode 100644 index 0000000..c5621ab --- /dev/null +++ b/test/controllers/resource_types_controller_test.rb @@ -0,0 +1,48 @@ +require "test_helper" + +class ResourceTypesControllerTest < ActionDispatch::IntegrationTest + setup do + @resource_type = resource_types(:one) + 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 + assert_difference("ResourceType.count") do + post resource_types_url, params: { resource_type: { name: @resource_type.name } } + end + + 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 diff --git a/test/fixtures/resource_types.yml b/test/fixtures/resource_types.yml new file mode 100644 index 0000000..7d41224 --- /dev/null +++ b/test/fixtures/resource_types.yml @@ -0,0 +1,7 @@ +# Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html + +one: + name: MyString + +two: + name: MyString diff --git a/test/models/resource_type_test.rb b/test/models/resource_type_test.rb new file mode 100644 index 0000000..43ef137 --- /dev/null +++ b/test/models/resource_type_test.rb @@ -0,0 +1,7 @@ +require "test_helper" + +class ResourceTypeTest < ActiveSupport::TestCase + # test "the truth" do + # assert true + # end +end diff --git a/test/system/resource_types_test.rb b/test/system/resource_types_test.rb new file mode 100644 index 0000000..54fc45f --- /dev/null +++ b/test/system/resource_types_test.rb @@ -0,0 +1,41 @@ +require "application_system_test_case" + +class ResourceTypesTest < ApplicationSystemTestCase + setup do + @resource_type = resource_types(:one) + end + + test "visiting the index" do + visit resource_types_url + assert_selector "h1", text: "Resource types" + end + + test "should create resource type" do + visit resource_types_url + click_on "New resource type" + + fill_in "Name", with: @resource_type.name + click_on "Create Resource type" + + assert_text "Resource type was successfully created" + click_on "Back" + end + + test "should update Resource type" do + visit resource_type_url(@resource_type) + click_on "Edit this resource type", match: :first + + fill_in "Name", with: @resource_type.name + click_on "Update Resource type" + + assert_text "Resource type was successfully updated" + click_on "Back" + end + + test "should destroy Resource type" do + visit resource_type_url(@resource_type) + click_on "Destroy this resource type", match: :first + + assert_text "Resource type was successfully destroyed" + end +end -- cgit v1.2.3