summaryrefslogtreecommitdiff
path: root/spec/models/group_milestone_spec.rb
diff options
context:
space:
mode:
authorFatih Acet <acetfatih@gmail.com>2018-12-20 12:14:33 +0100
committerFatih Acet <acetfatih@gmail.com>2018-12-20 13:33:09 +0100
commite9ef02096be859e31c155174fe2784d8a7ba73e3 (patch)
treec839c271e35cd1474801ff20d90bf9be3a2135bf /spec/models/group_milestone_spec.rb
parentf7ac8041f7ba3639085c26b4185eda00fd54a6e7 (diff)
downloadgitlab-ce-e9ef02096be859e31c155174fe2784d8a7ba73e3.tar.gz
Add project milestone link to dashboard milestonesccr/49289_milestone_link
One of the steps to deprecate dashboard milestones. Links do dashboard milestone are replaced with links for each project milestone
Diffstat (limited to 'spec/models/group_milestone_spec.rb')
-rw-r--r--spec/models/group_milestone_spec.rb27
1 files changed, 25 insertions, 2 deletions
diff --git a/spec/models/group_milestone_spec.rb b/spec/models/group_milestone_spec.rb
index b60676afc91..fcc33cd95fe 100644
--- a/spec/models/group_milestone_spec.rb
+++ b/spec/models/group_milestone_spec.rb
@@ -20,13 +20,36 @@ describe GroupMilestone do
end
describe '.build_collection' do
- before do
- project_milestone
+ let(:group) { create(:group) }
+ let(:project1) { create(:project, group: group) }
+ let(:project2) { create(:project, path: 'gitlab-ci', group: group) }
+ let(:project3) { create(:project, path: 'cookbook-gitlab', group: group) }
+
+ let!(:projects) do
+ [
+ project1,
+ project2,
+ project3
+ ]
end
it 'returns array of milestones, each with group assigned' do
milestones = described_class.build_collection(group, [project], {})
expect(milestones).to all(have_attributes(group: group))
end
+
+ context 'when adding new milestones' do
+ it 'does not add more queries' do
+ control_count = ActiveRecord::QueryRecorder.new do
+ described_class.build_collection(group, projects, {})
+ end.count
+
+ create(:milestone, title: 'This title', project: project1)
+
+ expect do
+ described_class.build_collection(group, projects, {})
+ end.not_to exceed_all_query_limit(control_count)
+ end
+ end
end
end