diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-08-19 12:08:42 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-08-19 12:08:42 +0300 |
commit | b76ae638462ab0f673e5915986070518dd3f9ad3 (patch) | |
tree | bdab0533383b52873be0ec0eb4d3c66598ff8b91 /spec/models/timelog_spec.rb | |
parent | 434373eabe7b4be9593d18a585fb763f1e5f1a6f (diff) |
Add latest changes from gitlab-org/gitlab@14-2-stable-eev14.2.0-rc42
Diffstat (limited to 'spec/models/timelog_spec.rb')
-rw-r--r-- | spec/models/timelog_spec.rb | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/spec/models/timelog_spec.rb b/spec/models/timelog_spec.rb index 9d6fda1d2a9..d6c31307e30 100644 --- a/spec/models/timelog_spec.rb +++ b/spec/models/timelog_spec.rb @@ -70,8 +70,9 @@ RSpec.describe Timelog do let_it_be(:medium_time_ago) { 15.days.ago } let_it_be(:long_time_ago) { 65.days.ago } - let_it_be(:timelog) { create(:issue_timelog, spent_at: long_time_ago) } - let_it_be(:timelog1) { create(:issue_timelog, spent_at: medium_time_ago, issue: group_issue) } + let_it_be(:user) { create(:user) } + let_it_be(:timelog) { create(:issue_timelog, spent_at: long_time_ago, user: user) } + let_it_be(:timelog1) { create(:issue_timelog, spent_at: medium_time_ago, issue: group_issue, user: user) } let_it_be(:timelog2) { create(:issue_timelog, spent_at: short_time_ago, issue: subgroup_issue) } let_it_be(:timelog3) { create(:merge_request_timelog, spent_at: long_time_ago) } let_it_be(:timelog4) { create(:merge_request_timelog, spent_at: medium_time_ago, merge_request: group_merge_request) } @@ -83,6 +84,25 @@ RSpec.describe Timelog do end end + describe '.for_user' do + it 'return timelogs created by user' do + expect(described_class.for_user(user)).to contain_exactly(timelog, timelog1) + end + end + + describe '.in_project' do + it 'returns timelogs created for project issues and merge requests' do + project = create(:project, :empty_repo) + + create(:issue_timelog) + create(:merge_request_timelog) + timelog1 = create(:issue_timelog, issue: create(:issue, project: project)) + timelog2 = create(:merge_request_timelog, merge_request: create(:merge_request, source_project: project)) + + expect(described_class.in_project(project.id)).to contain_exactly(timelog1, timelog2) + end + end + describe '.at_or_after' do it 'returns timelogs at the time limit' do timelogs = described_class.at_or_after(short_time_ago) |