diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2019-10-16 06:06:12 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2019-10-16 06:06:12 +0300 |
commit | f155cc9034f2247c5d368f9b0212ad44248b0c5e (patch) | |
tree | 902480293b665d74a337aeae6a0521104f561988 /spec/helpers/blob_helper_spec.rb | |
parent | c920712fab6abdc37de9444e6bbcd170c295b21a (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/helpers/blob_helper_spec.rb')
-rw-r--r-- | spec/helpers/blob_helper_spec.rb | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/spec/helpers/blob_helper_spec.rb b/spec/helpers/blob_helper_spec.rb index e5e16e69833..4996e27c2e6 100644 --- a/spec/helpers/blob_helper_spec.rb +++ b/spec/helpers/blob_helper_spec.rb @@ -270,4 +270,32 @@ describe BlobHelper do end end end + + describe '#ide_fork_and_edit_path' do + let(:project) { create(:project) } + let(:current_user) { create(:user) } + let(:can_push_code) { true } + + before do + allow(helper).to receive(:current_user).and_return(current_user) + allow(helper).to receive(:can?).and_return(can_push_code) + end + + it 'returns path to fork the repo with a redirect param to the full IDE path' do + uri = URI(helper.ide_fork_and_edit_path(project, "master", "")) + params = CGI.unescape(uri.query) + + expect(uri.path).to eq("/#{project.namespace.path}/#{project.path}/-/forks") + expect(params).to include("continue[to]=/-/ide/project/#{project.namespace.path}/#{project.path}/edit/master") + expect(params).to include("namespace_key=#{current_user.namespace.id}") + end + + context 'when user is not logged in' do + let(:current_user) { nil } + + it 'returns nil' do + expect(helper.ide_fork_and_edit_path(project, "master", "")).to be_nil + end + end + end end |