summaryrefslogtreecommitdiff
path: root/spec/views/projects/tree
diff options
context:
space:
mode:
Diffstat (limited to 'spec/views/projects/tree')
-rw-r--r--spec/views/projects/tree/_tree_header.html.haml_spec.rb44
-rw-r--r--spec/views/projects/tree/_tree_row.html.haml_spec.rb2
-rw-r--r--spec/views/projects/tree/show.html.haml_spec.rb2
3 files changed, 48 insertions, 0 deletions
diff --git a/spec/views/projects/tree/_tree_header.html.haml_spec.rb b/spec/views/projects/tree/_tree_header.html.haml_spec.rb
new file mode 100644
index 00000000000..4b71ea9ffe3
--- /dev/null
+++ b/spec/views/projects/tree/_tree_header.html.haml_spec.rb
@@ -0,0 +1,44 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+describe 'projects/tree/_tree_header' do
+ let(:project) { create(:project, :repository) }
+ let(:current_user) { create(:user) }
+ let(:repository) { project.repository }
+
+ before do
+ assign(:project, project)
+ assign(:repository, repository)
+ assign(:id, File.join('master', ''))
+ assign(:ref, 'master')
+
+ allow(view).to receive(:current_user).and_return(current_user)
+ allow(view).to receive(:can_collaborate_with_project?) { true }
+ end
+
+ it 'does not render the WebIDE button when user cannot create fork or cannot open MR' do
+ allow(view).to receive(:can?) { false }
+
+ render
+
+ expect(rendered).not_to have_link('Web IDE')
+ end
+
+ it 'renders the WebIDE button when user can create fork and can open MR in project' do
+ allow(view).to receive(:can?) { true }
+
+ render
+
+ expect(rendered).to have_link('Web IDE')
+ end
+
+ it 'opens a popup confirming a fork if the user can create fork/MR but cannot collaborate with the project' do
+ allow(view).to receive(:can?) { true }
+ allow(view).to receive(:can_collaborate_with_project?) { false }
+
+ render
+
+ expect(rendered).to have_link('Web IDE', href: '#modal-confirm-fork')
+ end
+end
diff --git a/spec/views/projects/tree/_tree_row.html.haml_spec.rb b/spec/views/projects/tree/_tree_row.html.haml_spec.rb
index 3353b7665e2..ff2fe8aeb6c 100644
--- a/spec/views/projects/tree/_tree_row.html.haml_spec.rb
+++ b/spec/views/projects/tree/_tree_row.html.haml_spec.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
require 'spec_helper'
describe 'projects/tree/_tree_row' do
diff --git a/spec/views/projects/tree/show.html.haml_spec.rb b/spec/views/projects/tree/show.html.haml_spec.rb
index 5bb0173ab89..960cf42a793 100644
--- a/spec/views/projects/tree/show.html.haml_spec.rb
+++ b/spec/views/projects/tree/show.html.haml_spec.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
require 'spec_helper'
describe 'projects/tree/show' do