2024-09-05 22:54:38 +02:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
|
|
require "test_helper"
|
2024-07-16 20:22:59 +02:00
|
|
|
|
|
|
|
|
class ElementsControllerTest < ActionDispatch::IntegrationTest
|
|
|
|
|
setup do
|
|
|
|
|
@element = elements(:one)
|
2024-07-22 22:40:56 +02:00
|
|
|
@checklist = checklists(:one)
|
2024-07-16 20:22:59 +02:00
|
|
|
end
|
|
|
|
|
|
2024-09-05 22:54:38 +02:00
|
|
|
test "should get index" do
|
2024-07-16 20:22:59 +02:00
|
|
|
get elements_url
|
|
|
|
|
assert_response :success
|
|
|
|
|
end
|
|
|
|
|
|
2024-09-05 22:54:38 +02:00
|
|
|
test "should get new" do
|
2024-07-16 20:22:59 +02:00
|
|
|
get new_element_url
|
|
|
|
|
assert_response :success
|
|
|
|
|
end
|
|
|
|
|
|
2024-09-05 22:54:38 +02:00
|
|
|
test "should create element" do
|
|
|
|
|
assert_difference("Element.count") do
|
2024-07-22 22:40:56 +02:00
|
|
|
post elements_url,
|
2024-07-26 00:59:00 +02:00
|
|
|
params: { element: { description_html: @element.description_html, path: @element.path, report_id: @element.report_id,
|
2024-07-22 22:40:56 +02:00
|
|
|
title: @element.title, checklist_id: @checklist.id } }
|
2024-07-16 20:22:59 +02:00
|
|
|
end
|
|
|
|
|
|
2024-07-22 22:40:56 +02:00
|
|
|
assert_redirected_to report_url(Element.last.report)
|
2024-07-16 20:22:59 +02:00
|
|
|
end
|
|
|
|
|
|
2024-09-05 22:54:38 +02:00
|
|
|
test "should show element" do
|
2024-07-16 20:22:59 +02:00
|
|
|
get element_url(@element)
|
|
|
|
|
assert_response :success
|
|
|
|
|
end
|
|
|
|
|
|
2024-09-05 22:54:38 +02:00
|
|
|
test "should get edit" do
|
2024-07-16 20:22:59 +02:00
|
|
|
get edit_element_url(@element)
|
|
|
|
|
assert_response :success
|
|
|
|
|
end
|
|
|
|
|
|
2024-09-05 22:54:38 +02:00
|
|
|
test "should update element" do
|
2024-07-22 22:40:56 +02:00
|
|
|
patch element_url(@element),
|
2024-07-26 00:59:00 +02:00
|
|
|
params: { element: { description_html: @element.description_html, path: @element.path, report_id: @element.report_id,
|
2024-07-22 22:40:56 +02:00
|
|
|
title: @element.title } }
|
2024-07-16 20:22:59 +02:00
|
|
|
assert_redirected_to element_url(@element)
|
|
|
|
|
end
|
|
|
|
|
|
2024-09-05 22:54:38 +02:00
|
|
|
test "should destroy element" do
|
|
|
|
|
assert_difference("Element.count", -1) do
|
2024-07-16 20:22:59 +02:00
|
|
|
delete element_url(@element)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
assert_redirected_to elements_url
|
|
|
|
|
end
|
|
|
|
|
end
|