a11yist/test/controllers/reports_controller_test.rb
david 729ed13521
Some checks failed
/ Run tests (push) Failing after 1m19s
/ Run system tests (push) Failing after 1m18s
/ Build, push and deploy image (push) Has been skipped
start of iteration 2
2024-10-31 23:13:18 +01:00

66 lines
1.4 KiB
Ruby

# frozen_string_literal: true
require "test_helper"
class ReportsControllerTest < 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
@report = reports(:one)
Account.create(email: "test@example.com", password: "password")
login("test@example.com", "password")
end
test "should get index" do
get reports_url
assert_response :success
end
test "should get new" do
get new_report_url
assert_response :success
end
test "should create report" do
assert_difference("Report.count") do
post reports_url, 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 reports_url
end
end