diff options
Diffstat (limited to 'spec')
-rw-r--r-- | spec/finders/todos_finder_spec.rb | 22 | ||||
-rw-r--r-- | spec/lib/backup/repository_spec.rb | 24 | ||||
-rw-r--r-- | spec/lib/gitlab/git/repository_spec.rb | 14 | ||||
-rw-r--r-- | spec/lib/gitlab/gitaly_client/storage_service_spec.rb | 13 | ||||
-rw-r--r-- | spec/tasks/gitlab/backup_rake_spec.rb | 39 |
5 files changed, 74 insertions, 38 deletions
diff --git a/spec/finders/todos_finder_spec.rb b/spec/finders/todos_finder_spec.rb index a0bf48f218a..9a3ffffb3f2 100644 --- a/spec/finders/todos_finder_spec.rb +++ b/spec/finders/todos_finder_spec.rb @@ -73,6 +73,28 @@ describe TodosFinder do end end + context 'when filtering by author' do + let(:author1) { create(:user) } + let(:author2) { create(:user) } + + let!(:todo1) { create(:todo, user: user, author: author1) } + let!(:todo2) { create(:todo, user: user, author: author2) } + + it 'returns correct todos when filtering by an author' do + todos = finder.new(user, { author_id: author1.id }).execute + + expect(todos).to match_array([todo1]) + end + + context 'querying for multiple authors' do + it 'returns the correct todo items' do + todos = finder.new(user, { author_id: [author2.id, author1.id] }).execute + + expect(todos).to match_array([todo2, todo1]) + end + end + end + context 'with subgroups' do let(:subgroup) { create(:group, parent: group) } let!(:todo3) { create(:todo, user: user, group: subgroup, target: issue) } diff --git a/spec/lib/backup/repository_spec.rb b/spec/lib/backup/repository_spec.rb index 582effcc303..bf827fb3914 100644 --- a/spec/lib/backup/repository_spec.rb +++ b/spec/lib/backup/repository_spec.rb @@ -83,30 +83,6 @@ describe Backup::Repository do end end - describe '#prepare_directories', :seed_helper do - before do - allow(FileUtils).to receive(:mkdir_p).and_call_original - allow(FileUtils).to receive(:mv).and_call_original - end - - after(:all) do - ensure_seeds - end - - it' removes all repositories' do - # Sanity check: there should be something for us to delete - expect(list_repositories).to include(File.join(SEED_STORAGE_PATH, TEST_REPO_PATH)) - - subject.prepare_directories - - expect(list_repositories).to be_empty - end - - def list_repositories - Dir[File.join(SEED_STORAGE_PATH, '*.git')] - end - end - describe '#empty_repo?' do context 'for a wiki' do let(:wiki) { create(:project_wiki) } diff --git a/spec/lib/gitlab/git/repository_spec.rb b/spec/lib/gitlab/git/repository_spec.rb index 354260f23f6..04a648a0da0 100644 --- a/spec/lib/gitlab/git/repository_spec.rb +++ b/spec/lib/gitlab/git/repository_spec.rb @@ -2254,7 +2254,7 @@ describe Gitlab::Git::Repository, :seed_helper do end describe '#remove' do - let(:project) { create(:project, :repository)} + let(:project) { create(:project, :repository) } let(:repository) { project.repository } it 'removes the repository' do @@ -2264,5 +2264,17 @@ describe Gitlab::Git::Repository, :seed_helper do expect(repository.raw_repository.exists?).to be false end + + context 'when the repository does not exist' do + let(:repository) { create(:project).repository } + + it 'is idempotent' do + expect(repository.exists?).to be false + + repository.remove + + expect(repository.raw_repository.exists?).to be false + end + end end end diff --git a/spec/lib/gitlab/gitaly_client/storage_service_spec.rb b/spec/lib/gitlab/gitaly_client/storage_service_spec.rb deleted file mode 100644 index 6c25e2d6ebd..00000000000 --- a/spec/lib/gitlab/gitaly_client/storage_service_spec.rb +++ /dev/null @@ -1,13 +0,0 @@ -require 'spec_helper' - -describe Gitlab::GitalyClient::StorageService do - describe '#delete_all_repositories' do - let!(:project) { create(:project, :repository) } - - it 'removes all repositories' do - described_class.new(project.repository_storage).delete_all_repositories - - expect(project.repository.exists?).to be(false) - end - end -end diff --git a/spec/tasks/gitlab/backup_rake_spec.rb b/spec/tasks/gitlab/backup_rake_spec.rb index b307453f078..e58919c8688 100644 --- a/spec/tasks/gitlab/backup_rake_spec.rb +++ b/spec/tasks/gitlab/backup_rake_spec.rb @@ -117,6 +117,45 @@ describe 'gitlab:app namespace rake task' do expect(raw_repo.empty?).to be(true) end end + + context 'when the backup is restored' do + let!(:included_project) { create(:project, :repository) } + + before do + expect { run_rake_task('gitlab:backup:create') }.to output.to_stdout + + backup_tar = Dir.glob(File.join(Gitlab.config.backup.path, '*_gitlab_backup.tar')).last + allow(Dir).to receive(:glob).and_return([backup_tar]) + allow(File).to receive(:exist?).and_return(true) + allow(Kernel).to receive(:system).and_return(true) + allow(FileUtils).to receive(:cp_r).and_return(true) + allow(FileUtils).to receive(:mv).and_return(true) + allow(YAML).to receive(:load_file) + .and_return({ gitlab_version: Gitlab::VERSION }) + + expect(Rake::Task['gitlab:db:drop_tables']).to receive(:invoke) + expect(Rake::Task['gitlab:backup:db:restore']).to receive(:invoke) + expect(Rake::Task['gitlab:backup:repo:restore']).to receive(:invoke) + expect(Rake::Task['gitlab:backup:builds:restore']).to receive(:invoke) + expect(Rake::Task['gitlab:backup:uploads:restore']).to receive(:invoke) + expect(Rake::Task['gitlab:backup:artifacts:restore']).to receive(:invoke) + expect(Rake::Task['gitlab:backup:pages:restore']).to receive(:invoke) + expect(Rake::Task['gitlab:backup:lfs:restore']).to receive(:invoke) + expect(Rake::Task['gitlab:backup:registry:restore']).to receive(:invoke) + expect(Rake::Task['gitlab:shell:setup']).to receive(:invoke) + + # We only need a backup of the repositories for this test + stub_env('SKIP', 'db,uploads,builds,artifacts,lfs,registry') + end + + it 'restores the data' do + expect { run_rake_task('gitlab:backup:restore') }.to output.to_stdout + + raw_repo = included_project.repository.raw + + expect(raw_repo.empty?).to be(false) + end + end end # backup_restore task describe 'backup' do |