a11yist/test/controllers/checklists_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

70 lines
1.7 KiB
Ruby

# frozen_string_literal: true
require "test_helper"
class ChecklistsControllerTest < 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
@checklist = checklists(:one)
Account.create(email: "test@example.com", password: "password")
login("test@example.com", "password")
end
test "should get index" do
get checklists_url
assert_response :success
end
test "should get new" do
get new_checklist_url
assert_response :success
end
test "should create checklist" do
assert_difference("Checklist.count") do
post checklists_url,
params: { checklist: { code: @checklist.code, description_html: @checklist.description_html,
name: @checklist.name } }
end
assert_redirected_to checklist_url(Checklist.last)
end
test "should show checklist" do
get checklist_url(@checklist)
assert_response :success
end
test "should get edit" do
get edit_checklist_url(@checklist)
assert_response :success
end
test "should update checklist" do
patch checklist_url(@checklist),
params: { checklist: { code: @checklist.code, description_html: @checklist.description_html,
name: @checklist.name } }
assert_redirected_to checklist_url(@checklist)
end
test "should destroy checklist" do
assert_difference("Checklist.count", -1) do
delete checklist_url(@checklist)
end
assert_redirected_to checklists_url
end
end