summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorDouwe Maan <douwe@gitlab.com>2017-12-15 09:02:24 +0000
committerDouwe Maan <douwe@gitlab.com>2017-12-15 09:02:24 +0000
commit1baea77438779e74657b49ca26810d6c8f041b41 (patch)
tree480634259d9a6d88351a842a4a49561001ec111c /spec
parentc96e2edc105a46c93bcbf6841c8ec52270d6a601 (diff)
parentcbd3ce8f41fc5691a1d23aca0ffe3221ab5d26af (diff)
downloadgitlab-ce-1baea77438779e74657b49ca26810d6c8f041b41.tar.gz
Merge branch 'lfs-badge' into 'master'
Added LFS badge to indicate LFS tracked files Closes #15567 See merge request gitlab-org/gitlab-ce!15845
Diffstat (limited to 'spec')
-rw-r--r--spec/features/projects/tree/tree_show_spec.rb28
-rw-r--r--spec/helpers/tree_helper_spec.rb1
-rw-r--r--spec/views/projects/tree/_blob_item.html.haml_spec.rb40
-rw-r--r--spec/views/projects/tree/show.html.haml_spec.rb1
4 files changed, 70 insertions, 0 deletions
diff --git a/spec/features/projects/tree/tree_show_spec.rb b/spec/features/projects/tree/tree_show_spec.rb
new file mode 100644
index 00000000000..c8a17871508
--- /dev/null
+++ b/spec/features/projects/tree/tree_show_spec.rb
@@ -0,0 +1,28 @@
+require 'spec_helper'
+
+feature 'Projects tree' do
+ let(:user) { create(:user) }
+ let(:project) { create(:project, :repository) }
+
+ before do
+ project.add_master(user)
+ sign_in(user)
+
+ visit project_tree_path(project, 'master')
+ end
+
+ it 'renders tree table' do
+ expect(page).to have_selector('.tree-item')
+ expect(page).not_to have_selector('.label-lfs', text: 'LFS')
+ end
+
+ context 'LFS' do
+ before do
+ visit project_tree_path(project, File.join('master', 'files/lfs'))
+ end
+
+ it 'renders LFS badge on blob item' do
+ expect(page).to have_selector('.label-lfs', text: 'LFS')
+ end
+ end
+end
diff --git a/spec/helpers/tree_helper_spec.rb b/spec/helpers/tree_helper_spec.rb
index c358ccae9c3..d3b1be599dd 100644
--- a/spec/helpers/tree_helper_spec.rb
+++ b/spec/helpers/tree_helper_spec.rb
@@ -9,6 +9,7 @@ describe TreeHelper do
before do
@id = sha
@project = project
+ @lfs_blob_ids = []
end
it 'displays all entries without a warning' do
diff --git a/spec/views/projects/tree/_blob_item.html.haml_spec.rb b/spec/views/projects/tree/_blob_item.html.haml_spec.rb
new file mode 100644
index 00000000000..6a477c712ff
--- /dev/null
+++ b/spec/views/projects/tree/_blob_item.html.haml_spec.rb
@@ -0,0 +1,40 @@
+require 'spec_helper'
+
+describe 'projects/tree/_blob_item' do
+ let(:project) { create(:project, :repository) }
+ let(:repository) { project.repository }
+ let(:blob_item) { Gitlab::Git::Tree.where(repository, SeedRepo::Commit::ID, 'files/ruby').first }
+
+ before do
+ assign(:project, project)
+ assign(:repository, repository)
+ assign(:id, File.join('master', ''))
+ assign(:lfs_blob_ids, [])
+ end
+
+ it 'renders blob item' do
+ render_partial(blob_item)
+
+ expect(rendered).to have_content(blob_item.name)
+ expect(rendered).not_to have_selector('.label-lfs', text: 'LFS')
+ end
+
+ describe 'LFS blob' do
+ before do
+ assign(:lfs_blob_ids, [blob_item].map(&:id))
+
+ render_partial(blob_item)
+ end
+
+ it 'renders LFS badge' do
+ expect(rendered).to have_selector('.label-lfs', text: 'LFS')
+ end
+ end
+
+ def render_partial(blob_item)
+ render partial: 'projects/tree/blob_item', locals: {
+ blob_item: blob_item,
+ type: 'blob'
+ }
+ end
+end
diff --git a/spec/views/projects/tree/show.html.haml_spec.rb b/spec/views/projects/tree/show.html.haml_spec.rb
index 3c25e341b39..44b32df0395 100644
--- a/spec/views/projects/tree/show.html.haml_spec.rb
+++ b/spec/views/projects/tree/show.html.haml_spec.rb
@@ -9,6 +9,7 @@ describe 'projects/tree/show' do
before do
assign(:project, project)
assign(:repository, repository)
+ assign(:lfs_blob_ids, [])
allow(view).to receive(:can?).and_return(true)
allow(view).to receive(:can_collaborate_with_project?).and_return(true)