Commit d20db103 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Merge branch 'readding_group_member' of /home/git/repositories/gitlab/gitlabhq

parents eda5b3b1 97cf31c4
......@@ -26,7 +26,8 @@ class Group < Namespace
def add_users(user_ids, group_access)
user_ids.compact.each do |user_id|
self.users_groups.create(user_id: user_id, group_access: group_access)
user = self.users_groups.find_or_initialize_by_user_id(user_id)
user.update_attributes(group_access: group_access)
end
end
......
......@@ -42,4 +42,16 @@ describe Group do
it { group.users_groups.masters.map(&:user).should include(user) }
end
describe :add_users do
let(:user) { create(:user) }
before { group.add_users([user.id], UsersGroup::GUEST) }
it "should update the group permission" do
group.users_groups.guests.map(&:user).should include(user)
group.add_users([user.id], UsersGroup::DEVELOPER)
group.users_groups.developers.map(&:user).should include(user)
group.users_groups.guests.map(&:user).should_not include(user)
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