2024-09-05 22:54:38 +02:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
|
|
require "test_helper"
|
2024-07-19 02:29:18 +02:00
|
|
|
|
2024-11-08 22:05:31 +01:00
|
|
|
class ChecklistEntriesControllerTest < ::ControllerTest
|
2024-09-22 22:49:53 +02:00
|
|
|
teardown do
|
|
|
|
|
logout
|
|
|
|
|
end
|
|
|
|
|
|
2024-07-19 02:29:18 +02:00
|
|
|
setup do
|
|
|
|
|
@checklist_entry = checklist_entries(:one)
|
2024-11-08 22:05:31 +01:00
|
|
|
User.create!(email_address: "test@example.com", password: "password")
|
2024-09-22 22:49:53 +02:00
|
|
|
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
|