Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
c3c05892
Commit
c3c05892
authored
Nov 24, 2020
by
dcouture
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove usage of allow_any_instance_of
parent
30ffdabf
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
7 deletions
+7
-7
spec/helpers/gitlab_script_tag_helper_spec.rb
spec/helpers/gitlab_script_tag_helper_spec.rb
+7
-7
No files found.
spec/helpers/gitlab_script_tag_helper_spec.rb
View file @
c3c05892
...
...
@@ -4,14 +4,14 @@ require 'spec_helper'
RSpec
.
describe
GitlabScriptTagHelper
do
before
do
allow
_any_instance_of
(
GitlabScriptTagH
elper
).
to
receive
(
:content_security_policy_nonce
).
and_return
(
'noncevalue'
)
allow
(
h
elper
).
to
receive
(
:content_security_policy_nonce
).
and_return
(
'noncevalue'
)
end
describe
'external script tag'
do
let
(
:script_url
)
{
'test.js'
}
it
'returns a script tag with defer=true and a nonce'
do
expect
(
javascript_include_tag
(
script_url
).
to_s
)
expect
(
helper
.
javascript_include_tag
(
script_url
).
to_s
)
.
to
eq
"<script src=
\"
/javascripts/
#{
script_url
}
\"
defer=
\"
defer
\"
nonce=
\"
noncevalue
\"
></script>"
end
end
...
...
@@ -21,24 +21,24 @@ RSpec.describe GitlabScriptTagHelper do
let
(
:tag_with_nonce_and_type
)
{
"<script type=
\"
application/javascript
\"
nonce=
\"
noncevalue
\"
>
\n
//<![CDATA[
\n
alert(1)
\n
//]]>
\n
</script>"
}
it
'returns a script tag with a nonce using block syntax'
do
expect
(
javascript_tag
{
'alert(1)'
}.
to_s
).
to
eq
tag_with_nonce
expect
(
helper
.
javascript_tag
{
'alert(1)'
}.
to_s
).
to
eq
tag_with_nonce
end
it
'returns a script tag with a nonce using block syntax with options'
do
expect
(
javascript_tag
(
type:
'application/javascript'
)
{
'alert(1)'
}.
to_s
).
to
eq
tag_with_nonce_and_type
expect
(
helper
.
javascript_tag
(
type:
'application/javascript'
)
{
'alert(1)'
}.
to_s
).
to
eq
tag_with_nonce_and_type
end
it
'returns a script tag with a nonce using argument syntax'
do
expect
(
javascript_tag
(
'alert(1)'
).
to_s
).
to
eq
tag_with_nonce
expect
(
helper
.
javascript_tag
(
'alert(1)'
).
to_s
).
to
eq
tag_with_nonce
end
it
'returns a script tag with a nonce using argument syntax with options'
do
expect
(
javascript_tag
(
'alert(1)'
,
type:
'application/javascript'
).
to_s
).
to
eq
tag_with_nonce_and_type
expect
(
helper
.
javascript_tag
(
'alert(1)'
,
type:
'application/javascript'
).
to_s
).
to
eq
tag_with_nonce_and_type
end
# This scenario does not really make sense, but it's supported so we test it
it
'returns a script tag with a nonce using argument and block syntax with options'
do
expect
(
javascript_tag
(
'// ignored'
,
type:
'application/javascript'
)
{
'alert(1)'
}.
to_s
).
to
eq
tag_with_nonce_and_type
expect
(
helper
.
javascript_tag
(
'// ignored'
,
type:
'application/javascript'
)
{
'alert(1)'
}.
to_s
).
to
eq
tag_with_nonce_and_type
end
end
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment