diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-02-26 21:09:24 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-02-26 21:09:24 +0300 |
commit | 619d0b6922a6cf95d291fbbf5fa3d09e772a1ea8 (patch) | |
tree | fb8f8e036cec1b32166206bb5102af6c5dca8cfe /spec/lib/gitlab | |
parent | 17ab40ca089e1aef61a83f77ab6df62a72f6ce06 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/lib/gitlab')
23 files changed, 95 insertions, 82 deletions
diff --git a/spec/lib/gitlab/checks/branch_check_spec.rb b/spec/lib/gitlab/checks/branch_check_spec.rb index 7cc1722dfd4..fd7eaa1603f 100644 --- a/spec/lib/gitlab/checks/branch_check_spec.rb +++ b/spec/lib/gitlab/checks/branch_check_spec.rb @@ -15,7 +15,7 @@ describe Gitlab::Checks::BranchCheck do let(:ref) { 'refs/heads/master' } it 'raises an error' do - expect { subject.validate! }.to raise_error(Gitlab::GitAccess::UnauthorizedError, 'The default branch of a project cannot be deleted.') + expect { subject.validate! }.to raise_error(Gitlab::GitAccess::ForbiddenError, 'The default branch of a project cannot be deleted.') end end @@ -28,7 +28,7 @@ describe Gitlab::Checks::BranchCheck do it 'raises an error if the user is not allowed to do forced pushes to protected branches' do expect(Gitlab::Checks::ForcePush).to receive(:force_push?).and_return(true) - expect { subject.validate! }.to raise_error(Gitlab::GitAccess::UnauthorizedError, 'You are not allowed to force push code to a protected branch on this project.') + expect { subject.validate! }.to raise_error(Gitlab::GitAccess::ForbiddenError, 'You are not allowed to force push code to a protected branch on this project.') end it 'raises an error if the user is not allowed to merge to protected branches' do @@ -38,13 +38,13 @@ describe Gitlab::Checks::BranchCheck do expect(user_access).to receive(:can_merge_to_branch?).and_return(false) expect(user_access).to receive(:can_push_to_branch?).and_return(false) - expect { subject.validate! }.to raise_error(Gitlab::GitAccess::UnauthorizedError, 'You are not allowed to merge code into protected branches on this project.') + expect { subject.validate! }.to raise_error(Gitlab::GitAccess::ForbiddenError, 'You are not allowed to merge code into protected branches on this project.') end it 'raises an error if the user is not allowed to push to protected branches' do expect(user_access).to receive(:can_push_to_branch?).and_return(false) - expect { subject.validate! }.to raise_error(Gitlab::GitAccess::UnauthorizedError, 'You are not allowed to push code to protected branches on this project.') + expect { subject.validate! }.to raise_error(Gitlab::GitAccess::ForbiddenError, 'You are not allowed to push code to protected branches on this project.') end context 'when project repository is empty' do @@ -58,7 +58,7 @@ describe Gitlab::Checks::BranchCheck do end it 'raises an error' do - expect { subject.validate! }.to raise_error(Gitlab::GitAccess::UnauthorizedError, /Ask a project Owner or Maintainer to create a default branch/) + expect { subject.validate! }.to raise_error(Gitlab::GitAccess::ForbiddenError, /Ask a project Owner or Maintainer to create a default branch/) end end @@ -109,7 +109,7 @@ describe Gitlab::Checks::BranchCheck do end it 'raises an error' do - expect { subject.validate! }.to raise_error(Gitlab::GitAccess::UnauthorizedError, 'You are not allowed to create protected branches on this project.') + expect { subject.validate! }.to raise_error(Gitlab::GitAccess::ForbiddenError, 'You are not allowed to create protected branches on this project.') end end @@ -135,7 +135,7 @@ describe Gitlab::Checks::BranchCheck do end it 'raises an error' do - expect { subject.validate! }.to raise_error(Gitlab::GitAccess::UnauthorizedError, 'You can only use an existing protected branch ref as the basis of a new protected branch.') + expect { subject.validate! }.to raise_error(Gitlab::GitAccess::ForbiddenError, 'You can only use an existing protected branch ref as the basis of a new protected branch.') end end @@ -157,7 +157,7 @@ describe Gitlab::Checks::BranchCheck do context 'via SSH' do it 'raises an error' do - expect { subject.validate! }.to raise_error(Gitlab::GitAccess::UnauthorizedError, 'You can only create protected branches using the web interface and API.') + expect { subject.validate! }.to raise_error(Gitlab::GitAccess::ForbiddenError, 'You can only create protected branches using the web interface and API.') end end end @@ -171,7 +171,7 @@ describe Gitlab::Checks::BranchCheck do context 'if the user is not allowed to delete protected branches' do it 'raises an error' do - expect { subject.validate! }.to raise_error(Gitlab::GitAccess::UnauthorizedError, 'You are not allowed to delete protected branches from this project. Only a project maintainer or owner can delete a protected branch.') + expect { subject.validate! }.to raise_error(Gitlab::GitAccess::ForbiddenError, 'You are not allowed to delete protected branches from this project. Only a project maintainer or owner can delete a protected branch.') end end @@ -190,7 +190,7 @@ describe Gitlab::Checks::BranchCheck do context 'over SSH or HTTP' do it 'raises an error' do - expect { subject.validate! }.to raise_error(Gitlab::GitAccess::UnauthorizedError, 'You can only delete protected branches using the web interface.') + expect { subject.validate! }.to raise_error(Gitlab::GitAccess::ForbiddenError, 'You can only delete protected branches using the web interface.') end end end diff --git a/spec/lib/gitlab/checks/diff_check_spec.rb b/spec/lib/gitlab/checks/diff_check_spec.rb index b9134b8d6ab..467b4ed3a21 100644 --- a/spec/lib/gitlab/checks/diff_check_spec.rb +++ b/spec/lib/gitlab/checks/diff_check_spec.rb @@ -34,7 +34,7 @@ describe Gitlab::Checks::DiffCheck do context 'when change is sent by a different user' do it 'raises an error if the user is not allowed to update the file' do - expect { subject.validate! }.to raise_error(Gitlab::GitAccess::UnauthorizedError, "The path 'README' is locked in Git LFS by #{lock.user.name}") + expect { subject.validate! }.to raise_error(Gitlab::GitAccess::ForbiddenError, "The path 'README' is locked in Git LFS by #{lock.user.name}") end end diff --git a/spec/lib/gitlab/checks/lfs_check_spec.rb b/spec/lib/gitlab/checks/lfs_check_spec.rb index dad14e100a7..c86481d1abe 100644 --- a/spec/lib/gitlab/checks/lfs_check_spec.rb +++ b/spec/lib/gitlab/checks/lfs_check_spec.rb @@ -50,7 +50,7 @@ describe Gitlab::Checks::LfsCheck do end it 'fails if any LFS blobs are missing' do - expect { subject.validate! }.to raise_error(Gitlab::GitAccess::UnauthorizedError, /LFS objects are missing/) + expect { subject.validate! }.to raise_error(Gitlab::GitAccess::ForbiddenError, /LFS objects are missing/) end it 'succeeds if LFS objects have already been uploaded' do diff --git a/spec/lib/gitlab/checks/push_check_spec.rb b/spec/lib/gitlab/checks/push_check_spec.rb index e1bd52d6c0b..857d71732fe 100644 --- a/spec/lib/gitlab/checks/push_check_spec.rb +++ b/spec/lib/gitlab/checks/push_check_spec.rb @@ -15,7 +15,7 @@ describe Gitlab::Checks::PushCheck do expect(user_access).to receive(:can_do_action?).with(:push_code).and_return(false) expect(project).to receive(:branch_allows_collaboration?).with(user_access.user, 'master').and_return(false) - expect { subject.validate! }.to raise_error(Gitlab::GitAccess::UnauthorizedError, 'You are not allowed to push code to this project.') + expect { subject.validate! }.to raise_error(Gitlab::GitAccess::ForbiddenError, 'You are not allowed to push code to this project.') end end end diff --git a/spec/lib/gitlab/checks/tag_check_spec.rb b/spec/lib/gitlab/checks/tag_check_spec.rb index 80e9eb504ad..0c94171646e 100644 --- a/spec/lib/gitlab/checks/tag_check_spec.rb +++ b/spec/lib/gitlab/checks/tag_check_spec.rb @@ -11,7 +11,7 @@ describe Gitlab::Checks::TagCheck do it 'raises an error when user does not have access' do allow(user_access).to receive(:can_do_action?).with(:admin_tag).and_return(false) - expect { subject.validate! }.to raise_error(Gitlab::GitAccess::UnauthorizedError, 'You are not allowed to change existing tags on this project.') + expect { subject.validate! }.to raise_error(Gitlab::GitAccess::ForbiddenError, 'You are not allowed to change existing tags on this project.') end context 'with protected tag' do @@ -27,7 +27,7 @@ describe Gitlab::Checks::TagCheck do let(:newrev) { '0000000000000000000000000000000000000000' } it 'is prevented' do - expect { subject.validate! }.to raise_error(Gitlab::GitAccess::UnauthorizedError, /cannot be deleted/) + expect { subject.validate! }.to raise_error(Gitlab::GitAccess::ForbiddenError, /cannot be deleted/) end end @@ -36,7 +36,7 @@ describe Gitlab::Checks::TagCheck do let(:newrev) { '54fcc214b94e78d7a41a9a8fe6d87a5e59500e51' } it 'is prevented' do - expect { subject.validate! }.to raise_error(Gitlab::GitAccess::UnauthorizedError, /cannot be updated/) + expect { subject.validate! }.to raise_error(Gitlab::GitAccess::ForbiddenError, /cannot be updated/) end end end @@ -47,7 +47,7 @@ describe Gitlab::Checks::TagCheck do let(:ref) { 'refs/tags/v9.1.0' } it 'prevents creation below access level' do - expect { subject.validate! }.to raise_error(Gitlab::GitAccess::UnauthorizedError, /allowed to create this tag as it is protected/) + expect { subject.validate! }.to raise_error(Gitlab::GitAccess::ForbiddenError, /allowed to create this tag as it is protected/) end context 'when user has access' do diff --git a/spec/lib/gitlab/git_access_spec.rb b/spec/lib/gitlab/git_access_spec.rb index 0831021b22b..f95349a2125 100644 --- a/spec/lib/gitlab/git_access_spec.rb +++ b/spec/lib/gitlab/git_access_spec.rb @@ -32,8 +32,8 @@ describe Gitlab::GitAccess do it 'blocks ssh git push and pull' do aggregate_failures do - expect { push_access_check }.to raise_unauthorized('Git access over SSH is not allowed') - expect { pull_access_check }.to raise_unauthorized('Git access over SSH is not allowed') + expect { push_access_check }.to raise_forbidden('Git access over SSH is not allowed') + expect { pull_access_check }.to raise_forbidden('Git access over SSH is not allowed') end end end @@ -48,8 +48,8 @@ describe Gitlab::GitAccess do it 'blocks http push and pull' do aggregate_failures do - expect { push_access_check }.to raise_unauthorized('Git access over HTTP is not allowed') - expect { pull_access_check }.to raise_unauthorized('Git access over HTTP is not allowed') + expect { push_access_check }.to raise_forbidden('Git access over HTTP is not allowed') + expect { pull_access_check }.to raise_forbidden('Git access over HTTP is not allowed') end end @@ -58,7 +58,7 @@ describe Gitlab::GitAccess do it "doesn't block http pull" do aggregate_failures do - expect { pull_access_check }.not_to raise_unauthorized('Git access over HTTP is not allowed') + expect { pull_access_check }.not_to raise_forbidden('Git access over HTTP is not allowed') end end @@ -67,7 +67,7 @@ describe Gitlab::GitAccess do it "doesn't block http pull" do aggregate_failures do - expect { pull_access_check }.not_to raise_unauthorized('Git access over HTTP is not allowed') + expect { pull_access_check }.not_to raise_forbidden('Git access over HTTP is not allowed') end end end @@ -165,7 +165,7 @@ describe Gitlab::GitAccess do end it 'does not block pushes with "not found"' do - expect { push_access_check }.to raise_unauthorized(described_class::ERROR_MESSAGES[:auth_upload]) + expect { push_access_check }.to raise_forbidden(described_class::ERROR_MESSAGES[:auth_upload]) end end @@ -178,7 +178,7 @@ describe Gitlab::GitAccess do end it 'blocks the push' do - expect { push_access_check }.to raise_unauthorized(described_class::ERROR_MESSAGES[:upload]) + expect { push_access_check }.to raise_forbidden(described_class::ERROR_MESSAGES[:upload]) end end @@ -208,7 +208,7 @@ describe Gitlab::GitAccess do end it 'does not block pushes with "not found"' do - expect { push_access_check }.to raise_unauthorized(described_class::ERROR_MESSAGES[:upload]) + expect { push_access_check }.to raise_forbidden(described_class::ERROR_MESSAGES[:upload]) end end @@ -285,8 +285,8 @@ describe Gitlab::GitAccess do it 'does not allow keys which are too small', :aggregate_failures do expect(actor).not_to be_valid - expect { pull_access_check }.to raise_unauthorized('Your SSH key must be at least 4096 bits.') - expect { push_access_check }.to raise_unauthorized('Your SSH key must be at least 4096 bits.') + expect { pull_access_check }.to raise_forbidden('Your SSH key must be at least 4096 bits.') + expect { push_access_check }.to raise_forbidden('Your SSH key must be at least 4096 bits.') end end @@ -297,8 +297,8 @@ describe Gitlab::GitAccess do it 'does not allow keys which are too small', :aggregate_failures do expect(actor).not_to be_valid - expect { pull_access_check }.to raise_unauthorized(/Your SSH key type is forbidden/) - expect { push_access_check }.to raise_unauthorized(/Your SSH key type is forbidden/) + expect { pull_access_check }.to raise_forbidden(/Your SSH key type is forbidden/) + expect { push_access_check }.to raise_forbidden(/Your SSH key type is forbidden/) end end end @@ -363,7 +363,7 @@ describe Gitlab::GitAccess do let(:authentication_abilities) { [] } it 'raises unauthorized with download error' do - expect { pull_access_check }.to raise_unauthorized(described_class::ERROR_MESSAGES[:auth_download]) + expect { pull_access_check }.to raise_forbidden(described_class::ERROR_MESSAGES[:auth_download]) end context 'when authentication abilities include download code' do @@ -387,7 +387,7 @@ describe Gitlab::GitAccess do let(:authentication_abilities) { [] } it 'raises unauthorized with push error' do - expect { push_access_check }.to raise_unauthorized(described_class::ERROR_MESSAGES[:auth_upload]) + expect { push_access_check }.to raise_forbidden(described_class::ERROR_MESSAGES[:auth_upload]) end context 'when authentication abilities include push code' do @@ -414,7 +414,7 @@ describe Gitlab::GitAccess do end context 'when calling git-upload-pack' do - it { expect { pull_access_check }.to raise_unauthorized('Pulling over HTTP is not allowed.') } + it { expect { pull_access_check }.to raise_forbidden('Pulling over HTTP is not allowed.') } end context 'when calling git-receive-pack' do @@ -428,7 +428,7 @@ describe Gitlab::GitAccess do end context 'when calling git-receive-pack' do - it { expect { push_access_check }.to raise_unauthorized('Pushing over HTTP is not allowed.') } + it { expect { push_access_check }.to raise_forbidden('Pushing over HTTP is not allowed.') } end context 'when calling git-upload-pack' do @@ -445,7 +445,7 @@ describe Gitlab::GitAccess do allow(Gitlab::Database).to receive(:read_only?) { true } end - it { expect { push_access_check }.to raise_unauthorized(described_class::ERROR_MESSAGES[:cannot_push_to_read_only]) } + it { expect { push_access_check }.to raise_forbidden(described_class::ERROR_MESSAGES[:cannot_push_to_read_only]) } end end @@ -559,21 +559,21 @@ describe Gitlab::GitAccess do it 'disallows guests to pull' do project.add_guest(user) - expect { pull_access_check }.to raise_unauthorized(described_class::ERROR_MESSAGES[:download]) + expect { pull_access_check }.to raise_forbidden(described_class::ERROR_MESSAGES[:download]) end it 'disallows blocked users to pull' do project.add_maintainer(user) user.block - expect { pull_access_check }.to raise_unauthorized('Your account has been blocked.') + expect { pull_access_check }.to raise_forbidden('Your account has been blocked.') end it 'disallows deactivated users to pull' do project.add_maintainer(user) user.deactivate! - expect { pull_access_check }.to raise_unauthorized("Your account has been deactivated by your administrator. Please log back in from a web browser to reactivate your account at #{Gitlab.config.gitlab.url}") + expect { pull_access_check }.to raise_forbidden("Your account has been deactivated by your administrator. Please log back in from a web browser to reactivate your account at #{Gitlab.config.gitlab.url}") end context 'when the project repository does not exist' do @@ -610,7 +610,7 @@ describe Gitlab::GitAccess do it 'does not give access to download code' do public_project.project_feature.update_attribute(:repository_access_level, ProjectFeature::DISABLED) - expect { pull_access_check }.to raise_unauthorized(described_class::ERROR_MESSAGES[:download]) + expect { pull_access_check }.to raise_forbidden(described_class::ERROR_MESSAGES[:download]) end end end @@ -722,7 +722,7 @@ describe Gitlab::GitAccess do context 'when is not member of the project' do context 'pull code' do - it { expect { pull_access_check }.to raise_unauthorized(described_class::ERROR_MESSAGES[:download]) } + it { expect { pull_access_check }.to raise_forbidden(described_class::ERROR_MESSAGES[:download]) } end end end @@ -828,7 +828,7 @@ describe Gitlab::GitAccess do expect(&check).not_to raise_error, -> { "expected #{action} to be allowed" } else - expect(&check).to raise_error(Gitlab::GitAccess::UnauthorizedError), + expect(&check).to raise_error(Gitlab::GitAccess::ForbiddenError), -> { "expected #{action} to be disallowed" } end end @@ -965,7 +965,7 @@ describe Gitlab::GitAccess do it 'does not allow deactivated users to push' do user.deactivate! - expect { push_access_check }.to raise_unauthorized("Your account has been deactivated by your administrator. Please log back in from a web browser to reactivate your account at #{Gitlab.config.gitlab.url}") + expect { push_access_check }.to raise_forbidden("Your account has been deactivated by your administrator. Please log back in from a web browser to reactivate your account at #{Gitlab.config.gitlab.url}") end it 'cleans up the files' do @@ -1009,26 +1009,26 @@ describe Gitlab::GitAccess do project.add_reporter(user) end - it { expect { push_access_check }.to raise_unauthorized(described_class::ERROR_MESSAGES[:auth_upload]) } + it { expect { push_access_check }.to raise_forbidden(described_class::ERROR_MESSAGES[:auth_upload]) } end context 'when unauthorized' do context 'to public project' do let(:project) { create(:project, :public, :repository) } - it { expect { push_access_check }.to raise_unauthorized(described_class::ERROR_MESSAGES[:auth_upload]) } + it { expect { push_access_check }.to raise_forbidden(described_class::ERROR_MESSAGES[:auth_upload]) } end context 'to internal project' do let(:project) { create(:project, :internal, :repository) } - it { expect { push_access_check }.to raise_unauthorized(described_class::ERROR_MESSAGES[:auth_upload]) } + it { expect { push_access_check }.to raise_forbidden(described_class::ERROR_MESSAGES[:auth_upload]) } end context 'to private project' do let(:project) { create(:project, :private, :repository) } - it { expect { push_access_check }.to raise_unauthorized(described_class::ERROR_MESSAGES[:auth_upload]) } + it { expect { push_access_check }.to raise_forbidden(described_class::ERROR_MESSAGES[:auth_upload]) } end end end @@ -1039,7 +1039,7 @@ describe Gitlab::GitAccess do it 'denies push access' do project.add_maintainer(user) - expect { push_access_check }.to raise_unauthorized('The repository is temporarily read-only. Please try again later.') + expect { push_access_check }.to raise_forbidden('The repository is temporarily read-only. Please try again later.') end end @@ -1060,7 +1060,7 @@ describe Gitlab::GitAccess do context 'to public project' do let(:project) { create(:project, :public, :repository) } - it { expect { push_access_check }.to raise_unauthorized(described_class::ERROR_MESSAGES[:deploy_key_upload]) } + it { expect { push_access_check }.to raise_forbidden(described_class::ERROR_MESSAGES[:deploy_key_upload]) } end context 'to internal project' do @@ -1083,14 +1083,14 @@ describe Gitlab::GitAccess do key.deploy_keys_projects.create(project: project, can_push: false) end - it { expect { push_access_check }.to raise_unauthorized(described_class::ERROR_MESSAGES[:deploy_key_upload]) } + it { expect { push_access_check }.to raise_forbidden(described_class::ERROR_MESSAGES[:deploy_key_upload]) } end context 'when unauthorized' do context 'to public project' do let(:project) { create(:project, :public, :repository) } - it { expect { push_access_check }.to raise_unauthorized(described_class::ERROR_MESSAGES[:deploy_key_upload]) } + it { expect { push_access_check }.to raise_forbidden(described_class::ERROR_MESSAGES[:deploy_key_upload]) } end context 'to internal project' do @@ -1121,7 +1121,7 @@ describe Gitlab::GitAccess do it 'blocks access when the user did not accept terms', :aggregate_failures do actions.each do |action| - expect { action.call }.to raise_unauthorized(/must accept the Terms of Service in order to perform this action/) + expect { action.call }.to raise_forbidden(/must accept the Terms of Service in order to perform this action/) end end @@ -1211,8 +1211,8 @@ describe Gitlab::GitAccess do access.check('git-receive-pack', changes) end - def raise_unauthorized(message) - raise_error(Gitlab::GitAccess::UnauthorizedError, message) + def raise_forbidden(message) + raise_error(Gitlab::GitAccess::ForbiddenError, message) end def raise_not_found diff --git a/spec/lib/gitlab/git_access_wiki_spec.rb b/spec/lib/gitlab/git_access_wiki_spec.rb index 99c9369a2b9..b5e673c9e79 100644 --- a/spec/lib/gitlab/git_access_wiki_spec.rb +++ b/spec/lib/gitlab/git_access_wiki_spec.rb @@ -33,7 +33,7 @@ describe Gitlab::GitAccessWiki do end it 'does not give access to upload wiki code' do - expect { subject }.to raise_error(Gitlab::GitAccess::UnauthorizedError, "You can't push code to a read-only GitLab instance.") + expect { subject }.to raise_error(Gitlab::GitAccess::ForbiddenError, "You can't push code to a read-only GitLab instance.") end end end @@ -70,7 +70,7 @@ describe Gitlab::GitAccessWiki do it 'does not give access to download wiki code' do project.project_feature.update_attribute(:wiki_access_level, ProjectFeature::DISABLED) - expect { subject }.to raise_error(Gitlab::GitAccess::UnauthorizedError, 'You are not allowed to download code from this project.') + expect { subject }.to raise_error(Gitlab::GitAccess::ForbiddenError, 'You are not allowed to download code from this project.') end end end diff --git a/spec/lib/gitlab/gitaly_client/commit_service_spec.rb b/spec/lib/gitlab/gitaly_client/commit_service_spec.rb index 5c36d6d35af..00182983418 100644 --- a/spec/lib/gitlab/gitaly_client/commit_service_spec.rb +++ b/spec/lib/gitlab/gitaly_client/commit_service_spec.rb @@ -306,5 +306,19 @@ describe Gitlab::GitalyClient::CommitService do client.find_commits(order: 'topo') end + + it 'sends an RPC request with an author' do + request = Gitaly::FindCommitsRequest.new( + repository: repository_message, + disable_walk: true, + order: 'NONE', + author: "Billy Baggins <bilbo@shire.com>" + ) + + expect_any_instance_of(Gitaly::CommitService::Stub).to receive(:find_commits) + .with(request, kind_of(Hash)).and_return([]) + + client.find_commits(order: 'default', author: "Billy Baggins <bilbo@shire.com>") + end end end diff --git a/spec/lib/gitlab/import_export/base_object_builder_spec.rb b/spec/lib/gitlab/import_export/base/object_builder_spec.rb index fbb3b08cf56..e5242ae0bfc 100644 --- a/spec/lib/gitlab/import_export/base_object_builder_spec.rb +++ b/spec/lib/gitlab/import_export/base/object_builder_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Gitlab::ImportExport::BaseObjectBuilder do +describe Gitlab::ImportExport::Base::ObjectBuilder do let(:project) do create(:project, :repository, :builds_disabled, @@ -11,7 +11,7 @@ describe Gitlab::ImportExport::BaseObjectBuilder do path: 'project') end let(:klass) { Milestone } - let(:attributes) { { 'title' => 'Test BaseObjectBuilder Milestone', 'project' => project } } + let(:attributes) { { 'title' => 'Test Base::ObjectBuilder Milestone', 'project' => project } } subject { described_class.build(klass, attributes) } diff --git a/spec/lib/gitlab/import_export/base_relation_factory_spec.rb b/spec/lib/gitlab/import_export/base/relation_factory_spec.rb index e02d8f3d2e6..1011de83c95 100644 --- a/spec/lib/gitlab/import_export/base_relation_factory_spec.rb +++ b/spec/lib/gitlab/import_export/base/relation_factory_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Gitlab::ImportExport::BaseRelationFactory do +describe Gitlab::ImportExport::Base::RelationFactory do let(:user) { create(:admin) } let(:project) { create(:project) } let(:members_mapper) { double('members_mapper').as_null_object } @@ -13,7 +13,7 @@ describe Gitlab::ImportExport::BaseRelationFactory do subject do described_class.create(relation_sym: relation_sym, relation_hash: relation_hash, - object_builder: Gitlab::ImportExport::GroupProjectObjectBuilder, + object_builder: Gitlab::ImportExport::Project::ObjectBuilder, members_mapper: members_mapper, user: user, importable: project, diff --git a/spec/lib/gitlab/import_export/fork_spec.rb b/spec/lib/gitlab/import_export/fork_spec.rb index 09e4f62c686..8aa28353c04 100644 --- a/spec/lib/gitlab/import_export/fork_spec.rb +++ b/spec/lib/gitlab/import_export/fork_spec.rb @@ -24,11 +24,11 @@ describe 'forked project import' do end let(:saver) do - Gitlab::ImportExport::ProjectTreeSaver.new(project: project_with_repo, current_user: user, shared: shared) + Gitlab::ImportExport::Project::TreeSaver.new(project: project_with_repo, current_user: user, shared: shared) end let(:restorer) do - Gitlab::ImportExport::ProjectTreeRestorer.new(user: user, shared: shared, project: project) + Gitlab::ImportExport::Project::TreeRestorer.new(user: user, shared: shared, project: project) end before do diff --git a/spec/lib/gitlab/import_export/group_object_builder_spec.rb b/spec/lib/gitlab/import_export/group/object_builder_spec.rb index 08b2dae1147..781670b0aa5 100644 --- a/spec/lib/gitlab/import_export/group_object_builder_spec.rb +++ b/spec/lib/gitlab/import_export/group/object_builder_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Gitlab::ImportExport::GroupObjectBuilder do +describe Gitlab::ImportExport::Group::ObjectBuilder do let(:group) { create(:group) } let(:base_attributes) do { diff --git a/spec/lib/gitlab/import_export/group_relation_factory_spec.rb b/spec/lib/gitlab/import_export/group/relation_factory_spec.rb index 9208b2ad203..332648d5c89 100644 --- a/spec/lib/gitlab/import_export/group_relation_factory_spec.rb +++ b/spec/lib/gitlab/import_export/group/relation_factory_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Gitlab::ImportExport::GroupRelationFactory do +describe Gitlab::ImportExport::Group::RelationFactory do let(:group) { create(:group) } let(:members_mapper) { double('members_mapper').as_null_object } let(:user) { create(:admin) } @@ -11,7 +11,7 @@ describe Gitlab::ImportExport::GroupRelationFactory do described_class.create(relation_sym: relation_sym, relation_hash: relation_hash, members_mapper: members_mapper, - object_builder: Gitlab::ImportExport::GroupObjectBuilder, + object_builder: Gitlab::ImportExport::Group::ObjectBuilder, user: user, importable: group, excluded_keys: excluded_keys) diff --git a/spec/lib/gitlab/import_export/group_tree_restorer_spec.rb b/spec/lib/gitlab/import_export/group/tree_restorer_spec.rb index b2c8398d358..5584f1503f7 100644 --- a/spec/lib/gitlab/import_export/group_tree_restorer_spec.rb +++ b/spec/lib/gitlab/import_export/group/tree_restorer_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Gitlab::ImportExport::GroupTreeRestorer do +describe Gitlab::ImportExport::Group::TreeRestorer do include ImportExport::CommonUtil let(:shared) { Gitlab::ImportExport::Shared.new(group) } diff --git a/spec/lib/gitlab/import_export/group_tree_saver_spec.rb b/spec/lib/gitlab/import_export/group/tree_saver_spec.rb index 7f49c7af8fa..845eb8e308b 100644 --- a/spec/lib/gitlab/import_export/group_tree_saver_spec.rb +++ b/spec/lib/gitlab/import_export/group/tree_saver_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Gitlab::ImportExport::GroupTreeSaver do +describe Gitlab::ImportExport::Group::TreeSaver do describe 'saves the group tree into a json object' do let(:shared) { Gitlab::ImportExport::Shared.new(group) } let(:group_tree_saver) { described_class.new(group: group, current_user: user, shared: shared) } @@ -72,7 +72,7 @@ describe Gitlab::ImportExport::GroupTreeSaver do # except: # context 'with description override' do # context 'group members' do - # ^ These are specific for the groupTreeSaver + # ^ These are specific for the Group::TreeSaver context 'JSON' do let(:saved_group_json) do group_tree_saver.save diff --git a/spec/lib/gitlab/import_export/importer_spec.rb b/spec/lib/gitlab/import_export/importer_spec.rb index 942af4084e5..07857269004 100644 --- a/spec/lib/gitlab/import_export/importer_spec.rb +++ b/spec/lib/gitlab/import_export/importer_spec.rb @@ -63,7 +63,7 @@ describe Gitlab::ImportExport::Importer do end it 'restores the ProjectTree' do - expect(Gitlab::ImportExport::ProjectTreeRestorer).to receive(:new).and_call_original + expect(Gitlab::ImportExport::Project::TreeRestorer).to receive(:new).and_call_original importer.execute end diff --git a/spec/lib/gitlab/import_export/group_project_object_builder_spec.rb b/spec/lib/gitlab/import_export/project/object_builder_spec.rb index 34049cbf570..c9d1410400a 100644 --- a/spec/lib/gitlab/import_export/group_project_object_builder_spec.rb +++ b/spec/lib/gitlab/import_export/project/object_builder_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Gitlab::ImportExport::GroupProjectObjectBuilder do +describe Gitlab::ImportExport::Project::ObjectBuilder do let!(:group) { create(:group, :private) } let!(:subgroup) { create(:group, :private, parent: group) } let!(:project) do diff --git a/spec/lib/gitlab/import_export/project_relation_factory_spec.rb b/spec/lib/gitlab/import_export/project/relation_factory_spec.rb index d0e89b2e57b..73ae6810706 100644 --- a/spec/lib/gitlab/import_export/project_relation_factory_spec.rb +++ b/spec/lib/gitlab/import_export/project/relation_factory_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Gitlab::ImportExport::ProjectRelationFactory do +describe Gitlab::ImportExport::Project::RelationFactory do let(:group) { create(:group) } let(:project) { create(:project, :repository, group: group) } let(:members_mapper) { double('members_mapper').as_null_object } @@ -11,7 +11,7 @@ describe Gitlab::ImportExport::ProjectRelationFactory do let(:created_object) do described_class.create(relation_sym: relation_sym, relation_hash: relation_hash, - object_builder: Gitlab::ImportExport::GroupProjectObjectBuilder, + object_builder: Gitlab::ImportExport::Project::ObjectBuilder, members_mapper: members_mapper, user: user, importable: project, @@ -243,11 +243,11 @@ describe Gitlab::ImportExport::ProjectRelationFactory do context 'Project references' do let(:relation_sym) { :project_foo_model } let(:relation_hash) do - Gitlab::ImportExport::ProjectRelationFactory::PROJECT_REFERENCES.map { |ref| { ref => 99 } }.inject(:merge) + Gitlab::ImportExport::Project::RelationFactory::PROJECT_REFERENCES.map { |ref| { ref => 99 } }.inject(:merge) end class ProjectFooModel < FooModel - attr_accessor(*Gitlab::ImportExport::ProjectRelationFactory::PROJECT_REFERENCES) + attr_accessor(*Gitlab::ImportExport::Project::RelationFactory::PROJECT_REFERENCES) end before do diff --git a/spec/lib/gitlab/import_export/project_tree_loader_spec.rb b/spec/lib/gitlab/import_export/project/tree_loader_spec.rb index b22de5a3f7b..e683eefa7c0 100644 --- a/spec/lib/gitlab/import_export/project_tree_loader_spec.rb +++ b/spec/lib/gitlab/import_export/project/tree_loader_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Gitlab::ImportExport::ProjectTreeLoader do +describe Gitlab::ImportExport::Project::TreeLoader do let(:fixture) { 'spec/fixtures/lib/gitlab/import_export/with_duplicates.json' } let(:project_tree) { JSON.parse(File.read(fixture)) } diff --git a/spec/lib/gitlab/import_export/project_tree_restorer_spec.rb b/spec/lib/gitlab/import_export/project/tree_restorer_spec.rb index c899217d164..312bbb58a28 100644 --- a/spec/lib/gitlab/import_export/project_tree_restorer_spec.rb +++ b/spec/lib/gitlab/import_export/project/tree_restorer_spec.rb @@ -1,9 +1,8 @@ # frozen_string_literal: true require 'spec_helper' -include ImportExport::CommonUtil -describe Gitlab::ImportExport::ProjectTreeRestorer do +describe Gitlab::ImportExport::Project::TreeRestorer do include ImportExport::CommonUtil let(:shared) { project.import_export_shared } diff --git a/spec/lib/gitlab/import_export/project_tree_saver_spec.rb b/spec/lib/gitlab/import_export/project/tree_saver_spec.rb index 126ac289a56..151fdf8810f 100644 --- a/spec/lib/gitlab/import_export/project_tree_saver_spec.rb +++ b/spec/lib/gitlab/import_export/project/tree_saver_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Gitlab::ImportExport::ProjectTreeSaver do +describe Gitlab::ImportExport::Project::TreeSaver do describe 'saves the project tree into a json object' do let(:shared) { project.import_export_shared } let(:project_tree_saver) { described_class.new(project: project, current_user: user, shared: shared) } @@ -75,7 +75,7 @@ describe Gitlab::ImportExport::ProjectTreeSaver do # except: # context 'with description override' do # context 'group members' do - # ^ These are specific for the ProjectTreeSaver + # ^ These are specific for the Project::TreeSaver context 'JSON' do let(:saved_project_json) do project_tree_saver.save diff --git a/spec/lib/gitlab/import_export/relation_rename_service_spec.rb b/spec/lib/gitlab/import_export/relation_rename_service_spec.rb index d62f5725f9e..2e251154e9f 100644 --- a/spec/lib/gitlab/import_export/relation_rename_service_spec.rb +++ b/spec/lib/gitlab/import_export/relation_rename_service_spec.rb @@ -22,7 +22,7 @@ describe Gitlab::ImportExport::RelationRenameService do end context 'when importing' do - let(:project_tree_restorer) { Gitlab::ImportExport::ProjectTreeRestorer.new(user: user, shared: shared, project: project) } + let(:project_tree_restorer) { Gitlab::ImportExport::Project::TreeRestorer.new(user: user, shared: shared, project: project) } let(:file_content) { IO.read(File.join(shared.export_path, 'project.json')) } let(:json_file) { ActiveSupport::JSON.decode(file_content) } @@ -99,7 +99,7 @@ describe Gitlab::ImportExport::RelationRenameService do let(:relation_tree_saver) { Gitlab::ImportExport::RelationTreeSaver.new } let(:project_tree_saver) do - Gitlab::ImportExport::ProjectTreeSaver.new( + Gitlab::ImportExport::Project::TreeSaver.new( project: project, current_user: user, shared: shared) end diff --git a/spec/lib/gitlab/import_export/relation_tree_restorer_spec.rb b/spec/lib/gitlab/import_export/relation_tree_restorer_spec.rb index edb2c0a131a..80901feb893 100644 --- a/spec/lib/gitlab/import_export/relation_tree_restorer_spec.rb +++ b/spec/lib/gitlab/import_export/relation_tree_restorer_spec.rb @@ -39,8 +39,8 @@ describe Gitlab::ImportExport::RelationTreeRestorer do context 'when restoring a project' do let(:path) { 'spec/fixtures/lib/gitlab/import_export/complex/project.json' } let(:importable) { create(:project, :builds_enabled, :issues_disabled, name: 'project', path: 'project') } - let(:object_builder) { Gitlab::ImportExport::GroupProjectObjectBuilder } - let(:relation_factory) { Gitlab::ImportExport::ProjectRelationFactory } + let(:object_builder) { Gitlab::ImportExport::Project::ObjectBuilder } + let(:relation_factory) { Gitlab::ImportExport::Project::RelationFactory } let(:reader) { Gitlab::ImportExport::Reader.new(shared: shared) } let(:tree_hash) { importable_hash } |