2019-10-08 08:06:01 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-12-12 04:11:01 -05:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2020-06-24 11:08:50 -04:00
|
|
|
RSpec.describe 'projects/tree/_tree_row' do
|
2017-12-12 04:11:01 -05:00
|
|
|
let(:project) { create(:project, :repository) }
|
|
|
|
let(:repository) { project.repository }
|
2020-03-31 08:08:09 -04:00
|
|
|
|
|
|
|
# rubocop: disable Rails/FindBy
|
|
|
|
# This is not ActiveRecord where..first
|
2017-12-12 04:11:01 -05:00
|
|
|
let(:blob_item) { Gitlab::Git::Tree.where(repository, SeedRepo::Commit::ID, 'files/ruby').first }
|
2020-03-31 08:08:09 -04:00
|
|
|
# rubocop: enable Rails/FindBy
|
2017-12-12 04:11:01 -05:00
|
|
|
|
|
|
|
before do
|
|
|
|
assign(:project, project)
|
|
|
|
assign(:repository, repository)
|
|
|
|
assign(:id, File.join('master', ''))
|
2017-12-14 06:31:50 -05:00
|
|
|
assign(:lfs_blob_ids, [])
|
2017-12-12 04:11:01 -05:00
|
|
|
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
|
2017-12-14 06:31:50 -05:00
|
|
|
assign(:lfs_blob_ids, [blob_item].map(&:id))
|
2017-12-12 04:11:01 -05:00
|
|
|
|
|
|
|
render_partial(blob_item)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'renders LFS badge' do
|
|
|
|
expect(rendered).to have_selector('.label-lfs', text: 'LFS')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2018-10-17 20:03:15 -04:00
|
|
|
def render_partial(items)
|
|
|
|
render partial: 'projects/tree/tree_row', collection: [items].flatten
|
2017-12-12 04:11:01 -05:00
|
|
|
end
|
|
|
|
end
|