Project

General

Profile

Defect #38443 ยป 38443.patch

Go MAEDA, 2023-04-12 16:27

View differences:

app/models/group.rb
80 80
  def user_added(user)
81 81
    members.preload(:member_roles).each do |member|
82 82
      next if member.project_id.nil?
83
      # skip if the group is a member without roles in the project
84
      next if member.member_roles.empty?
83 85

  
84 86
      user_member =
85 87
        Member.find_or_initialize_by(:project_id => member.project_id, :user_id => user.id)
test/unit/group_test.rb
177 177

  
178 178
    assert_equal %w(A B), Group.sorted.to_a.map(&:name)
179 179
  end
180

  
181
  def test_user_added_should_not_fail_when_group_role_is_empty
182
    group = Group.find(11)
183
    project = Project.first
184
    user = User.find(9)
185

  
186
    m = Member.create!(:principal => group, :project => project, :role_ids => [1])
187
    MemberRole.where(:member_id => m.id).delete_all
188

  
189
    assert_nothing_raised {group.users << user}
190
    assert group.users.include?(user)
191
  end
180 192
end
    (1-1/1)