Fix bug with team assignation on project from #4109

This commit is contained in:
Andrey Kumanyaev 2013-06-01 19:24:15 +04:00
parent ee2124b7e9
commit 08c2c94d46
2 changed files with 30 additions and 2 deletions

View file

@ -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?

View 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