entity scaffold

This commit is contained in:
2023-01-13 20:50:41 +02:00
parent c46ecb73e0
commit 26ea76c8e9
15 changed files with 272 additions and 1 deletions

View File

@ -0,0 +1,48 @@
require "test_helper"
class EntitiesControllerTest < ActionDispatch::IntegrationTest
setup do
@entity = entities(:one)
end
test "should get index" do
get entities_url
assert_response :success
end
test "should get new" do
get new_entity_url
assert_response :success
end
test "should create entity" do
assert_difference("Entity.count") do
post entities_url, params: { entity: { ha_id: @entity.ha_id, name: @entity.name, type: @entity.type } }
end
assert_redirected_to entity_url(Entity.last)
end
test "should show entity" do
get entity_url(@entity)
assert_response :success
end
test "should get edit" do
get edit_entity_url(@entity)
assert_response :success
end
test "should update entity" do
patch entity_url(@entity), params: { entity: { ha_id: @entity.ha_id, name: @entity.name, type: @entity.type } }
assert_redirected_to entity_url(@entity)
end
test "should destroy entity" do
assert_difference("Entity.count", -1) do
delete entity_url(@entity)
end
assert_redirected_to entities_url
end
end

11
test/fixtures/entities.yml vendored Normal file
View File

@ -0,0 +1,11 @@
# Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
one:
name: MyString
ha_id: MyString
type:
two:
name: MyString
ha_id: MyString
type:

View File

@ -0,0 +1,7 @@
require "test_helper"
class EntityTest < ActiveSupport::TestCase
# test "the truth" do
# assert true
# end
end

View File

@ -0,0 +1,45 @@
require "application_system_test_case"
class EntitiesTest < ApplicationSystemTestCase
setup do
@entity = entities(:one)
end
test "visiting the index" do
visit entities_url
assert_selector "h1", text: "Entities"
end
test "should create entity" do
visit entities_url
click_on "New entity"
fill_in "Ha", with: @entity.ha_id
fill_in "Name", with: @entity.name
fill_in "Type", with: @entity.type
click_on "Create Entity"
assert_text "Entity was successfully created"
click_on "Back"
end
test "should update Entity" do
visit entity_url(@entity)
click_on "Edit this entity", match: :first
fill_in "Ha", with: @entity.ha_id
fill_in "Name", with: @entity.name
fill_in "Type", with: @entity.type
click_on "Update Entity"
assert_text "Entity was successfully updated"
click_on "Back"
end
test "should destroy Entity" do
visit entity_url(@entity)
click_on "Destroy this entity", match: :first
assert_text "Entity was successfully destroyed"
end
end