diff options
author | Tiago Botelho <tiagonbotelho@hotmail.com> | 2017-11-28 15:46:29 +0300 |
---|---|---|
committer | Tiago Botelho <tiagonbotelho@hotmail.com> | 2017-11-28 15:46:29 +0300 |
commit | 9a65e9b2605c8d9c878ffa844a7c7b6331f0df19 (patch) | |
tree | 3712eb9e63d5a2fcf33ce5eeb48c0a6eb1149182 /spec | |
parent | 1613a631868fe6347236dc25fa83dea01fa1b0c7 (diff) | |
parent | 47c3d360e2857bb6715c7d79bd177bc8cb84ac61 (diff) |
Merge branch '10-2-stable-patch-3' of https://gitlab.com/gitlab-org/gitlab-ce into 10-2-stable-patch-3
Diffstat (limited to 'spec')
-rw-r--r-- | spec/finders/admin/projects_finder_spec.rb | 2 | ||||
-rw-r--r-- | spec/models/project_spec.rb | 18 | ||||
-rw-r--r-- | spec/services/search/global_service_spec.rb | 4 | ||||
-rw-r--r-- | spec/tasks/gitlab/cleanup_rake_spec.rb | 46 |
4 files changed, 39 insertions, 31 deletions
diff --git a/spec/finders/admin/projects_finder_spec.rb b/spec/finders/admin/projects_finder_spec.rb index 4b67203a0df..7901d5fee28 100644 --- a/spec/finders/admin/projects_finder_spec.rb +++ b/spec/finders/admin/projects_finder_spec.rb @@ -136,7 +136,7 @@ describe Admin::ProjectsFinder do context 'filter by name' do let(:params) { { name: 'C' } } - it { is_expected.to match_array([shared_project, public_project, private_project]) } + it { is_expected.to match_array([public_project]) } end context 'sorting' do diff --git a/spec/models/project_spec.rb b/spec/models/project_spec.rb index f7f19d464d1..549c97a9afd 100644 --- a/spec/models/project_spec.rb +++ b/spec/models/project_spec.rb @@ -1254,24 +1254,6 @@ describe Project do expect(described_class.search(project.path.upcase)).to eq([project]) end - it 'returns projects with a matching namespace name' do - expect(described_class.search(project.namespace.name)).to eq([project]) - end - - it 'returns projects with a partially matching namespace name' do - expect(described_class.search(project.namespace.name[0..2])).to eq([project]) - end - - it 'returns projects with a matching namespace name regardless of the casing' do - expect(described_class.search(project.namespace.name.upcase)).to eq([project]) - end - - it 'returns projects when eager loading namespaces' do - relation = described_class.all.includes(:namespace) - - expect(relation.search(project.namespace.name)).to eq([project]) - end - describe 'with pending_delete project' do let(:pending_delete_project) { create(:project, pending_delete: true) } diff --git a/spec/services/search/global_service_spec.rb b/spec/services/search/global_service_spec.rb index 1309240b430..d8dba26e194 100644 --- a/spec/services/search/global_service_spec.rb +++ b/spec/services/search/global_service_spec.rb @@ -35,8 +35,8 @@ describe Search::GlobalService do expect(results.objects('projects')).to match_array [internal_project, public_project] end - it 'namespace name is searchable' do - results = described_class.new(user, search: found_project.namespace.path).execute + it 'project name is searchable' do + results = described_class.new(user, search: found_project.name).execute expect(results.objects('projects')).to match_array [found_project] end diff --git a/spec/tasks/gitlab/cleanup_rake_spec.rb b/spec/tasks/gitlab/cleanup_rake_spec.rb index 641eccfd334..9e746ceddd6 100644 --- a/spec/tasks/gitlab/cleanup_rake_spec.rb +++ b/spec/tasks/gitlab/cleanup_rake_spec.rb @@ -5,7 +5,7 @@ describe 'gitlab:cleanup rake tasks' do Rake.application.rake_require 'tasks/gitlab/cleanup' end - context 'cleanup repositories' do + describe 'cleanup' do let(:gitaly_address) { Gitlab.config.repositories.storages.default.gitaly_address } let(:storages) do { @@ -22,20 +22,46 @@ describe 'gitlab:cleanup rake tasks' do FileUtils.rm_rf(Settings.absolute('tmp/tests/default_storage')) end - it 'moves it to an orphaned path' do - FileUtils.mkdir_p(Settings.absolute('tmp/tests/default_storage/broken/project.git')) - run_rake_task('gitlab:cleanup:repos') - repo_list = Dir['tmp/tests/default_storage/broken/*'] + describe 'cleanup:repos' do + before do + FileUtils.mkdir_p(Settings.absolute('tmp/tests/default_storage/broken/project.git')) + FileUtils.mkdir_p(Settings.absolute('tmp/tests/default_storage/@hashed/12/34/5678.git')) + end - expect(repo_list.first).to include('+orphaned+') + it 'moves it to an orphaned path' do + run_rake_task('gitlab:cleanup:repos') + repo_list = Dir['tmp/tests/default_storage/broken/*'] + + expect(repo_list.first).to include('+orphaned+') + end + + it 'ignores @hashed repos' do + run_rake_task('gitlab:cleanup:repos') + + expect(Dir.exist?(Settings.absolute('tmp/tests/default_storage/@hashed/12/34/5678.git'))).to be_truthy + end end - it 'ignores @hashed repos' do - FileUtils.mkdir_p(Settings.absolute('tmp/tests/default_storage/@hashed/12/34/5678.git')) + describe 'cleanup:dirs' do + it 'removes missing namespaces' do + FileUtils.mkdir_p(Settings.absolute("tmp/tests/default_storage/namespace_1/project.git")) + FileUtils.mkdir_p(Settings.absolute("tmp/tests/default_storage/namespace_2/project.git")) + allow(Namespace).to receive(:pluck).and_return('namespace_1') + + stub_env('REMOVE', 'true') + run_rake_task('gitlab:cleanup:dirs') + + expect(Dir.exist?(Settings.absolute('tmp/tests/default_storage/namespace_1'))).to be_truthy + expect(Dir.exist?(Settings.absolute('tmp/tests/default_storage/namespace_2'))).to be_falsey + end + + it 'ignores @hashed directory' do + FileUtils.mkdir_p(Settings.absolute('tmp/tests/default_storage/@hashed/12/34/5678.git')) - run_rake_task('gitlab:cleanup:repos') + run_rake_task('gitlab:cleanup:dirs') - expect(Dir.exist?(Settings.absolute('tmp/tests/default_storage/@hashed/12/34/5678.git'))).to be_truthy + expect(Dir.exist?(Settings.absolute('tmp/tests/default_storage/@hashed/12/34/5678.git'))).to be_truthy + end end end end |