Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-06-04 17:17:05 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2020-06-04 17:17:05 +0300
commit2b171e66adf713653c04005e08c02dd823622bdb (patch)
tree977965c0f9e4c93fa66c1f02b876391df115ac97 /spec/services
parentbab5bdce96a258068d69c4b2811f036f151ed60b (diff)
Add latest changes from gitlab-org/gitlab@13-0-stable-ee
Diffstat (limited to 'spec/services')
-rw-r--r--spec/services/ci/stop_environments_service_spec.rb6
-rw-r--r--spec/services/snippets/update_service_spec.rb58
2 files changed, 62 insertions, 2 deletions
diff --git a/spec/services/ci/stop_environments_service_spec.rb b/spec/services/ci/stop_environments_service_spec.rb
index 19a6bcc307f..ebbe6c37b87 100644
--- a/spec/services/ci/stop_environments_service_spec.rb
+++ b/spec/services/ci/stop_environments_service_spec.rb
@@ -222,8 +222,10 @@ describe Ci::StopEnvironmentsService do
it 'tracks the exception' do
expect(Gitlab::ErrorTracking)
- .to receive(:track_error)
- .with(Gitlab::Access::AccessDeniedError, anything).twice
+ .to receive(:track_exception)
+ .with(Gitlab::Access::AccessDeniedError, anything)
+ .twice
+ .and_call_original
subject
end
diff --git a/spec/services/snippets/update_service_spec.rb b/spec/services/snippets/update_service_spec.rb
index 38747ae907f..6c3ae52befc 100644
--- a/spec/services/snippets/update_service_spec.rb
+++ b/spec/services/snippets/update_service_spec.rb
@@ -302,6 +302,60 @@ describe Snippets::UpdateService do
end
end
+ shared_examples 'only file_name is present' do
+ let(:base_opts) do
+ {
+ file_name: file_name
+ }
+ end
+
+ shared_examples 'content is not updated' do
+ specify do
+ existing_content = snippet.blobs.first.data
+ response = subject
+ snippet = response.payload[:snippet]
+
+ blob = snippet.repository.blob_at('master', file_name)
+
+ expect(blob).not_to be_nil
+ expect(response).to be_success
+ expect(blob.data).to eq existing_content
+ end
+ end
+
+ context 'when renaming the file_name' do
+ let(:file_name) { 'new_file_name' }
+
+ it_behaves_like 'content is not updated'
+ end
+
+ context 'when file_name does not change' do
+ let(:file_name) { snippet.blobs.first.path }
+
+ it_behaves_like 'content is not updated'
+ end
+ end
+
+ shared_examples 'only content is present' do
+ let(:content) { 'new_content' }
+ let(:base_opts) do
+ {
+ content: content
+ }
+ end
+
+ it 'updates the content' do
+ response = subject
+ snippet = response.payload[:snippet]
+
+ blob = snippet.repository.blob_at('master', snippet.blobs.first.path)
+
+ expect(blob).not_to be_nil
+ expect(response).to be_success
+ expect(blob.data).to eq content
+ end
+ end
+
context 'when Project Snippet' do
let_it_be(:project) { create(:project) }
let!(:snippet) { create(:project_snippet, :repository, author: user, project: project) }
@@ -316,6 +370,8 @@ describe Snippets::UpdateService do
it_behaves_like 'updates repository content'
it_behaves_like 'commit operation fails'
it_behaves_like 'committable attributes'
+ it_behaves_like 'only file_name is present'
+ it_behaves_like 'only content is present'
it_behaves_like 'snippets spam check is performed' do
before do
subject
@@ -340,6 +396,8 @@ describe Snippets::UpdateService do
it_behaves_like 'updates repository content'
it_behaves_like 'commit operation fails'
it_behaves_like 'committable attributes'
+ it_behaves_like 'only file_name is present'
+ it_behaves_like 'only content is present'
it_behaves_like 'snippets spam check is performed' do
before do
subject