Fix bug with team assignation on project from #4109
This commit is contained in:
parent
ee2124b7e9
commit
08c2c94d46
2 changed files with 30 additions and 2 deletions
|
@ -99,8 +99,8 @@ module Gitlab
|
|||
|
||||
teams ||= project.user_teams.with_member(user)
|
||||
|
||||
if action && (action == :added) && (teams.count == 1)
|
||||
result_access ||= project.users_project.with_user(user).first.project_access
|
||||
if action && (action == :added)
|
||||
result_access = project.users_projects.with_user(user).first.project_access
|
||||
end
|
||||
|
||||
if teams.any?
|
||||
|
|
28
spec/lib/gitlab/user_team_manager_spec.rb
Normal file
28
spec/lib/gitlab/user_team_manager_spec.rb
Normal file
|
@ -0,0 +1,28 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe Gitlab::UserTeamManager do
|
||||
before do
|
||||
@user = create :user
|
||||
@project = create :project, creator: @user
|
||||
|
||||
@master = create :user
|
||||
@developer = create :user
|
||||
@reporter = create :user
|
||||
|
||||
@project.team << [@master, :master]
|
||||
@project.team << [@developer, :developer]
|
||||
@project.team << [@reporter, :reporter]
|
||||
|
||||
@team = create :user_team, owner: @user
|
||||
|
||||
@team.add_members([@master.id, @developer.id, @reporter.id], UsersProject::DEVELOPER, false)
|
||||
end
|
||||
|
||||
it "should assign team to project with correct permissions result" do
|
||||
@team.assign_to_project(@project, UsersProject::MASTER)
|
||||
|
||||
@project.users_projects.find_by_user_id(@master).project_access.should == UsersProject::MASTER
|
||||
@project.users_projects.find_by_user_id(@developer).project_access.should == UsersProject::DEVELOPER
|
||||
@project.users_projects.find_by_user_id(@reporter).project_access.should == UsersProject::DEVELOPER
|
||||
end
|
||||
end
|
Loading…
Reference in a new issue