diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2019-12-04 21:08:46 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2019-12-04 21:08:46 +0300 |
commit | b41cd8cb92d53454b2b160ba922d33801933a9cf (patch) | |
tree | 3519da8856f8bf12ce9e75248e5ecb9ed4eacf14 /spec/models/issue | |
parent | 8d3aee3636da5181ae94d23b47c6794b5610ab01 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/models/issue')
-rw-r--r-- | spec/models/issue/metrics_spec.rb | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/spec/models/issue/metrics_spec.rb b/spec/models/issue/metrics_spec.rb index 7aa0d97b194..0d0628277a6 100644 --- a/spec/models/issue/metrics_spec.rb +++ b/spec/models/issue/metrics_spec.rb @@ -7,6 +7,33 @@ describe Issue::Metrics do subject { create(:issue, project: project) } + describe '.for_issues' do + subject(:scope) { described_class.for_issues([issue1, issue2]) } + + let(:issue1) { create(:issue) } + let(:issue2) { create(:issue) } + + it 'returns metrics associated with given issues' do + create(:issue) + + expect(scope).to match_array([issue1.metrics, issue2.metrics]) + end + end + + describe '.with_first_mention_not_earlier_than' do + subject(:scope) { described_class.with_first_mention_not_earlier_than(timestamp) } + + let(:timestamp) { DateTime.now } + + it 'returns metrics without mentioning in commit or with mentioning after given timestamp' do + issue1 = create(:issue) + issue2 = create(:issue).tap { |i| i.metrics.update!(first_mentioned_in_commit_at: timestamp + 1.day) } + create(:issue).tap { |i| i.metrics.update!(first_mentioned_in_commit_at: timestamp - 1.day) } + + expect(scope).to match_array([issue1.metrics, issue2.metrics]) + end + end + describe "when recording the default set of issue metrics on issue save" do context "milestones" do it "records the first time an issue is associated with a milestone" do |