summaryrefslogtreecommitdiff
path: root/spec/models/timelog_spec.rb
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2019-12-10 12:07:55 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2019-12-10 12:07:55 +0000
commit5e11c9b77cb1b2b77ee29359047b55807afe255d (patch)
tree40b02dead6acdcaab9cc15efc9ae4710c2ed78a8 /spec/models/timelog_spec.rb
parent97d4d926630822d0e1a638206909679c962d2f0a (diff)
downloadgitlab-ce-5e11c9b77cb1b2b77ee29359047b55807afe255d.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/models/timelog_spec.rb')
-rw-r--r--spec/models/timelog_spec.rb26
1 files changed, 26 insertions, 0 deletions
diff --git a/spec/models/timelog_spec.rb b/spec/models/timelog_spec.rb
index 7321a458817..33c1afad59f 100644
--- a/spec/models/timelog_spec.rb
+++ b/spec/models/timelog_spec.rb
@@ -41,4 +41,30 @@ RSpec.describe Timelog do
expect(subject).to be_valid
end
end
+
+ describe 'scopes' do
+ describe 'for_issues_in_group' do
+ it 'return timelogs created for group issues' do
+ group = create(:group)
+ subgroup = create(:group, parent: group)
+
+ create(:timelog, issue: create(:issue, project: create(:project)))
+ timelog1 = create(:timelog, issue: create(:issue, project: create(:project, group: group)))
+ timelog2 = create(:timelog, issue: create(:issue, project: create(:project, group: subgroup)))
+
+ expect(described_class.for_issues_in_group(group)).to contain_exactly(timelog1, timelog2)
+ end
+ end
+
+ describe 'between_dates' do
+ it 'returns collection of timelogs within given dates' do
+ create(:timelog, spent_at: 65.days.ago)
+ timelog1 = create(:timelog, spent_at: 15.days.ago)
+ timelog2 = create(:timelog, spent_at: 5.days.ago)
+ timelogs = described_class.between_dates(20.days.ago, 1.day.ago)
+
+ expect(timelogs).to contain_exactly(timelog1, timelog2)
+ end
+ end
+ end
end