summaryrefslogtreecommitdiff
path: root/spec/presenters/blob_presenter_spec.rb
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2021-11-26 12:12:49 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2021-11-26 12:12:49 +0000
commit5343536f2bb402bc767db2d015e45ac87189d7c3 (patch)
tree29e7630ace5f465f0b3d6374c044dbb57227d694 /spec/presenters/blob_presenter_spec.rb
parentbc8f298b647859a411d38a440c397e5990ef4941 (diff)
downloadgitlab-ce-5343536f2bb402bc767db2d015e45ac87189d7c3.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/presenters/blob_presenter_spec.rb')
-rw-r--r--spec/presenters/blob_presenter_spec.rb22
1 files changed, 22 insertions, 0 deletions
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