Commit ec76102b authored by Eugenia Grieff's avatar Eugenia Grieff Committed by Thong Kuah

Save epic without touching when reordering

parent b0c6ede1
...@@ -27,7 +27,7 @@ module EpicLinks ...@@ -27,7 +27,7 @@ module EpicLinks
after_epic = Epic.in_parents(epic.parent_id).find(params[:move_after_id]) if params[:move_after_id] after_epic = Epic.in_parents(epic.parent_id).find(params[:move_after_id]) if params[:move_after_id]
epic.move_between(before_epic, after_epic) epic.move_between(before_epic, after_epic)
epic.save! epic.save!(touch: false)
end end
end end
end end
---
title: Change epics reordering to not update timestamps
merge_request: 14441
author:
type: changed
...@@ -23,6 +23,22 @@ describe EpicLinks::UpdateService do ...@@ -23,6 +23,22 @@ describe EpicLinks::UpdateService do
end end
describe '#execute' do describe '#execute' do
shared_examples 'updating timestamps' do
it 'does not update moved epic' do
updated_at = epic_to_move.updated_at
subject
expect(epic_to_move.reload.updated_at.change(usec: 0)).to eq(updated_at.change(usec: 0))
end
it 'does not update parent epic' do
updated_at = parent_epic.updated_at
subject
expect(parent_epic.reload.updated_at.change(usec: 0)).to eq(updated_at.change(usec: 0))
end
end
context 'when params are nil' do context 'when params are nil' do
let(:params) { { move_before_id: nil, move_after_id: nil } } let(:params) { { move_before_id: nil, move_after_id: nil } }
...@@ -35,6 +51,8 @@ describe EpicLinks::UpdateService do ...@@ -35,6 +51,8 @@ describe EpicLinks::UpdateService do
context 'when moving to start' do context 'when moving to start' do
let(:params) { { move_before_id: nil, move_after_id: child_epic1.id } } let(:params) { { move_before_id: nil, move_after_id: child_epic1.id } }
it_behaves_like 'updating timestamps'
it 'reorders child epics' do it 'reorders child epics' do
expect(subject).to include(status: :success) expect(subject).to include(status: :success)
expect(ordered_epics).to eq([child_epic3, child_epic1, child_epic2, child_epic4]) expect(ordered_epics).to eq([child_epic3, child_epic1, child_epic2, child_epic4])
...@@ -44,6 +62,8 @@ describe EpicLinks::UpdateService do ...@@ -44,6 +62,8 @@ describe EpicLinks::UpdateService do
context 'when moving to end' do context 'when moving to end' do
let(:params) { { move_before_id: child_epic4.id, move_after_id: nil } } let(:params) { { move_before_id: child_epic4.id, move_after_id: nil } }
it_behaves_like 'updating timestamps'
it 'reorders child epics' do it 'reorders child epics' do
expect(subject).to include(status: :success) expect(subject).to include(status: :success)
expect(ordered_epics).to eq([child_epic1, child_epic2, child_epic4, child_epic3]) expect(ordered_epics).to eq([child_epic1, child_epic2, child_epic4, child_epic3])
...@@ -53,6 +73,8 @@ describe EpicLinks::UpdateService do ...@@ -53,6 +73,8 @@ describe EpicLinks::UpdateService do
context 'when moving between siblings' do context 'when moving between siblings' do
let(:params) { { move_before_id: child_epic1.id, move_after_id: child_epic2.id } } let(:params) { { move_before_id: child_epic1.id, move_after_id: child_epic2.id } }
it_behaves_like 'updating timestamps'
it 'reorders child epics' do it 'reorders child epics' do
expect(subject).to include(status: :success) expect(subject).to include(status: :success)
expect(ordered_epics).to eq([child_epic1, child_epic3, child_epic2, child_epic4]) expect(ordered_epics).to eq([child_epic1, child_epic3, child_epic2, child_epic4])
......
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