2019-09-30 08:06:01 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2014-02-03 21:35:48 -05:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2020-06-24 05:08:32 -04:00
|
|
|
RSpec.describe SubmoduleHelper do
|
2015-04-10 01:07:32 -04:00
|
|
|
include RepoHelpers
|
|
|
|
|
2019-07-22 08:25:56 -04:00
|
|
|
let(:submodule_item) { double(id: 'hash', path: 'rack') }
|
|
|
|
let(:config) { Gitlab.config.gitlab }
|
|
|
|
let(:repo) { double }
|
2020-01-20 16:08:46 -05:00
|
|
|
let(:submodules) { Gitlab::SubmoduleLinks.new(repo) }
|
|
|
|
|
|
|
|
before do
|
|
|
|
allow(repo).to receive(:submodule_links).and_return(submodules)
|
|
|
|
end
|
2014-02-03 21:35:48 -05:00
|
|
|
|
2019-07-22 08:25:56 -04:00
|
|
|
shared_examples 'submodule_links' do
|
2014-02-03 21:35:48 -05:00
|
|
|
context 'submodule on self' do
|
|
|
|
before do
|
2015-05-21 17:49:06 -04:00
|
|
|
allow(Gitlab.config.gitlab).to receive(:protocol).and_return('http') # set this just to be sure
|
2014-02-03 21:35:48 -05:00
|
|
|
end
|
|
|
|
|
2016-07-25 14:16:19 -04:00
|
|
|
it 'detects ssh on standard port' do
|
2015-05-21 17:49:06 -04:00
|
|
|
allow(Gitlab.config.gitlab_shell).to receive(:ssh_port).and_return(22) # set this just to be sure
|
|
|
|
allow(Gitlab.config.gitlab_shell).to receive(:ssh_path_prefix).and_return(Settings.send(:build_gitlab_shell_ssh_path_prefix))
|
2020-03-10 08:08:16 -04:00
|
|
|
stub_url([config.ssh_user, '@', config.host, ':gitlab-org/gitlab-foss.git'].join(''))
|
|
|
|
expect(subject).to eq([namespace_project_path('gitlab-org', 'gitlab-foss'), namespace_project_tree_path('gitlab-org', 'gitlab-foss', 'hash')])
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'detects ssh on standard port without a username' do
|
|
|
|
allow(Gitlab.config.gitlab_shell).to receive(:ssh_port).and_return(22) # set this just to be sure
|
|
|
|
allow(Gitlab.config.gitlab_shell).to receive(:ssh_user).and_return('')
|
|
|
|
allow(Gitlab.config.gitlab_shell).to receive(:ssh_path_prefix).and_return(Settings.send(:build_gitlab_shell_ssh_path_prefix))
|
|
|
|
stub_url([config.host, ':gitlab-org/gitlab-foss.git'].join(''))
|
2019-09-18 10:02:45 -04:00
|
|
|
expect(subject).to eq([namespace_project_path('gitlab-org', 'gitlab-foss'), namespace_project_tree_path('gitlab-org', 'gitlab-foss', 'hash')])
|
2014-02-03 21:35:48 -05:00
|
|
|
end
|
2014-02-10 06:02:26 -05:00
|
|
|
|
2016-07-25 14:16:19 -04:00
|
|
|
it 'detects ssh on non-standard port' do
|
2015-05-21 17:49:06 -04:00
|
|
|
allow(Gitlab.config.gitlab_shell).to receive(:ssh_port).and_return(2222)
|
|
|
|
allow(Gitlab.config.gitlab_shell).to receive(:ssh_path_prefix).and_return(Settings.send(:build_gitlab_shell_ssh_path_prefix))
|
2020-03-10 08:08:16 -04:00
|
|
|
stub_url(['ssh://', config.ssh_user, '@', config.host, ':2222/gitlab-org/gitlab-foss.git'].join(''))
|
|
|
|
expect(subject).to eq([namespace_project_path('gitlab-org', 'gitlab-foss'), namespace_project_tree_path('gitlab-org', 'gitlab-foss', 'hash')])
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'detects ssh on non-standard port without a username' do
|
|
|
|
allow(Gitlab.config.gitlab_shell).to receive(:ssh_port).and_return(2222)
|
|
|
|
allow(Gitlab.config.gitlab_shell).to receive(:ssh_user).and_return('')
|
|
|
|
allow(Gitlab.config.gitlab_shell).to receive(:ssh_path_prefix).and_return(Settings.send(:build_gitlab_shell_ssh_path_prefix))
|
|
|
|
stub_url(['ssh://', config.host, ':2222/gitlab-org/gitlab-foss.git'].join(''))
|
2019-09-18 10:02:45 -04:00
|
|
|
expect(subject).to eq([namespace_project_path('gitlab-org', 'gitlab-foss'), namespace_project_tree_path('gitlab-org', 'gitlab-foss', 'hash')])
|
2014-02-03 21:35:48 -05:00
|
|
|
end
|
|
|
|
|
2016-07-25 14:16:19 -04:00
|
|
|
it 'detects http on standard port' do
|
2015-05-21 17:49:06 -04:00
|
|
|
allow(Gitlab.config.gitlab).to receive(:port).and_return(80)
|
|
|
|
allow(Gitlab.config.gitlab).to receive(:url).and_return(Settings.send(:build_gitlab_url))
|
2019-09-18 10:02:45 -04:00
|
|
|
stub_url(['http://', config.host, '/gitlab-org/gitlab-foss.git'].join(''))
|
|
|
|
expect(subject).to eq([namespace_project_path('gitlab-org', 'gitlab-foss'), namespace_project_tree_path('gitlab-org', 'gitlab-foss', 'hash')])
|
2014-02-03 21:35:48 -05:00
|
|
|
end
|
|
|
|
|
2016-07-25 14:16:19 -04:00
|
|
|
it 'detects http on non-standard port' do
|
2015-05-21 17:49:06 -04:00
|
|
|
allow(Gitlab.config.gitlab).to receive(:port).and_return(3000)
|
|
|
|
allow(Gitlab.config.gitlab).to receive(:url).and_return(Settings.send(:build_gitlab_url))
|
2019-09-18 10:02:45 -04:00
|
|
|
stub_url(['http://', config.host, ':3000/gitlab-org/gitlab-foss.git'].join(''))
|
|
|
|
expect(subject).to eq([namespace_project_path('gitlab-org', 'gitlab-foss'), namespace_project_tree_path('gitlab-org', 'gitlab-foss', 'hash')])
|
2014-02-03 21:35:48 -05:00
|
|
|
end
|
|
|
|
|
2016-07-25 14:16:19 -04:00
|
|
|
it 'works with relative_url_root' do
|
2015-05-21 17:49:06 -04:00
|
|
|
allow(Gitlab.config.gitlab).to receive(:port).and_return(80) # set this just to be sure
|
|
|
|
allow(Gitlab.config.gitlab).to receive(:relative_url_root).and_return('/gitlab/root')
|
|
|
|
allow(Gitlab.config.gitlab).to receive(:url).and_return(Settings.send(:build_gitlab_url))
|
2019-09-18 10:02:45 -04:00
|
|
|
stub_url(['http://', config.host, '/gitlab/root/gitlab-org/gitlab-foss.git'].join(''))
|
|
|
|
expect(subject).to eq([namespace_project_path('gitlab-org', 'gitlab-foss'), namespace_project_tree_path('gitlab-org', 'gitlab-foss', 'hash')])
|
2014-02-03 21:35:48 -05:00
|
|
|
end
|
2017-06-05 02:26:20 -04:00
|
|
|
|
|
|
|
it 'works with subgroups' do
|
|
|
|
allow(Gitlab.config.gitlab).to receive(:port).and_return(80) # set this just to be sure
|
|
|
|
allow(Gitlab.config.gitlab).to receive(:relative_url_root).and_return('/gitlab/root')
|
|
|
|
allow(Gitlab.config.gitlab).to receive(:url).and_return(Settings.send(:build_gitlab_url))
|
2019-09-18 10:02:45 -04:00
|
|
|
stub_url(['http://', config.host, '/gitlab/root/gitlab-org/sub/gitlab-foss.git'].join(''))
|
|
|
|
expect(subject).to eq([namespace_project_path('gitlab-org/sub', 'gitlab-foss'), namespace_project_tree_path('gitlab-org/sub', 'gitlab-foss', 'hash')])
|
2017-06-05 02:26:20 -04:00
|
|
|
end
|
2014-02-03 21:35:48 -05:00
|
|
|
end
|
2014-02-10 06:02:26 -05:00
|
|
|
|
2020-03-16 17:09:21 -04:00
|
|
|
context 'submodule on gist.github.com' do
|
|
|
|
it 'detects ssh' do
|
|
|
|
stub_url('git@gist.github.com:gitlab-org/gitlab-foss.git')
|
|
|
|
is_expected.to eq(['https://gist.github.com/gitlab-org/gitlab-foss', 'https://gist.github.com/gitlab-org/gitlab-foss/hash'])
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'detects http' do
|
|
|
|
stub_url('http://gist.github.com/gitlab-org/gitlab-foss.git')
|
|
|
|
is_expected.to eq(['https://gist.github.com/gitlab-org/gitlab-foss', 'https://gist.github.com/gitlab-org/gitlab-foss/hash'])
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'detects https' do
|
|
|
|
stub_url('https://gist.github.com/gitlab-org/gitlab-foss.git')
|
|
|
|
is_expected.to eq(['https://gist.github.com/gitlab-org/gitlab-foss', 'https://gist.github.com/gitlab-org/gitlab-foss/hash'])
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'handles urls with no .git on the end' do
|
|
|
|
stub_url('http://gist.github.com/gitlab-org/gitlab-foss')
|
|
|
|
is_expected.to eq(['https://gist.github.com/gitlab-org/gitlab-foss', 'https://gist.github.com/gitlab-org/gitlab-foss/hash'])
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'returns original with non-standard url' do
|
|
|
|
stub_url('http://gist.github.com/another/gitlab-org/gitlab-foss.git')
|
|
|
|
is_expected.to eq([repo.submodule_url_for, nil])
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2014-02-03 21:35:48 -05:00
|
|
|
context 'submodule on github.com' do
|
2016-07-25 14:16:19 -04:00
|
|
|
it 'detects ssh' do
|
2019-09-18 10:02:45 -04:00
|
|
|
stub_url('git@github.com:gitlab-org/gitlab-foss.git')
|
|
|
|
expect(subject).to eq(['https://github.com/gitlab-org/gitlab-foss', 'https://github.com/gitlab-org/gitlab-foss/tree/hash'])
|
2014-02-03 21:35:48 -05:00
|
|
|
end
|
2014-02-10 06:02:26 -05:00
|
|
|
|
2016-07-25 14:16:19 -04:00
|
|
|
it 'detects http' do
|
2019-09-18 10:02:45 -04:00
|
|
|
stub_url('http://github.com/gitlab-org/gitlab-foss.git')
|
|
|
|
expect(subject).to eq(['https://github.com/gitlab-org/gitlab-foss', 'https://github.com/gitlab-org/gitlab-foss/tree/hash'])
|
2014-02-03 21:35:48 -05:00
|
|
|
end
|
2014-02-10 06:02:26 -05:00
|
|
|
|
2016-07-25 14:16:19 -04:00
|
|
|
it 'detects https' do
|
2019-09-18 10:02:45 -04:00
|
|
|
stub_url('https://github.com/gitlab-org/gitlab-foss.git')
|
|
|
|
expect(subject).to eq(['https://github.com/gitlab-org/gitlab-foss', 'https://github.com/gitlab-org/gitlab-foss/tree/hash'])
|
2014-02-03 21:35:48 -05:00
|
|
|
end
|
2014-02-10 06:02:26 -05:00
|
|
|
|
2017-04-18 01:44:16 -04:00
|
|
|
it 'handles urls with no .git on the end' do
|
2019-09-18 10:02:45 -04:00
|
|
|
stub_url('http://github.com/gitlab-org/gitlab-foss')
|
|
|
|
expect(subject).to eq(['https://github.com/gitlab-org/gitlab-foss', 'https://github.com/gitlab-org/gitlab-foss/tree/hash'])
|
2017-04-18 01:44:16 -04:00
|
|
|
end
|
2014-02-03 21:35:48 -05:00
|
|
|
|
2017-04-18 01:44:16 -04:00
|
|
|
it 'returns original with non-standard url' do
|
2019-09-18 10:02:45 -04:00
|
|
|
stub_url('http://github.com/another/gitlab-org/gitlab-foss.git')
|
2019-07-22 08:25:56 -04:00
|
|
|
expect(subject).to eq([repo.submodule_url_for, nil])
|
2014-02-03 21:35:48 -05:00
|
|
|
end
|
|
|
|
end
|
2014-02-10 06:02:26 -05:00
|
|
|
|
2017-04-18 01:44:32 -04:00
|
|
|
context 'in-repository submodule' do
|
|
|
|
let(:group) { create(:group, name: "Master Project", path: "master-project") }
|
2017-08-02 15:55:11 -04:00
|
|
|
let(:project) { create(:project, group: group) }
|
2017-04-18 01:44:32 -04:00
|
|
|
|
|
|
|
it 'in-repository' do
|
2018-07-13 13:04:29 -04:00
|
|
|
allow(repo).to receive(:project).and_return(project)
|
|
|
|
|
2017-04-18 01:44:32 -04:00
|
|
|
stub_url('./')
|
2020-01-27 07:08:35 -05:00
|
|
|
expect(subject).to eq(["/master-project/#{project.path}", "/master-project/#{project.path}/-/tree/hash"])
|
2017-04-18 01:44:32 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2014-02-03 21:35:48 -05:00
|
|
|
context 'submodule on gitlab.com' do
|
2016-07-25 14:16:19 -04:00
|
|
|
it 'detects ssh' do
|
2019-09-18 10:02:45 -04:00
|
|
|
stub_url('git@gitlab.com:gitlab-org/gitlab-foss.git')
|
2020-01-27 07:08:35 -05:00
|
|
|
expect(subject).to eq(['https://gitlab.com/gitlab-org/gitlab-foss', 'https://gitlab.com/gitlab-org/gitlab-foss/-/tree/hash'])
|
2014-02-03 21:35:48 -05:00
|
|
|
end
|
2014-02-10 06:02:26 -05:00
|
|
|
|
2016-07-25 14:16:19 -04:00
|
|
|
it 'detects http' do
|
2019-09-18 10:02:45 -04:00
|
|
|
stub_url('http://gitlab.com/gitlab-org/gitlab-foss.git')
|
2020-01-27 07:08:35 -05:00
|
|
|
expect(subject).to eq(['https://gitlab.com/gitlab-org/gitlab-foss', 'https://gitlab.com/gitlab-org/gitlab-foss/-/tree/hash'])
|
2014-02-03 21:35:48 -05:00
|
|
|
end
|
2014-02-10 06:02:26 -05:00
|
|
|
|
2016-07-25 14:16:19 -04:00
|
|
|
it 'detects https' do
|
2019-09-18 10:02:45 -04:00
|
|
|
stub_url('https://gitlab.com/gitlab-org/gitlab-foss.git')
|
2020-01-27 07:08:35 -05:00
|
|
|
expect(subject).to eq(['https://gitlab.com/gitlab-org/gitlab-foss', 'https://gitlab.com/gitlab-org/gitlab-foss/-/tree/hash'])
|
2014-02-03 21:35:48 -05:00
|
|
|
end
|
2014-02-10 06:02:26 -05:00
|
|
|
|
2017-04-18 01:44:16 -04:00
|
|
|
it 'handles urls with no .git on the end' do
|
2019-09-18 10:02:45 -04:00
|
|
|
stub_url('http://gitlab.com/gitlab-org/gitlab-foss')
|
2020-01-27 07:08:35 -05:00
|
|
|
expect(subject).to eq(['https://gitlab.com/gitlab-org/gitlab-foss', 'https://gitlab.com/gitlab-org/gitlab-foss/-/tree/hash'])
|
2017-04-18 01:44:16 -04:00
|
|
|
end
|
2014-02-03 21:35:48 -05:00
|
|
|
|
2017-05-28 17:18:18 -04:00
|
|
|
it 'handles urls with trailing whitespace' do
|
2019-09-18 10:02:45 -04:00
|
|
|
stub_url('http://gitlab.com/gitlab-org/gitlab-foss.git ')
|
2020-01-27 07:08:35 -05:00
|
|
|
expect(subject).to eq(['https://gitlab.com/gitlab-org/gitlab-foss', 'https://gitlab.com/gitlab-org/gitlab-foss/-/tree/hash'])
|
2017-05-28 17:18:18 -04:00
|
|
|
end
|
|
|
|
|
2017-04-18 01:44:16 -04:00
|
|
|
it 'returns original with non-standard url' do
|
2019-09-18 10:02:45 -04:00
|
|
|
stub_url('http://gitlab.com/another/gitlab-org/gitlab-foss.git')
|
2019-07-22 08:25:56 -04:00
|
|
|
expect(subject).to eq([repo.submodule_url_for, nil])
|
2014-02-03 21:35:48 -05:00
|
|
|
end
|
|
|
|
end
|
2014-02-10 06:02:26 -05:00
|
|
|
|
2014-02-03 21:35:48 -05:00
|
|
|
context 'submodule on unsupported' do
|
2017-04-10 12:55:31 -04:00
|
|
|
it 'sanitizes unsupported protocols' do
|
|
|
|
stub_url('javascript:alert("XSS");')
|
|
|
|
|
2019-07-22 08:25:56 -04:00
|
|
|
expect(subject).to eq([nil, nil])
|
2017-04-10 12:55:31 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'sanitizes unsupported protocols disguised as a repository URL' do
|
|
|
|
stub_url('javascript:alert("XSS");foo/bar.git')
|
|
|
|
|
2019-07-22 08:25:56 -04:00
|
|
|
expect(subject).to eq([nil, nil])
|
2017-04-10 12:55:31 -04:00
|
|
|
end
|
|
|
|
|
2017-09-15 10:28:41 -04:00
|
|
|
it 'sanitizes invalid URL with extended ASCII' do
|
|
|
|
stub_url('é')
|
|
|
|
|
2019-07-22 08:25:56 -04:00
|
|
|
expect(subject).to eq([nil, nil])
|
2017-09-15 10:28:41 -04:00
|
|
|
end
|
|
|
|
|
2016-07-25 14:16:19 -04:00
|
|
|
it 'returns original' do
|
2019-09-18 10:02:45 -04:00
|
|
|
stub_url('http://mygitserver.com/gitlab-org/gitlab-foss')
|
2014-02-03 21:35:48 -05:00
|
|
|
|
2019-07-22 08:25:56 -04:00
|
|
|
expect(subject).to eq([repo.submodule_url_for, nil])
|
2014-02-03 21:35:48 -05:00
|
|
|
end
|
|
|
|
end
|
2015-04-10 01:07:32 -04:00
|
|
|
|
|
|
|
context 'submodules with relative links' do
|
2018-08-13 00:01:59 -04:00
|
|
|
let(:group) { create(:group, name: "top group", path: "top-group") }
|
2017-08-02 15:55:11 -04:00
|
|
|
let(:project) { create(:project, group: group) }
|
2018-08-13 00:01:59 -04:00
|
|
|
let(:repo) { double(:repo, project: project) }
|
|
|
|
|
|
|
|
def expect_relative_link_to_resolve_to(relative_path, expected_path)
|
2020-01-20 16:08:46 -05:00
|
|
|
stub_url(relative_path)
|
2019-07-22 08:25:56 -04:00
|
|
|
result = subject
|
2018-08-13 00:01:59 -04:00
|
|
|
|
2020-01-27 07:08:35 -05:00
|
|
|
expect(result).to eq([expected_path, "#{expected_path}/-/tree/#{submodule_item.id}"])
|
2018-08-13 00:01:59 -04:00
|
|
|
end
|
2015-04-10 01:07:32 -04:00
|
|
|
|
2018-08-13 00:01:59 -04:00
|
|
|
it 'handles project under same group' do
|
|
|
|
expect_relative_link_to_resolve_to('../test.git', "/#{group.path}/test")
|
2015-04-10 01:07:32 -04:00
|
|
|
end
|
|
|
|
|
2018-08-13 00:01:59 -04:00
|
|
|
it 'handles trailing whitespace' do
|
|
|
|
expect_relative_link_to_resolve_to('../test.git ', "/#{group.path}/test")
|
2017-06-28 15:01:39 -04:00
|
|
|
end
|
|
|
|
|
2018-08-13 00:01:59 -04:00
|
|
|
it 'handles project under another top group' do
|
|
|
|
expect_relative_link_to_resolve_to('../../baz/test.git ', "/baz/test")
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'repo path resolves to be located at root (namespace absent)' do
|
|
|
|
it 'returns nil' do
|
2020-01-20 16:08:46 -05:00
|
|
|
stub_url('../../test.git')
|
2018-08-13 00:01:59 -04:00
|
|
|
|
2019-07-22 08:25:56 -04:00
|
|
|
result = subject
|
2018-08-13 00:01:59 -04:00
|
|
|
|
|
|
|
expect(result).to eq([nil, nil])
|
|
|
|
end
|
2015-04-10 01:07:32 -04:00
|
|
|
end
|
|
|
|
|
2018-08-13 00:01:59 -04:00
|
|
|
context 'repo path resolves to be located underneath current project path' do
|
|
|
|
it 'returns nil because it is not possible to have repo nested under another repo' do
|
2020-01-20 16:08:46 -05:00
|
|
|
stub_url('./test.git')
|
2018-08-13 00:01:59 -04:00
|
|
|
|
2019-07-22 08:25:56 -04:00
|
|
|
result = subject
|
2018-08-13 00:01:59 -04:00
|
|
|
|
|
|
|
expect(result).to eq([nil, nil])
|
|
|
|
end
|
2015-04-10 01:07:32 -04:00
|
|
|
end
|
|
|
|
|
2018-08-13 00:01:59 -04:00
|
|
|
context 'subgroup' do
|
|
|
|
let(:sub_group) { create(:group, parent: group, name: "sub group", path: "sub-group") }
|
|
|
|
let(:sub_project) { create(:project, group: sub_group) }
|
|
|
|
|
|
|
|
context 'project in sub group' do
|
|
|
|
let(:project) { sub_project }
|
|
|
|
|
|
|
|
it "handles referencing ancestor group's project" do
|
|
|
|
expect_relative_link_to_resolve_to('../../../top-group/test.git', "/#{group.path}/test")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
it "handles referencing descendent group's project" do
|
|
|
|
expect_relative_link_to_resolve_to('../sub-group/test.git', "/top-group/sub-group/test")
|
|
|
|
end
|
|
|
|
|
|
|
|
it "handles referencing another top group's project" do
|
|
|
|
expect_relative_link_to_resolve_to('../../frontend/css/test.git', "/frontend/css/test")
|
|
|
|
end
|
2015-04-10 01:07:32 -04:00
|
|
|
end
|
2015-04-23 10:42:28 -04:00
|
|
|
|
|
|
|
context 'personal project' do
|
|
|
|
let(:user) { create(:user) }
|
2017-08-02 15:55:11 -04:00
|
|
|
let(:project) { create(:project, namespace: user.namespace) }
|
2015-04-23 10:42:28 -04:00
|
|
|
|
2018-08-13 00:01:59 -04:00
|
|
|
it 'handles referencing another personal project' do
|
|
|
|
expect_relative_link_to_resolve_to('../test.git', "/#{user.username}/test")
|
2015-04-23 10:42:28 -04:00
|
|
|
end
|
|
|
|
end
|
2015-04-10 01:07:32 -04:00
|
|
|
end
|
2019-07-25 18:01:17 -04:00
|
|
|
|
|
|
|
context 'unknown submodule' do
|
|
|
|
before do
|
|
|
|
# When there is no `.gitmodules` file, or if `.gitmodules` does not
|
|
|
|
# know the submodule at the specified path,
|
|
|
|
# `Repository#submodule_url_for` returns `nil`
|
|
|
|
stub_url(nil)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'returns no links' do
|
|
|
|
expect(subject).to eq([nil, nil])
|
|
|
|
end
|
|
|
|
end
|
2014-02-03 21:35:48 -05:00
|
|
|
end
|
2014-02-10 06:02:26 -05:00
|
|
|
|
2019-07-22 08:25:56 -04:00
|
|
|
context 'as view helpers in view context' do
|
|
|
|
subject { helper.submodule_links(submodule_item) }
|
|
|
|
|
|
|
|
before do
|
|
|
|
self.instance_variable_set(:@repository, repo)
|
|
|
|
end
|
|
|
|
|
|
|
|
it_behaves_like 'submodule_links'
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'as stand-alone module' do
|
|
|
|
subject { described_class.submodule_links(submodule_item, nil, repo) }
|
|
|
|
|
|
|
|
it_behaves_like 'submodule_links'
|
|
|
|
end
|
|
|
|
|
2014-02-10 06:02:26 -05:00
|
|
|
def stub_url(url)
|
2020-01-20 16:08:46 -05:00
|
|
|
allow(submodules).to receive(:submodule_url_for).and_return(url)
|
2015-05-21 17:49:06 -04:00
|
|
|
allow(repo).to receive(:submodule_url_for).and_return(url)
|
2014-02-10 06:02:26 -05:00
|
|
|
end
|
2014-02-03 21:35:48 -05:00
|
|
|
end
|