2021-04-29 21:17:54 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
RSpec.describe Gitlab::Bullet do
|
2023-03-04 22:38:38 +05:30
|
|
|
context 'with bullet installed' do
|
|
|
|
before do
|
2021-04-29 21:17:54 +05:30
|
|
|
stub_env('ENABLE_BULLET', nil)
|
2023-03-04 22:38:38 +05:30
|
|
|
stub_const('::Bullet', double)
|
2021-04-29 21:17:54 +05:30
|
|
|
end
|
|
|
|
|
2023-03-04 22:38:38 +05:30
|
|
|
describe '#enabled?' do
|
|
|
|
context 'with env enabled' do
|
|
|
|
before do
|
|
|
|
stub_env('ENABLE_BULLET', true)
|
|
|
|
allow(Gitlab.config.bullet).to receive(:enabled).and_return(false)
|
|
|
|
end
|
2021-04-29 21:17:54 +05:30
|
|
|
|
2023-03-04 22:38:38 +05:30
|
|
|
it 'is enabled' do
|
|
|
|
expect(described_class.enabled?).to be(true)
|
|
|
|
end
|
2021-04-29 21:17:54 +05:30
|
|
|
end
|
|
|
|
|
2023-03-04 22:38:38 +05:30
|
|
|
context 'with env disabled' do
|
|
|
|
before do
|
|
|
|
stub_env('ENABLE_BULLET', false)
|
|
|
|
allow(Gitlab.config.bullet).to receive(:enabled).and_return(true)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'is not enabled' do
|
|
|
|
expect(described_class.enabled?).to be(false)
|
|
|
|
end
|
2021-04-29 21:17:54 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2023-03-04 22:38:38 +05:30
|
|
|
describe '#configure_bullet?' do
|
|
|
|
context 'with config enabled' do
|
|
|
|
before do
|
|
|
|
allow(Gitlab.config.bullet).to receive(:enabled).and_return(true)
|
|
|
|
end
|
2021-04-29 21:17:54 +05:30
|
|
|
|
2023-03-04 22:38:38 +05:30
|
|
|
it 'is configurable' do
|
|
|
|
expect(described_class.configure_bullet?).to be(true)
|
|
|
|
end
|
2021-04-29 21:17:54 +05:30
|
|
|
end
|
|
|
|
|
2023-03-04 22:38:38 +05:30
|
|
|
context 'with config disabled' do
|
|
|
|
before do
|
|
|
|
allow(Gitlab.config.bullet).to receive(:enabled).and_return(false)
|
|
|
|
end
|
2021-04-29 21:17:54 +05:30
|
|
|
|
2023-03-04 22:38:38 +05:30
|
|
|
it 'is not configurable' do
|
|
|
|
expect(described_class.configure_bullet?).to be(false)
|
|
|
|
end
|
2021-04-29 21:17:54 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|