debian-mirror-gitlab/spec/helpers/version_check_helper_spec.rb

38 lines
1.1 KiB
Ruby
Raw Normal View History

2019-12-21 20:55:43 +05:30
# frozen_string_literal: true
2017-08-17 22:00:37 +05:30
require 'spec_helper'
2020-07-28 23:09:34 +05:30
RSpec.describe VersionCheckHelper do
2022-03-02 08:16:31 +05:30
let_it_be(:user) { create(:user) }
2017-08-17 22:00:37 +05:30
2022-03-02 08:16:31 +05:30
describe '#show_version_check?' do
describe 'return conditions' do
where(:enabled, :consent, :is_admin, :result) do
[
[false, false, false, false],
[false, false, true, false],
[false, true, false, false],
[false, true, true, false],
[true, false, false, false],
[true, false, true, true],
[true, true, false, false],
[true, true, true, false]
]
2017-08-17 22:00:37 +05:30
end
2022-03-02 08:16:31 +05:30
with_them do
before do
stub_application_setting(version_check_enabled: enabled)
allow(User).to receive(:single_user).and_return(double(user, requires_usage_stats_consent?: consent))
allow(helper).to receive(:current_user).and_return(user)
allow(user).to receive(:can_read_all_resources?).and_return(is_admin)
end
2017-08-17 22:00:37 +05:30
2022-03-02 08:16:31 +05:30
it 'returns correct results' do
expect(helper.show_version_check?).to eq result
end
2017-08-17 22:00:37 +05:30
end
end
end
end