Commit e7c0bd95 authored by Francisco Javier López's avatar Francisco Javier López Committed by Shinya Maeda

Avoid snippet redirection if snippets_binary_blob enabled

parent 8214da07
...@@ -132,6 +132,8 @@ module SnippetsActions ...@@ -132,6 +132,8 @@ module SnippetsActions
end end
def redirect_if_binary def redirect_if_binary
return if Feature.enabled?(:snippets_binary_blob)
redirect_to gitlab_snippet_path(snippet) if blob&.binary? redirect_to gitlab_snippet_path(snippet) if blob&.binary?
end end
end end
# frozen_string_literal: true # frozen_string_literal: true
RSpec.shared_examples 'editing snippet checks blob is binary' do RSpec.shared_examples 'editing snippet checks blob is binary' do
let(:snippets_binary_blob_value) { true }
before do before do
sign_in(user) sign_in(user)
...@@ -8,6 +10,8 @@ RSpec.shared_examples 'editing snippet checks blob is binary' do ...@@ -8,6 +10,8 @@ RSpec.shared_examples 'editing snippet checks blob is binary' do
allow(blob).to receive(:binary?).and_return(binary) allow(blob).to receive(:binary?).and_return(binary)
end end
stub_feature_flags(snippets_binary_blob: snippets_binary_blob_value)
subject subject
end end
...@@ -23,13 +27,24 @@ RSpec.shared_examples 'editing snippet checks blob is binary' do ...@@ -23,13 +27,24 @@ RSpec.shared_examples 'editing snippet checks blob is binary' do
context 'when blob is binary' do context 'when blob is binary' do
let(:binary) { true } let(:binary) { true }
it 'redirects away' do it 'responds with status 200' do
expect(response).to redirect_to(gitlab_snippet_path(snippet)) 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 end
end end
RSpec.shared_examples 'updating snippet checks blob is binary' do RSpec.shared_examples 'updating snippet checks blob is binary' do
let(:snippets_binary_blob_value) { true }
before do before do
sign_in(user) sign_in(user)
...@@ -37,6 +52,8 @@ RSpec.shared_examples 'updating snippet checks blob is binary' do ...@@ -37,6 +52,8 @@ RSpec.shared_examples 'updating snippet checks blob is binary' do
allow(blob).to receive(:binary?).and_return(binary) allow(blob).to receive(:binary?).and_return(binary)
end end
stub_feature_flags(snippets_binary_blob: snippets_binary_blob_value)
subject subject
end end
...@@ -52,9 +69,18 @@ RSpec.shared_examples 'updating snippet checks blob is binary' do ...@@ -52,9 +69,18 @@ RSpec.shared_examples 'updating snippet checks blob is binary' do
context 'when blob is binary' do context 'when blob is binary' do
let(:binary) { true } 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(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 end
end end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment