diff options
author | Jan Provaznik <jprovaznik@gitlab.com> | 2017-12-07 20:24:39 +0100 |
---|---|---|
committer | Jan Provaznik <jprovaznik@gitlab.com> | 2018-01-30 12:02:27 +0100 |
commit | 80cde9b35eb450bd9a17d1191ea160139b838323 (patch) | |
tree | ee02111b090a33d1439973add5419ea25275a64a | |
parent | 51c8d5b2f3517e37b5313fc7f57436c2f6da5e4b (diff) | |
download | gitlab-ce-jprovazn-skip-disk-validation.tar.gz |
Use skip_disk_validation for projects in testsjprovazn-skip-disk-validation
Project creation fails by default if a repository with
the same name already exists on disk. This may cause
problems in tests which re-use a project name because
repository is not deleted on disk together when deleting a
project.
Instead of explicitly cleanup repositories before
tests which create a project with repository (current approach),
disk validation is skipped which should be also a little bit
faster.
If a test is sensitive about existing repository,
"TestEnv.clean_test_path" can be used explicitly around the test
to cleanup the repository.
To avoid a regression, TestEnv.clean_test_path is removed only from
"before" blocks in this patch (if removed from "after", there
is possibility that some test would start failing).
Related to #40900
7 files changed, 11 insertions, 8 deletions
diff --git a/spec/factories/projects.rb b/spec/factories/projects.rb index d0f3911f730..532395e1419 100644 --- a/spec/factories/projects.rb +++ b/spec/factories/projects.rb @@ -11,6 +11,8 @@ FactoryBot.define do # Behaves differently to nil due to cache_has_external_issue_tracker has_external_issue_tracker false + skip_disk_validation true + # Associations namespace creator { group ? create(:user) : namespace&.owner } diff --git a/spec/lib/gitlab/database/rename_reserved_paths_migration/v1/rename_base_spec.rb b/spec/lib/gitlab/database/rename_reserved_paths_migration/v1/rename_base_spec.rb index cc7cb3f23fd..58ebd467eed 100644 --- a/spec/lib/gitlab/database/rename_reserved_paths_migration/v1/rename_base_spec.rb +++ b/spec/lib/gitlab/database/rename_reserved_paths_migration/v1/rename_base_spec.rb @@ -6,7 +6,6 @@ describe Gitlab::Database::RenameReservedPathsMigration::V1::RenameBase, :delete before do allow(migration).to receive(:say) - TestEnv.clean_test_path end def migration_namespace(namespace) diff --git a/spec/lib/gitlab/database/rename_reserved_paths_migration/v1/rename_namespaces_spec.rb b/spec/lib/gitlab/database/rename_reserved_paths_migration/v1/rename_namespaces_spec.rb index f31475dbd71..a5fdfb741cb 100644 --- a/spec/lib/gitlab/database/rename_reserved_paths_migration/v1/rename_namespaces_spec.rb +++ b/spec/lib/gitlab/database/rename_reserved_paths_migration/v1/rename_namespaces_spec.rb @@ -7,7 +7,6 @@ describe Gitlab::Database::RenameReservedPathsMigration::V1::RenameNamespaces, : before do allow(migration).to receive(:say) - TestEnv.clean_test_path end def migration_namespace(namespace) diff --git a/spec/lib/gitlab/database/rename_reserved_paths_migration/v1/rename_projects_spec.rb b/spec/lib/gitlab/database/rename_reserved_paths_migration/v1/rename_projects_spec.rb index 0958144643b..e047293c007 100644 --- a/spec/lib/gitlab/database/rename_reserved_paths_migration/v1/rename_projects_spec.rb +++ b/spec/lib/gitlab/database/rename_reserved_paths_migration/v1/rename_projects_spec.rb @@ -11,7 +11,6 @@ describe Gitlab::Database::RenameReservedPathsMigration::V1::RenameProjects, :de before do allow(migration).to receive(:say) - TestEnv.clean_test_path end describe '#projects_for_paths' do diff --git a/spec/requests/api/projects_spec.rb b/spec/requests/api/projects_spec.rb index 97e7ffcd38e..7e0ec9017e2 100644 --- a/spec/requests/api/projects_spec.rb +++ b/spec/requests/api/projects_spec.rb @@ -462,7 +462,7 @@ describe API::Projects do expect(response).to have_gitlab_http_status(201) project.each_pair do |k, v| - next if %i[has_external_issue_tracker issues_enabled merge_requests_enabled wiki_enabled].include?(k) + next if %i[has_external_issue_tracker issues_enabled merge_requests_enabled wiki_enabled skip_disk_validation].include?(k) expect(json_response[k.to_s]).to eq(v) end @@ -669,7 +669,7 @@ describe API::Projects do expect(response).to have_gitlab_http_status(201) project.each_pair do |k, v| - next if %i[has_external_issue_tracker path].include?(k) + next if %i[has_external_issue_tracker path skip_disk_validation].include?(k) expect(json_response[k.to_s]).to eq(v) end diff --git a/spec/requests/api/v3/projects_spec.rb b/spec/requests/api/v3/projects_spec.rb index 13e465e0b2d..4ef939e9621 100644 --- a/spec/requests/api/v3/projects_spec.rb +++ b/spec/requests/api/v3/projects_spec.rb @@ -403,7 +403,7 @@ describe API::V3::Projects do post v3_api('/projects', user), project project.each_pair do |k, v| - next if %i[has_external_issue_tracker issues_enabled merge_requests_enabled wiki_enabled].include?(k) + next if %i[has_external_issue_tracker issues_enabled merge_requests_enabled wiki_enabled skip_disk_validation].include?(k) expect(json_response[k.to_s]).to eq(v) end @@ -547,7 +547,7 @@ describe API::V3::Projects do expect(response).to have_gitlab_http_status(201) project.each_pair do |k, v| - next if %i[has_external_issue_tracker path].include?(k) + next if %i[has_external_issue_tracker path skip_disk_validation].include?(k) expect(json_response[k.to_s]).to eq(v) end diff --git a/spec/services/projects/update_service_spec.rb b/spec/services/projects/update_service_spec.rb index fc6aa713d6f..bd63bf199d7 100644 --- a/spec/services/projects/update_service_spec.rb +++ b/spec/services/projects/update_service_spec.rb @@ -5,7 +5,11 @@ describe Projects::UpdateService do let(:user) { create(:user) } let(:project) do - create(:project, creator: user, namespace: user.namespace) + create(:project, skip_disk_validation: false, creator: user, namespace: user.namespace) + end + + before do + TestEnv.clean_test_path end describe '#execute' do |