Commit bd59e59d authored by Felipe Artur's avatar Felipe Artur

Add visibility level icon and a couple of specs

parent 5551ccd7
...@@ -28,7 +28,7 @@ module GroupsHelper ...@@ -28,7 +28,7 @@ module GroupsHelper
group = Group.find_by(path: group) group = Group.find_by(path: group)
end end
if group && can?(current_user, :read_group, group) && group.avatar.present? if group && group.avatar.present?
group.avatar.url group.avatar.url
else else
'no_group_avatar.png' 'no_group_avatar.png'
...@@ -43,4 +43,8 @@ module GroupsHelper ...@@ -43,4 +43,8 @@ module GroupsHelper
full_title full_title
end end
end end
def group_visibility_description(group)
"#{visibility_level_label(group.visibility_level)} - #{group_visibility_level_description(group.visibility_level)}"
end
end end
...@@ -21,6 +21,9 @@ ...@@ -21,6 +21,9 @@
= icon('users') = icon('users')
= number_with_delimiter(group.users.count) = 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" = image_tag group_icon(group), class: "avatar s40 hidden-xs"
= link_to group, class: 'group-name title' do = link_to group, class: 'group-name title' do
= group.name = group.name
......
class AddVisibilityLevelToGroups < ActiveRecord::Migration class AddVisibilityLevelToGroups < ActiveRecord::Migration
def change def change
#All groups will be private when created #All groups public by default
add_column :namespaces, :visibility_level, :integer, null: false, default: 20 add_column :namespaces, :visibility_level, :integer, null: false, default: 20
end end
end end
...@@ -20,4 +20,42 @@ describe GroupsController do ...@@ -20,4 +20,42 @@ describe GroupsController do
end end
end 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 end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment