1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
|
# frozen_string_literal: true
require "test_helper"
class DashboardStaticsControllerTest < ActionDispatch::IntegrationTest
def test_it_serves_assets
get graphql_dashboard.static_path("dashboard.css")
assert_includes response.body, "#header-icon {"
assert_equal response.headers["Cache-Control"], "max-age=31556952, public"
end
def test_it_doesnt_trigger_csrf_failure
original_forgery_protection = ActionController::Base.allow_forgery_protection
ActionController::Base.allow_forgery_protection = true
get graphql_dashboard.static_path("dashboard.js")
assert_equal 200, response.status
ensure
ActionController::Base.allow_forgery_protection = original_forgery_protection
end
def test_it_responds_404_for_others
get graphql_dashboard.static_path("other.rb")
assert_equal 404, response.status
assert_raises ActionController::UrlGenerationError do
graphql_dashboard.static_path("invalid~char.js")
end
get graphql_dashboard.static_path("invalid-char.js").sub("-char", "~char")
assert_equal 404, response.status
end
end
|