debian-mirror-gitlab/spec/services/service_ping/permit_data_categories_service_spec.rb
2021-10-27 15:23:28 +05:30

43 lines
1.3 KiB
Ruby

# frozen_string_literal: true
require 'spec_helper'
RSpec.describe ServicePing::PermitDataCategoriesService do
describe '#execute', :without_license do
subject(:permitted_categories) { described_class.new.execute }
context 'when usage ping setting is set to true' do
before do
allow(User).to receive(:single_user).and_return(double(:user, requires_usage_stats_consent?: false))
stub_config_setting(usage_ping_enabled: true)
end
it 'returns all categories' do
expect(permitted_categories).to match_array(%w[standard subscription operational optional])
end
end
context 'when usage ping setting is set to false' do
before do
allow(User).to receive(:single_user).and_return(double(:user, requires_usage_stats_consent?: false))
stub_config_setting(usage_ping_enabled: false)
end
it 'returns no categories' do
expect(permitted_categories).to match_array([])
end
end
context 'when User.single_user&.requires_usage_stats_consent? is required' do
before do
allow(User).to receive(:single_user).and_return(double(:user, requires_usage_stats_consent?: true))
stub_config_setting(usage_ping_enabled: true)
end
it 'returns no categories' do
expect(permitted_categories).to match_array([])
end
end
end
end