diff options
author | Sean McGivern <sean@mcgivern.me.uk> | 2017-11-13 14:25:51 +0300 |
---|---|---|
committer | Sean McGivern <sean@mcgivern.me.uk> | 2017-11-13 14:25:51 +0300 |
commit | 3d24c01a1925475b35d072e0cad971939a9e8564 (patch) | |
tree | 435aa66b67c0b791c9944453b7eff686319cd816 /spec | |
parent | 9b1e9da986267e3d5c910ca523d67f40be7b4878 (diff) | |
parent | 8f6b3d7452447b5ef6c669c2ff5ad3b394e27dea (diff) |
Merge branch '39335-add-time-spend-to-milestones' into 'master'
Add total time spent to milestones
Closes #39335
See merge request gitlab-org/gitlab-ce!15116
Diffstat (limited to 'spec')
-rw-r--r-- | spec/features/milestone_spec.rb | 29 | ||||
-rw-r--r-- | spec/models/concerns/milestoneish_spec.rb | 17 |
2 files changed, 46 insertions, 0 deletions
diff --git a/spec/features/milestone_spec.rb b/spec/features/milestone_spec.rb index 6c9dc67ad74..27efc32c95b 100644 --- a/spec/features/milestone_spec.rb +++ b/spec/features/milestone_spec.rb @@ -65,4 +65,33 @@ feature 'Milestone' do expect(find('.alert-danger')).to have_content('already being used for another group or project milestone.') end end + + feature 'Open a milestone' do + scenario 'shows total issue time spent correctly when no time has been logged' do + milestone = create(:milestone, project: project, title: 8.7) + + visit project_milestone_path(project, milestone) + + page.within('.block.time_spent') do + expect(page).to have_content 'No time spent' + expect(page).to have_content 'None' + end + end + + scenario 'shows total issue time spent' do + milestone = create(:milestone, project: project, title: 8.7) + issue1 = create(:issue, project: project, milestone: milestone) + issue2 = create(:issue, project: project, milestone: milestone) + issue1.spend_time(duration: 3600, user: user) + issue1.save! + issue2.spend_time(duration: 7200, user: user) + issue2.save! + + visit project_milestone_path(project, milestone) + + page.within('.block.time_spent') do + expect(page).to have_content '3h' + end + end + end end diff --git a/spec/models/concerns/milestoneish_spec.rb b/spec/models/concerns/milestoneish_spec.rb index 66353935427..9048da0c73d 100644 --- a/spec/models/concerns/milestoneish_spec.rb +++ b/spec/models/concerns/milestoneish_spec.rb @@ -186,4 +186,21 @@ describe Milestone, 'Milestoneish' do expect(milestone.elapsed_days).to eq(2) end end + + describe '#total_issue_time_spent' do + it 'calculates total issue time spent' do + closed_issue_1.spend_time(duration: 300, user: author) + closed_issue_1.save! + closed_issue_2.spend_time(duration: 600, user: assignee) + closed_issue_2.save! + + expect(milestone.total_issue_time_spent).to eq(900) + end + end + + describe '#human_total_issue_time_spent' do + it 'returns nil if no time has been spent' do + expect(milestone.human_total_issue_time_spent).to be_nil + end + end end |