Welcome to mirror list, hosted at ThFree Co, Russian Federation.

group_public_or_visible_to_user_spec.rb « cop « rubocop « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 2348552f9e47d1e981dad0e3e6a4fbb4a932b8bd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# frozen_string_literal: true

require 'fast_spec_helper'
require_relative '../../../rubocop/cop/group_public_or_visible_to_user'

RSpec.describe RuboCop::Cop::GroupPublicOrVisibleToUser do
  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

  subject(:cop) { described_class.new }

  it 'flags the use of Group.public_or_visible_to_user with a constant receiver' do
    expect_offense(<<~CODE)
      Group.public_or_visible_to_user
      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ #{msg}
    CODE
  end

  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')
  end

  it 'does not flag the use of Group.public_or_visible_to_user with a send receiver' do
    expect_no_offenses('foo.public_or_visible_to_user')
  end
end