debian-mirror-gitlab/spec/lib/gitlab/legacy_github_import/label_formatter_spec.rb

37 lines
913 B
Ruby
Raw Normal View History

2020-01-01 13:55:28 +05:30
# frozen_string_literal: true
2016-06-02 11:05:42 +05:30
require 'spec_helper'
2020-07-28 23:09:34 +05:30
RSpec.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