Commit 0447c731 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Merge pull request #4161 from Undev/fix-#4109

Fix bug with team assignation on project from #4109
parents c2280985 41f88f46
......@@ -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 if project.users_projects.with_user(user).any?
end
if teams.any?
......
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
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