Commit b56e4038 authored by Tiago Botelho's avatar Tiago Botelho

Removes irrelevant unit tests for remote mirror and mirrors with the same URL

parent a5accabe
......@@ -63,7 +63,8 @@ module EE
end
def valid_mirror_user?(mirror_params)
return true unless mirror_params[:mirror_user_id].present?
return true unless mirror_params[:mirror]
return false unless mirror_params[:mirror_user_id].present?
default_mirror_users.map(&:id).include?(mirror_params[:mirror_user_id].to_i)
end
......
......@@ -19,22 +19,6 @@ describe Projects::MirrorsController do
do_put(project, remote_mirrors_attributes: { '0' => { 'enabled' => 1, 'url' => url } })
end.to change { RemoteMirror.count }.to(1)
end
context 'when remote mirror has the same URL' do
it 'does not allow to create the remote mirror' do
expect do
do_put(project, remote_mirrors_attributes: { '0' => { 'enabled' => 1, 'url' => project.import_url } })
end.not_to change { RemoteMirror.count }
end
context 'with disabled local mirror' do
it 'allows to create a remote mirror' do
expect do
do_put(project, mirror: 0, remote_mirrors_attributes: { '0' => { 'enabled' => 1, 'url' => project.import_url } })
end.to change { RemoteMirror.count }.to(1)
end
end
end
end
context 'when the current project has a remote mirror' do
......@@ -55,8 +39,6 @@ describe Projects::MirrorsController do
context 'when trying to create a mirror with a different URL' do
it 'should setup the mirror' do
expect_any_instance_of(EE::Project).to receive(:force_import_job!)
do_put(project, mirror: true, mirror_user_id: project.owner.id, import_url: 'http://local.dev')
expect(project.reload.mirror).to eq(true)
......@@ -65,8 +47,6 @@ describe Projects::MirrorsController do
context 'mirror user is not the current user' do
it 'should only assign the current user' do
expect_any_instance_of(EE::Project).to receive(:force_import_job!)
new_user = create(:user)
project.add_maintainer(new_user)
......@@ -94,7 +74,6 @@ describe Projects::MirrorsController do
it 'creates a new mirror' do
sign_in(admin)
expect_any_instance_of(EE::Project).to receive(:force_import_job!)
expect do
do_put(project, mirror: true, mirror_user_id: admin.id, import_url: url)
......@@ -120,8 +99,6 @@ describe Projects::MirrorsController do
context 'when project does not have a mirror' do
it 'allows to create a mirror' do
expect_any_instance_of(EE::Project).to receive(:force_import_job!)
expect do
do_put(project, mirror: true, mirror_user_id: project.owner.id, import_url: url)
end.to change { Project.mirror.count }.to(1)
......
......@@ -144,8 +144,6 @@ describe ProjectsController do
end
it 'updates repository mirror attributes' do
expect_any_instance_of(EE::Project).to receive(:force_import_job!)
put :update,
namespace_id: project.namespace,
id: project,
......
......@@ -31,6 +31,12 @@ describe Projects::UpdateService, '#execute' do
expect(updated_project.mirror_user_id).to eq(user.id)
expect(updated_project.mirror_trigger_builds).to be true
end
it 'forces an import job' do
expect(project).to receive(:force_import_job!).once
update_project(project, user, opts)
end
end
context 'when unlicensed' do
......@@ -47,6 +53,12 @@ describe Projects::UpdateService, '#execute' do
expect(updated_project.mirror_user_id).to be_nil
expect(updated_project.mirror_trigger_builds).to be false
end
it 'does not force an import job' do
expect(project).not_to receive(:force_import_job!)
update_project(project, user, opts)
end
end
end
......
......@@ -140,7 +140,7 @@ module API
post do
attrs = declared_params(include_missing: false)
attrs = translate_params_for_compatibility(attrs)
attrs[:mirror_user_id] = current_user.id if attrs[:import_url].present?
attrs[:mirror_user_id] = current_user.id if attrs[:mirror]
project = ::Projects::CreateService.new(current_user, attrs).execute
......@@ -174,7 +174,7 @@ module API
attrs = declared_params(include_missing: false)
attrs = translate_params_for_compatibility(attrs)
attrs[:mirror_user_id] = user.id if attrs[:import_url].present?
attrs[:mirror_user_id] = user.id if attrs[:mirror]
project = ::Projects::CreateService.new(user, attrs).execute
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment