Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'spec/presenters/blob_presenter_spec.rb')
-rw-r--r--spec/presenters/blob_presenter_spec.rb36
1 files changed, 30 insertions, 6 deletions
diff --git a/spec/presenters/blob_presenter_spec.rb b/spec/presenters/blob_presenter_spec.rb
index 28e18708eab..8c0347b3c8d 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
@@ -45,6 +67,10 @@ RSpec.describe BlobPresenter do
end
end
+ describe '#code_owners' do
+ it { expect(presenter.code_owners).to match_array([]) }
+ end
+
describe '#ide_edit_path' do
it { expect(presenter.ide_edit_path).to eq("/-/ide/project/#{project.full_path}/edit/HEAD/-/files/ruby/regex.rb") }
end
@@ -133,27 +159,25 @@ RSpec.describe BlobPresenter do
presenter.highlight
end
end
- end
- describe '#highlight_transformed' do
context 'when blob is ipynb' do
let(:blob) { repository.blob_at('f6b7a707', 'files/ipython/markdown-table.ipynb') }
let(:git_blob) { blob.__getobj__ }
before do
- allow(git_blob).to receive(:transformed_for_diff).and_return(true)
+ allow(Gitlab::Diff::CustomDiff).to receive(:transformed_for_diff?).and_return(true)
end
it 'uses md as the transformed language' do
expect(Gitlab::Highlight).to receive(:highlight).with('files/ipython/markdown-table.ipynb', anything, plain: nil, language: 'md')
- presenter.highlight_transformed
+ presenter.highlight
end
it 'transforms the blob' do
expect(Gitlab::Highlight).to receive(:highlight).with('files/ipython/markdown-table.ipynb', include("%%"), plain: nil, language: 'md')
- presenter.highlight_transformed
+ presenter.highlight
end
end
@@ -171,7 +195,7 @@ RSpec.describe BlobPresenter do
it 'does not transform the file' do
expect(Gitlab::Highlight).to receive(:highlight).with('files/ruby/regex.rb', git_blob.data, plain: nil, language: 'ruby')
- presenter.highlight_transformed
+ presenter.highlight
end
end
end