Commit ed802649 authored by Stan Hu's avatar Stan Hu

Fix flaky import_export/group/tree_saver_spec.rb spec

The spec previously expected the last board in the serialized response
to be the one with the milestone, but the database may return the boards
in any order. We make the test more robust by searching for the specific
board ID that has the milestone.

Closes https://gitlab.com/gitlab-org/gitlab/issues/208763
parent 61e3e6c2
......@@ -141,15 +141,12 @@ describe Gitlab::ImportExport::Group::TreeSaver do
context 'when there are boards with predefined milestones' do
let(:milestone) { Milestone::Upcoming }
before do
create(:board, group: group, milestone_id: milestone.id)
end
let!(:board_with_milestone) { create(:board, group: group, milestone_id: milestone.id) }
it 'saves the milestone data' do
expect_successful_save(group_tree_saver)
board_data = saved_group_json['boards'].last
board_data = saved_group_json['boards'].find { |board| board['id'] == board_with_milestone.id }
expect(board_data).to include(
'milestone_id' => milestone.id,
......@@ -164,15 +161,12 @@ describe Gitlab::ImportExport::Group::TreeSaver do
context 'when there are boards with persisted milestones' do
let(:milestone) { create(:milestone) }
before do
create(:board, group: group, milestone: milestone)
end
let!(:board_with_milestone) { create(:board, group: group, milestone_id: milestone.id) }
it 'saves the milestone data' do
expect_successful_save(group_tree_saver)
board_data = saved_group_json['boards'].last
board_data = saved_group_json['boards'].find { |board| board['id'] == board_with_milestone.id }
expect(board_data).to include(
'milestone_id' => milestone.id,
......
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