summaryrefslogtreecommitdiff
path: root/spec/presenters/blob_presenter_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/presenters/blob_presenter_spec.rb')
-rw-r--r--spec/presenters/blob_presenter_spec.rb46
1 files changed, 45 insertions, 1 deletions
diff --git a/spec/presenters/blob_presenter_spec.rb b/spec/presenters/blob_presenter_spec.rb
index 225386d9596..80e08db6099 100644
--- a/spec/presenters/blob_presenter_spec.rb
+++ b/spec/presenters/blob_presenter_spec.rb
@@ -28,7 +28,7 @@ RSpec.describe BlobPresenter do
end
describe '#replace_path' do
- it { expect(presenter.replace_path).to eq("/#{project.full_path}/-/create/#{blob.commit_id}/#{blob.path}") }
+ it { expect(presenter.replace_path).to eq("/#{project.full_path}/-/update/#{blob.commit_id}/#{blob.path}") }
end
describe '#can_current_user_push_to_branch' do
@@ -71,6 +71,40 @@ RSpec.describe BlobPresenter do
end
end
+ context 'Gitpod' do
+ let(:gitpod_url) { "https://gitpod.io" }
+ let(:gitpod_application_enabled) { true }
+ let(:gitpod_user_enabled) { true }
+
+ before do
+ allow(user).to receive(:gitpod_enabled).and_return(gitpod_user_enabled)
+ allow(Gitlab::CurrentSettings).to receive(:gitpod_enabled).and_return(gitpod_application_enabled)
+ allow(Gitlab::CurrentSettings).to receive(:gitpod_url).and_return(gitpod_url)
+ end
+
+ context 'Gitpod enabled for application and user' do
+ describe '#gitpod_blob_url' do
+ it { expect(presenter.gitpod_blob_url).to eq("#{gitpod_url}##{"http://localhost/#{project.full_path}/-/tree/#{blob.commit_id}/#{blob.path}"}") }
+ end
+ end
+
+ context 'Gitpod disabled at application level' do
+ let(:gitpod_application_enabled) { false }
+
+ describe '#gitpod_blob_url' do
+ it { expect(presenter.gitpod_blob_url).to eq(nil) }
+ end
+ end
+
+ context 'Gitpod disabled at user level' do
+ let(:gitpod_user_enabled) { false }
+
+ describe '#gitpod_blob_url' do
+ it { expect(presenter.gitpod_blob_url).to eq(nil) }
+ end
+ end
+ end
+
describe '#find_file_path' do
it { expect(presenter.find_file_path).to eq("/#{project.full_path}/-/find_file/HEAD/files/ruby/regex.rb") }
end
@@ -154,6 +188,16 @@ RSpec.describe BlobPresenter do
end
end
+ describe '#code_navigation_path' do
+ let(:code_navigation_path) { Gitlab::CodeNavigationPath.new(project, blob.commit_id).full_json_path_for(blob.path) }
+
+ it { expect(presenter.code_navigation_path).to eq(code_navigation_path) }
+ end
+
+ describe '#project_blob_path_root' do
+ it { expect(presenter.project_blob_path_root).to eq("/#{project.full_path}/-/blob/HEAD") }
+ end
+
context 'given a Gitlab::Graphql::Representation::TreeEntry' do
let(:blob) { Gitlab::Graphql::Representation::TreeEntry.new(super(), repository) }