debian-mirror-gitlab/spec/models/concerns/project_api_compatibility_spec.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

60 lines
1.5 KiB
Ruby
Raw Normal View History

2019-09-30 21:07:59 +05:30
# frozen_string_literal: true
require 'spec_helper'
2020-07-28 23:09:34 +05:30
RSpec.describe ProjectAPICompatibility do
2019-09-30 21:07:59 +05:30
let(:project) { create(:project) }
# git_strategy
it "converts build_git_strategy=fetch to build_allow_git_fetch=true" do
project.update!(build_git_strategy: 'fetch')
expect(project.build_allow_git_fetch).to eq(true)
end
it "converts build_git_strategy=clone to build_allow_git_fetch=false" do
project.update!(build_git_strategy: 'clone')
expect(project.build_allow_git_fetch).to eq(false)
end
describe '#auto_devops_enabled' do
where(
initial: [:missing, nil, false, true],
final: [nil, false, true]
)
with_them do
before do
project.build_auto_devops(enabled: initial) unless initial == :missing
end
# Implicit auto devops when enabled is nil
let(:expected) { final.nil? ? true : final }
it 'sets the correct value' do
project.update!(auto_devops_enabled: final)
expect(project.auto_devops_enabled?).to eq(expected)
end
end
end
describe '#auto_devops_deploy_strategy' do
where(
initial: [:missing, *ProjectAutoDevops.deploy_strategies.keys],
final: ProjectAutoDevops.deploy_strategies.keys
)
with_them do
before do
project.build_auto_devops(deploy_strategy: initial) unless initial == :missing
end
it 'sets the correct value' do
project.update!(auto_devops_deploy_strategy: final)
expect(project.auto_devops.deploy_strategy).to eq(final)
end
end
end
end