Fix RSpec/NamedSubject in ee_root_controller_spec

What does this MR do and why?

Fixes RSpec/NamedSubject offenses in ee/spec/controllers/ee/root_controller_spec.rb by replacing the anonymous subject reference with controller, the RSpec Rails helper method for accessing the controller instance.

The RSpec/NamedSubject cop flags unnamed subjects to keep specs clear and prevent ambiguous subject references.

# bad
RSpec.describe User do
  subject { described_class.new }

  it 'is valid' do
    expect(subject.valid?).to be(true)
  end
end

# good
RSpec.describe User do
  subject(:user) { described_class.new }

  it 'is valid' do
    expect(user.valid?).to be(true)
  end
end

# also good
RSpec.describe User do
  subject(:user) { described_class.new }

  it { is_expected.to be_valid }
end

This file is listed in .rubocop_todo/rspec/named_subject.yml. Its entry has been removed from the todo list as part of this fix.

Offenses fixed

  • Line 68: allow(subject).to receive(:current_user)allow(controller).to receive(:current_user)

References

Relates to: #589138

MR acceptance checklist

Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

Merge request reports

Loading