Commit e3f361fa authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Merge branch 'refactor/group_owners' of /home/git/repositories/gitlab/gitlabhq

parents 8674e1c2 c6096e47
...@@ -20,9 +20,9 @@ class Admin::GroupsController < Admin::ApplicationController ...@@ -20,9 +20,9 @@ class Admin::GroupsController < Admin::ApplicationController
def create def create
@group = Group.new(params[:group]) @group = Group.new(params[:group])
@group.path = @group.name.dup.parameterize if @group.name @group.path = @group.name.dup.parameterize if @group.name
@group.owner = current_user
if @group.save if @group.save
@group.add_owner(current_user)
redirect_to [:admin, @group], notice: 'Group was successfully created.' redirect_to [:admin, @group], notice: 'Group was successfully created.'
else else
render "new" render "new"
...@@ -30,14 +30,7 @@ class Admin::GroupsController < Admin::ApplicationController ...@@ -30,14 +30,7 @@ class Admin::GroupsController < Admin::ApplicationController
end end
def update def update
group_params = params[:group].dup if @group.update_attributes(params[:group])
owner_id =group_params.delete(:owner_id)
if owner_id
@group.change_owner(User.find(owner_id))
end
if @group.update_attributes(group_params)
redirect_to [:admin, @group], notice: 'Group was successfully updated.' redirect_to [:admin, @group], notice: 'Group was successfully updated.'
else else
render "edit" render "edit"
......
...@@ -21,9 +21,9 @@ class GroupsController < ApplicationController ...@@ -21,9 +21,9 @@ class GroupsController < ApplicationController
def create def create
@group = Group.new(params[:group]) @group = Group.new(params[:group])
@group.path = @group.name.dup.parameterize if @group.name @group.path = @group.name.dup.parameterize if @group.name
@group.owner = current_user
if @group.save if @group.save
@group.add_owner(current_user)
redirect_to @group, notice: 'Group was successfully created.' redirect_to @group, notice: 'Group was successfully created.'
else else
render action: "new" render action: "new"
...@@ -73,15 +73,7 @@ class GroupsController < ApplicationController ...@@ -73,15 +73,7 @@ class GroupsController < ApplicationController
end end
def update def update
group_params = params[:group].dup if @group.update_attributes(params[:group])
owner_id = group_params.delete(:owner_id)
if owner_id
@group.owner = User.find(owner_id)
@group.save
end
if @group.update_attributes(group_params)
redirect_to @group, notice: 'Group was successfully updated.' redirect_to @group, notice: 'Group was successfully updated.'
else else
render action: "edit" render action: "edit"
......
...@@ -8,8 +8,8 @@ class Profiles::GroupsController < ApplicationController ...@@ -8,8 +8,8 @@ class Profiles::GroupsController < ApplicationController
def leave def leave
@users_group = group.users_groups.where(user_id: current_user.id).first @users_group = group.users_groups.where(user_id: current_user.id).first
if group.owner == current_user if group.last_owner?(current_user)
redirect_to(profile_groups_path, alert: "You can't leave group. You must transfer it to another owner before leaving.") redirect_to(profile_groups_path, alert: "You can't leave group. You must add at least one more owner to it.")
else else
@users_group.destroy @users_group.destroy
redirect_to(profile_groups_path, info: "You left #{group.name} group.") redirect_to(profile_groups_path, info: "You left #{group.name} group.")
......
...@@ -19,7 +19,7 @@ class UsersGroupsController < ApplicationController ...@@ -19,7 +19,7 @@ class UsersGroupsController < ApplicationController
def destroy def destroy
@users_group = @group.users_groups.find(params[:id]) @users_group = @group.users_groups.find(params[:id])
@users_group.destroy unless @users_group.user == @group.owner @users_group.destroy
respond_to do |format| respond_to do |format|
format.html { redirect_to members_group_path(@group), notice: 'User was successfully removed from group.' } format.html { redirect_to members_group_path(@group), notice: 'User was successfully removed from group.' }
......
...@@ -79,7 +79,7 @@ class Ability ...@@ -79,7 +79,7 @@ class Ability
rules << project_admin_rules rules << project_admin_rules
end end
if project.group && project.group.owners.include?(user) if project.group && project.group.has_owner?(user)
rules << project_admin_rules rules << project_admin_rules
end end
...@@ -159,7 +159,7 @@ class Ability ...@@ -159,7 +159,7 @@ class Ability
end end
# Only group owner and administrators can manage group # Only group owner and administrators can manage group
if group.owners.include?(user) || user.admin? if group.has_owner?(user) || user.admin?
rules << [ rules << [
:manage_group, :manage_group,
:manage_namespace :manage_namespace
......
...@@ -16,14 +16,12 @@ class Group < Namespace ...@@ -16,14 +16,12 @@ class Group < Namespace
has_many :users_groups, dependent: :destroy has_many :users_groups, dependent: :destroy
has_many :users, through: :users_groups has_many :users, through: :users_groups
after_create :add_owner
def human_name def human_name
name name
end end
def owners def owners
@owners ||= (users_groups.owners.map(&:user) << owner).uniq @owners ||= users_groups.owners.map(&:user)
end end
def add_users(user_ids, group_access) def add_users(user_ids, group_access)
...@@ -36,20 +34,19 @@ class Group < Namespace ...@@ -36,20 +34,19 @@ class Group < Namespace
self.users_groups.create(user_id: user.id, group_access: group_access) self.users_groups.create(user_id: user.id, group_access: group_access)
end end
def change_owner(user) def add_owner(user)
self.owner = user self.add_user(user, UsersGroup::OWNER)
membership = users_groups.where(user_id: user.id).first
if membership
membership.update_attributes(group_access: UsersGroup::OWNER)
else
add_owner
end end
def has_owner?(user)
owners.include?(user)
end end
private def last_owner?(user)
has_owner?(user) && owners.size == 1
end
def add_owner def members
self.add_users([owner.id], UsersGroup::OWNER) users_groups
end end
end end
...@@ -20,7 +20,7 @@ class Namespace < ActiveRecord::Base ...@@ -20,7 +20,7 @@ class Namespace < ActiveRecord::Base
has_many :projects, dependent: :destroy has_many :projects, dependent: :destroy
belongs_to :owner, class_name: "User" belongs_to :owner, class_name: "User"
validates :owner, presence: true validates :owner, presence: true, unless: ->(n) { n.type == "Group" }
validates :name, presence: true, uniqueness: true, validates :name, presence: true, uniqueness: true,
length: { within: 0..255 }, length: { within: 0..255 },
format: { with: Gitlab::Regex.name_regex, format: { with: Gitlab::Regex.name_regex,
......
...@@ -249,10 +249,10 @@ class Project < ActiveRecord::Base ...@@ -249,10 +249,10 @@ class Project < ActiveRecord::Base
end end
def owner def owner
if namespace if group
namespace_owner group
else else
creator namespace.try(:owner)
end end
end end
...@@ -276,10 +276,6 @@ class Project < ActiveRecord::Base ...@@ -276,10 +276,6 @@ class Project < ActiveRecord::Base
end end
end end
def namespace_owner
namespace.try(:owner)
end
def path_with_namespace def path_with_namespace
if namespace if namespace
namespace.path + '/' + path namespace.path + '/' + path
......
...@@ -135,7 +135,7 @@ class User < ActiveRecord::Base ...@@ -135,7 +135,7 @@ class User < ActiveRecord::Base
# Remove user from all groups # Remove user from all groups
user.users_groups.find_each do |membership| user.users_groups.find_each do |membership|
# skip owned resources # skip owned resources
next if membership.group.owners.include?(user) next if membership.group.last_owner?(user)
return false unless membership.destroy return false unless membership.destroy
end end
......
...@@ -23,13 +23,15 @@ class SystemHooksService ...@@ -23,13 +23,15 @@ class SystemHooksService
case model case model
when Project when Project
owner = model.owner
data.merge!({ data.merge!({
name: model.name, name: model.name,
path: model.path, path: model.path,
path_with_namespace: model.path_with_namespace, path_with_namespace: model.path_with_namespace,
project_id: model.id, project_id: model.id,
owner_name: model.owner.name, owner_name: owner.name,
owner_email: model.owner.email owner_email: owner.respond_to?(:email) ? owner.email : nil
}) })
when User when User
data.merge!({ data.merge!({
......
...@@ -31,11 +31,8 @@ ...@@ -31,11 +31,8 @@
.clearfix.light.append-bottom-10 .clearfix.light.append-bottom-10
%span %span
%b Owner: %b Members:
- if group.owner %span.badge= group.members.size
= link_to group.owner_name, admin_user_path(group.owner)
- else
(deleted)
\| \|
%span %span
%b Projects: %b Projects:
......
...@@ -24,26 +24,6 @@ ...@@ -24,26 +24,6 @@
%strong %strong
= @group.description = @group.description
%li
%span.light Owned by:
%strong
- if @group.owner
= link_to @group.owner_name, admin_user_path(@group.owner)
- else
(deleted)
.pull-right
= link_to "#", class: "btn btn-small change-owner-link" do
%i.icon-edit
Change owner
%li.change-owner-holder.hide.bgred
.form-holder
%strong.cred New Owner:
= form_for [:admin, @group] do |f|
= users_select_tag(:"group[owner_id]")
.prepend-top-10
= f.submit 'Change Owner', class: "btn btn-remove"
= link_to "Cancel", "#", class: "btn change-owner-cancel-link"
%li %li
%span.light Created at: %span.light Created at:
%strong %strong
...@@ -92,4 +72,5 @@ ...@@ -92,4 +72,5 @@
= link_to user.name, admin_user_path(user) = link_to user.name, admin_user_path(user)
%span.pull-right.light %span.pull-right.light
= member.human_access = member.human_access
= link_to group_users_group_path(@group, member), confirm: remove_user_from_group_message(@group, user), method: :delete, remote: true, class: "btn-tiny btn btn-remove", title: 'Remove user from group' do
%i.icon-minus.icon-white
...@@ -25,7 +25,7 @@ ...@@ -25,7 +25,7 @@
%span.light Owned by: %span.light Owned by:
%strong %strong
- if @project.owner - if @project.owner
= link_to @project.owner_name, admin_user_path(@project.owner) = link_to @project.owner_name, [:admin, @project.owner]
- else - else
(deleted) (deleted)
......
...@@ -9,8 +9,6 @@ ...@@ -9,8 +9,6 @@
= link_to '#tab-projects', 'data-toggle' => 'tab' do = link_to '#tab-projects', 'data-toggle' => 'tab' do
%i.icon-folder-close %i.icon-folder-close
Projects Projects
%li
= link_to 'Transfer', '#tab-transfer', 'data-toggle' => 'tab'
%li %li
= link_to 'Remove', '#tab-remove', 'data-toggle' => 'tab' = link_to 'Remove', '#tab-remove', 'data-toggle' => 'tab'
...@@ -65,17 +63,6 @@ ...@@ -65,17 +63,6 @@
- if @group.projects.blank? - if @group.projects.blank?
%p.nothing_here_message This group has no projects yet %p.nothing_here_message This group has no projects yet
.tab-pane#tab-transfer
.ui-box.ui-box-danger
.title Transfer group
.ui-box-body
%p
Transferring group will cause loss of admin control over group and all child projects
= form_for @group do |f|
= users_select_tag(:'group[owner_id]')
%hr
= f.submit 'Transfer group', class: "btn btn-small btn-remove"
.tab-pane#tab-remove .tab-pane#tab-remove
.ui-box.ui-box-danger .ui-box.ui-box-danger
.title Remove group .title Remove group
......
...@@ -2,6 +2,9 @@ ...@@ -2,6 +2,9 @@
Group members Group members
%p.light %p.light
Members of group have access to all group projects. Members of group have access to all group projects.
Read more about permissions
%strong= link_to "here", help_permissions_path, class: "vlink"
%hr %hr
- can_manage_group = current_user.can? :manage_group, @group - can_manage_group = current_user.can? :manage_group, @group
.ui-box .ui-box
......
= render layout: 'help/layout' do = render layout: 'help/layout' do
%h3.page-title Permissions %h3.page-title Permissions
%p.light User has different abilities depends on access level he has in particular group or project
%hr
%h4 Project:
%table.table %table.table
%thead %thead
%tr %tr
...@@ -158,3 +161,50 @@ ...@@ -158,3 +161,50 @@
%td %td
%td %td
%td.permission-x &#10003; %td.permission-x &#10003;
%h4 Group
%table.table
%thead
%tr
%th Action
%th Guest
%th Reporter
%th Developer
%th Master
%th Owner
%tbody
%tr
%td Browse group
%td.permission-x &#10003;
%td.permission-x &#10003;
%td.permission-x &#10003;
%td.permission-x &#10003;
%td.permission-x &#10003;
%tr
%td Edit group
%td
%td
%td
%td
%td.permission-x &#10003;
%tr
%td Create project in group
%td
%td
%td
%td
%td.permission-x &#10003;
%tr
%td Manage group members
%td
%td
%td
%td
%td.permission-x &#10003;
%tr
%td Remove group
%td
%td
%td
%td
%td.permission-x &#10003;
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
%span.pull-right %span.pull-right
%strong= member.human_access %strong= member.human_access
- if show_controls && user != @group.owner && user != current_user - if show_controls && can?(current_user, :manage_group, @group) && current_user != user
= link_to '#', class: "btn-tiny btn js-toggle-button", title: 'Edit access level' do = link_to '#', class: "btn-tiny btn js-toggle-button", title: 'Edit access level' do
%i.icon-edit %i.icon-edit
= link_to group_users_group_path(@group, member), confirm: remove_user_from_group_message(@group, user), method: :delete, remote: true, class: "btn-tiny btn btn-remove", title: 'Remove user from group' do = link_to group_users_group_path(@group, member), confirm: remove_user_from_group_message(@group, user), method: :delete, remote: true, class: "btn-tiny btn btn-remove", title: 'Remove user from group' do
...@@ -20,4 +20,4 @@ ...@@ -20,4 +20,4 @@
= form_for [@group, member], remote: true do |f| = form_for [@group, member], remote: true do |f|
.alert.prepend-top-20 .alert.prepend-top-20
= f.select :group_access, options_for_select(UsersGroup.group_access_roles, member.group_access) = f.select :group_access, options_for_select(UsersGroup.group_access_roles, member.group_access)
= f.submit 'Save', class: 'btn btn-save' = f.submit 'Save', class: 'btn btn-save btn-small'
class ChangeOwnerIdForGroup < ActiveRecord::Migration
def up
change_column :namespaces, :owner_id, :integer, null: true
end
def down
change_column :namespaces, :owner_id, :integer, null: false
end
end
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
# #
# It's strongly recommended to check this file into your version control system. # It's strongly recommended to check this file into your version control system.
ActiveRecord::Schema.define(:version => 20130909132950) do ActiveRecord::Schema.define(:version => 20130926081215) do
create_table "deploy_keys_projects", :force => true do |t| create_table "deploy_keys_projects", :force => true do |t|
t.integer "deploy_key_id", :null => false t.integer "deploy_key_id", :null => false
...@@ -129,7 +129,7 @@ ActiveRecord::Schema.define(:version => 20130909132950) do ...@@ -129,7 +129,7 @@ ActiveRecord::Schema.define(:version => 20130909132950) do
create_table "namespaces", :force => true do |t| create_table "namespaces", :force => true do |t|
t.string "name", :null => false t.string "name", :null => false
t.string "path", :null => false t.string "path", :null => false
t.integer "owner_id", :null => false t.integer "owner_id"
t.datetime "created_at", :null => false t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false t.datetime "updated_at", :null => false
t.string "type" t.string "type"
......
...@@ -10,7 +10,8 @@ class Groups < Spinach::FeatureSteps ...@@ -10,7 +10,8 @@ class Groups < Spinach::FeatureSteps
end end
And 'I have group with projects' do And 'I have group with projects' do
@group = create(:group, owner: current_user) @group = create(:group)
@group.add_owner(current_user)
@project = create(:project, namespace: @group) @project = create(:project, namespace: @group)
@event = create(:closed_issue_event, project: @project) @event = create(:closed_issue_event, project: @project)
......
...@@ -25,13 +25,15 @@ describe Projects::CreateContext do ...@@ -25,13 +25,15 @@ describe Projects::CreateContext do
context 'group namespace' do context 'group namespace' do
before do before do
@group = create :group, owner: @user @group = create :group
@group.add_owner(@user)
@opts.merge!(namespace_id: @group.id) @opts.merge!(namespace_id: @group.id)
@project = create_project(@user, @opts) @project = create_project(@user, @opts)
end end
it { @project.should be_valid } it { @project.should be_valid }
it { @project.owner.should == @user } it { @project.owner.should == @group }
it { @project.namespace.should == @group } it { @project.namespace.should == @group }
end end
......
...@@ -71,7 +71,6 @@ FactoryGirl.define do ...@@ -71,7 +71,6 @@ FactoryGirl.define do
factory :group do factory :group do
sequence(:name) { |n| "group#{n}" } sequence(:name) { |n| "group#{n}" }
path { name.downcase.gsub(/\s/, '_') } path { name.downcase.gsub(/\s/, '_') }
owner
type 'Group' type 'Group'
end end
......
...@@ -10,11 +10,13 @@ describe "Group access" do ...@@ -10,11 +10,13 @@ describe "Group access" do
describe "Group" do describe "Group" do
let(:group) { create(:group) } let(:group) { create(:group) }
let(:owner) { create(:owner) }
let(:master) { create(:user) } let(:master) { create(:user) }
let(:reporter) { create(:user) } let(:reporter) { create(:user) }
let(:guest) { create(:user) } let(:guest) { create(:user) }
before do before do
group.add_user(owner, Gitlab::Access::OWNER)
group.add_user(master, Gitlab::Access::MASTER) group.add_user(master, Gitlab::Access::MASTER)
group.add_user(reporter, Gitlab::Access::REPORTER) group.add_user(reporter, Gitlab::Access::REPORTER)
group.add_user(guest, Gitlab::Access::GUEST) group.add_user(guest, Gitlab::Access::GUEST)
...@@ -23,7 +25,7 @@ describe "Group access" do ...@@ -23,7 +25,7 @@ describe "Group access" do
describe "GET /groups/:path" do describe "GET /groups/:path" do
subject { group_path(group) } subject { group_path(group) }
it { should be_allowed_for group.owner } it { should be_allowed_for owner }
it { should be_allowed_for master } it { should be_allowed_for master }
it { should be_allowed_for reporter } it { should be_allowed_for reporter }
it { should be_allowed_for :admin } it { should be_allowed_for :admin }
...@@ -35,7 +37,7 @@ describe "Group access" do ...@@ -35,7 +37,7 @@ describe "Group access" do
describe "GET /groups/:path/issues" do describe "GET /groups/:path/issues" do
subject { issues_group_path(group) } subject { issues_group_path(group) }
it { should be_allowed_for group.owner } it { should be_allowed_for owner }
it { should be_allowed_for master } it { should be_allowed_for master }
it { should be_allowed_for reporter } it { should be_allowed_for reporter }
it { should be_allowed_for :admin } it { should be_allowed_for :admin }
...@@ -47,7 +49,7 @@ describe "Group access" do ...@@ -47,7 +49,7 @@ describe "Group access" do
describe "GET /groups/:path/merge_requests" do describe "GET /groups/:path/merge_requests" do
subject { merge_requests_group_path(group) } subject { merge_requests_group_path(group) }
it { should be_allowed_for group.owner } it { should be_allowed_for owner }
it { should be_allowed_for master } it { should be_allowed_for master }
it { should be_allowed_for reporter } it { should be_allowed_for reporter }
it { should be_allowed_for :admin } it { should be_allowed_for :admin }
...@@ -59,7 +61,7 @@ describe "Group access" do ...@@ -59,7 +61,7 @@ describe "Group access" do
describe "GET /groups/:path/members" do describe "GET /groups/:path/members" do
subject { members_group_path(group) } subject { members_group_path(group) }
it { should be_allowed_for group.owner } it { should be_allowed_for owner }
it { should be_allowed_for master } it { should be_allowed_for master }
it { should be_allowed_for reporter } it { should be_allowed_for reporter }
it { should be_allowed_for :admin } it { should be_allowed_for :admin }
...@@ -71,7 +73,7 @@ describe "Group access" do ...@@ -71,7 +73,7 @@ describe "Group access" do
describe "GET /groups/:path/edit" do describe "GET /groups/:path/edit" do
subject { edit_group_path(group) } subject { edit_group_path(group) }
it { should be_allowed_for group.owner } it { should be_allowed_for owner }
it { should be_denied_for master } it { should be_denied_for master }
it { should be_denied_for reporter } it { should be_denied_for reporter }
it { should be_allowed_for :admin } it { should be_allowed_for :admin }
......
...@@ -26,10 +26,10 @@ describe Group do ...@@ -26,10 +26,10 @@ describe Group do
it { should validate_uniqueness_of(:name) } it { should validate_uniqueness_of(:name) }
it { should validate_presence_of :path } it { should validate_presence_of :path }
it { should validate_uniqueness_of(:path) } it { should validate_uniqueness_of(:path) }
it { should validate_presence_of :owner } it { should_not validate_presence_of :owner }
describe :users do describe :users do
it { group.users.should == [group.owner] } it { group.users.should == group.owners }
end end
describe :human_name do describe :human_name do
...@@ -38,7 +38,7 @@ describe Group do ...@@ -38,7 +38,7 @@ describe Group do
describe :add_users do describe :add_users do
let(:user) { create(:user) } let(:user) { create(:user) }
before { group.add_users([user.id], UsersGroup::MASTER) } before { group.add_user(user, UsersGroup::MASTER) }
it { group.users_groups.masters.map(&:user).should include(user) } it { group.users_groups.masters.map(&:user).should include(user) }
end end
......
...@@ -85,7 +85,6 @@ describe Project do ...@@ -85,7 +85,6 @@ describe Project do
it { should respond_to(:execute_hooks) } it { should respond_to(:execute_hooks) }
it { should respond_to(:transfer) } it { should respond_to(:transfer) }
it { should respond_to(:name_with_namespace) } it { should respond_to(:name_with_namespace) }
it { should respond_to(:namespace_owner) }
it { should respond_to(:owner) } it { should respond_to(:owner) }
it { should respond_to(:path_with_namespace) } it { should respond_to(:path_with_namespace) }
end end
......
...@@ -130,11 +130,12 @@ describe User do ...@@ -130,11 +130,12 @@ describe User do
before do before do
ActiveRecord::Base.observers.enable(:user_observer) ActiveRecord::Base.observers.enable(:user_observer)
@user = create :user @user = create :user
@group = create :group, owner: @user @group = create :group
@group.add_owner(@user)
end end
it { @user.several_namespaces?.should be_true } it { @user.several_namespaces?.should be_true }
it { @user.namespaces.should include(@user.namespace, @group) } it { @user.namespaces.should include(@user.namespace) }
it { @user.authorized_groups.should == [@group] } it { @user.authorized_groups.should == [@group] }
it { @user.owned_groups.should == [@group] } it { @user.owned_groups.should == [@group] }
end end
...@@ -144,9 +145,10 @@ describe User do ...@@ -144,9 +145,10 @@ describe User do
ActiveRecord::Base.observers.enable(:user_observer) ActiveRecord::Base.observers.enable(:user_observer)
@user = create :user @user = create :user
@user2 = create :user @user2 = create :user
@group = create :group, owner: @user @group = create :group
@group.add_owner(@user)
@group.add_users([@user2.id], UsersGroup::OWNER) @group.add_user(@user2, UsersGroup::OWNER)
end end
it { @user2.several_namespaces?.should be_true } it { @user2.several_namespaces?.should be_true }
......
...@@ -6,8 +6,13 @@ describe API::API do ...@@ -6,8 +6,13 @@ describe API::API do
let(:user1) { create(:user) } let(:user1) { create(:user) }
let(:user2) { create(:user) } let(:user2) { create(:user) }
let(:admin) { create(:admin) } let(:admin) { create(:admin) }
let!(:group1) { create(:group, owner: user1) } let!(:group1) { create(:group) }
let!(:group2) { create(:group, owner: user2) } let!(:group2) { create(:group) }
before do
group1.add_owner(user1)
group2.add_owner(user2)
end
describe "GET /groups" do describe "GET /groups" do
context "when unauthenticated" do context "when unauthenticated" do
...@@ -130,14 +135,19 @@ describe API::API do ...@@ -130,14 +135,19 @@ describe API::API do
let(:master) { create(:user) } let(:master) { create(:user) }
let(:guest) { create(:user) } let(:guest) { create(:user) }
let!(:group_with_members) do let!(:group_with_members) do
group = create(:group, owner: owner) group = create(:group)
group.add_users([reporter.id], UsersGroup::REPORTER) group.add_users([reporter.id], UsersGroup::REPORTER)
group.add_users([developer.id], UsersGroup::DEVELOPER) group.add_users([developer.id], UsersGroup::DEVELOPER)
group.add_users([master.id], UsersGroup::MASTER) group.add_users([master.id], UsersGroup::MASTER)
group.add_users([guest.id], UsersGroup::GUEST) group.add_users([guest.id], UsersGroup::GUEST)
group group
end end
let!(:group_no_members) { create(:group, owner: owner) } let!(:group_no_members) { create(:group) }
before do
group_with_members.add_owner owner
group_no_members.add_owner owner
end
describe "GET /groups/:id/members" do describe "GET /groups/:id/members" do
context "when authenticated as user that is part or the group" do context "when authenticated as user that is part or the group" do
......
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