a11yist/test/controllers/elements_controller_test.rb
david 6e1a17281d
Some checks failed
/ Run tests (push) Failing after 55s
/ Run system tests (push) Failing after 55s
/ Build, push and deploy image (push) Has been skipped
Fix tests
2024-09-22 22:49:53 +02:00

71 lines
1.7 KiB
Ruby

# frozen_string_literal: true
require "test_helper"
class ElementsControllerTest < ActionDispatch::IntegrationTest
def login(email, password)
post "/login", params: { email: email, password: password }
assert_redirected_to "/"
end
def logout
post "/logout"
assert_redirected_to "/"
end
teardown do
logout
end
setup do
@element = elements(:one)
@checklist = checklists(:one)
Account.create(email: "test@example.com", password: "password")
login("test@example.com", "password")
end
test "should get index" do
get elements_url
assert_response :success
end
test "should get new" do
get new_element_url
assert_response :success
end
test "should create element" do
assert_difference("Element.count") do
post elements_url,
params: { element: { description_html: @element.description_html, path: @element.path, report_id: @element.report_id,
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_html: @element.description_html, path: @element.path, report_id: @element.report_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 elements_url
end
end