2016-06-24 01:26:33 -04:00
|
|
|
require 'spec_helper'
|
2016-01-18 06:35:30 -05:00
|
|
|
require_relative '../../config/initializers/1_settings'
|
|
|
|
|
2017-07-10 10:24:02 -04:00
|
|
|
describe Settings do
|
2017-05-17 12:17:15 -04:00
|
|
|
describe '#repositories' do
|
|
|
|
it 'assigns the default failure attributes' do
|
|
|
|
repository_settings = Gitlab.config.repositories.storages['broken']
|
|
|
|
|
|
|
|
expect(repository_settings['failure_count_threshold']).to eq(10)
|
|
|
|
expect(repository_settings['failure_wait_time']).to eq(30)
|
|
|
|
expect(repository_settings['failure_reset_time']).to eq(1800)
|
|
|
|
expect(repository_settings['storage_timeout']).to eq(5)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2016-01-18 06:35:30 -05:00
|
|
|
describe '#host_without_www' do
|
|
|
|
context 'URL with protocol' do
|
|
|
|
it 'returns the host' do
|
2017-07-25 13:09:00 -04:00
|
|
|
expect(described_class.host_without_www('http://foo.com')).to eq 'foo.com'
|
|
|
|
expect(described_class.host_without_www('http://www.foo.com')).to eq 'foo.com'
|
|
|
|
expect(described_class.host_without_www('http://secure.foo.com')).to eq 'secure.foo.com'
|
|
|
|
expect(described_class.host_without_www('http://www.gravatar.com/avatar/%{hash}?s=%{size}&d=identicon')).to eq 'gravatar.com'
|
2016-01-18 06:35:30 -05:00
|
|
|
|
2017-07-25 13:09:00 -04:00
|
|
|
expect(described_class.host_without_www('https://foo.com')).to eq 'foo.com'
|
|
|
|
expect(described_class.host_without_www('https://www.foo.com')).to eq 'foo.com'
|
|
|
|
expect(described_class.host_without_www('https://secure.foo.com')).to eq 'secure.foo.com'
|
|
|
|
expect(described_class.host_without_www('https://secure.gravatar.com/avatar/%{hash}?s=%{size}&d=identicon')).to eq 'secure.gravatar.com'
|
2016-01-18 06:35:30 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'URL without protocol' do
|
|
|
|
it 'returns the host' do
|
2017-07-25 13:09:00 -04:00
|
|
|
expect(described_class.host_without_www('foo.com')).to eq 'foo.com'
|
|
|
|
expect(described_class.host_without_www('www.foo.com')).to eq 'foo.com'
|
|
|
|
expect(described_class.host_without_www('secure.foo.com')).to eq 'secure.foo.com'
|
|
|
|
expect(described_class.host_without_www('www.gravatar.com/avatar/%{hash}?s=%{size}&d=identicon')).to eq 'gravatar.com'
|
2016-01-18 06:35:30 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
context 'URL with user/port' do
|
|
|
|
it 'returns the host' do
|
2017-07-25 13:09:00 -04:00
|
|
|
expect(described_class.host_without_www('bob:pass@foo.com:8080')).to eq 'foo.com'
|
|
|
|
expect(described_class.host_without_www('bob:pass@www.foo.com:8080')).to eq 'foo.com'
|
|
|
|
expect(described_class.host_without_www('bob:pass@secure.foo.com:8080')).to eq 'secure.foo.com'
|
|
|
|
expect(described_class.host_without_www('bob:pass@www.gravatar.com:8080/avatar/%{hash}?s=%{size}&d=identicon')).to eq 'gravatar.com'
|
2016-01-18 06:35:30 -05:00
|
|
|
|
2017-07-25 13:09:00 -04:00
|
|
|
expect(described_class.host_without_www('http://bob:pass@foo.com:8080')).to eq 'foo.com'
|
|
|
|
expect(described_class.host_without_www('http://bob:pass@www.foo.com:8080')).to eq 'foo.com'
|
|
|
|
expect(described_class.host_without_www('http://bob:pass@secure.foo.com:8080')).to eq 'secure.foo.com'
|
|
|
|
expect(described_class.host_without_www('http://bob:pass@www.gravatar.com:8080/avatar/%{hash}?s=%{size}&d=identicon')).to eq 'gravatar.com'
|
2016-01-18 06:35:30 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|