require_relative 'test_helper' class AppTest < Minitest::Test include Rack::Test::Methods def app AsxpioWeb end def setup Mail::TestMailer.deliveries.clear TestDb.clean! if TestDb.available? end def csrf_token_from(path, env = {}) get path, {}, env assert last_response.ok?, "GET #{path} failed: #{last_response.status}" last_response.body[/name="authenticity_token" value="([^"]+)"/, 1] || flunk("no CSRF token found on #{path}") end def admin_env(extra = {}) { 'HTTP_AUTHORIZATION' => "Basic #{Base64.strict_encode64("#{ENV['ADMIN_USER']}:#{ENV['ADMIN_PASSWORD']}")}" }.merge(extra) end # --- public pages --------------------------------------------------------- def test_index_renders get '/' assert last_response.ok? end def test_healthz get '/healthz' assert last_response.ok? assert_equal 'ok', last_response.body end # --- contact page --------------------------------------------------------- # The form was removed (persistent spam); the page keeps the direct contacts. def test_contact_page_renders_without_form get '/contact' assert last_response.ok? assert_includes last_response.body, 'ie@asxp.io' refute_match %r{