From 5343536f2bb402bc767db2d015e45ac87189d7c3 Mon Sep 17 00:00:00 2001 From: GitLab Bot Date: Fri, 26 Nov 2021 12:12:49 +0000 Subject: Add latest changes from gitlab-org/gitlab@master --- spec/presenters/blob_presenter_spec.rb | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'spec/presenters/blob_presenter_spec.rb') diff --git a/spec/presenters/blob_presenter_spec.rb b/spec/presenters/blob_presenter_spec.rb index 28e18708eab..cd38e74e0ea 100644 --- a/spec/presenters/blob_presenter_spec.rb +++ b/spec/presenters/blob_presenter_spec.rb @@ -31,6 +31,28 @@ RSpec.describe BlobPresenter do it { expect(presenter.replace_path).to eq("/#{project.full_path}/-/create/#{blob.commit_id}/#{blob.path}") } end + describe '#can_current_user_push_to_branch' do + let(:branch_exists) { true } + + before do + allow(project.repository).to receive(:branch_exists?).with(blob.commit_id).and_return(branch_exists) + end + + it { expect(presenter.can_current_user_push_to_branch?).to eq(true) } + + context 'current_user is nil' do + let(:user) { nil } + + it { expect(presenter.can_current_user_push_to_branch?).to eq(false) } + end + + context 'branch does not exist' do + let(:branch_exists) { false } + + it { expect(presenter.can_current_user_push_to_branch?).to eq(false) } + end + end + describe '#pipeline_editor_path' do context 'when blob is .gitlab-ci.yml' do before do -- cgit v1.2.1