a11yist/test/controllers/elements_controller_test.rb
david c35c7da6e0
Some checks failed
/ Run tests (push) Successful in 2m51s
/ Run system tests (push) Failing after 3m29s
/ Build, push and deploy image (push) Has been cancelled
Migrate to Rais 8.0
- Remove all Rodauth stuff and implement simple custom auth
- Migrate from sprockets to propshaft, hack some bootstrap stuff
2024-11-08 22:05:31 +01:00

60 lines
1.5 KiB
Ruby

# frozen_string_literal: true
require "test_helper"
class ElementsControllerTest < ::ControllerTest
teardown do
logout
end
setup do
@element = elements(:one)
@checklist = checklists(:one)
User.create!(email_address: "test@example.com", password: "password")
login("test@example.com", "password")
end
test "should get index" do
get page_elements_url(@element.page)
assert_response :success
end
test "should get new" do
get new_page_element_url(@element.page)
assert_response :success
end
test "should create element" do
assert_difference("Element.count") do
post page_elements_url(@element.page),
params: { element: { description: @element.description, title: @element.title, checklist_id: @checklist.id } }
end
assert_redirected_to report_url(Element.last.report)
end
test "should show element" do
get element_url(@element)
assert_response :success
end
test "should get edit" do
get edit_element_url(@element)
assert_response :success
end
test "should update element" do
patch element_url(@element),
params: { element: { description: @element.description, page_id: @element.page_id,
title: @element.title } }
assert_redirected_to element_url(@element)
end
test "should destroy element" do
assert_difference("Element.count", -1) do
delete element_url(@element)
end
assert_redirected_to page_elements_url(@element.page)
end
end