2016-06-02 11:05:42 +05:30
|
|
|
require 'spec_helper'
|
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
describe Gitlab::LegacyGithubImport::LabelFormatter do
|
2017-09-10 17:25:29 +05:30
|
|
|
let(:project) { create(:project) }
|
2016-09-29 09:46:39 +05:30
|
|
|
let(:raw) { double(name: 'improvements', color: 'e6e6e6') }
|
2016-06-02 11:05:42 +05:30
|
|
|
|
2016-09-29 09:46:39 +05:30
|
|
|
subject { described_class.new(project, raw) }
|
2016-06-02 11:05:42 +05:30
|
|
|
|
2016-09-29 09:46:39 +05:30
|
|
|
describe '#attributes' do
|
|
|
|
it 'returns formatted attributes' do
|
|
|
|
expect(subject.attributes).to eq({
|
2016-06-02 11:05:42 +05:30
|
|
|
project: project,
|
|
|
|
title: 'improvements',
|
|
|
|
color: '#e6e6e6'
|
|
|
|
})
|
|
|
|
end
|
|
|
|
end
|
2016-09-29 09:46:39 +05:30
|
|
|
|
|
|
|
describe '#create!' do
|
|
|
|
context 'when label does not exist' do
|
|
|
|
it 'creates a new label' do
|
|
|
|
expect { subject.create! }.to change(Label, :count).by(1)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when label exists' do
|
|
|
|
it 'does not create a new label' do
|
2017-08-17 22:00:37 +05:30
|
|
|
Labels::CreateService.new(name: raw.name).execute(project: project)
|
2016-09-29 09:46:39 +05:30
|
|
|
|
|
|
|
expect { subject.create! }.not_to change(Label, :count)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2016-06-02 11:05:42 +05:30
|
|
|
end
|