Skip to content
Snippets Groups Projects
Commit d4976829 authored by Robert Speicher's avatar Robert Speicher
Browse files

Auto-correct `RSpec/DescribedClass` violations

parent 0a556523
No related branches found
No related tags found
No related merge requests found
Showing
with 64 additions and 64 deletions
Loading
Loading
@@ -4,7 +4,7 @@ describe ApplicationController do
let(:user) { create(:user) }
 
describe '#check_password_expiration' do
let(:controller) { ApplicationController.new }
let(:controller) { described_class.new }
 
it 'redirects if the user is over their password expiry' do
user.password_expires_at = Time.new(2002)
Loading
Loading
@@ -34,7 +34,7 @@ describe ApplicationController do
 
describe "#authenticate_user_from_token!" do
describe "authenticating a user from a private token" do
controller(ApplicationController) do
controller(described_class) do
def index
render text: "authenticated"
end
Loading
Loading
@@ -66,7 +66,7 @@ describe ApplicationController do
end
 
describe "authenticating a user from a personal access token" do
controller(ApplicationController) do
controller(described_class) do
def index
render text: 'authenticated'
end
Loading
Loading
@@ -115,7 +115,7 @@ describe ApplicationController do
end
 
context 'two-factor authentication' do
let(:controller) { ApplicationController.new }
let(:controller) { described_class.new }
 
describe '#check_two_factor_requirement' do
subject { controller.send :check_two_factor_requirement }
Loading
Loading
Loading
Loading
@@ -16,7 +16,7 @@ describe IssuesFinder do
set(:label_link) { create(:label_link, label: label, target: issue2) }
let(:search_user) { user }
let(:params) { {} }
let(:issues) { IssuesFinder.new(search_user, params.reverse_merge(scope: scope, state: 'opened')).execute }
let(:issues) { described_class.new(search_user, params.reverse_merge(scope: scope, state: 'opened')).execute }
 
before(:context) do
project1.team << [user, :master]
Loading
Loading
@@ -282,15 +282,15 @@ describe IssuesFinder do
let!(:confidential_issue) { create(:issue, project: project, confidential: true) }
 
it 'returns non confidential issues for nil user' do
expect(IssuesFinder.send(:not_restricted_by_confidentiality, nil)).to include(public_issue)
expect(described_class.send(:not_restricted_by_confidentiality, nil)).to include(public_issue)
end
 
it 'returns non confidential issues for user not authorized for the issues projects' do
expect(IssuesFinder.send(:not_restricted_by_confidentiality, user)).to include(public_issue)
expect(described_class.send(:not_restricted_by_confidentiality, user)).to include(public_issue)
end
 
it 'returns all issues for user authorized for the issues projects' do
expect(IssuesFinder.send(:not_restricted_by_confidentiality, authorized_user)).to include(public_issue, confidential_issue)
expect(described_class.send(:not_restricted_by_confidentiality, authorized_user)).to include(public_issue, confidential_issue)
end
end
end
Loading
Loading
@@ -23,26 +23,26 @@ describe MergeRequestsFinder do
describe "#execute" do
it 'filters by scope' do
params = { scope: 'authored', state: 'opened' }
merge_requests = MergeRequestsFinder.new(user, params).execute
merge_requests = described_class.new(user, params).execute
expect(merge_requests.size).to eq(3)
end
 
it 'filters by project' do
params = { project_id: project1.id, scope: 'authored', state: 'opened' }
merge_requests = MergeRequestsFinder.new(user, params).execute
merge_requests = described_class.new(user, params).execute
expect(merge_requests.size).to eq(1)
end
 
it 'filters by non_archived' do
params = { non_archived: true }
merge_requests = MergeRequestsFinder.new(user, params).execute
merge_requests = described_class.new(user, params).execute
expect(merge_requests.size).to eq(3)
end
 
it 'filters by iid' do
params = { project_id: project1.id, iids: merge_request1.iid }
 
merge_requests = MergeRequestsFinder.new(user, params).execute
merge_requests = described_class.new(user, params).execute
 
expect(merge_requests).to contain_exactly(merge_request1)
end
Loading
Loading
Loading
Loading
@@ -14,13 +14,13 @@ describe SnippetsFinder do
let!(:snippet3) { create(:personal_snippet, :public) }
 
it "returns all private and internal snippets" do
snippets = SnippetsFinder.new.execute(user, filter: :all)
snippets = described_class.new.execute(user, filter: :all)
expect(snippets).to include(snippet2, snippet3)
expect(snippets).not_to include(snippet1)
end
 
it "returns all public snippets" do
snippets = SnippetsFinder.new.execute(nil, filter: :all)
snippets = described_class.new.execute(nil, filter: :all)
expect(snippets).to include(snippet3)
expect(snippets).not_to include(snippet1, snippet2)
end
Loading
Loading
@@ -32,7 +32,7 @@ describe SnippetsFinder do
let!(:snippet3) { create(:personal_snippet, :public) }
 
it "returns public public snippets" do
snippets = SnippetsFinder.new.execute(nil, filter: :public)
snippets = described_class.new.execute(nil, filter: :public)
 
expect(snippets).to include(snippet3)
expect(snippets).not_to include(snippet1, snippet2)
Loading
Loading
@@ -45,36 +45,36 @@ describe SnippetsFinder do
let!(:snippet3) { create(:personal_snippet, :public, author: user) }
 
it "returns all public and internal snippets" do
snippets = SnippetsFinder.new.execute(user1, filter: :by_user, user: user)
snippets = described_class.new.execute(user1, filter: :by_user, user: user)
expect(snippets).to include(snippet2, snippet3)
expect(snippets).not_to include(snippet1)
end
 
it "returns internal snippets" do
snippets = SnippetsFinder.new.execute(user, filter: :by_user, user: user, scope: "are_internal")
snippets = described_class.new.execute(user, filter: :by_user, user: user, scope: "are_internal")
expect(snippets).to include(snippet2)
expect(snippets).not_to include(snippet1, snippet3)
end
 
it "returns private snippets" do
snippets = SnippetsFinder.new.execute(user, filter: :by_user, user: user, scope: "are_private")
snippets = described_class.new.execute(user, filter: :by_user, user: user, scope: "are_private")
expect(snippets).to include(snippet1)
expect(snippets).not_to include(snippet2, snippet3)
end
 
it "returns public snippets" do
snippets = SnippetsFinder.new.execute(user, filter: :by_user, user: user, scope: "are_public")
snippets = described_class.new.execute(user, filter: :by_user, user: user, scope: "are_public")
expect(snippets).to include(snippet3)
expect(snippets).not_to include(snippet1, snippet2)
end
 
it "returns all snippets" do
snippets = SnippetsFinder.new.execute(user, filter: :by_user, user: user)
snippets = described_class.new.execute(user, filter: :by_user, user: user)
expect(snippets).to include(snippet1, snippet2, snippet3)
end
 
it "returns only public snippets if unauthenticated user" do
snippets = SnippetsFinder.new.execute(nil, filter: :by_user, user: user)
snippets = described_class.new.execute(nil, filter: :by_user, user: user)
expect(snippets).to include(snippet3)
expect(snippets).not_to include(snippet2, snippet1)
end
Loading
Loading
@@ -88,43 +88,43 @@ describe SnippetsFinder do
end
 
it "returns public snippets for unauthorized user" do
snippets = SnippetsFinder.new.execute(nil, filter: :by_project, project: project1)
snippets = described_class.new.execute(nil, filter: :by_project, project: project1)
expect(snippets).to include(@snippet3)
expect(snippets).not_to include(@snippet1, @snippet2)
end
 
it "returns public and internal snippets for non project members" do
snippets = SnippetsFinder.new.execute(user, filter: :by_project, project: project1)
snippets = described_class.new.execute(user, filter: :by_project, project: project1)
expect(snippets).to include(@snippet2, @snippet3)
expect(snippets).not_to include(@snippet1)
end
 
it "returns public snippets for non project members" do
snippets = SnippetsFinder.new.execute(user, filter: :by_project, project: project1, scope: "are_public")
snippets = described_class.new.execute(user, filter: :by_project, project: project1, scope: "are_public")
expect(snippets).to include(@snippet3)
expect(snippets).not_to include(@snippet1, @snippet2)
end
 
it "returns internal snippets for non project members" do
snippets = SnippetsFinder.new.execute(user, filter: :by_project, project: project1, scope: "are_internal")
snippets = described_class.new.execute(user, filter: :by_project, project: project1, scope: "are_internal")
expect(snippets).to include(@snippet2)
expect(snippets).not_to include(@snippet1, @snippet3)
end
 
it "does not return private snippets for non project members" do
snippets = SnippetsFinder.new.execute(user, filter: :by_project, project: project1, scope: "are_private")
snippets = described_class.new.execute(user, filter: :by_project, project: project1, scope: "are_private")
expect(snippets).not_to include(@snippet1, @snippet2, @snippet3)
end
 
it "returns all snippets for project members" do
project1.team << [user, :developer]
snippets = SnippetsFinder.new.execute(user, filter: :by_project, project: project1)
snippets = described_class.new.execute(user, filter: :by_project, project: project1)
expect(snippets).to include(@snippet1, @snippet2, @snippet3)
end
 
it "returns private snippets for project members" do
project1.team << [user, :developer]
snippets = SnippetsFinder.new.execute(user, filter: :by_project, project: project1, scope: "are_private")
snippets = described_class.new.execute(user, filter: :by_project, project: project1, scope: "are_private")
expect(snippets).to include(@snippet1)
end
end
Loading
Loading
Loading
Loading
@@ -11,7 +11,7 @@ describe Banzai::Renderer do
end
 
describe '#render_field' do
let(:renderer) { Banzai::Renderer }
let(:renderer) { described_class }
subject { renderer.render_field(object, :field) }
 
context 'with a stale cache' do
Loading
Loading
Loading
Loading
@@ -5,7 +5,7 @@ describe Gitlab::ChangesList do
let(:invalid_changes) { 1 }
 
context 'when changes is a valid string' do
let(:changes_list) { Gitlab::ChangesList.new(valid_changes_string) }
let(:changes_list) { described_class.new(valid_changes_string) }
 
it 'splits elements by newline character' do
expect(changes_list).to contain_exactly({
Loading
Loading
Loading
Loading
@@ -3,14 +3,14 @@ require 'spec_helper'
describe Gitlab::Ci::Build::Credentials::Factory do
let(:build) { create(:ci_build, name: 'spinach', stage: 'test', stage_idx: 0) }
 
subject { Gitlab::Ci::Build::Credentials::Factory.new(build).create! }
subject { described_class.new(build).create! }
 
class TestProvider
def initialize(build); end
end
 
before do
allow_any_instance_of(Gitlab::Ci::Build::Credentials::Factory).to receive(:providers).and_return([TestProvider])
allow_any_instance_of(described_class).to receive(:providers).and_return([TestProvider])
end
 
context 'when provider is valid' do
Loading
Loading
Loading
Loading
@@ -4,14 +4,14 @@ describe Gitlab::Ci::Build::Credentials::Registry do
let(:build) { create(:ci_build, name: 'spinach', stage: 'test', stage_idx: 0) }
let(:registry_url) { 'registry.example.com:5005' }
 
subject { Gitlab::Ci::Build::Credentials::Registry.new(build) }
subject { described_class.new(build) }
 
before do
stub_container_registry_config(host_port: registry_url)
end
 
it 'contains valid DockerRegistry credentials' do
expect(subject).to be_kind_of(Gitlab::Ci::Build::Credentials::Registry)
expect(subject).to be_kind_of(described_class)
 
expect(subject.username).to eq 'gitlab-ci-token'
expect(subject.password).to eq build.token
Loading
Loading
@@ -20,7 +20,7 @@ describe Gitlab::Ci::Build::Credentials::Registry do
end
 
describe '.valid?' do
subject { Gitlab::Ci::Build::Credentials::Registry.new(build).valid? }
subject { described_class.new(build).valid? }
 
context 'when registry is enabled' do
before do
Loading
Loading
Loading
Loading
@@ -10,7 +10,7 @@ describe Gitlab::CurrentSettings do
describe '#current_application_settings' do
context 'with DB available' do
before do
allow_any_instance_of(Gitlab::CurrentSettings).to receive(:connect_to_db?).and_return(true)
allow_any_instance_of(described_class).to receive(:connect_to_db?).and_return(true)
end
 
it 'attempts to use cached values first' do
Loading
Loading
@@ -36,7 +36,7 @@ describe Gitlab::CurrentSettings do
 
context 'with DB unavailable' do
before do
allow_any_instance_of(Gitlab::CurrentSettings).to receive(:connect_to_db?).and_return(false)
allow_any_instance_of(described_class).to receive(:connect_to_db?).and_return(false)
end
 
it 'returns an in-memory ApplicationSetting object' do
Loading
Loading
Loading
Loading
@@ -20,7 +20,7 @@ describe Gitlab::CycleAnalytics::BaseEventFetcher do
 
before do
allow_any_instance_of(Gitlab::ReferenceExtractor).to receive(:issues).and_return(Issue.all)
allow_any_instance_of(Gitlab::CycleAnalytics::BaseEventFetcher).to receive(:serialize) do |event|
allow_any_instance_of(described_class).to receive(:serialize) do |event|
event
end
 
Loading
Loading
Loading
Loading
@@ -9,7 +9,7 @@ describe Gitlab::Git::Util do
["foo\n\n", 2],
].each do |string, line_count|
it "counts #{line_count} lines in #{string.inspect}" do
expect(Gitlab::Git::Util.count_lines(string)).to eq(line_count)
expect(described_class.count_lines(string)).to eq(line_count)
end
end
end
Loading
Loading
Loading
Loading
@@ -3,7 +3,7 @@ require 'spec_helper'
describe Gitlab::GitalyClient::Ref do
let(:project) { create(:empty_project) }
let(:repo_path) { project.repository.path_to_repo }
let(:client) { Gitlab::GitalyClient::Ref.new(project.repository) }
let(:client) { described_class.new(project.repository) }
 
before do
allow(Gitlab.config.gitaly).to receive(:enabled).and_return(true)
Loading
Loading
Loading
Loading
@@ -20,7 +20,7 @@ describe Gitlab::LDAP::Person do
it 'uses the configured name attribute and handles values as an array' do
name = 'John Doe'
entry['cn'] = [name]
person = Gitlab::LDAP::Person.new(entry, 'ldapmain')
person = described_class.new(entry, 'ldapmain')
 
expect(person.name).to eq(name)
end
Loading
Loading
@@ -30,7 +30,7 @@ describe Gitlab::LDAP::Person do
it 'returns the value of mail, if present' do
mail = 'john@example.com'
entry['mail'] = mail
person = Gitlab::LDAP::Person.new(entry, 'ldapmain')
person = described_class.new(entry, 'ldapmain')
 
expect(person.email).to eq([mail])
end
Loading
Loading
@@ -38,7 +38,7 @@ describe Gitlab::LDAP::Person do
it 'returns the value of userPrincipalName, if mail and email are not present' do
user_principal_name = 'john.doe@example.com'
entry['userPrincipalName'] = user_principal_name
person = Gitlab::LDAP::Person.new(entry, 'ldapmain')
person = described_class.new(entry, 'ldapmain')
 
expect(person.email).to eq([user_principal_name])
end
Loading
Loading
Loading
Loading
@@ -20,7 +20,7 @@ describe Gitlab::Metrics do
 
expect(pool).to receive(:with).and_yield(connection)
expect(connection).to receive(:write_points).with(an_instance_of(Array))
expect(Gitlab::Metrics).to receive(:pool).and_return(pool)
expect(described_class).to receive(:pool).and_return(pool)
 
described_class.submit_metrics([{ 'series' => 'kittens', 'tags' => {} }])
end
Loading
Loading
@@ -64,7 +64,7 @@ describe Gitlab::Metrics do
describe '.measure' do
context 'without a transaction' do
it 'returns the return value of the block' do
val = Gitlab::Metrics.measure(:foo) { 10 }
val = described_class.measure(:foo) { 10 }
 
expect(val).to eq(10)
end
Loading
Loading
@@ -74,7 +74,7 @@ describe Gitlab::Metrics do
let(:transaction) { Gitlab::Metrics::Transaction.new }
 
before do
allow(Gitlab::Metrics).to receive(:current_transaction).
allow(described_class).to receive(:current_transaction).
and_return(transaction)
end
 
Loading
Loading
@@ -88,11 +88,11 @@ describe Gitlab::Metrics do
expect(transaction).to receive(:increment).
with('foo_call_count', 1)
 
Gitlab::Metrics.measure(:foo) { 10 }
described_class.measure(:foo) { 10 }
end
 
it 'returns the return value of the block' do
val = Gitlab::Metrics.measure(:foo) { 10 }
val = described_class.measure(:foo) { 10 }
 
expect(val).to eq(10)
end
Loading
Loading
@@ -105,7 +105,7 @@ describe Gitlab::Metrics do
expect_any_instance_of(Gitlab::Metrics::Transaction).
not_to receive(:add_tag)
 
Gitlab::Metrics.tag_transaction(:foo, 'bar')
described_class.tag_transaction(:foo, 'bar')
end
end
 
Loading
Loading
@@ -113,13 +113,13 @@ describe Gitlab::Metrics do
let(:transaction) { Gitlab::Metrics::Transaction.new }
 
it 'adds the tag to the transaction' do
expect(Gitlab::Metrics).to receive(:current_transaction).
expect(described_class).to receive(:current_transaction).
and_return(transaction)
 
expect(transaction).to receive(:add_tag).
with(:foo, 'bar')
 
Gitlab::Metrics.tag_transaction(:foo, 'bar')
described_class.tag_transaction(:foo, 'bar')
end
end
end
Loading
Loading
@@ -130,7 +130,7 @@ describe Gitlab::Metrics do
expect_any_instance_of(Gitlab::Metrics::Transaction).
not_to receive(:action=)
 
Gitlab::Metrics.action = 'foo'
described_class.action = 'foo'
end
end
 
Loading
Loading
@@ -138,12 +138,12 @@ describe Gitlab::Metrics do
it 'sets the action of a transaction' do
trans = Gitlab::Metrics::Transaction.new
 
expect(Gitlab::Metrics).to receive(:current_transaction).
expect(described_class).to receive(:current_transaction).
and_return(trans)
 
expect(trans).to receive(:action=).with('foo')
 
Gitlab::Metrics.action = 'foo'
described_class.action = 'foo'
end
end
end
Loading
Loading
@@ -160,7 +160,7 @@ describe Gitlab::Metrics do
expect_any_instance_of(Gitlab::Metrics::Transaction).
not_to receive(:add_event)
 
Gitlab::Metrics.add_event(:meow)
described_class.add_event(:meow)
end
end
 
Loading
Loading
@@ -170,10 +170,10 @@ describe Gitlab::Metrics do
 
expect(transaction).to receive(:add_event).with(:meow)
 
expect(Gitlab::Metrics).to receive(:current_transaction).
expect(described_class).to receive(:current_transaction).
and_return(transaction)
 
Gitlab::Metrics.add_event(:meow)
described_class.add_event(:meow)
end
end
end
Loading
Loading
Loading
Loading
@@ -13,14 +13,14 @@ describe Gitlab::SidekiqThrottler do
 
describe '#execute!' do
it 'sets limits on the selected queues' do
Gitlab::SidekiqThrottler.execute!
described_class.execute!
 
expect(Sidekiq::Queue['build'].limit).to eq 4
expect(Sidekiq::Queue['project_cache'].limit).to eq 4
end
 
it 'does not set limits on other queues' do
Gitlab::SidekiqThrottler.execute!
described_class.execute!
 
expect(Sidekiq::Queue['merge'].limit).to be_nil
end
Loading
Loading
Loading
Loading
@@ -3,7 +3,7 @@ require 'spec_helper'
describe Gitlab::SlashCommands::Dsl do
before :all do
DummyClass = Struct.new(:project) do
include Gitlab::SlashCommands::Dsl
include Gitlab::SlashCommands::Dsl # rubocop:disable RSpec/DescribedClass
 
desc 'A command with no args'
command :no_args, :none do
Loading
Loading
Loading
Loading
@@ -24,7 +24,7 @@ describe Gitlab::Template::GitignoreTemplate do
it 'returns the Gitignore object of a valid file' do
ruby = subject.find('Ruby')
 
expect(ruby).to be_a Gitlab::Template::GitignoreTemplate
expect(ruby).to be_a described_class
expect(ruby.name).to eq('Ruby')
end
end
Loading
Loading
Loading
Loading
@@ -25,7 +25,7 @@ describe Gitlab::Template::GitlabCiYmlTemplate do
it 'returns the GitlabCiYml object of a valid file' do
ruby = subject.find('Ruby')
 
expect(ruby).to be_a Gitlab::Template::GitlabCiYmlTemplate
expect(ruby).to be_a described_class
expect(ruby.name).to eq('Ruby')
end
end
Loading
Loading
Loading
Loading
@@ -37,7 +37,7 @@ describe Gitlab::Template::IssueTemplate do
it 'returns the issue object of a valid file' do
ruby = subject.find('bug', project)
 
expect(ruby).to be_a Gitlab::Template::IssueTemplate
expect(ruby).to be_a described_class
expect(ruby.name).to eq('bug')
end
end
Loading
Loading
Loading
Loading
@@ -37,7 +37,7 @@ describe Gitlab::Template::MergeRequestTemplate do
it 'returns the merge request object of a valid file' do
ruby = subject.find('bug', project)
 
expect(ruby).to be_a Gitlab::Template::MergeRequestTemplate
expect(ruby).to be_a described_class
expect(ruby.name).to eq('bug')
end
end
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment