debian-mirror-gitlab/spec/rubocop/cop/group_public_or_visible_to_user_spec.rb

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

27 lines
934 B
Ruby
Raw Normal View History

2019-12-26 22:10:19 +05:30
# frozen_string_literal: true
2022-10-11 01:57:18 +05:30
require 'rubocop_spec_helper'
2018-11-08 19:23:39 +05:30
require_relative '../../../rubocop/cop/group_public_or_visible_to_user'
2021-03-08 18:12:59 +05:30
RSpec.describe RuboCop::Cop::GroupPublicOrVisibleToUser do
2021-03-11 19:13:27 +05:30
let(:msg) do
"`Group.public_or_visible_to_user` should be used with extreme care. " \
"Please ensure that you are not using it on its own and that the amount of rows being filtered is reasonable."
end
2018-11-08 19:23:39 +05:30
it 'flags the use of Group.public_or_visible_to_user with a constant receiver' do
2021-03-11 19:13:27 +05:30
expect_offense(<<~CODE)
Group.public_or_visible_to_user
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ #{msg}
CODE
2018-11-08 19:23:39 +05:30
end
2021-03-11 19:13:27 +05:30
it 'does not flag the use of public_or_visible_to_user with a constant that is not Group' do
expect_no_offenses('Project.public_or_visible_to_user')
2018-11-08 19:23:39 +05:30
end
it 'does not flag the use of Group.public_or_visible_to_user with a send receiver' do
2021-03-11 19:13:27 +05:30
expect_no_offenses('foo.public_or_visible_to_user')
2018-11-08 19:23:39 +05:30
end
end