a11yist/test/controllers/checklist_entries_controller_test.rb

71 lines
1.9 KiB
Ruby
Raw Normal View History

2024-09-05 22:54:38 +02:00
# frozen_string_literal: true
require "test_helper"
2024-07-19 02:29:18 +02:00
class ChecklistEntriesControllerTest < ActionDispatch::IntegrationTest
2024-09-22 22:49:53 +02:00
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
2024-07-19 02:29:18 +02:00
setup do
@checklist_entry = checklist_entries(:one)
2024-09-22 22:49:53 +02:00
Account.create(email: "test@example.com", password: "password")
login("test@example.com", "password")
2024-07-19 02:29:18 +02:00
end
2024-09-05 22:54:38 +02:00
test "should get index" do
2024-07-19 02:29:18 +02:00
get checklist_entries_url
assert_response :success
end
2024-09-05 22:54:38 +02:00
test "should get new" do
2024-07-22 22:40:56 +02:00
get new_checklist_entry_url(checklist_id: @checklist_entry.checklist_id)
2024-07-19 02:29:18 +02:00
assert_response :success
end
2024-09-05 22:54:38 +02:00
test "should create checklist_entry" do
assert_difference("ChecklistEntry.count") do
2024-07-22 22:40:56 +02:00
post checklist_entries_url,
params: { checklist_entry: { check_id: @checklist_entry.check_id, checklist_id: @checklist_entry.checklist_id,
position: @checklist_entry.position } }
2024-07-19 02:29:18 +02:00
end
2024-07-22 22:40:56 +02:00
assert_redirected_to checklist_url(ChecklistEntry.last.checklist)
2024-07-19 02:29:18 +02:00
end
2024-09-05 22:54:38 +02:00
test "should show checklist_entry" do
2024-07-19 02:29:18 +02:00
get checklist_entry_url(@checklist_entry)
assert_response :success
end
2024-09-05 22:54:38 +02:00
test "should get edit" do
2024-07-19 02:29:18 +02:00
get edit_checklist_entry_url(@checklist_entry)
assert_response :success
end
2024-09-05 22:54:38 +02:00
test "should update checklist_entry" do
2024-07-22 22:40:56 +02:00
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)
2024-07-19 02:29:18 +02:00
end
2024-09-05 22:54:38 +02:00
test "should destroy checklist_entry" do
assert_difference("ChecklistEntry.count", -1) do
2024-07-19 02:29:18 +02:00
delete checklist_entry_url(@checklist_entry)
end
assert_redirected_to checklist_entries_url
end
end