Commit 23fee68b authored by Mark Chao's avatar Mark Chao

Rename to update_start_and_due_dates for clarity

parent dfc1a7c3
......@@ -82,7 +82,7 @@ module EE
::Group
end
def update_dates(epics)
def update_start_and_due_dates(epics)
groups = epics.includes(:issues).group_by do |epic|
milestone_ids = epic.issues.map(&:milestone_id)
milestone_ids.compact!
......@@ -142,7 +142,7 @@ module EE
# Needed to use EntityDateHelper#remaining_days_in_words
alias_attribute(:due_date, :end_date)
def update_dates
def update_start_and_due_dates
results = Epics::DateSourcingMilestonesFinder.execute(id)
self.start_date = start_date_is_fixed? ? start_date_fixed : results.start_date
......
......@@ -10,7 +10,7 @@ module EE
result = super
if issue.previous_changes.include?(:milestone_id) && issue.epic
issue.epic.update_dates
issue.epic.update_start_and_due_dates
end
result
......
......@@ -10,7 +10,7 @@ module EE
super
if dates_changed?(milestone)
::Epic.update_dates(
::Epic.update_start_and_due_dates(
::Epic.joins(:issues).where(issues: { milestone_id: milestone.id })
)
end
......
......@@ -2,7 +2,7 @@ module EpicIssues
class CreateService < IssuableLinks::CreateService
def execute
result = super
issuable.update_dates
issuable.update_start_and_due_dates
result
end
......
......@@ -2,7 +2,7 @@ module EpicIssues
class DestroyService < IssuableLinks::DestroyService
def execute
result = super
link.epic.update_dates
link.epic.update_start_and_due_dates
result
end
......
......@@ -8,7 +8,7 @@ module Epics
update(epic)
if (params.keys.map(&:to_sym) & [:start_date_fixed, :start_date_is_fixed, :due_date_fixed, :due_date_is_fixed]).present?
epic.update_dates
epic.update_start_and_due_dates
end
epic
......
......@@ -137,12 +137,12 @@ describe Epic do
end
end
describe '#update_dates' do
describe '#update_start_and_due_dates' do
context 'fixed date is set' do
subject { create(:epic, :use_fixed_dates, start_date: nil, end_date: nil) }
it 'updates to fixed date' do
subject.update_dates
subject.update_start_and_due_dates
expect(subject.start_date).to eq(subject.start_date_fixed)
expect(subject.due_date).to eq(subject.due_date_fixed)
......@@ -177,7 +177,7 @@ describe Epic do
context 'complete start and due dates' do
it 'updates to milestone dates' do
subject.update_dates
subject.update_start_and_due_dates
expect(subject.start_date).to eq(milestone1.start_date)
expect(subject.due_date).to eq(milestone2.due_date)
......@@ -201,7 +201,7 @@ describe Epic do
end
it 'updates to milestone dates' do
subject.update_dates
subject.update_start_and_due_dates
expect(subject.start_date).to eq(milestone1.start_date)
expect(subject.due_date).to eq(nil)
......@@ -225,7 +225,7 @@ describe Epic do
end
it 'updates to milestone dates' do
subject.update_dates
subject.update_start_and_due_dates
expect(subject.start_date).to eq(nil)
expect(subject.due_date).to eq(nil)
......@@ -239,7 +239,7 @@ describe Epic do
end
it 'updates to milestone dates' do
subject.update_dates
subject.update_start_and_due_dates
expect(subject.start_date).to eq(nil)
expect(subject.start_date_sourcing_milestone_id).to eq(nil)
......@@ -256,7 +256,7 @@ describe Epic do
context 'complete start and due dates' do
it 'updates to milestone dates' do
subject.update_dates
subject.update_start_and_due_dates
expect(subject.start_date).to eq(milestone1.start_date)
expect(subject.due_date).to eq(milestone1.due_date)
......@@ -273,7 +273,7 @@ describe Epic do
end
it 'updates to milestone dates' do
subject.update_dates
subject.update_start_and_due_dates
expect(subject.start_date).to eq(milestone1.start_date)
expect(subject.due_date).to eq(nil)
......@@ -290,7 +290,7 @@ describe Epic do
end
it 'updates to milestone dates' do
subject.update_dates
subject.update_start_and_due_dates
expect(subject.start_date).to eq(nil)
expect(subject.due_date).to eq(nil)
......@@ -300,7 +300,7 @@ describe Epic do
end
end
describe '.update_dates' do
describe '.update_start_and_due_dates' do
def link_epic_to_milestone(epic, milestone)
create(:issue, epic: epic, milestone: milestone)
end
......@@ -322,7 +322,7 @@ describe Epic do
link_epic_to_milestone(epics[2], milestone1)
link_epic_to_milestone(epics[2], milestone2)
described_class.update_dates(described_class.where(id: epics.map(&:id)))
described_class.update_start_and_due_dates(described_class.where(id: epics.map(&:id)))
epics.each(&:reload)
......@@ -350,7 +350,7 @@ describe Epic do
link_epic_to_milestone(epics[0], milestone)
ActiveRecord::QueryRecorder.new do
described_class.update_dates(described_class.where(id: epics.map(&:id)))
described_class.update_start_and_due_dates(described_class.where(id: epics.map(&:id)))
end.count
end
......@@ -360,7 +360,7 @@ describe Epic do
epics << create(:epic)
expect do
described_class.update_dates(described_class.where(id: epics.map(&:id)))
described_class.update_start_and_due_dates(described_class.where(id: epics.map(&:id)))
end.not_to exceed_query_limit(control_count)
end
......@@ -371,7 +371,7 @@ describe Epic do
link_epic_to_milestone(epics[1], milestone)
expect do
described_class.update_dates(described_class.where(id: epics.map(&:id)))
described_class.update_start_and_due_dates(described_class.where(id: epics.map(&:id)))
end.not_to exceed_query_limit(control_count)
end
end
......
......@@ -18,8 +18,8 @@ describe Issues::UpdateService do
context 'updating milestone' do
let(:milestone) { create(:milestone) }
it 'calls epic#update_dates' do
expect(epic).to receive(:update_dates).twice
it 'calls epic#update_start_and_due_dates' do
expect(epic).to receive(:update_start_and_due_dates).twice
update_issue(milestone: milestone)
update_issue(milestone_id: nil)
......@@ -27,8 +27,8 @@ describe Issues::UpdateService do
end
context 'updating other fields' do
it 'does not call epic#update_dates' do
expect(epic).not_to receive(:update_dates)
it 'does not call epic#update_start_and_due_dates' do
expect(epic).not_to receive(:update_start_and_due_dates)
update_issue(title: 'foo')
end
end
......
......@@ -270,8 +270,8 @@ describe EpicIssues::CreateService do
end
context 'refresh epic dates' do
it 'calls epic#update_dates' do
expect(epic).to receive(:update_dates)
it 'calls epic#update_start_and_due_dates' do
expect(epic).to receive(:update_start_and_due_dates)
assign_issue([valid_reference])
end
......
......@@ -77,8 +77,8 @@ describe EpicIssues::DestroyService do
end
context 'refresh epic dates' do
it 'calls epic#update_dates' do
expect(epic).to receive(:update_dates)
it 'calls epic#update_start_and_due_dates' do
expect(epic).to receive(:update_start_and_due_dates)
subject
end
......
......@@ -130,16 +130,16 @@ describe Epics::UpdateService do
context 'refresh epic dates' do
context 'date fields are updated' do
it 'calls epic#update_dates' do
expect(epic).to receive(:update_dates)
it 'calls epic#update_start_and_due_dates' do
expect(epic).to receive(:update_start_and_due_dates)
update_epic(start_date_is_fixed: true, start_date_fixed: Date.today)
end
end
context 'date fields are not updated' do
it 'does not call epic#update_dates' do
expect(epic).not_to receive(:update_dates)
it 'does not call epic#update_start_and_due_dates' do
expect(epic).not_to receive(:update_start_and_due_dates)
update_epic(title: 'foo')
end
......
......@@ -4,7 +4,7 @@ require 'spec_helper'
describe Milestones::UpdateService do
describe '#execute' do
context 'refresh related epic dates' do
it 'calls epic#update_dates' do
it 'updates milestone sourced dates' do
project = create(:project)
user = build(:user)
milestone = create(:milestone, project: project)
......@@ -14,8 +14,6 @@ describe Milestones::UpdateService do
described_class.new(project, user, { due_date: due_date }).execute(milestone)
epic.reload
expect(epic.reload).to have_attributes(
start_date: nil,
start_date_sourcing_milestone: nil,
......
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