2015-03-12 17:51:41 -04:00
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
describe GroupsHelper do
|
2017-06-20 17:35:55 -04:00
|
|
|
include ApplicationHelper
|
|
|
|
|
2015-03-12 17:51:41 -04:00
|
|
|
describe 'group_icon' do
|
2015-06-22 14:00:17 -04:00
|
|
|
avatar_file_path = File.join(Rails.root, 'spec', 'fixtures', 'banana_sample.gif')
|
2015-03-12 17:51:41 -04:00
|
|
|
|
2016-07-25 14:16:19 -04:00
|
|
|
it 'returns an url for the avatar' do
|
2015-03-12 17:51:41 -04:00
|
|
|
group = create(:group)
|
2016-12-18 20:35:07 -05:00
|
|
|
group.avatar = fixture_file_upload(avatar_file_path)
|
2015-03-12 17:51:41 -04:00
|
|
|
group.save!
|
2017-06-21 09:48:12 -04:00
|
|
|
expect(group_icon(group.path).to_s)
|
2017-07-17 09:46:59 -04:00
|
|
|
.to match("/uploads/-/system/group/avatar/#{group.id}/banana_sample.gif")
|
2015-03-12 17:51:41 -04:00
|
|
|
end
|
|
|
|
|
2016-07-25 14:16:19 -04:00
|
|
|
it 'gives default avatar_icon when no avatar is present' do
|
2015-03-12 17:51:41 -04:00
|
|
|
group = create(:group)
|
|
|
|
group.save!
|
|
|
|
expect(group_icon(group.path)).to match('group_avatar.png')
|
|
|
|
end
|
|
|
|
end
|
2016-09-06 12:48:00 -04:00
|
|
|
|
|
|
|
describe 'group_lfs_status' do
|
|
|
|
let(:group) { create(:group) }
|
2017-08-02 15:55:11 -04:00
|
|
|
let!(:project) { create(:project, namespace_id: group.id) }
|
2016-09-06 12:48:00 -04:00
|
|
|
|
|
|
|
before do
|
|
|
|
allow(Gitlab.config.lfs).to receive(:enabled).and_return(true)
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'only one project in group' do
|
|
|
|
before do
|
|
|
|
group.update_attribute(:lfs_enabled, true)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'returns all projects as enabled' do
|
|
|
|
expect(group_lfs_status(group)).to include('Enabled for all projects')
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'returns all projects as disabled' do
|
|
|
|
project.update_attribute(:lfs_enabled, false)
|
|
|
|
|
|
|
|
expect(group_lfs_status(group)).to include('Enabled for 0 out of 1 project')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'more than one project in group' do
|
|
|
|
before do
|
2017-08-02 15:55:11 -04:00
|
|
|
create(:project, namespace_id: group.id)
|
2016-09-06 12:48:00 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
context 'LFS enabled in group' do
|
|
|
|
before do
|
|
|
|
group.update_attribute(:lfs_enabled, true)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'returns both projects as enabled' do
|
|
|
|
expect(group_lfs_status(group)).to include('Enabled for all projects')
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'returns only one as enabled' do
|
|
|
|
project.update_attribute(:lfs_enabled, false)
|
|
|
|
|
|
|
|
expect(group_lfs_status(group)).to include('Enabled for 1 out of 2 projects')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'LFS disabled in group' do
|
|
|
|
before do
|
|
|
|
group.update_attribute(:lfs_enabled, false)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'returns both projects as disabled' do
|
|
|
|
expect(group_lfs_status(group)).to include('Disabled for all projects')
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'returns only one as disabled' do
|
|
|
|
project.update_attribute(:lfs_enabled, true)
|
|
|
|
|
|
|
|
expect(group_lfs_status(group)).to include('Disabled for 1 out of 2 projects')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2017-06-20 17:35:55 -04:00
|
|
|
|
2017-06-26 11:32:22 -04:00
|
|
|
describe 'group_title', :nested_groups do
|
2017-06-20 17:35:55 -04:00
|
|
|
let(:group) { create(:group) }
|
|
|
|
let(:nested_group) { create(:group, parent: group) }
|
|
|
|
let(:deep_nested_group) { create(:group, parent: nested_group) }
|
|
|
|
let!(:very_deep_nested_group) { create(:group, parent: deep_nested_group) }
|
|
|
|
|
|
|
|
it 'outputs the groups in the correct order' do
|
2017-06-30 12:52:11 -04:00
|
|
|
expect(helper.group_title(very_deep_nested_group)).to match(/>#{group.name}<\/a>.*>#{nested_group.name}<\/a>.*>#{deep_nested_group.name}<\/a>/)
|
2017-06-20 17:35:55 -04:00
|
|
|
end
|
|
|
|
end
|
2015-03-12 17:51:41 -04:00
|
|
|
end
|