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

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

53 lines
1.5 KiB
Ruby
Raw Normal View History

2019-12-21 20:55:43 +05:30
# frozen_string_literal: true
2019-12-04 20:38:33 +05:30
require 'spec_helper'
2016-06-02 11:05:42 +05:30
2020-07-28 23:09:34 +05:30
RSpec.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-07-07 11:18:12 +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-07-07 11:18:12 +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