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
130ac7e9
Commit
130ac7e9
authored
Aug 19, 2020
by
Francisco Javier López
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove redirection when snippet blob is binary
parent
844dc3e0
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
5 additions
and
137 deletions
+5
-137
app/controllers/concerns/snippets_actions.rb
app/controllers/concerns/snippets_actions.rb
+0
-8
changelogs/unreleased/fj-remove-snippet-redirection-when-blob-binary.yml
...leased/fj-remove-snippet-redirection-when-blob-binary.yml
+5
-0
spec/controllers/projects/snippets_controller_spec.rb
spec/controllers/projects/snippets_controller_spec.rb
+0
-29
spec/controllers/snippets_controller_spec.rb
spec/controllers/snippets_controller_spec.rb
+0
-14
spec/support/shared_examples/controllers/binary_blob_shared_examples.rb
...hared_examples/controllers/binary_blob_shared_examples.rb
+0
-86
No files found.
app/controllers/concerns/snippets_actions.rb
View file @
130ac7e9
...
...
@@ -14,8 +14,6 @@ module SnippetsActions
skip_before_action
:verify_authenticity_token
,
if:
->
{
action_name
==
'show'
&&
js_request?
}
before_action
:redirect_if_binary
,
only:
[
:edit
,
:update
]
respond_to
:html
end
...
...
@@ -134,10 +132,4 @@ module SnippetsActions
recaptcha_check_with_fallback
(
errors
.
empty?
)
{
render
action
}
end
def
redirect_if_binary
return
if
Feature
.
enabled?
(
:snippets_binary_blob
)
redirect_to
gitlab_snippet_path
(
snippet
)
if
blob
&
.
binary?
end
end
changelogs/unreleased/fj-remove-snippet-redirection-when-blob-binary.yml
0 → 100644
View file @
130ac7e9
---
title
:
Remove redirection when snippet has a binary blob
merge_request
:
39858
author
:
type
:
changed
spec/controllers/projects/snippets_controller_spec.rb
View file @
130ac7e9
...
...
@@ -190,20 +190,6 @@ RSpec.describe Projects::SnippetsController do
snippet
.
reload
end
it_behaves_like
'updating snippet checks blob is binary'
do
let_it_be
(
:title
)
{
'Foo'
}
let
(
:params
)
do
{
namespace_id:
project
.
namespace
.
to_param
,
project_id:
project
,
id:
snippet
.
id
,
project_snippet:
{
title:
title
}
}
end
subject
{
put
:update
,
params:
params
}
end
context
'when the snippet is spam'
do
before
do
allow_next_instance_of
(
Spam
::
AkismetService
)
do
|
instance
|
...
...
@@ -611,19 +597,4 @@ RSpec.describe Projects::SnippetsController do
end
end
end
describe
'GET #edit'
do
it_behaves_like
'editing snippet checks blob is binary'
do
let
(
:snippet
)
{
create
(
:project_snippet
,
:private
,
project:
project
,
author:
user
)
}
let
(
:params
)
do
{
namespace_id:
project
.
namespace
,
project_id:
project
,
id:
snippet
}
end
subject
{
get
:edit
,
params:
params
}
end
end
end
spec/controllers/snippets_controller_spec.rb
View file @
130ac7e9
...
...
@@ -334,12 +334,6 @@ RSpec.describe SnippetsController do
snippet
.
reload
end
it_behaves_like
'updating snippet checks blob is binary'
do
let_it_be
(
:title
)
{
'Foo'
}
subject
{
put
:update
,
params:
{
id:
snippet
,
personal_snippet:
{
title:
title
}
}
}
end
context
'when the snippet is spam'
do
before
do
allow_next_instance_of
(
Spam
::
AkismetService
)
do
|
instance
|
...
...
@@ -746,12 +740,4 @@ RSpec.describe SnippetsController do
end
end
end
describe
'GET #edit'
do
it_behaves_like
'editing snippet checks blob is binary'
do
let_it_be
(
:snippet
)
{
create
(
:personal_snippet
,
:public
,
:repository
,
author:
user
)
}
subject
{
get
:edit
,
params:
{
id:
snippet
}
}
end
end
end
spec/support/shared_examples/controllers/binary_blob_shared_examples.rb
deleted
100644 → 0
View file @
844dc3e0
# 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
)
allow_next_instance_of
(
Blob
)
do
|
blob
|
allow
(
blob
).
to
receive
(
:binary?
).
and_return
(
binary
)
end
stub_feature_flags
(
snippets_binary_blob:
snippets_binary_blob_value
)
subject
end
context
'when blob is text'
do
let
(
:binary
)
{
false
}
it
'responds with status 200'
do
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
response
).
to
render_template
(
:edit
)
end
end
context
'when blob is binary'
do
let
(
:binary
)
{
true
}
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
)
allow_next_instance_of
(
Blob
)
do
|
blob
|
allow
(
blob
).
to
receive
(
:binary?
).
and_return
(
binary
)
end
stub_feature_flags
(
snippets_binary_blob:
snippets_binary_blob_value
)
subject
end
context
'when blob is text'
do
let
(
:binary
)
{
false
}
it
'updates successfully'
do
expect
(
snippet
.
reload
.
title
).
to
eq
title
expect
(
response
).
to
redirect_to
(
gitlab_snippet_path
(
snippet
))
end
end
context
'when blob is binary'
do
let
(
:binary
)
{
true
}
it
'updates successfully'
do
expect
(
snippet
.
reload
.
title
).
to
eq
title
expect
(
response
).
to
redirect_to
(
gitlab_snippet_path
(
snippet
))
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