Commit 8b687c88 authored by Heinrich Lee Yu's avatar Heinrich Lee Yu

Merge branch 'fj-remove-flag-version-snippets' into 'master'

Remove feature flag version_snippets

See merge request gitlab-org/gitlab!27705
parents 4a879333 4c989ba9
...@@ -53,10 +53,10 @@ module SnippetsActions ...@@ -53,10 +53,10 @@ module SnippetsActions
def blob def blob
return unless snippet return unless snippet
@blob ||= if Feature.enabled?(:version_snippets, current_user) && !snippet.repository.empty? @blob ||= if snippet.empty_repo?
snippet.blobs.first
else
snippet.blob snippet.blob
else
snippet.blobs.first
end end
end end
# rubocop:enable Gitlab/ModuleWithInstanceVariables # rubocop:enable Gitlab/ModuleWithInstanceVariables
......
...@@ -4,7 +4,6 @@ module Repositories ...@@ -4,7 +4,6 @@ module Repositories
class GitHttpController < Repositories::GitHttpClientController class GitHttpController < Repositories::GitHttpClientController
include WorkhorseRequest include WorkhorseRequest
before_action :snippet_request_allowed?
before_action :access_check before_action :access_check
prepend_before_action :deny_head_requests, only: [:info_refs] prepend_before_action :deny_head_requests, only: [:info_refs]
...@@ -121,13 +120,6 @@ module Repositories ...@@ -121,13 +120,6 @@ module Repositories
def log_user_activity def log_user_activity
Users::ActivityService.new(user).execute Users::ActivityService.new(user).execute
end end
def snippet_request_allowed?
if repo_type.snippet? && Feature.disabled?(:version_snippets, user)
Gitlab::AppLogger.info('Snippet access attempt with feature disabled')
render plain: 'Snippet git access is disabled.', status: :forbidden
end
end
end end
end end
......
...@@ -319,10 +319,6 @@ class Snippet < ApplicationRecord ...@@ -319,10 +319,6 @@ class Snippet < ApplicationRecord
Digest::SHA256.hexdigest("#{title}#{description}#{created_at}#{updated_at}") Digest::SHA256.hexdigest("#{title}#{description}#{created_at}#{updated_at}")
end end
def versioned_enabled_for?(user)
::Feature.enabled?(:version_snippets, user) && repository_exists?
end
def file_name_on_repo def file_name_on_repo
return if repository.empty? return if repository.empty?
......
...@@ -12,11 +12,11 @@ class SnippetPresenter < Gitlab::View::Presenter::Delegated ...@@ -12,11 +12,11 @@ class SnippetPresenter < Gitlab::View::Presenter::Delegated
end end
def ssh_url_to_repo def ssh_url_to_repo
snippet.ssh_url_to_repo if snippet.versioned_enabled_for?(current_user) snippet.ssh_url_to_repo if snippet.repository_exists?
end end
def http_url_to_repo def http_url_to_repo
snippet.http_url_to_repo if snippet.versioned_enabled_for?(current_user) snippet.http_url_to_repo if snippet.repository_exists?
end end
def can_read_snippet? def can_read_snippet?
...@@ -36,10 +36,10 @@ class SnippetPresenter < Gitlab::View::Presenter::Delegated ...@@ -36,10 +36,10 @@ class SnippetPresenter < Gitlab::View::Presenter::Delegated
end end
def blob def blob
if Feature.enabled?(:version_snippets, current_user) && !snippet.repository.empty? if snippet.empty_repo?
snippet.blobs.first
else
snippet.blob snippet.blob
else
snippet.blobs.first
end end
end end
......
...@@ -40,7 +40,7 @@ module Snippets ...@@ -40,7 +40,7 @@ module Snippets
def save_and_commit def save_and_commit
snippet_saved = @snippet.save snippet_saved = @snippet.save
if snippet_saved && Feature.enabled?(:version_snippets, current_user) if snippet_saved
create_repository create_repository
create_commit create_commit
end end
......
...@@ -43,17 +43,8 @@ module Snippets ...@@ -43,17 +43,8 @@ module Snippets
# the repository we can just return # the repository we can just return
return true unless committable_attributes? return true unless committable_attributes?
# In order to avoid non migrated snippets scenarios, create_repository_for(snippet)
# if the snippet does not have a repository we created it create_commit(snippet)
# We don't need to check if the repository exists
# because `create_repository` already handles it
if Feature.enabled?(:version_snippets, current_user)
create_repository_for(snippet)
end
# If the snippet repository exists we commit always
# the changes
create_commit(snippet) if snippet.repository_exists?
true true
rescue => e rescue => e
......
---
title: Enabling git versioned snippets
merge_request: 27705
author:
type: added
...@@ -13,10 +13,9 @@ module API ...@@ -13,10 +13,9 @@ module API
expose :raw_url do |snippet| expose :raw_url do |snippet|
Gitlab::UrlBuilder.build(snippet, raw: true) Gitlab::UrlBuilder.build(snippet, raw: true)
end end
expose :ssh_url_to_repo, :http_url_to_repo, if: ->(snippet) { snippet.versioned_enabled_for?(options[:current_user]) } expose :ssh_url_to_repo, :http_url_to_repo, if: ->(snippet) { snippet.repository_exists? }
expose :file_name do |snippet| expose :file_name do |snippet|
(::Feature.enabled?(:version_snippets, options[:current_user]) && snippet.file_name_on_repo) || snippet.file_name_on_repo || snippet.file_name
snippet.file_name
end end
end end
end end
......
...@@ -4,12 +4,12 @@ module API ...@@ -4,12 +4,12 @@ module API
module Helpers module Helpers
module SnippetsHelpers module SnippetsHelpers
def content_for(snippet) def content_for(snippet)
if ::Feature.enabled?(:version_snippets, current_user) && !snippet.empty_repo? if snippet.empty_repo?
snippet.content
else
blob = snippet.blobs.first blob = snippet.blobs.first
blob.load_all_data! blob.load_all_data!
blob.data blob.data
else
snippet.content
end end
end end
end end
......
...@@ -112,10 +112,6 @@ module API ...@@ -112,10 +112,6 @@ module API
# check_ip - optional, only in EE version, may limit access to # check_ip - optional, only in EE version, may limit access to
# group resources based on its IP restrictions # group resources based on its IP restrictions
post "/allowed" do post "/allowed" do
if repo_type.snippet? && params[:protocol] != 'web' && Feature.disabled?(:version_snippets, actor.user)
break response_with_status(code: 401, success: false, message: 'Snippet git access is disabled.')
end
# It was moved to a separate method so that EE can alter its behaviour more # It was moved to a separate method so that EE can alter its behaviour more
# easily. # easily.
check_allowed(params) check_allowed(params)
......
...@@ -10,7 +10,6 @@ module Gitlab ...@@ -10,7 +10,6 @@ module Gitlab
end end
def restore def restore
return true unless Feature.enabled?(:version_snippets, @user)
return true unless Dir.exist?(snippets_repo_bundle_path) return true unless Dir.exist?(snippets_repo_bundle_path)
@project.snippets.find_each.all? do |snippet| @project.snippets.find_each.all? do |snippet|
......
...@@ -12,8 +12,6 @@ module Gitlab ...@@ -12,8 +12,6 @@ module Gitlab
end end
def save def save
return true unless Feature.enabled?(:version_snippets, @current_user)
create_snippets_repo_directory create_snippets_repo_directory
@project.snippets.find_each.all? do |snippet| @project.snippets.find_each.all? do |snippet|
......
...@@ -346,20 +346,6 @@ describe Projects::SnippetsController do ...@@ -346,20 +346,6 @@ describe Projects::SnippetsController do
expect(assigns(:blob)).to eq(project_snippet.blobs.first) expect(assigns(:blob)).to eq(project_snippet.blobs.first)
end end
context 'when feature flag version_snippets is disabled' do
before do
stub_feature_flags(version_snippets: false)
end
it 'returns the snippet database content' do
subject
blob = assigns(:blob)
expect(blob.data).to eq(project_snippet.content)
end
end
end end
%w[show raw].each do |action| %w[show raw].each do |action|
......
...@@ -165,44 +165,6 @@ describe Repositories::GitHttpController do ...@@ -165,44 +165,6 @@ describe Repositories::GitHttpController do
end end
end end
shared_examples 'snippet feature flag disabled behavior' do
before do
stub_feature_flags(version_snippets: false)
request.headers.merge! auth_env(user.username, user.password, nil)
end
describe 'GET #info_refs' do
let(:params) { container_params.merge(service: 'git-upload-pack') }
it 'returns 403' do
expect(controller).not_to receive(:access_check)
get :info_refs, params: params
expect(response).to have_gitlab_http_status(:forbidden)
expect(response.body).to eq 'Snippet git access is disabled.'
end
end
describe 'POST #git_upload_pack' do
before do
allow(controller).to receive(:authenticate_user).and_return(true)
allow(controller).to receive(:verify_workhorse_api!).and_return(true)
allow(controller).to receive(:access_check).and_return(nil)
end
it 'returns 403' do
expect(controller).not_to receive(:access_check)
post :git_upload_pack, params: params
expect(response).to have_gitlab_http_status(:forbidden)
expect(response.body).to eq 'Snippet git access is disabled.'
end
end
end
context 'when repository container is a project' do context 'when repository container is a project' do
it_behaves_like 'info_refs behavior' do it_behaves_like 'info_refs behavior' do
let(:user) { project.owner } let(:user) { project.owner }
...@@ -226,9 +188,6 @@ describe Repositories::GitHttpController do ...@@ -226,9 +188,6 @@ describe Repositories::GitHttpController do
let(:expected_class) { Gitlab::GitAccessSnippet } let(:expected_class) { Gitlab::GitAccessSnippet }
let(:expected_object) { personal_snippet } let(:expected_object) { personal_snippet }
end end
it_behaves_like 'snippet feature flag disabled behavior' do
let(:user) { personal_snippet.author }
end
end end
context 'when repository container is a project snippet' do context 'when repository container is a project snippet' do
...@@ -243,8 +202,5 @@ describe Repositories::GitHttpController do ...@@ -243,8 +202,5 @@ describe Repositories::GitHttpController do
let(:expected_class) { Gitlab::GitAccessSnippet } let(:expected_class) { Gitlab::GitAccessSnippet }
let(:expected_object) { project_snippet } let(:expected_object) { project_snippet }
end end
it_behaves_like 'snippet feature flag disabled behavior' do
let(:user) { project_snippet.author }
end
end end
end end
...@@ -86,20 +86,6 @@ describe SnippetsController do ...@@ -86,20 +86,6 @@ describe SnippetsController do
expect(assigns(:blob)).to eq(personal_snippet.blobs.first) expect(assigns(:blob)).to eq(personal_snippet.blobs.first)
end end
context 'when feature flag version_snippets is disabled' do
before do
stub_feature_flags(version_snippets: false)
end
it 'returns the snippet database content' do
subject
blob = assigns(:blob)
expect(blob.data).to eq(personal_snippet.content)
end
end
end end
context 'when the personal snippet is private' do context 'when the personal snippet is private' do
...@@ -572,24 +558,6 @@ describe SnippetsController do ...@@ -572,24 +558,6 @@ describe SnippetsController do
expect(response.cache_control[:public]).to eq snippet.public? expect(response.cache_control[:public]).to eq snippet.public?
end end
context 'when feature flag version_snippets is disabled' do
before do
stub_feature_flags(version_snippets: false)
end
it_behaves_like '200 status'
it_behaves_like 'CRLF line ending'
it 'returns snippet database content' do
subject
expect(response.body).to eq snippet.content
expect(response.header['Content-Type']).to eq('text/plain; charset=utf-8')
end
it_behaves_like 'content disposition headers'
end
context 'when snippet repository is empty' do context 'when snippet repository is empty' do
before do before do
allow_any_instance_of(Repository).to receive(:empty?).and_return(true) allow_any_instance_of(Repository).to receive(:empty?).and_return(true)
......
...@@ -7,12 +7,9 @@ describe 'Projects > Snippets > User updates a snippet', :js do ...@@ -7,12 +7,9 @@ describe 'Projects > Snippets > User updates a snippet', :js do
let_it_be(:project) { create(:project, namespace: user.namespace) } let_it_be(:project) { create(:project, namespace: user.namespace) }
let_it_be(:snippet, reload: true) { create(:project_snippet, :repository, project: project, author: user) } let_it_be(:snippet, reload: true) { create(:project_snippet, :repository, project: project, author: user) }
let(:version_snippet_enabled) { true }
before do before do
stub_feature_flags(snippets_vue: false) stub_feature_flags(snippets_vue: false)
stub_feature_flags(snippets_edit_vue: false) stub_feature_flags(snippets_edit_vue: false)
stub_feature_flags(version_snippets: version_snippet_enabled)
project.add_maintainer(user) project.add_maintainer(user)
sign_in(user) sign_in(user)
...@@ -35,18 +32,6 @@ describe 'Projects > Snippets > User updates a snippet', :js do ...@@ -35,18 +32,6 @@ describe 'Projects > Snippets > User updates a snippet', :js do
end end
end end
context 'when feature flag :version_snippets is disabled' do
let(:version_snippet_enabled) { false }
it 'displays the snippet file_name and content' do
aggregate_failures do
expect(page.find_field('project_snippet_file_name').value).to eq snippet.file_name
expect(page.find('.file-content')).to have_content(snippet.content)
expect(page.find('.snippet-file-content', visible: false).value).to eq snippet.content
end
end
end
it 'updates a snippet' do it 'updates a snippet' do
fill_in('project_snippet_title', with: 'Snippet new title') fill_in('project_snippet_title', with: 'Snippet new title')
click_button('Save') click_button('Save')
......
...@@ -10,12 +10,9 @@ describe 'User edits snippet', :js do ...@@ -10,12 +10,9 @@ describe 'User edits snippet', :js do
let_it_be(:user) { create(:user) } let_it_be(:user) { create(:user) }
let_it_be(:snippet, reload: true) { create(:personal_snippet, :repository, :public, file_name: file_name, content: content, author: user) } let_it_be(:snippet, reload: true) { create(:personal_snippet, :repository, :public, file_name: file_name, content: content, author: user) }
let(:version_snippet_enabled) { true }
before do before do
stub_feature_flags(snippets_vue: false) stub_feature_flags(snippets_vue: false)
stub_feature_flags(snippets_edit_vue: false) stub_feature_flags(snippets_edit_vue: false)
stub_feature_flags(version_snippets: version_snippet_enabled)
sign_in(user) sign_in(user)
...@@ -33,18 +30,6 @@ describe 'User edits snippet', :js do ...@@ -33,18 +30,6 @@ describe 'User edits snippet', :js do
end end
end end
context 'when feature flag :version_snippets is disabled' do
let(:version_snippet_enabled) { false }
it 'displays the snippet file_name and content' do
aggregate_failures do
expect(page.find_field('personal_snippet_file_name').value).to eq file_name
expect(page.find('.file-content')).to have_content(content)
expect(page.find('.snippet-file-content', visible: false).value).to eq content
end
end
end
it 'updates the snippet' do it 'updates the snippet' do
fill_in 'personal_snippet_title', with: 'New Snippet Title' fill_in 'personal_snippet_title', with: 'New Snippet Title'
......
...@@ -35,14 +35,6 @@ describe GitlabSchema.types['Snippet'] do ...@@ -35,14 +35,6 @@ describe GitlabSchema.types['Snippet'] do
expect(response['sshUrlToRepo']).to eq(snippet.ssh_url_to_repo) expect(response['sshUrlToRepo']).to eq(snippet.ssh_url_to_repo)
expect(response['httpUrlToRepo']).to eq(snippet.http_url_to_repo) expect(response['httpUrlToRepo']).to eq(snippet.http_url_to_repo)
end end
context 'when version_snippets feature is disabled' do
before do
stub_feature_flags(version_snippets: false)
end
it_behaves_like 'response without repository URLs'
end
end end
end end
......
...@@ -26,14 +26,6 @@ describe ::API::Entities::Snippet do ...@@ -26,14 +26,6 @@ describe ::API::Entities::Snippet do
expect(subject[:file_name]).to eq snippet.blobs.first.path expect(subject[:file_name]).to eq snippet.blobs.first.path
end end
context 'when feature flag :version_snippets is disabled' do
it 'returns attribute from db' do
stub_feature_flags(version_snippets: false)
expect(subject[:file_name]).to eq snippet.file_name
end
end
context 'when repository is empty' do context 'when repository is empty' do
it 'returns attribute from db' do it 'returns attribute from db' do
allow(snippet.repository).to receive(:empty?).and_return(true) allow(snippet.repository).to receive(:empty?).and_return(true)
...@@ -48,14 +40,6 @@ describe ::API::Entities::Snippet do ...@@ -48,14 +40,6 @@ describe ::API::Entities::Snippet do
expect(subject[:ssh_url_to_repo]).to eq snippet.ssh_url_to_repo expect(subject[:ssh_url_to_repo]).to eq snippet.ssh_url_to_repo
end end
context 'when feature flag :version_snippets is disabled' do
it 'does not include attribute' do
stub_feature_flags(version_snippets: false)
expect(subject).not_to include(:ssh_url_to_repo)
end
end
context 'when repository does not exist' do context 'when repository does not exist' do
it 'does not include attribute' do it 'does not include attribute' do
allow(snippet).to receive(:repository_exists?).and_return(false) allow(snippet).to receive(:repository_exists?).and_return(false)
...@@ -70,14 +54,6 @@ describe ::API::Entities::Snippet do ...@@ -70,14 +54,6 @@ describe ::API::Entities::Snippet do
expect(subject[:http_url_to_repo]).to eq snippet.http_url_to_repo expect(subject[:http_url_to_repo]).to eq snippet.http_url_to_repo
end end
context 'when feature flag :version_snippets is disabled' do
it 'does not include attribute' do
stub_feature_flags(version_snippets: false)
expect(subject).not_to include(:http_url_to_repo)
end
end
context 'when repository does not exist' do context 'when repository does not exist' do
it 'does not include attribute' do it 'does not include attribute' do
allow(snippet).to receive(:repository_exists?).and_return(false) allow(snippet).to receive(:repository_exists?).and_return(false)
......
...@@ -31,19 +31,6 @@ describe Gitlab::GitAccessSnippet do ...@@ -31,19 +31,6 @@ describe Gitlab::GitAccessSnippet do
end end
end end
describe 'when feature flag :version_snippets is disabled' do
let(:user) { snippet.author }
before do
stub_feature_flags(version_snippets: false)
end
it 'allows push and pull access' do
expect { pull_access_check }.not_to raise_error
expect { push_access_check }.not_to raise_error
end
end
describe '#check_snippet_accessibility!' do describe '#check_snippet_accessibility!' do
context 'when the snippet exists' do context 'when the snippet exists' do
it 'allows access' do it 'allows access' do
......
...@@ -735,31 +735,19 @@ describe Snippet do ...@@ -735,31 +735,19 @@ describe Snippet do
end end
end end
describe '#versioned_enabled_for?' do describe '#url_to_repo' do
let_it_be(:user) { create(:user) } subject { snippet.url_to_repo }
subject { snippet.versioned_enabled_for?(user) } context 'with personal snippet' do
let(:snippet) { create(:personal_snippet) }
context 'with repository and version_snippets enabled' do it { is_expected.to eq(Gitlab.config.gitlab_shell.ssh_path_prefix + "snippets/#{snippet.id}.git") }
let!(:snippet) { create(:personal_snippet, :repository, author: user) }
it { is_expected.to be_truthy }
end
context 'without repository' do
let!(:snippet) { create(:personal_snippet, author: user) }
it { is_expected.to be_falsy }
end end
context 'without version_snippets feature disabled' do context 'with project snippet' do
let!(:snippet) { create(:personal_snippet, :repository, author: user) } let(:snippet) { create(:project_snippet) }
before do
stub_feature_flags(version_snippets: false)
end
it { is_expected.to be_falsy } it { is_expected.to eq(Gitlab.config.gitlab_shell.ssh_path_prefix + "#{snippet.project.full_path}/snippets/#{snippet.id}.git") }
end end
end end
end end
...@@ -323,18 +323,6 @@ describe API::Internal::Base do ...@@ -323,18 +323,6 @@ describe API::Internal::Base do
end end
end end
shared_examples 'snippets with disabled feature flag' do
context 'when feature flag :version_snippets is disabled' do
it 'returns 401' do
stub_feature_flags(version_snippets: false)
subject
expect(response).to have_gitlab_http_status(:unauthorized)
end
end
end
shared_examples 'snippet success' do shared_examples 'snippet success' do
it 'responds with success' do it 'responds with success' do
subject subject
...@@ -344,18 +332,6 @@ describe API::Internal::Base do ...@@ -344,18 +332,6 @@ describe API::Internal::Base do
end end
end end
shared_examples 'snippets with web protocol' do
it_behaves_like 'snippet success'
context 'with disabled version flag' do
before do
stub_feature_flags(version_snippets: false)
end
it_behaves_like 'snippet success'
end
end
context 'git push with personal snippet' do context 'git push with personal snippet' do
subject { push(key, personal_snippet, env: env.to_json, changes: snippet_changes) } subject { push(key, personal_snippet, env: env.to_json, changes: snippet_changes) }
...@@ -369,12 +345,6 @@ describe API::Internal::Base do ...@@ -369,12 +345,6 @@ describe API::Internal::Base do
expect(user.reload.last_activity_on).to be_nil expect(user.reload.last_activity_on).to be_nil
end end
it_behaves_like 'snippets with disabled feature flag'
it_behaves_like 'snippets with web protocol' do
subject { push(key, personal_snippet, 'web', env: env.to_json, changes: snippet_changes) }
end
it_behaves_like 'sets hook env' do it_behaves_like 'sets hook env' do
let(:gl_repository) { Gitlab::GlRepository::SNIPPET.identifier_for_container(personal_snippet) } let(:gl_repository) { Gitlab::GlRepository::SNIPPET.identifier_for_container(personal_snippet) }
end end
...@@ -392,12 +362,6 @@ describe API::Internal::Base do ...@@ -392,12 +362,6 @@ describe API::Internal::Base do
expect(json_response["gl_repository"]).to eq("snippet-#{personal_snippet.id}") expect(json_response["gl_repository"]).to eq("snippet-#{personal_snippet.id}")
expect(user.reload.last_activity_on).to eql(Date.today) expect(user.reload.last_activity_on).to eql(Date.today)
end end
it_behaves_like 'snippets with disabled feature flag'
it_behaves_like 'snippets with web protocol' do
subject { pull(key, personal_snippet, 'web') }
end
end end
context 'git push with project snippet' do context 'git push with project snippet' do
...@@ -413,12 +377,6 @@ describe API::Internal::Base do ...@@ -413,12 +377,6 @@ describe API::Internal::Base do
expect(user.reload.last_activity_on).to be_nil expect(user.reload.last_activity_on).to be_nil
end end
it_behaves_like 'snippets with disabled feature flag'
it_behaves_like 'snippets with web protocol' do
subject { push(key, project_snippet, 'web', env: env.to_json, changes: snippet_changes) }
end
it_behaves_like 'sets hook env' do it_behaves_like 'sets hook env' do
let(:gl_repository) { Gitlab::GlRepository::SNIPPET.identifier_for_container(project_snippet) } let(:gl_repository) { Gitlab::GlRepository::SNIPPET.identifier_for_container(project_snippet) }
end end
...@@ -434,14 +392,6 @@ describe API::Internal::Base do ...@@ -434,14 +392,6 @@ describe API::Internal::Base do
expect(json_response["gl_repository"]).to eq("snippet-#{project_snippet.id}") expect(json_response["gl_repository"]).to eq("snippet-#{project_snippet.id}")
expect(user.reload.last_activity_on).to eql(Date.today) expect(user.reload.last_activity_on).to eql(Date.today)
end end
it_behaves_like 'snippets with disabled feature flag' do
subject { pull(key, project_snippet) }
end
it_behaves_like 'snippets with web protocol' do
subject { pull(key, project_snippet, 'web') }
end
end end
context "git pull" do context "git pull" do
......
...@@ -99,16 +99,6 @@ describe API::ProjectSnippets do ...@@ -99,16 +99,6 @@ describe API::ProjectSnippets do
expect(json_response['http_url_to_repo']).to eq(snippet.http_url_to_repo) expect(json_response['http_url_to_repo']).to eq(snippet.http_url_to_repo)
end end
context 'when feature flag :version_snippets is disabled' do
before do
stub_feature_flags(version_snippets: false)
get api("/projects/#{project.id}/snippets/#{snippet.id}", user)
end
it_behaves_like 'snippet response without repository URLs'
end
it 'returns 404 for invalid snippet id' do it 'returns 404 for invalid snippet id' do
get api("/projects/#{project.id}/snippets/#{non_existing_record_id}", user) get api("/projects/#{project.id}/snippets/#{non_existing_record_id}", user)
...@@ -150,18 +140,6 @@ describe API::ProjectSnippets do ...@@ -150,18 +140,6 @@ describe API::ProjectSnippets do
expect(blob.data).to eq params[:code] expect(blob.data).to eq params[:code]
end end
context 'when feature flag :version_snippets is disabled' do
it 'does not create snippet repository' do
stub_feature_flags(version_snippets: false)
expect do
subject
end.to change { ProjectSnippet.count }.by(1)
expect(snippet.repository_exists?).to be_falsey
end
end
end end
context 'with an external user' do context 'with an external user' do
......
...@@ -166,16 +166,6 @@ describe API::Snippets do ...@@ -166,16 +166,6 @@ describe API::Snippets do
expect(json_response['http_url_to_repo']).to eq(private_snippet.http_url_to_repo) expect(json_response['http_url_to_repo']).to eq(private_snippet.http_url_to_repo)
end end
context 'when feature flag :version_snippets is disabled' do
before do
stub_feature_flags(version_snippets: false)
get api("/snippets/#{private_snippet.id}", author)
end
it_behaves_like 'snippet response without repository URLs'
end
it 'shows private snippets to an admin' do it 'shows private snippets to an admin' do
get api("/snippets/#{private_snippet.id}", admin) get api("/snippets/#{private_snippet.id}", admin)
...@@ -245,18 +235,6 @@ describe API::Snippets do ...@@ -245,18 +235,6 @@ describe API::Snippets do
expect(blob.data).to eq params[:content] expect(blob.data).to eq params[:content]
end end
context 'when feature flag :version_snippets is disabled' do
it 'does not create snippet repository' do
stub_feature_flags(version_snippets: false)
expect do
subject
end.to change { PersonalSnippet.count }.by(1)
expect(snippet.repository_exists?).to be_falsey
end
end
end end
context 'with restricted visibility settings' do context 'with restricted visibility settings' do
......
...@@ -228,28 +228,6 @@ describe Snippets::CreateService do ...@@ -228,28 +228,6 @@ describe Snippets::CreateService do
expect(snippet.repository_exists?).to be_falsey expect(snippet.repository_exists?).to be_falsey
end end
end end
context 'when feature flag :version_snippets is disabled' do
before do
stub_feature_flags(version_snippets: false)
end
it 'does not create snippet repository' do
expect do
subject
end.to change(Snippet, :count).by(1)
expect(snippet.repository_exists?).to be_falsey
end
it 'does not try to commit files' do
expect_next_instance_of(described_class) do |instance|
expect(instance).not_to receive(:create_commit)
end
subject
end
end
end end
shared_examples 'after_save callback to store_mentions' do |mentionable_class| shared_examples 'after_save callback to store_mentions' do |mentionable_class|
......
...@@ -112,25 +112,16 @@ describe Snippets::UpdateService do ...@@ -112,25 +112,16 @@ describe Snippets::UpdateService do
expect(blob.data).to eq options[:content] expect(blob.data).to eq options[:content]
end end
context 'when the repository does not exist' do context 'when the repository creation fails' do
it 'does not try to commit file' do
allow(snippet).to receive(:repository_exists?).and_return(false)
expect(service).not_to receive(:create_commit)
subject
end
end
context 'when feature flag is disabled' do
before do before do
stub_feature_flags(version_snippets: false) allow(snippet).to receive(:repository_exists?).and_return(false)
end end
it 'does not create repository' do it 'raise an error' do
subject response = subject
expect(snippet.repository).not_to exist expect(response).to be_error
expect(response.payload[:snippet].errors[:repository].to_sentence).to eq 'Error updating the snippet'
end end
it 'does not try to commit file' do it 'does not try to commit file' do
......
...@@ -66,16 +66,6 @@ RSpec.shared_examples 'snippet blob content' do ...@@ -66,16 +66,6 @@ RSpec.shared_examples 'snippet blob content' do
expect(response.body).to eq(snippet.blobs.first.data) expect(response.body).to eq(snippet.blobs.first.data)
end end
context 'when feature flag :version_snippets is disabled' do
it 'returns content from database' do
stub_feature_flags(version_snippets: false)
subject
expect(response.body).to eq(snippet.content)
end
end
context 'when snippet repository is empty' do context 'when snippet repository is empty' do
let(:snippet) { snippet_with_empty_repo } let(:snippet) { snippet_with_empty_repo }
......
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