hubfeenix.fi/test/controllers/entities_controller_test.rb
2023-01-13 21:47:31 +02:00

49 lines
1.1 KiB
Ruby

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, member_id: @entity.member_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, member_id: @entity.member_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