aboutsummaryrefslogtreecommitdiffstats
path: root/actionview
diff options
context:
space:
mode:
authoryuuji.yaginuma <yuuji.yaginuma@gmail.com>2019-02-14 13:51:18 +0900
committeryuuji.yaginuma <yuuji.yaginuma@gmail.com>2019-02-14 13:51:18 +0900
commit3f186e30452b700483c42c8d07f095c7b5c031b8 (patch)
tree232e3e7e3caca9c3ea71a757545ef97ba68dd26c /actionview
parentac68550ae6d117b1d257f5df38ba76e03b7e2cf4 (diff)
downloadrails-3f186e30452b700483c42c8d07f095c7b5c031b8.tar.gz
rails-3f186e30452b700483c42c8d07f095c7b5c031b8.tar.bz2
rails-3f186e30452b700483c42c8d07f095c7b5c031b8.zip
Add test for `csp_meta_tag`
Diffstat (limited to 'actionview')
-rw-r--r--actionview/test/template/csp_helper_test.rb31
1 files changed, 31 insertions, 0 deletions
diff --git a/actionview/test/template/csp_helper_test.rb b/actionview/test/template/csp_helper_test.rb
new file mode 100644
index 0000000000..8bad25ba7d
--- /dev/null
+++ b/actionview/test/template/csp_helper_test.rb
@@ -0,0 +1,31 @@
+# frozen_string_literal: true
+
+require "abstract_unit"
+
+class CspHelperWithCspEnabledTest < ActionView::TestCase
+ tests ActionView::Helpers::CspHelper
+
+ def content_security_policy_nonce
+ "iyhD0Yc0W+c="
+ end
+
+ def content_security_policy?
+ true
+ end
+
+ def test_csp_meta_tag
+ assert_equal "<meta name=\"csp-nonce\" content=\"iyhD0Yc0W+c=\" />", csp_meta_tag
+ end
+end
+
+class CspHelperWithCspDisabledTest < ActionView::TestCase
+ tests ActionView::Helpers::CspHelper
+
+ def content_security_policy?
+ false
+ end
+
+ def test_csp_meta_tag
+ assert_nil csp_meta_tag
+ end
+end