debian-mirror-gitlab/spec/controllers/concerns/import_url_params_spec.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

77 lines
1.9 KiB
Ruby
Raw Normal View History

2019-07-31 22:56:46 +05:30
# frozen_string_literal: true
require 'spec_helper'
2020-06-23 00:09:42 +05:30
RSpec.describe ImportUrlParams do
2019-07-31 22:56:46 +05:30
let(:import_url_params) do
2021-12-11 22:18:48 +05:30
controller = double('controller', params: params).extend(described_class)
2019-07-31 22:56:46 +05:30
controller.import_url_params
end
context 'empty URL' do
let(:params) do
ActionController::Parameters.new(project: {
title: 'Test'
})
end
it 'returns empty hash' do
expect(import_url_params).to eq({})
end
end
context 'url and password separately provided' do
let(:params) do
ActionController::Parameters.new(project: {
import_url: 'https://url.com',
import_url_user: 'user', import_url_password: 'password'
})
end
describe '#import_url_params' do
it 'returns hash with import_url' do
expect(import_url_params).to eq(
2020-04-08 14:13:33 +05:30
import_url: "https://user:password@url.com",
import_type: 'git'
2019-07-31 22:56:46 +05:30
)
end
end
end
context 'url with provided empty credentials' do
let(:params) do
ActionController::Parameters.new(project: {
import_url: 'https://user:password@url.com',
import_url_user: '', import_url_password: ''
})
end
describe '#import_url_params' do
it 'does not change the url' do
expect(import_url_params).to eq(
2020-04-08 14:13:33 +05:30
import_url: "https://user:password@url.com",
import_type: 'git'
2019-07-31 22:56:46 +05:30
)
end
end
end
2022-06-21 17:19:12 +05:30
context 'url with provided mixed credentials' do
let(:params) do
ActionController::Parameters.new(project: {
import_url: 'https://user@url.com',
import_url_user: '', import_url_password: 'password'
})
end
describe '#import_url_params' do
it 'returns import_url built from both url and hash credentials' do
expect(import_url_params).to eq(
import_url: 'https://user:password@url.com',
import_type: 'git'
)
end
end
end
2019-07-31 22:56:46 +05:30
end