56 lines
1.3 KiB
Ruby
56 lines
1.3 KiB
Ruby
# frozen_string_literal: true
|
|
|
|
require "test_helper"
|
|
|
|
class ReportsControllerTest < ::ControllerTest
|
|
teardown do
|
|
logout
|
|
end
|
|
|
|
setup do
|
|
@report = reports(:one)
|
|
User.create!(email_address: "test@example.com", password: "password")
|
|
login("test@example.com", "password")
|
|
end
|
|
|
|
test "should get index" do
|
|
get project_reports_url(@report.project)
|
|
assert_response :success
|
|
end
|
|
|
|
test "should get new" do
|
|
get new_project_report_url(@report.project)
|
|
assert_response :success
|
|
end
|
|
|
|
test "should create report" do
|
|
assert_difference("Report.count") do
|
|
post project_reports_url(@report.project), params: { report: { comment: @report.comment, name: @report.name } }
|
|
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
|
|
patch report_url(@report), params: { report: { comment: @report.comment, name: @report.name } }
|
|
assert_redirected_to report_url(@report)
|
|
end
|
|
|
|
test "should destroy report" do
|
|
assert_difference("Report.count", -1) do
|
|
delete report_url(@report)
|
|
end
|
|
|
|
assert_redirected_to project_url(@report.project)
|
|
end
|
|
end
|