From 7571152d1d9da4331df023d3f153399cedd54c3c Mon Sep 17 00:00:00 2001 From: Sam Date: Wed, 8 May 2013 10:32:29 +1000 Subject: [PATCH] fix issue adding users to groups --- app/models/group.rb | 4 ++-- spec/models/group_spec.rb | 5 +++++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/app/models/group.rb b/app/models/group.rb index 69657be4565..970c6e5312c 100644 --- a/app/models/group.rb +++ b/app/models/group.rb @@ -76,8 +76,8 @@ class Group < ActiveRecord::Base GroupUser.where(group_id: trust_group_ids, user_id: user_id).delete_all if group = Group[name] - group_users.build(user_id: user_id) - group_users.save! + group.group_users.build(user_id: user_id) + group.save! else refresh_automatic_group!(name) end diff --git a/spec/models/group_spec.rb b/spec/models/group_spec.rb index 253532faee3..1236fb4404d 100644 --- a/spec/models/group_spec.rb +++ b/spec/models/group_spec.rb @@ -47,6 +47,11 @@ describe Group do Group[:trust_level_1].user_ids.should == [] Group[:trust_level_2].user_ids.should == [user.id] + + user2 = Fabricate(:coding_horror) + user2.change_trust_level!(:regular) + + Group[:trust_level_2].user_ids.sort.should == [user.id, user2.id].sort end end