summaryrefslogtreecommitdiff
path: root/spec/lib/gitlab/github_import/importer/releases_importer_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/lib/gitlab/github_import/importer/releases_importer_spec.rb')
-rw-r--r--spec/lib/gitlab/github_import/importer/releases_importer_spec.rb40
1 files changed, 18 insertions, 22 deletions
diff --git a/spec/lib/gitlab/github_import/importer/releases_importer_spec.rb b/spec/lib/gitlab/github_import/importer/releases_importer_spec.rb
index a1585fd2eb3..0e5419e6c5e 100644
--- a/spec/lib/gitlab/github_import/importer/releases_importer_spec.rb
+++ b/spec/lib/gitlab/github_import/importer/releases_importer_spec.rb
@@ -4,17 +4,17 @@ describe Gitlab::GithubImport::Importer::ReleasesImporter do
let(:project) { create(:project) }
let(:client) { double(:client) }
let(:importer) { described_class.new(project, client) }
- let(:github_release_name) { 'Initial Release' }
let(:created_at) { Time.new(2017, 1, 1, 12, 00) }
+ let(:updated_at) { Time.new(2017, 1, 1, 12, 15) }
let(:released_at) { Time.new(2017, 1, 1, 12, 00) }
- let(:github_release) do
+ let(:release) do
double(
- :github_release,
+ :release,
tag_name: '1.0',
- name: github_release_name,
body: 'This is my release',
created_at: created_at,
+ updated_at: updated_at,
published_at: released_at
)
end
@@ -25,7 +25,7 @@ describe Gitlab::GithubImport::Importer::ReleasesImporter do
tag_name: '1.0',
description: 'This is my release',
created_at: created_at,
- updated_at: created_at,
+ updated_at: updated_at,
released_at: released_at
}
@@ -37,8 +37,8 @@ describe Gitlab::GithubImport::Importer::ReleasesImporter do
end
describe '#build_releases' do
- it 'returns an Array containing release rows' do
- expect(importer).to receive(:each_release).and_return([github_release])
+ it 'returns an Array containnig release rows' do
+ expect(importer).to receive(:each_release).and_return([release])
rows = importer.build_releases
@@ -49,13 +49,13 @@ describe Gitlab::GithubImport::Importer::ReleasesImporter do
it 'does not create releases that already exist' do
create(:release, project: project, tag: '1.0', description: '1.0')
- expect(importer).to receive(:each_release).and_return([github_release])
+ expect(importer).to receive(:each_release).and_return([release])
expect(importer.build_releases).to be_empty
end
it 'uses a default release description if none is provided' do
- expect(github_release).to receive(:body).and_return('')
- expect(importer).to receive(:each_release).and_return([github_release])
+ expect(release).to receive(:body).and_return('')
+ expect(importer).to receive(:each_release).and_return([release])
release = importer.build_releases.first
@@ -64,7 +64,7 @@ describe Gitlab::GithubImport::Importer::ReleasesImporter do
end
describe '#build' do
- let(:release_hash) { importer.build(github_release) }
+ let(:release_hash) { importer.build(release) }
it 'returns the attributes of the release as a Hash' do
expect(release_hash).to be_an_instance_of(Hash)
@@ -88,17 +88,13 @@ describe Gitlab::GithubImport::Importer::ReleasesImporter do
end
it 'includes the updated timestamp' do
- expect(release_hash[:updated_at]).to eq(created_at)
- end
-
- it 'includes the release name' do
- expect(release_hash[:name]).to eq(github_release_name)
+ expect(release_hash[:updated_at]).to eq(updated_at)
end
end
end
describe '#each_release' do
- let(:github_release) { double(:github_release) }
+ let(:release) { double(:release) }
before do
allow(project).to receive(:import_source).and_return('foo/bar')
@@ -106,7 +102,7 @@ describe Gitlab::GithubImport::Importer::ReleasesImporter do
allow(client)
.to receive(:releases)
.with('foo/bar')
- .and_return([github_release].to_enum)
+ .and_return([release].to_enum)
end
it 'returns an Enumerator' do
@@ -114,19 +110,19 @@ describe Gitlab::GithubImport::Importer::ReleasesImporter do
end
it 'yields every release to the Enumerator' do
- expect(importer.each_release.next).to eq(github_release)
+ expect(importer.each_release.next).to eq(release)
end
end
describe '#description_for' do
it 'returns the description when present' do
- expect(importer.description_for(github_release)).to eq(github_release.body)
+ expect(importer.description_for(release)).to eq(release.body)
end
it 'returns a generated description when one is not present' do
- allow(github_release).to receive(:body).and_return('')
+ allow(release).to receive(:body).and_return('')
- expect(importer.description_for(github_release)).to eq('Release for tag 1.0')
+ expect(importer.description_for(release)).to eq('Release for tag 1.0')
end
end
end