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
path: root/spec
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-03-17 00:09:21 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2020-03-17 00:09:21 +0300
commit87af6f2e0590af0ed1bb3e5de1bb5d21855a94d2 (patch)
tree2abe2661b10cf6281bc03855b3053a072c64fbbf /spec
parentc43ba2677f41ad0b5fc6f3af6baf4266c70dfcb3 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec')
-rw-r--r--spec/helpers/submodule_helper_spec.rb27
-rw-r--r--spec/lib/gitlab/danger/helper_spec.rb1
-rw-r--r--spec/lib/gitlab/diff/highlight_cache_spec.rb22
-rw-r--r--spec/lib/gitlab/repository_cache_adapter_spec.rb3
-rw-r--r--spec/lib/gitlab/repository_set_cache_spec.rb46
-rw-r--r--spec/services/commits/cherry_pick_service_spec.rb12
-rw-r--r--spec/services/deployments/link_merge_requests_service_spec.rb47
-rw-r--r--spec/services/system_notes/merge_requests_service_spec.rb2
8 files changed, 95 insertions, 65 deletions
diff --git a/spec/helpers/submodule_helper_spec.rb b/spec/helpers/submodule_helper_spec.rb
index 7db45c05cb5..db0836c8550 100644
--- a/spec/helpers/submodule_helper_spec.rb
+++ b/spec/helpers/submodule_helper_spec.rb
@@ -81,6 +81,33 @@ describe SubmoduleHelper do
end
end
+ context 'submodule on gist.github.com' do
+ it 'detects ssh' do
+ stub_url('git@gist.github.com:gitlab-org/gitlab-foss.git')
+ is_expected.to eq(['https://gist.github.com/gitlab-org/gitlab-foss', 'https://gist.github.com/gitlab-org/gitlab-foss/hash'])
+ end
+
+ it 'detects http' do
+ stub_url('http://gist.github.com/gitlab-org/gitlab-foss.git')
+ is_expected.to eq(['https://gist.github.com/gitlab-org/gitlab-foss', 'https://gist.github.com/gitlab-org/gitlab-foss/hash'])
+ end
+
+ it 'detects https' do
+ stub_url('https://gist.github.com/gitlab-org/gitlab-foss.git')
+ is_expected.to eq(['https://gist.github.com/gitlab-org/gitlab-foss', 'https://gist.github.com/gitlab-org/gitlab-foss/hash'])
+ end
+
+ it 'handles urls with no .git on the end' do
+ stub_url('http://gist.github.com/gitlab-org/gitlab-foss')
+ is_expected.to eq(['https://gist.github.com/gitlab-org/gitlab-foss', 'https://gist.github.com/gitlab-org/gitlab-foss/hash'])
+ end
+
+ it 'returns original with non-standard url' do
+ stub_url('http://gist.github.com/another/gitlab-org/gitlab-foss.git')
+ is_expected.to eq([repo.submodule_url_for, nil])
+ end
+ end
+
context 'submodule on github.com' do
it 'detects ssh' do
stub_url('git@github.com:gitlab-org/gitlab-foss.git')
diff --git a/spec/lib/gitlab/danger/helper_spec.rb b/spec/lib/gitlab/danger/helper_spec.rb
index c76a1ffaa14..dd183281977 100644
--- a/spec/lib/gitlab/danger/helper_spec.rb
+++ b/spec/lib/gitlab/danger/helper_spec.rb
@@ -222,6 +222,7 @@ describe Gitlab::Danger::Helper do
'lib/gitlab/danger/foo' | :engineering_productivity
'ee/lib/gitlab/danger/foo' | :engineering_productivity
'.overcommit.yml.example' | :engineering_productivity
+ '.editorconfig' | :engineering_productivity
'tooling/overcommit/foo' | :engineering_productivity
'lib/gitlab/ci/templates/Security/SAST.gitlab-ci.yml' | :backend
diff --git a/spec/lib/gitlab/diff/highlight_cache_spec.rb b/spec/lib/gitlab/diff/highlight_cache_spec.rb
index 457e81bc95f..a16e5e185bb 100644
--- a/spec/lib/gitlab/diff/highlight_cache_spec.rb
+++ b/spec/lib/gitlab/diff/highlight_cache_spec.rb
@@ -97,6 +97,28 @@ describe Gitlab::Diff::HighlightCache, :clean_gitlab_redis_cache do
let(:paths) { merge_request.diffs.raw_diff_files.select(&:text?).map(&:file_path) }
end
+ it 'updates memory usage metrics if Redis version >= 4' do
+ allow_next_instance_of(Redis) do |redis|
+ allow(redis).to receive(:info).and_return({ "redis_version" => "4.0.0" })
+
+ expect(described_class.gitlab_redis_diff_caching_memory_usage_bytes)
+ .to receive(:observe).and_call_original
+
+ cache.send(:write_to_redis_hash, diff_hash)
+ end
+ end
+
+ it 'does not update memory usage metrics if Redis version < 4' do
+ allow_next_instance_of(Redis) do |redis|
+ allow(redis).to receive(:info).and_return({ "redis_version" => "3.0.0" })
+
+ expect(described_class.gitlab_redis_diff_caching_memory_usage_bytes)
+ .not_to receive(:observe).and_call_original
+
+ cache.send(:write_to_redis_hash, diff_hash)
+ end
+ end
+
context 'different diff_collections for the same diffable' do
before do
cache.write_if_empty
diff --git a/spec/lib/gitlab/repository_cache_adapter_spec.rb b/spec/lib/gitlab/repository_cache_adapter_spec.rb
index b4fc504ea60..dba5ffc84c5 100644
--- a/spec/lib/gitlab/repository_cache_adapter_spec.rb
+++ b/spec/lib/gitlab/repository_cache_adapter_spec.rb
@@ -211,8 +211,7 @@ describe Gitlab::RepositoryCacheAdapter do
it 'expires the caches of the given methods' do
expect(cache).to receive(:expire).with(:rendered_readme)
expect(cache).to receive(:expire).with(:branch_names)
- expect(redis_set_cache).to receive(:expire).with(:rendered_readme)
- expect(redis_set_cache).to receive(:expire).with(:branch_names)
+ expect(redis_set_cache).to receive(:expire).with(:rendered_readme, :branch_names)
expect(redis_hash_cache).to receive(:delete).with(:rendered_readme)
expect(redis_hash_cache).to receive(:delete).with(:branch_names)
diff --git a/spec/lib/gitlab/repository_set_cache_spec.rb b/spec/lib/gitlab/repository_set_cache_spec.rb
index bcf27b338f6..c5d95e53120 100644
--- a/spec/lib/gitlab/repository_set_cache_spec.rb
+++ b/spec/lib/gitlab/repository_set_cache_spec.rb
@@ -51,12 +51,52 @@ describe Gitlab::RepositorySetCache, :clean_gitlab_redis_cache do
end
describe '#expire' do
- it 'expires the given key from the cache' do
+ subject { cache.expire(*keys) }
+
+ before do
cache.write(:foo, ['value'])
+ cache.write(:bar, ['value2'])
+ end
+ it 'actually wrote the values' do
expect(cache.read(:foo)).to contain_exactly('value')
- expect(cache.expire(:foo)).to eq(1)
- expect(cache.read(:foo)).to be_empty
+ expect(cache.read(:bar)).to contain_exactly('value2')
+ end
+
+ context 'single key' do
+ let(:keys) { %w(foo) }
+
+ it { is_expected.to eq(1) }
+
+ it 'deletes the given key from the cache' do
+ subject
+
+ expect(cache.read(:foo)).to be_empty
+ end
+ end
+
+ context 'multiple keys' do
+ let(:keys) { %w(foo bar) }
+
+ it { is_expected.to eq(2) }
+
+ it 'deletes the given keys from the cache' do
+ subject
+
+ expect(cache.read(:foo)).to be_empty
+ expect(cache.read(:bar)).to be_empty
+ end
+ end
+
+ context "unlink isn't supported" do
+ before do
+ allow_any_instance_of(Redis).to receive(:unlink) { raise ::Redis::CommandError }
+ end
+
+ it 'still deletes the given key' do
+ expect(cache.expire(:foo)).to eq(1)
+ expect(cache.read(:foo)).to be_empty
+ end
end
end
diff --git a/spec/services/commits/cherry_pick_service_spec.rb b/spec/services/commits/cherry_pick_service_spec.rb
index ead1932c2d1..3b797b8ac02 100644
--- a/spec/services/commits/cherry_pick_service_spec.rb
+++ b/spec/services/commits/cherry_pick_service_spec.rb
@@ -61,18 +61,6 @@ describe Commits::CherryPickService do
expect(mr_notes.length).to eq(1)
expect(mr_notes[0].commit_id).to eq(result[:result])
end
-
- context 'when :track_mr_picking feature flag is disabled' do
- before do
- stub_feature_flags(track_mr_picking: false)
- end
-
- it 'does not add system notes' do
- expect do
- cherry_pick(merge_commit_sha, branch_name)
- end.not_to change { Note.count }
- end
- end
end
def find_cherry_pick_notes(noteable)
diff --git a/spec/services/deployments/link_merge_requests_service_spec.rb b/spec/services/deployments/link_merge_requests_service_spec.rb
index 2f635c7ad62..aa2cecbf897 100644
--- a/spec/services/deployments/link_merge_requests_service_spec.rb
+++ b/spec/services/deployments/link_merge_requests_service_spec.rb
@@ -160,53 +160,6 @@ describe Deployments::LinkMergeRequestsService do
expect(deploy.merge_requests).to be_empty
end
-
- context 'when :track_mr_picking feature flag is disabled' do
- before do
- stub_feature_flags(track_mr_picking: false)
- end
-
- it 'does not link picked merge requests' do
- environment = create(:environment, project: project)
- deploy =
- create(:deployment, :success, project: project, environment: environment)
-
- picked_mr = create(
- :merge_request,
- :merged,
- merge_commit_sha: '123abc',
- source_project: project,
- target_project: project
- )
-
- mr1 = create(
- :merge_request,
- :merged,
- merge_commit_sha: mr1_merge_commit_sha,
- source_project: project,
- target_project: project
- )
-
- # mr1 includes c1c67abba which is a cherry-pick of the fake picked_mr merge request
- create(:track_mr_picking_note, noteable: picked_mr, project: project, commit_id: 'c1c67abbaf91f624347bb3ae96eabe3a1b742478')
-
- mr2 = create(
- :merge_request,
- :merged,
- merge_commit_sha: mr2_merge_commit_sha,
- source_project: project,
- target_project: project
- )
-
- described_class.new(deploy).link_merge_requests_for_range(
- first_deployment_sha,
- mr2_merge_commit_sha
- )
-
- expect(deploy.merge_requests).to include(mr1, mr2)
- expect(deploy.merge_requests).not_to include(picked_mr)
- end
- end
end
describe '#link_all_merged_merge_requests' do
diff --git a/spec/services/system_notes/merge_requests_service_spec.rb b/spec/services/system_notes/merge_requests_service_spec.rb
index f5c071502f5..13d6367a585 100644
--- a/spec/services/system_notes/merge_requests_service_spec.rb
+++ b/spec/services/system_notes/merge_requests_service_spec.rb
@@ -253,7 +253,7 @@ describe ::SystemNotes::MergeRequestsService do
end
it "posts the 'picked merge request' system note" do
- expect(subject.note).to eq("picked this merge request into branch [`#{branch_name}`](/#{project.full_path}/-/tree/#{branch_name}) with commit #{commit_sha}")
+ expect(subject.note).to eq("picked the changes into the branch [`#{branch_name}`](/#{project.full_path}/-/tree/#{branch_name}) with commit #{commit_sha}")
end
it 'links the merge request and the cherry-pick commit' do