Commit 91ebc5cd authored by Bob Van Landuyt's avatar Bob Van Landuyt

Merge branch 'sh-github-import-handle-nil-dates' into 'master'

GitHub import: Handle nil published_at dates

Closes #33732

See merge request gitlab-org/gitlab!18355
parents b93dda6e e37b3d15
---
title: 'GitHub import: Handle nil published_at dates'
merge_request: 18355
author:
type: fixed
......@@ -37,7 +37,8 @@ module Gitlab
description: description_for(release),
created_at: release.created_at,
updated_at: release.created_at,
released_at: release.published_at,
# Draft releases will have a null published_at
released_at: release.published_at || Time.current,
project_id: project.id
}
end
......
......@@ -10,7 +10,8 @@ module Gitlab
name: raw_data.name,
description: raw_data.body,
created_at: raw_data.created_at,
released_at: raw_data.published_at,
# Draft releases will have a null published_at
released_at: raw_data.published_at || Time.current,
updated_at: raw_data.created_at
}
end
......
......@@ -34,6 +34,22 @@ describe Gitlab::GithubImport::Importer::ReleasesImporter do
importer.execute
end
it 'imports draft releases' do
release_double = double(
name: 'Test',
body: 'This is description',
tag_name: '1.0',
description: 'This is my release',
created_at: created_at,
updated_at: created_at,
published_at: nil
)
expect(importer).to receive(:each_release).and_return([release_double])
expect { importer.execute }.to change { Release.count }.by(1)
end
end
describe '#build_releases' do
......
......@@ -37,6 +37,14 @@ describe Gitlab::LegacyGithubImport::ReleaseFormatter do
expect(release.attributes).to eq(expected)
end
context 'with a nil published_at date' do
let(:published_at) { nil }
it 'inserts a timestamp for released_at' do
expect(release.attributes[:released_at]).to be_a(Time)
end
end
end
describe '#valid' do
......
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