2020-03-05 15:07:52 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
require 'spec_helper'
|
|
|
|
require Rails.root.join('db', 'migrate', '20200304160801_delete_template_services_duplicated_by_type.rb')
|
|
|
|
|
2020-03-11 21:09:19 +00:00
|
|
|
describe DeleteTemplateServicesDuplicatedByType do
|
2020-03-05 15:07:52 +00:00
|
|
|
let(:services) { table(:services) }
|
|
|
|
|
|
|
|
before do
|
|
|
|
services.create!(template: true, type: 'JenkinsService')
|
|
|
|
services.create!(template: true, type: 'JenkinsService')
|
|
|
|
services.create!(template: true, type: 'JiraService')
|
|
|
|
services.create!(template: true, type: 'JenkinsService')
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'deletes service templates duplicated by type except the one with the lowest ID' do
|
|
|
|
jenkins_service_id = services.where(type: 'JenkinsService').order(:id).pluck(:id).first
|
|
|
|
jira_service_id = services.where(type: 'JiraService').pluck(:id).first
|
|
|
|
|
|
|
|
migrate!
|
|
|
|
|
|
|
|
expect(services.pluck(:id)).to contain_exactly(jenkins_service_id, jira_service_id)
|
|
|
|
end
|
|
|
|
end
|