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

user_admin_spec.rb « cop « rubocop « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 3bf458348f3da079c51339683a52239970b9bcd2 (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
# frozen_string_literal: true

require 'fast_spec_helper'

require 'rubocop'
require_relative '../../../rubocop/cop/user_admin'

RSpec.describe RuboCop::Cop::UserAdmin do
  subject(:cop) { described_class.new }

  it 'flags a method call' do
    expect_offense(<<~SOURCE)
      user.admin?
           ^^^^^^ #{described_class::MSG}
    SOURCE
  end

  it 'flags a method call with safe operator' do
    expect_offense(<<~SOURCE)
      user&.admin?
            ^^^^^^ #{described_class::MSG}
    SOURCE
  end
end