diff options
Diffstat (limited to 'spec/services/projects/update_remote_mirror_service_spec.rb')
-rw-r--r-- | spec/services/projects/update_remote_mirror_service_spec.rb | 71 |
1 files changed, 20 insertions, 51 deletions
diff --git a/spec/services/projects/update_remote_mirror_service_spec.rb b/spec/services/projects/update_remote_mirror_service_spec.rb index 1de04888e0a..30530da8013 100644 --- a/spec/services/projects/update_remote_mirror_service_spec.rb +++ b/spec/services/projects/update_remote_mirror_service_spec.rb @@ -68,25 +68,12 @@ RSpec.describe Projects::UpdateRemoteMirrorService do end context "when given URLs containing escaped elements" do - using RSpec::Parameterized::TableSyntax + it_behaves_like "URLs containing escaped elements return expected status" do + let(:result) { execute! } - where(:url, :result_status) do - "https://user:0a%23@test.example.com/project.git" | :success - "https://git.example.com:1%2F%2F@source.developers.google.com/project.git" | :success - CGI.escape("git://localhost:1234/some-path?some-query=some-val\#@example.com/") | :error - CGI.escape(CGI.escape("https://user:0a%23@test.example.com/project.git")) | :error - end - - with_them do before do allow(remote_mirror).to receive(:url).and_return(url) end - - it "returns expected status" do - result = execute! - - expect(result[:status]).to eq(result_status) - end end end @@ -136,54 +123,36 @@ RSpec.describe Projects::UpdateRemoteMirrorService do stub_lfs_setting(enabled: true) end - context 'feature flag enabled' do - before do - stub_feature_flags(push_mirror_syncs_lfs: true) - end - - it 'pushes LFS objects to a HTTP repository' do - expect_next_instance_of(Lfs::PushService) do |service| - expect(service).to receive(:execute) - end - - execute! + it 'pushes LFS objects to a HTTP repository' do + expect_next_instance_of(Lfs::PushService) do |service| + expect(service).to receive(:execute) end - it 'does nothing to an SSH repository' do - remote_mirror.update!(url: 'ssh://example.com') - - expect_any_instance_of(Lfs::PushService).not_to receive(:execute) - - execute! - end + execute! + end - it 'does nothing if LFS is disabled' do - expect(project).to receive(:lfs_enabled?) { false } + it 'does nothing to an SSH repository' do + remote_mirror.update!(url: 'ssh://example.com') - expect_any_instance_of(Lfs::PushService).not_to receive(:execute) + expect_any_instance_of(Lfs::PushService).not_to receive(:execute) - execute! - end + execute! + end - it 'does nothing if non-password auth is specified' do - remote_mirror.update!(auth_method: 'ssh_public_key') + it 'does nothing if LFS is disabled' do + expect(project).to receive(:lfs_enabled?) { false } - expect_any_instance_of(Lfs::PushService).not_to receive(:execute) + expect_any_instance_of(Lfs::PushService).not_to receive(:execute) - execute! - end + execute! end - context 'feature flag disabled' do - before do - stub_feature_flags(push_mirror_syncs_lfs: false) - end + it 'does nothing if non-password auth is specified' do + remote_mirror.update!(auth_method: 'ssh_public_key') - it 'does nothing' do - expect_any_instance_of(Lfs::PushService).not_to receive(:execute) + expect_any_instance_of(Lfs::PushService).not_to receive(:execute) - execute! - end + execute! end end end |