diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-10-21 10:08:36 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-10-21 10:08:36 +0300 |
commit | 48aff82709769b098321c738f3444b9bdaa694c6 (patch) | |
tree | e00c7c43e2d9b603a5a6af576b1685e400410dee /spec/helpers/blob_helper_spec.rb | |
parent | 879f5329ee916a948223f8f43d77fba4da6cd028 (diff) |
Add latest changes from gitlab-org/gitlab@13-5-stable-eev13.5.0-rc42
Diffstat (limited to 'spec/helpers/blob_helper_spec.rb')
-rw-r--r-- | spec/helpers/blob_helper_spec.rb | 48 |
1 files changed, 34 insertions, 14 deletions
diff --git a/spec/helpers/blob_helper_spec.rb b/spec/helpers/blob_helper_spec.rb index 06f86e7716a..baa97781efa 100644 --- a/spec/helpers/blob_helper_spec.rb +++ b/spec/helpers/blob_helper_spec.rb @@ -5,16 +5,6 @@ require 'spec_helper' RSpec.describe BlobHelper do include TreeHelper - describe '#highlight' do - it 'wraps highlighted content' do - expect(helper.highlight('test.rb', '52')).to eq(%q[<pre class="code highlight"><code><span id="LC1" class="line" lang="ruby"><span class="mi">52</span></span></code></pre>]) - end - - it 'handles plain version' do - expect(helper.highlight('test.rb', '52', plain: true)).to eq(%q[<pre class="code highlight"><code><span id="LC1" class="line" lang="">52</span></code></pre>]) - end - end - describe "#sanitize_svg_data" do let(:input_svg_path) { File.join(Rails.root, 'spec', 'fixtures', 'unsanitized.svg') } let(:data) { File.read(input_svg_path) } @@ -455,13 +445,14 @@ RSpec.describe BlobHelper do end describe '#ide_fork_and_edit_path' do - let(:project) { create(:project) } - let(:current_user) { create(:user) } - let(:can_push_code) { true } + let_it_be(:project) { create(:project) } + let_it_be(:user) { create(:user) } + + let(:current_user) { user } before do allow(helper).to receive(:current_user).and_return(current_user) - allow(helper).to receive(:can?).and_return(can_push_code) + allow(helper).to receive(:can?).and_return(true) end it 'returns path to fork the repo with a redirect param to the full IDE path' do @@ -482,6 +473,35 @@ RSpec.describe BlobHelper do end end + describe '#fork_and_edit_path' do + let_it_be(:project) { create(:project) } + let_it_be(:user) { create(:user) } + + let(:current_user) { user } + + before do + allow(helper).to receive(:current_user).and_return(current_user) + allow(helper).to receive(:can?).and_return(true) + end + + it 'returns path to fork the repo with a redirect param to the full edit path' do + uri = URI(helper.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]=/#{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 + describe '#editing_ci_config?' do let(:project) { build(:project) } |