a11yist/test/controllers/checklist_entries_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.9 KiB
Ruby

# frozen_string_literal: true
require "test_helper"
class ChecklistEntriesControllerTest < 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_entry = checklist_entries(:one)
Account.create(email: "test@example.com", password: "password")
login("test@example.com", "password")
end
test "should get index" do
get checklist_entries_url
assert_response :success
end
test "should get new" do
get new_checklist_entry_url(checklist_id: @checklist_entry.checklist_id)
assert_response :success
end
test "should create checklist_entry" do
assert_difference("ChecklistEntry.count") do
post checklist_entries_url,
params: { checklist_entry: { check_id: @checklist_entry.check_id, checklist_id: @checklist_entry.checklist_id,
position: @checklist_entry.position } }
end
assert_redirected_to checklist_url(ChecklistEntry.last.checklist)
end
test "should show checklist_entry" do
get checklist_entry_url(@checklist_entry)
assert_response :success
end
test "should get edit" do
get edit_checklist_entry_url(@checklist_entry)
assert_response :success
end
test "should update checklist_entry" do
patch checklist_entry_url(@checklist_entry),
params: { checklist_entry: { check_id: @checklist_entry.check_id, checklist_id: @checklist_entry.checklist_id,
position: @checklist_entry.position } }
assert_redirected_to checklist_url(@checklist_entry.checklist)
end
test "should destroy checklist_entry" do
assert_difference("ChecklistEntry.count", -1) do
delete checklist_entry_url(@checklist_entry)
end
assert_redirected_to checklist_entries_url
end
end