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
e7c0bd95
Commit
e7c0bd95
authored
Jul 22, 2020
by
Francisco Javier López
Committed by
Shinya Maeda
Jul 22, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Avoid snippet redirection if snippets_binary_blob enabled
parent
8214da07
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
32 additions
and
4 deletions
+32
-4
app/controllers/concerns/snippets_actions.rb
app/controllers/concerns/snippets_actions.rb
+2
-0
spec/support/shared_examples/controllers/binary_blob_shared_examples.rb
...hared_examples/controllers/binary_blob_shared_examples.rb
+30
-4
No files found.
app/controllers/concerns/snippets_actions.rb
View file @
e7c0bd95
...
...
@@ -132,6 +132,8 @@ module SnippetsActions
end
def
redirect_if_binary
return
if
Feature
.
enabled?
(
:snippets_binary_blob
)
redirect_to
gitlab_snippet_path
(
snippet
)
if
blob
&
.
binary?
end
end
spec/support/shared_examples/controllers/binary_blob_shared_examples.rb
View file @
e7c0bd95
# frozen_string_literal: true
RSpec
.
shared_examples
'editing snippet checks blob is binary'
do
let
(
:snippets_binary_blob_value
)
{
true
}
before
do
sign_in
(
user
)
...
...
@@ -8,6 +10,8 @@ RSpec.shared_examples 'editing snippet checks blob is binary' do
allow
(
blob
).
to
receive
(
:binary?
).
and_return
(
binary
)
end
stub_feature_flags
(
snippets_binary_blob:
snippets_binary_blob_value
)
subject
end
...
...
@@ -23,13 +27,24 @@ RSpec.shared_examples 'editing snippet checks blob is binary' do
context
'when blob is binary'
do
let
(
:binary
)
{
true
}
it
'redirects away'
do
expect
(
response
).
to
redirect_to
(
gitlab_snippet_path
(
snippet
))
it
'responds with status 200'
do
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
response
).
to
render_template
(
:edit
)
end
context
'when feature flag :snippets_binary_blob is disabled'
do
let
(
:snippets_binary_blob_value
)
{
false
}
it
'redirects away'
do
expect
(
response
).
to
redirect_to
(
gitlab_snippet_path
(
snippet
))
end
end
end
end
RSpec
.
shared_examples
'updating snippet checks blob is binary'
do
let
(
:snippets_binary_blob_value
)
{
true
}
before
do
sign_in
(
user
)
...
...
@@ -37,6 +52,8 @@ RSpec.shared_examples 'updating snippet checks blob is binary' do
allow
(
blob
).
to
receive
(
:binary?
).
and_return
(
binary
)
end
stub_feature_flags
(
snippets_binary_blob:
snippets_binary_blob_value
)
subject
end
...
...
@@ -52,9 +69,18 @@ RSpec.shared_examples 'updating snippet checks blob is binary' do
context
'when blob is binary'
do
let
(
:binary
)
{
true
}
it
'redirects away without updating'
do
it
'updates successfully'
do
expect
(
snippet
.
reload
.
title
).
to
eq
title
expect
(
response
).
to
redirect_to
(
gitlab_snippet_path
(
snippet
))
expect
(
snippet
.
reload
.
title
).
not_to
eq
title
end
context
'when feature flag :snippets_binary_blob is disabled'
do
let
(
:snippets_binary_blob_value
)
{
false
}
it
'redirects away without updating'
do
expect
(
response
).
to
redirect_to
(
gitlab_snippet_path
(
snippet
))
expect
(
snippet
.
reload
.
title
).
not_to
eq
title
end
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