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

63 lines
2 KiB
Ruby
Raw Permalink Normal View History

2016-06-02 11:05:42 +05:30
require 'rails_helper'
describe ImportHelper do
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
2017-08-17 22:00:37 +05:30
describe '#provider_project_link' do
context 'when provider is "github"' do
context 'when provider does not specify a custom URL' do
it 'uses default GitHub URL' do
2017-09-10 17:25:29 +05:30
allow(Gitlab.config.omniauth).to receive(:providers)
.and_return([Settingslogic.new('name' => 'github')])
2016-06-02 11:05:42 +05:30
2017-09-10 17:25:29 +05:30
expect(helper.provider_project_link('github', 'octocat/Hello-World'))
.to include('href="https://github.com/octocat/Hello-World"')
2017-08-17 22:00:37 +05:30
end
2016-06-02 11:05:42 +05:30
end
2017-08-17 22:00:37 +05:30
context 'when provider specify a custom URL' do
it 'uses custom URL' do
2017-09-10 17:25:29 +05:30
allow(Gitlab.config.omniauth).to receive(:providers)
.and_return([Settingslogic.new('name' => 'github', 'url' => 'https://github.company.com')])
2016-06-02 11:05:42 +05:30
2017-09-10 17:25:29 +05:30
expect(helper.provider_project_link('github', 'octocat/Hello-World'))
.to include('href="https://github.company.com/octocat/Hello-World"')
2017-08-17 22:00:37 +05:30
end
end
end
context 'when provider is "gitea"' do
before do
assign(:gitea_host_url, 'https://try.gitea.io/')
end
it 'uses given host' do
2017-09-10 17:25:29 +05:30
expect(helper.provider_project_link('gitea', 'octocat/Hello-World'))
.to include('href="https://try.gitea.io/octocat/Hello-World"')
2016-06-02 11:05:42 +05:30
end
end
end
end