summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2014-06-04 11:52:17 +0300
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2014-06-04 11:52:17 +0300
commitc283fba3b7e9fb89ae2ed77597adee2700982718 (patch)
tree32abc3407cf38e9db36ed89ae81bfac8ce093366 /spec
parent5921c7481302913bffe88788c354f415cd19df82 (diff)
downloadgitlab-ce-c283fba3b7e9fb89ae2ed77597adee2700982718.tar.gz
Improve performance of application for large teams
This commit fixes a lot of sql queries to db for for groups and projects with big amount of members. Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
Diffstat (limited to 'spec')
-rw-r--r--spec/models/project_team_spec.rb35
1 files changed, 28 insertions, 7 deletions
diff --git a/spec/models/project_team_spec.rb b/spec/models/project_team_spec.rb
index 3e3543e85e1..1a7e3cd94b4 100644
--- a/spec/models/project_team_spec.rb
+++ b/spec/models/project_team_spec.rb
@@ -1,15 +1,36 @@
require "spec_helper"
describe ProjectTeam do
- let(:team) { create(:project).team }
+ let(:group) { create(:group) }
+ let(:project) { create(:empty_project, group: group) }
- describe "Respond to" do
- subject { team }
+ let(:master) { create(:user) }
+ let(:reporter) { create(:user) }
+ let(:guest) { create(:user) }
+ let(:nonmember) { create(:user) }
- it { should respond_to(:developers) }
- it { should respond_to(:masters) }
- it { should respond_to(:reporters) }
- it { should respond_to(:guests) }
+ before do
+ group.add_user(master, Gitlab::Access::MASTER)
+ group.add_user(reporter, Gitlab::Access::REPORTER)
+ group.add_user(guest, Gitlab::Access::GUEST)
+
+ # Add group guest as master to this project
+ # to test project access priority over group members
+ project.team << [guest, :master]
+ end
+
+ describe 'members collection' do
+ it { team.masters.should include(master) }
+ it { team.masters.should include(guest) }
+ it { team.masters.should_not include(reporter) }
+ it { team.masters.should_not include(nonmember) }
+ end
+
+ describe 'access methods' do
+ it { team.master?(master).should be_true }
+ it { team.master?(guest).should be_true }
+ it { team.master?(reporter).should be_false }
+ it { team.master?(nonmember).should be_false }
end
end