Add visibility level icon and a couple of specs
This commit is contained in:
parent
5551ccd720
commit
bd59e59d01
|
@ -28,7 +28,7 @@ module GroupsHelper
|
|||
group = Group.find_by(path: group)
|
||||
end
|
||||
|
||||
if group && can?(current_user, :read_group, group) && group.avatar.present?
|
||||
if group && group.avatar.present?
|
||||
group.avatar.url
|
||||
else
|
||||
'no_group_avatar.png'
|
||||
|
@ -43,4 +43,8 @@ module GroupsHelper
|
|||
full_title
|
||||
end
|
||||
end
|
||||
|
||||
def group_visibility_description(group)
|
||||
"#{visibility_level_label(group.visibility_level)} - #{group_visibility_level_description(group.visibility_level)}"
|
||||
end
|
||||
end
|
||||
|
|
|
@ -21,6 +21,9 @@
|
|||
= icon('users')
|
||||
= number_with_delimiter(group.users.count)
|
||||
|
||||
%span{title: group_visibility_description(group)}
|
||||
= visibility_level_icon(group.visibility_level, fw: false)
|
||||
|
||||
= image_tag group_icon(group), class: "avatar s40 hidden-xs"
|
||||
= link_to group, class: 'group-name title' do
|
||||
= group.name
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
class AddVisibilityLevelToGroups < ActiveRecord::Migration
|
||||
def change
|
||||
#All groups will be private when created
|
||||
#All groups public by default
|
||||
add_column :namespaces, :visibility_level, :integer, null: false, default: 20
|
||||
end
|
||||
end
|
||||
|
|
|
@ -20,4 +20,42 @@ describe GroupsController do
|
|||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe 'GET show' do
|
||||
let(:group) { create(:group, visibility_level: 20) }
|
||||
|
||||
it 'checks if group can be read' do
|
||||
expect(controller).to receive(:authorize_read_group!)
|
||||
get :show, id: group.path
|
||||
end
|
||||
end
|
||||
|
||||
describe 'POST create' do
|
||||
before { sign_in(create(:user)) }
|
||||
|
||||
it 'checks if group can be created' do
|
||||
expect(controller).to receive(:authorize_create_group!)
|
||||
post :create, { group: { name: "any params" } }
|
||||
end
|
||||
end
|
||||
|
||||
describe 'DELETE destroy' do
|
||||
before { sign_in(create(:user)) }
|
||||
let(:group) { create(:group, visibility_level: 20) }
|
||||
|
||||
it 'checks if group can be deleted' do
|
||||
expect(controller).to receive(:authorize_admin_group!)
|
||||
delete :destroy, id: group.path
|
||||
end
|
||||
end
|
||||
|
||||
describe 'PUT update' do
|
||||
before { sign_in(create(:user)) }
|
||||
let(:group) { create(:group, visibility_level: 20) }
|
||||
|
||||
it 'checks if group can be updated' do
|
||||
expect(controller).to receive(:authorize_admin_group!)
|
||||
put :update, id: group.path, group: { name: 'test' }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue