2024-09-05 22:54:38 +02:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
2024-07-16 20:22:59 +02:00
|
|
|
require "test_helper"
|
|
|
|
|
|
2024-11-08 22:05:31 +01:00
|
|
|
class ReportsControllerTest < ::ControllerTest
|
2024-09-22 22:49:53 +02:00
|
|
|
teardown do
|
|
|
|
|
logout
|
|
|
|
|
end
|
|
|
|
|
|
2024-07-16 20:22:59 +02:00
|
|
|
setup do
|
|
|
|
|
@report = reports(: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-16 20:22:59 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
test "should get index" do
|
2024-11-24 22:08:36 +01:00
|
|
|
get project_reports_url(@report.project)
|
2024-07-16 20:22:59 +02:00
|
|
|
assert_response :success
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
test "should get new" do
|
2024-11-24 22:08:36 +01:00
|
|
|
get new_project_report_url(@report.project)
|
2024-07-16 20:22:59 +02:00
|
|
|
assert_response :success
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
test "should create report" do
|
|
|
|
|
assert_difference("Report.count") do
|
2024-11-24 22:08:36 +01:00
|
|
|
post project_reports_url(@report.project), params: { report: { comment: @report.comment, name: @report.name } }
|
2024-07-16 20:22:59 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
assert_redirected_to report_url(Report.last)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
test "should show report" do
|
|
|
|
|
get report_url(@report)
|
|
|
|
|
assert_response :success
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
test "should get edit" do
|
|
|
|
|
get edit_report_url(@report)
|
|
|
|
|
assert_response :success
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
test "should update report" do
|
2024-10-31 23:13:18 +01:00
|
|
|
patch report_url(@report), params: { report: { comment: @report.comment, name: @report.name } }
|
2024-07-16 20:22:59 +02:00
|
|
|
assert_redirected_to report_url(@report)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
test "should destroy report" do
|
|
|
|
|
assert_difference("Report.count", -1) do
|
|
|
|
|
delete report_url(@report)
|
|
|
|
|
end
|
|
|
|
|
|
2024-11-24 22:08:36 +01:00
|
|
|
assert_redirected_to project_url(@report.project)
|
2024-07-16 20:22:59 +02:00
|
|
|
end
|
|
|
|
|
end
|