Commit 2e504c35 authored by Oswaldo Ferreira's avatar Oswaldo Ferreira

Avoid wrong closing dates being caught by the query on Burndown charts

parent 2f972adc
......@@ -88,7 +88,7 @@ class Burndown
# reopened.
internal_clause =
::Issue
.joins("LEFT OUTER JOIN events e ON issues.id = e.target_id AND e.target_type = 'Issue'")
.joins("LEFT OUTER JOIN events e ON issues.id = e.target_id AND e.target_type = 'Issue' AND e.action = #{Event::CLOSED}") # rubocop:disable GitlabSecurity/SqlInjection
.where(milestone: @milestone)
.where("state = 'closed' OR (state = 'opened' AND e.action = #{Event::CLOSED})") # rubocop:disable GitlabSecurity/SqlInjection
......
---
title: Avoid wrong closing dates being caught by the query on Burndown charts
merge_request:
author:
type: fixed
......@@ -110,6 +110,15 @@ describe Burndown do
# Create issues
issues = create_list(:issue, count, issue_params)
issues.each do |issue|
# Turns out we need to make sure older events that are not "closed"
# won't be caught by the query.
Event.create!(author: user,
target: issue,
created_at: Date.yesterday,
action: Event::CREATED)
end
# Close issues
closed = issues.slice(0..count / 2)
closed.each { |issue| close_issue(issue) }
......
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