Commit 3416c705 authored by Felipe Artur's avatar Felipe Artur

Add warning when burndown is not accurate

parent d789295a
class Burndown
attr_accessor :start_date, :due_date, :end_date, :issues_count, :issues_weight, :has_data
attr_reader :start_date, :due_date, :end_date, :issues_count, :issues_weight, :accurate
alias_method :accurate?, :accurate
def initialize(milestone)
@milestone = milestone
......@@ -7,7 +8,7 @@ class Burndown
@due_date = @milestone.due_date
@end_date = @milestone.due_date
@end_date = Date.today if @end_date.present? && @end_date > Date.today
@has_data = issues_with_closed_at.pluck(:closed_at).compact.any?
@accurate = issues_with_closed_at.where(closed_at: nil).empty?
@issues_count, @issues_weight = milestone.issues.reorder(nil).pluck('COUNT(*), COALESCE(SUM(weight), 0)').first
end
......
......@@ -7,6 +7,11 @@
= page_specific_javascript_bundle_tag('common_d3')
= page_specific_javascript_bundle_tag('burndown_chart')
- unless burndown.accurate?
#no-data-warning.settings-message.prepend-top-20
Some issues can't be shown in the burndown chart, as they were closed before GitLab 9.1 update.
= link_to "More information.", help_page_path('workflow/milestones')
- if can_generate_chart
.burndown-header
%h3
......
......@@ -3,12 +3,12 @@ require 'rails_helper'
describe 'Milestone show', feature: true do
let(:user) { create(:user) }
let(:project) { create(:empty_project) }
let(:milestone) { create(:milestone, project: project) }
let(:milestone) { create(:milestone, project: project, start_date: Date.today, due_date: 7.days.from_now) }
let(:labels) { create_list(:label, 2, project: project) }
let(:issue_params) { { project: project, assignee: user, author: user, milestone: milestone, labels: labels } }
before do
project.add_user(user, :developer)
project.add_user(user, :developer)
login_as(user)
end
......@@ -23,4 +23,33 @@ describe 'Milestone show', feature: true do
expect { visit_milestone }.not_to exceed_query_limit(control_count)
end
context 'burndown' do
before { issue_params.delete(:labels) }
context 'when closed issues does not have closed_at value' do
it 'shows warning' do
create(:issue, issue_params)
issue = create(:issue, issue_params)
issue.update(state: 'closed')
issue.update(closed_at: nil)
visit_milestone
expect(page).to have_selector('#no-data-warning')
end
end
context 'data is accurate' do
it 'does not show warning' do
create(:issue, issue_params)
issue = create(:issue, issue_params)
issue.close
visit_milestone
expect(page).not_to have_selector('#no-data-warning')
end
end
end
end
......@@ -60,7 +60,7 @@ describe Burndown, models: true do
it "it sets attribute has_data to true" do
burndown = described_class.new(milestone)
expect(burndown.has_data).to be_truthy
expect(burndown.accurate?).to be_truthy
end
context "when closed and reopened issues does not have closed_at" do
......@@ -79,7 +79,7 @@ describe Burndown, models: true do
it "it sets attribute has_data to false" do
burndown = described_class.new(milestone)
expect(burndown.has_data).to be_falsy
expect(burndown.accurate?).to be_falsy
end
end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment