2019-04-11 11:26:16 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
require 'spec_helper'
|
|
|
|
|
2020-06-03 23:08:05 -04:00
|
|
|
RSpec.describe ImportUrlParams do
|
2019-04-11 11:26:16 -04:00
|
|
|
let(:import_url_params) do
|
|
|
|
controller = OpenStruct.new(params: params).extend(described_class)
|
|
|
|
controller.import_url_params
|
|
|
|
end
|
|
|
|
|
2019-06-03 18:04:59 -04:00
|
|
|
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
|
|
|
|
|
2019-04-11 11:26:16 -04:00
|
|
|
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-03-19 20:09:29 -04:00
|
|
|
import_url: "https://user:password@url.com",
|
|
|
|
import_type: 'git'
|
2019-04-11 11:26:16 -04:00
|
|
|
)
|
|
|
|
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-03-19 20:09:29 -04:00
|
|
|
import_url: "https://user:password@url.com",
|
|
|
|
import_type: 'git'
|
2019-04-11 11:26:16 -04:00
|
|
|
)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|