diff options
author | Felipe Artur <felipefac@gmail.com> | 2016-03-03 16:52:38 -0300 |
---|---|---|
committer | Felipe Artur <felipefac@gmail.com> | 2016-03-10 10:38:36 -0300 |
commit | bd59e59d01c5e845c7f7d451feaa1488670f20de (patch) | |
tree | 23011fda4fe88f878f0ec0f4eed86fe1e6fae9b2 | |
parent | 5551ccd7201ea6b45a2e2721502ba55e8f525d8f (diff) | |
download | gitlab-ce-bd59e59d01c5e845c7f7d451feaa1488670f20de.tar.gz |
Add visibility level icon and a couple of specs
-rw-r--r-- | app/helpers/groups_helper.rb | 6 | ||||
-rw-r--r-- | app/views/shared/groups/_group.html.haml | 3 | ||||
-rw-r--r-- | db/migrate/20160301124843_add_visibility_level_to_groups.rb | 2 | ||||
-rw-r--r-- | spec/controllers/groups_controller_spec.rb | 38 |
4 files changed, 47 insertions, 2 deletions
diff --git a/app/helpers/groups_helper.rb b/app/helpers/groups_helper.rb index d918d8acd22..42e09149bd7 100644 --- a/app/helpers/groups_helper.rb +++ b/app/helpers/groups_helper.rb @@ -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 diff --git a/app/views/shared/groups/_group.html.haml b/app/views/shared/groups/_group.html.haml index fb9a8db0889..82eeb2088c8 100644 --- a/app/views/shared/groups/_group.html.haml +++ b/app/views/shared/groups/_group.html.haml @@ -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 diff --git a/db/migrate/20160301124843_add_visibility_level_to_groups.rb b/db/migrate/20160301124843_add_visibility_level_to_groups.rb index 86dc07f4333..cef553981e7 100644 --- a/db/migrate/20160301124843_add_visibility_level_to_groups.rb +++ b/db/migrate/20160301124843_add_visibility_level_to_groups.rb @@ -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 diff --git a/spec/controllers/groups_controller_spec.rb b/spec/controllers/groups_controller_spec.rb index 938e97298b6..e7ead824d20 100644 --- a/spec/controllers/groups_controller_spec.rb +++ b/spec/controllers/groups_controller_spec.rb @@ -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 |