debian-mirror-gitlab/spec/helpers/import_helper_spec.rb

51 lines
1.4 KiB
Ruby
Raw Normal View History

2016-06-02 11:05:42 +05:30
require 'rails_helper'
describe ImportHelper do
2018-11-20 20:47:30 +05:30
describe '#sanitize_project_name' do
2019-03-02 22:35:43 +05:30
it 'removes leading tildes' do
expect(helper.sanitize_project_name('~~root')).to eq('root')
end
2018-11-20 20:47:30 +05:30
it 'removes whitespace' do
expect(helper.sanitize_project_name('my test repo')).to eq('my-test-repo')
end
it 'removes disallowed characters' do
expect(helper.sanitize_project_name('Test&me$over*h_ere')).to eq('Test-me-over-h_ere')
end
end
2016-09-29 09:46:39 +05:30
describe '#import_project_target' do
let(:user) { create(:user) }
before do
allow(helper).to receive(:current_user).and_return(user)
end
context 'when current user can create namespaces' do
it 'returns project namespace' do
user.update_attribute(:can_create_group, true)
expect(helper.import_project_target('asd', 'vim')).to eq 'asd/vim'
end
end
context 'when current user can not create namespaces' do
it "takes the current user's namespace" do
user.update_attribute(:can_create_group, false)
expect(helper.import_project_target('asd', 'vim')).to eq "#{user.namespace_path}/vim"
end
end
end
2019-05-18 00:54:41 +05:30
describe '#provider_project_link_url' do
let(:full_path) { '/repo/path' }
let(:host_url) { 'http://provider.com/' }
2018-05-09 12:01:36 +05:30
2019-05-18 00:54:41 +05:30
it 'appends repo full path to provider host url' do
expect(helper.provider_project_link_url(host_url, full_path)).to match('http://provider.com/repo/path')
2016-06-02 11:05:42 +05:30
end
end
end