Commit d4976829 authored by Robert Speicher's avatar Robert Speicher

Auto-correct `RSpec/DescribedClass` violations

parent 0a556523
...@@ -4,7 +4,7 @@ describe ApplicationController do ...@@ -4,7 +4,7 @@ describe ApplicationController do
let(:user) { create(:user) } let(:user) { create(:user) }
describe '#check_password_expiration' do 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 it 'redirects if the user is over their password expiry' do
user.password_expires_at = Time.new(2002) user.password_expires_at = Time.new(2002)
...@@ -34,7 +34,7 @@ describe ApplicationController do ...@@ -34,7 +34,7 @@ describe ApplicationController do
describe "#authenticate_user_from_token!" do describe "#authenticate_user_from_token!" do
describe "authenticating a user from a private token" do describe "authenticating a user from a private token" do
controller(ApplicationController) do controller(described_class) do
def index def index
render text: "authenticated" render text: "authenticated"
end end
...@@ -66,7 +66,7 @@ describe ApplicationController do ...@@ -66,7 +66,7 @@ describe ApplicationController do
end end
describe "authenticating a user from a personal access token" do describe "authenticating a user from a personal access token" do
controller(ApplicationController) do controller(described_class) do
def index def index
render text: 'authenticated' render text: 'authenticated'
end end
...@@ -115,7 +115,7 @@ describe ApplicationController do ...@@ -115,7 +115,7 @@ describe ApplicationController do
end end
context 'two-factor authentication' do context 'two-factor authentication' do
let(:controller) { ApplicationController.new } let(:controller) { described_class.new }
describe '#check_two_factor_requirement' do describe '#check_two_factor_requirement' do
subject { controller.send :check_two_factor_requirement } subject { controller.send :check_two_factor_requirement }
......
...@@ -16,7 +16,7 @@ describe IssuesFinder do ...@@ -16,7 +16,7 @@ describe IssuesFinder do
set(:label_link) { create(:label_link, label: label, target: issue2) } set(:label_link) { create(:label_link, label: label, target: issue2) }
let(:search_user) { user } let(:search_user) { user }
let(:params) { {} } 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 before(:context) do
project1.team << [user, :master] project1.team << [user, :master]
...@@ -282,15 +282,15 @@ describe IssuesFinder do ...@@ -282,15 +282,15 @@ describe IssuesFinder do
let!(:confidential_issue) { create(:issue, project: project, confidential: true) } let!(:confidential_issue) { create(:issue, project: project, confidential: true) }
it 'returns non confidential issues for nil user' do 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 end
it 'returns non confidential issues for user not authorized for the issues projects' do 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 end
it 'returns all issues for user authorized for the issues projects' do 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 end
end end
...@@ -23,26 +23,26 @@ describe MergeRequestsFinder do ...@@ -23,26 +23,26 @@ describe MergeRequestsFinder do
describe "#execute" do describe "#execute" do
it 'filters by scope' do it 'filters by scope' do
params = { scope: 'authored', state: 'opened' } 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) expect(merge_requests.size).to eq(3)
end end
it 'filters by project' do it 'filters by project' do
params = { project_id: project1.id, scope: 'authored', state: 'opened' } 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) expect(merge_requests.size).to eq(1)
end end
it 'filters by non_archived' do it 'filters by non_archived' do
params = { non_archived: true } 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) expect(merge_requests.size).to eq(3)
end end
it 'filters by iid' do it 'filters by iid' do
params = { project_id: project1.id, iids: merge_request1.iid } 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) expect(merge_requests).to contain_exactly(merge_request1)
end end
......
...@@ -14,13 +14,13 @@ describe SnippetsFinder do ...@@ -14,13 +14,13 @@ describe SnippetsFinder do
let!(:snippet3) { create(:personal_snippet, :public) } let!(:snippet3) { create(:personal_snippet, :public) }
it "returns all private and internal snippets" do 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).to include(snippet2, snippet3)
expect(snippets).not_to include(snippet1) expect(snippets).not_to include(snippet1)
end end
it "returns all public snippets" do 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).to include(snippet3)
expect(snippets).not_to include(snippet1, snippet2) expect(snippets).not_to include(snippet1, snippet2)
end end
...@@ -32,7 +32,7 @@ describe SnippetsFinder do ...@@ -32,7 +32,7 @@ describe SnippetsFinder do
let!(:snippet3) { create(:personal_snippet, :public) } let!(:snippet3) { create(:personal_snippet, :public) }
it "returns public public snippets" do 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).to include(snippet3)
expect(snippets).not_to include(snippet1, snippet2) expect(snippets).not_to include(snippet1, snippet2)
...@@ -45,36 +45,36 @@ describe SnippetsFinder do ...@@ -45,36 +45,36 @@ describe SnippetsFinder do
let!(:snippet3) { create(:personal_snippet, :public, author: user) } let!(:snippet3) { create(:personal_snippet, :public, author: user) }
it "returns all public and internal snippets" do 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).to include(snippet2, snippet3)
expect(snippets).not_to include(snippet1) expect(snippets).not_to include(snippet1)
end end
it "returns internal snippets" do 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).to include(snippet2)
expect(snippets).not_to include(snippet1, snippet3) expect(snippets).not_to include(snippet1, snippet3)
end end
it "returns private snippets" do 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).to include(snippet1)
expect(snippets).not_to include(snippet2, snippet3) expect(snippets).not_to include(snippet2, snippet3)
end end
it "returns public snippets" do 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).to include(snippet3)
expect(snippets).not_to include(snippet1, snippet2) expect(snippets).not_to include(snippet1, snippet2)
end end
it "returns all snippets" do 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) expect(snippets).to include(snippet1, snippet2, snippet3)
end end
it "returns only public snippets if unauthenticated user" do 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).to include(snippet3)
expect(snippets).not_to include(snippet2, snippet1) expect(snippets).not_to include(snippet2, snippet1)
end end
...@@ -88,43 +88,43 @@ describe SnippetsFinder do ...@@ -88,43 +88,43 @@ describe SnippetsFinder do
end end
it "returns public snippets for unauthorized user" do 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).to include(@snippet3)
expect(snippets).not_to include(@snippet1, @snippet2) expect(snippets).not_to include(@snippet1, @snippet2)
end end
it "returns public and internal snippets for non project members" do 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).to include(@snippet2, @snippet3)
expect(snippets).not_to include(@snippet1) expect(snippets).not_to include(@snippet1)
end end
it "returns public snippets for non project members" do 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).to include(@snippet3)
expect(snippets).not_to include(@snippet1, @snippet2) expect(snippets).not_to include(@snippet1, @snippet2)
end end
it "returns internal snippets for non project members" do 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).to include(@snippet2)
expect(snippets).not_to include(@snippet1, @snippet3) expect(snippets).not_to include(@snippet1, @snippet3)
end end
it "does not return private snippets for non project members" do 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) expect(snippets).not_to include(@snippet1, @snippet2, @snippet3)
end end
it "returns all snippets for project members" do it "returns all snippets for project members" do
project1.team << [user, :developer] 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) expect(snippets).to include(@snippet1, @snippet2, @snippet3)
end end
it "returns private snippets for project members" do it "returns private snippets for project members" do
project1.team << [user, :developer] 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) expect(snippets).to include(@snippet1)
end end
end end
......
...@@ -11,7 +11,7 @@ describe Banzai::Renderer do ...@@ -11,7 +11,7 @@ describe Banzai::Renderer do
end end
describe '#render_field' do describe '#render_field' do
let(:renderer) { Banzai::Renderer } let(:renderer) { described_class }
subject { renderer.render_field(object, :field) } subject { renderer.render_field(object, :field) }
context 'with a stale cache' do context 'with a stale cache' do
......
...@@ -5,7 +5,7 @@ describe Gitlab::ChangesList do ...@@ -5,7 +5,7 @@ describe Gitlab::ChangesList do
let(:invalid_changes) { 1 } let(:invalid_changes) { 1 }
context 'when changes is a valid string' do 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 it 'splits elements by newline character' do
expect(changes_list).to contain_exactly({ expect(changes_list).to contain_exactly({
......
...@@ -3,14 +3,14 @@ require 'spec_helper' ...@@ -3,14 +3,14 @@ require 'spec_helper'
describe Gitlab::Ci::Build::Credentials::Factory do describe Gitlab::Ci::Build::Credentials::Factory do
let(:build) { create(:ci_build, name: 'spinach', stage: 'test', stage_idx: 0) } 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 class TestProvider
def initialize(build); end def initialize(build); end
end end
before do 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 end
context 'when provider is valid' do context 'when provider is valid' do
......
...@@ -4,14 +4,14 @@ describe Gitlab::Ci::Build::Credentials::Registry do ...@@ -4,14 +4,14 @@ describe Gitlab::Ci::Build::Credentials::Registry do
let(:build) { create(:ci_build, name: 'spinach', stage: 'test', stage_idx: 0) } let(:build) { create(:ci_build, name: 'spinach', stage: 'test', stage_idx: 0) }
let(:registry_url) { 'registry.example.com:5005' } let(:registry_url) { 'registry.example.com:5005' }
subject { Gitlab::Ci::Build::Credentials::Registry.new(build) } subject { described_class.new(build) }
before do before do
stub_container_registry_config(host_port: registry_url) stub_container_registry_config(host_port: registry_url)
end end
it 'contains valid DockerRegistry credentials' do 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.username).to eq 'gitlab-ci-token'
expect(subject.password).to eq build.token expect(subject.password).to eq build.token
...@@ -20,7 +20,7 @@ describe Gitlab::Ci::Build::Credentials::Registry do ...@@ -20,7 +20,7 @@ describe Gitlab::Ci::Build::Credentials::Registry do
end end
describe '.valid?' do describe '.valid?' do
subject { Gitlab::Ci::Build::Credentials::Registry.new(build).valid? } subject { described_class.new(build).valid? }
context 'when registry is enabled' do context 'when registry is enabled' do
before do before do
......
...@@ -10,7 +10,7 @@ describe Gitlab::CurrentSettings do ...@@ -10,7 +10,7 @@ describe Gitlab::CurrentSettings do
describe '#current_application_settings' do describe '#current_application_settings' do
context 'with DB available' do context 'with DB available' do
before 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 end
it 'attempts to use cached values first' do it 'attempts to use cached values first' do
...@@ -36,7 +36,7 @@ describe Gitlab::CurrentSettings do ...@@ -36,7 +36,7 @@ describe Gitlab::CurrentSettings do
context 'with DB unavailable' do context 'with DB unavailable' do
before 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 end
it 'returns an in-memory ApplicationSetting object' do it 'returns an in-memory ApplicationSetting object' do
......
...@@ -20,7 +20,7 @@ describe Gitlab::CycleAnalytics::BaseEventFetcher do ...@@ -20,7 +20,7 @@ describe Gitlab::CycleAnalytics::BaseEventFetcher do
before do before do
allow_any_instance_of(Gitlab::ReferenceExtractor).to receive(:issues).and_return(Issue.all) 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 event
end end
......
...@@ -9,7 +9,7 @@ describe Gitlab::Git::Util do ...@@ -9,7 +9,7 @@ describe Gitlab::Git::Util do
["foo\n\n", 2], ["foo\n\n", 2],
].each do |string, line_count| ].each do |string, line_count|
it "counts #{line_count} lines in #{string.inspect}" do 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 end
end end
......
...@@ -3,7 +3,7 @@ require 'spec_helper' ...@@ -3,7 +3,7 @@ require 'spec_helper'
describe Gitlab::GitalyClient::Ref do describe Gitlab::GitalyClient::Ref do
let(:project) { create(:empty_project) } let(:project) { create(:empty_project) }
let(:repo_path) { project.repository.path_to_repo } 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 before do
allow(Gitlab.config.gitaly).to receive(:enabled).and_return(true) allow(Gitlab.config.gitaly).to receive(:enabled).and_return(true)
......
...@@ -20,7 +20,7 @@ describe Gitlab::LDAP::Person do ...@@ -20,7 +20,7 @@ describe Gitlab::LDAP::Person do
it 'uses the configured name attribute and handles values as an array' do it 'uses the configured name attribute and handles values as an array' do
name = 'John Doe' name = 'John Doe'
entry['cn'] = [name] entry['cn'] = [name]
person = Gitlab::LDAP::Person.new(entry, 'ldapmain') person = described_class.new(entry, 'ldapmain')
expect(person.name).to eq(name) expect(person.name).to eq(name)
end end
...@@ -30,7 +30,7 @@ describe Gitlab::LDAP::Person do ...@@ -30,7 +30,7 @@ describe Gitlab::LDAP::Person do
it 'returns the value of mail, if present' do it 'returns the value of mail, if present' do
mail = 'john@example.com' mail = 'john@example.com'
entry['mail'] = mail entry['mail'] = mail
person = Gitlab::LDAP::Person.new(entry, 'ldapmain') person = described_class.new(entry, 'ldapmain')
expect(person.email).to eq([mail]) expect(person.email).to eq([mail])
end end
...@@ -38,7 +38,7 @@ describe Gitlab::LDAP::Person do ...@@ -38,7 +38,7 @@ describe Gitlab::LDAP::Person do
it 'returns the value of userPrincipalName, if mail and email are not present' do it 'returns the value of userPrincipalName, if mail and email are not present' do
user_principal_name = 'john.doe@example.com' user_principal_name = 'john.doe@example.com'
entry['userPrincipalName'] = user_principal_name 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]) expect(person.email).to eq([user_principal_name])
end end
......
...@@ -20,7 +20,7 @@ describe Gitlab::Metrics do ...@@ -20,7 +20,7 @@ describe Gitlab::Metrics do
expect(pool).to receive(:with).and_yield(connection) expect(pool).to receive(:with).and_yield(connection)
expect(connection).to receive(:write_points).with(an_instance_of(Array)) 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' => {} }]) described_class.submit_metrics([{ 'series' => 'kittens', 'tags' => {} }])
end end
...@@ -64,7 +64,7 @@ describe Gitlab::Metrics do ...@@ -64,7 +64,7 @@ describe Gitlab::Metrics do
describe '.measure' do describe '.measure' do
context 'without a transaction' do context 'without a transaction' do
it 'returns the return value of the block' 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) expect(val).to eq(10)
end end
...@@ -74,7 +74,7 @@ describe Gitlab::Metrics do ...@@ -74,7 +74,7 @@ describe Gitlab::Metrics do
let(:transaction) { Gitlab::Metrics::Transaction.new } let(:transaction) { Gitlab::Metrics::Transaction.new }
before do before do
allow(Gitlab::Metrics).to receive(:current_transaction). allow(described_class).to receive(:current_transaction).
and_return(transaction) and_return(transaction)
end end
...@@ -88,11 +88,11 @@ describe Gitlab::Metrics do ...@@ -88,11 +88,11 @@ describe Gitlab::Metrics do
expect(transaction).to receive(:increment). expect(transaction).to receive(:increment).
with('foo_call_count', 1) with('foo_call_count', 1)
Gitlab::Metrics.measure(:foo) { 10 } described_class.measure(:foo) { 10 }
end end
it 'returns the return value of the block' 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) expect(val).to eq(10)
end end
...@@ -105,7 +105,7 @@ describe Gitlab::Metrics do ...@@ -105,7 +105,7 @@ describe Gitlab::Metrics do
expect_any_instance_of(Gitlab::Metrics::Transaction). expect_any_instance_of(Gitlab::Metrics::Transaction).
not_to receive(:add_tag) not_to receive(:add_tag)
Gitlab::Metrics.tag_transaction(:foo, 'bar') described_class.tag_transaction(:foo, 'bar')
end end
end end
...@@ -113,13 +113,13 @@ describe Gitlab::Metrics do ...@@ -113,13 +113,13 @@ describe Gitlab::Metrics do
let(:transaction) { Gitlab::Metrics::Transaction.new } let(:transaction) { Gitlab::Metrics::Transaction.new }
it 'adds the tag to the transaction' do 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) and_return(transaction)
expect(transaction).to receive(:add_tag). expect(transaction).to receive(:add_tag).
with(:foo, 'bar') with(:foo, 'bar')
Gitlab::Metrics.tag_transaction(:foo, 'bar') described_class.tag_transaction(:foo, 'bar')
end end
end end
end end
...@@ -130,7 +130,7 @@ describe Gitlab::Metrics do ...@@ -130,7 +130,7 @@ describe Gitlab::Metrics do
expect_any_instance_of(Gitlab::Metrics::Transaction). expect_any_instance_of(Gitlab::Metrics::Transaction).
not_to receive(:action=) not_to receive(:action=)
Gitlab::Metrics.action = 'foo' described_class.action = 'foo'
end end
end end
...@@ -138,12 +138,12 @@ describe Gitlab::Metrics do ...@@ -138,12 +138,12 @@ describe Gitlab::Metrics do
it 'sets the action of a transaction' do it 'sets the action of a transaction' do
trans = Gitlab::Metrics::Transaction.new trans = Gitlab::Metrics::Transaction.new
expect(Gitlab::Metrics).to receive(:current_transaction). expect(described_class).to receive(:current_transaction).
and_return(trans) and_return(trans)
expect(trans).to receive(:action=).with('foo') expect(trans).to receive(:action=).with('foo')
Gitlab::Metrics.action = 'foo' described_class.action = 'foo'
end end
end end
end end
...@@ -160,7 +160,7 @@ describe Gitlab::Metrics do ...@@ -160,7 +160,7 @@ describe Gitlab::Metrics do
expect_any_instance_of(Gitlab::Metrics::Transaction). expect_any_instance_of(Gitlab::Metrics::Transaction).
not_to receive(:add_event) not_to receive(:add_event)
Gitlab::Metrics.add_event(:meow) described_class.add_event(:meow)
end end
end end
...@@ -170,10 +170,10 @@ describe Gitlab::Metrics do ...@@ -170,10 +170,10 @@ describe Gitlab::Metrics do
expect(transaction).to receive(:add_event).with(:meow) 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) and_return(transaction)
Gitlab::Metrics.add_event(:meow) described_class.add_event(:meow)
end end
end end
end end
......
...@@ -13,14 +13,14 @@ describe Gitlab::SidekiqThrottler do ...@@ -13,14 +13,14 @@ describe Gitlab::SidekiqThrottler do
describe '#execute!' do describe '#execute!' do
it 'sets limits on the selected queues' 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['build'].limit).to eq 4
expect(Sidekiq::Queue['project_cache'].limit).to eq 4 expect(Sidekiq::Queue['project_cache'].limit).to eq 4
end end
it 'does not set limits on other queues' do it 'does not set limits on other queues' do
Gitlab::SidekiqThrottler.execute! described_class.execute!
expect(Sidekiq::Queue['merge'].limit).to be_nil expect(Sidekiq::Queue['merge'].limit).to be_nil
end end
......
...@@ -3,7 +3,7 @@ require 'spec_helper' ...@@ -3,7 +3,7 @@ require 'spec_helper'
describe Gitlab::SlashCommands::Dsl do describe Gitlab::SlashCommands::Dsl do
before :all do before :all do
DummyClass = Struct.new(:project) do DummyClass = Struct.new(:project) do
include Gitlab::SlashCommands::Dsl include Gitlab::SlashCommands::Dsl # rubocop:disable RSpec/DescribedClass
desc 'A command with no args' desc 'A command with no args'
command :no_args, :none do command :no_args, :none do
......
...@@ -24,7 +24,7 @@ describe Gitlab::Template::GitignoreTemplate do ...@@ -24,7 +24,7 @@ describe Gitlab::Template::GitignoreTemplate do
it 'returns the Gitignore object of a valid file' do it 'returns the Gitignore object of a valid file' do
ruby = subject.find('Ruby') 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') expect(ruby.name).to eq('Ruby')
end end
end end
......
...@@ -25,7 +25,7 @@ describe Gitlab::Template::GitlabCiYmlTemplate do ...@@ -25,7 +25,7 @@ describe Gitlab::Template::GitlabCiYmlTemplate do
it 'returns the GitlabCiYml object of a valid file' do it 'returns the GitlabCiYml object of a valid file' do
ruby = subject.find('Ruby') 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') expect(ruby.name).to eq('Ruby')
end end
end end
......
...@@ -37,7 +37,7 @@ describe Gitlab::Template::IssueTemplate do ...@@ -37,7 +37,7 @@ describe Gitlab::Template::IssueTemplate do
it 'returns the issue object of a valid file' do it 'returns the issue object of a valid file' do
ruby = subject.find('bug', project) 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') expect(ruby.name).to eq('bug')
end end
end end
......
...@@ -37,7 +37,7 @@ describe Gitlab::Template::MergeRequestTemplate do ...@@ -37,7 +37,7 @@ describe Gitlab::Template::MergeRequestTemplate do
it 'returns the merge request object of a valid file' do it 'returns the merge request object of a valid file' do
ruby = subject.find('bug', project) 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') expect(ruby.name).to eq('bug')
end end
end end
......
...@@ -6,7 +6,7 @@ describe Gitlab::UsageData do ...@@ -6,7 +6,7 @@ describe Gitlab::UsageData do
let!(:board) { create(:board, project: project) } let!(:board) { create(:board, project: project) }
describe '#data' do describe '#data' do
subject { Gitlab::UsageData.data } subject { described_class.data }
it "gathers usage data" do it "gathers usage data" do
expect(subject.keys).to match_array(%i( expect(subject.keys).to match_array(%i(
...@@ -58,7 +58,7 @@ describe Gitlab::UsageData do ...@@ -58,7 +58,7 @@ describe Gitlab::UsageData do
end end
describe '#license_usage_data' do describe '#license_usage_data' do
subject { Gitlab::UsageData.license_usage_data } subject { described_class.license_usage_data }
it "gathers license data" do it "gathers license data" do
expect(subject[:uuid]).to eq(current_application_settings.uuid) expect(subject[:uuid]).to eq(current_application_settings.uuid)
......
This diff is collapsed.
require 'spec_helper' require 'spec_helper'
describe ::API::Helpers::InternalHelpers do describe ::API::Helpers::InternalHelpers do
include ::API::Helpers::InternalHelpers include described_class
describe '.clean_project_path' do describe '.clean_project_path' do
project = 'namespace/project' project = 'namespace/project'
......
...@@ -2,7 +2,7 @@ require 'spec_helper' ...@@ -2,7 +2,7 @@ require 'spec_helper'
describe API::Helpers do describe API::Helpers do
include API::APIGuard::HelperMethods include API::APIGuard::HelperMethods
include API::Helpers include described_class
include SentryHelper include SentryHelper
let(:user) { create(:user) } let(:user) { create(:user) }
......
...@@ -2,7 +2,7 @@ require "spec_helper" ...@@ -2,7 +2,7 @@ require "spec_helper"
describe MergeRequests::GetUrlsService do describe MergeRequests::GetUrlsService do
let(:project) { create(:project, :public, :repository) } let(:project) { create(:project, :public, :repository) }
let(:service) { MergeRequests::GetUrlsService.new(project) } let(:service) { described_class.new(project) }
let(:source_branch) { "my_branch" } let(:source_branch) { "my_branch" }
let(:new_merge_request_url) { "http://#{Gitlab.config.gitlab.host}/#{project.namespace.name}/#{project.path}/merge_requests/new?merge_request%5Bsource_branch%5D=#{source_branch}" } let(:new_merge_request_url) { "http://#{Gitlab.config.gitlab.host}/#{project.namespace.name}/#{project.path}/merge_requests/new?merge_request%5Bsource_branch%5D=#{source_branch}" }
let(:show_merge_request_url) { "http://#{Gitlab.config.gitlab.host}/#{project.namespace.name}/#{project.path}/merge_requests/#{merge_request.iid}" } let(:show_merge_request_url) { "http://#{Gitlab.config.gitlab.host}/#{project.namespace.name}/#{project.path}/merge_requests/#{merge_request.iid}" }
...@@ -89,7 +89,7 @@ describe MergeRequests::GetUrlsService do ...@@ -89,7 +89,7 @@ describe MergeRequests::GetUrlsService do
let!(:merge_request) { create(:merge_request, source_project: forked_project, target_project: project, source_branch: source_branch) } let!(:merge_request) { create(:merge_request, source_project: forked_project, target_project: project, source_branch: source_branch) }
let(:changes) { existing_branch_changes } let(:changes) { existing_branch_changes }
# Source project is now the forked one # Source project is now the forked one
let(:service) { MergeRequests::GetUrlsService.new(forked_project) } let(:service) { described_class.new(forked_project) }
before do before do
allow(forked_project).to receive(:empty_repo?).and_return(false) allow(forked_project).to receive(:empty_repo?).and_return(false)
......
require 'spec_helper' require 'spec_helper'
describe MergeRequests::MergeRequestDiffCacheService do describe MergeRequests::MergeRequestDiffCacheService do
let(:subject) { MergeRequests::MergeRequestDiffCacheService.new } let(:subject) { described_class.new }
describe '#execute' do describe '#execute' do
it 'retrieves the diff files to cache the highlighted result' do it 'retrieves the diff files to cache the highlighted result' do
......
...@@ -50,7 +50,7 @@ describe MergeRequests::ResolveService do ...@@ -50,7 +50,7 @@ describe MergeRequests::ResolveService do
context 'when the source and target project are the same' do context 'when the source and target project are the same' do
before do before do
MergeRequests::ResolveService.new(project, user, params).execute(merge_request) described_class.new(project, user, params).execute(merge_request)
end end
it 'creates a commit with the message' do it 'creates a commit with the message' do
...@@ -75,7 +75,7 @@ describe MergeRequests::ResolveService do ...@@ -75,7 +75,7 @@ describe MergeRequests::ResolveService do
end end
before do before do
MergeRequests::ResolveService.new(fork_project, user, params).execute(merge_request_from_fork) described_class.new(fork_project, user, params).execute(merge_request_from_fork)
end end
it 'creates a commit with the message' do it 'creates a commit with the message' do
...@@ -115,7 +115,7 @@ describe MergeRequests::ResolveService do ...@@ -115,7 +115,7 @@ describe MergeRequests::ResolveService do
end end
before do before do
MergeRequests::ResolveService.new(project, user, params).execute(merge_request) described_class.new(project, user, params).execute(merge_request)
end end
it 'creates a commit with the message' do it 'creates a commit with the message' do
...@@ -154,7 +154,7 @@ describe MergeRequests::ResolveService do ...@@ -154,7 +154,7 @@ describe MergeRequests::ResolveService do
} }
end end
let(:service) { MergeRequests::ResolveService.new(project, user, invalid_params) } let(:service) { described_class.new(project, user, invalid_params) }
it 'raises a MissingResolution error' do it 'raises a MissingResolution error' do
expect { service.execute(merge_request) }. expect { service.execute(merge_request) }.
...@@ -180,7 +180,7 @@ describe MergeRequests::ResolveService do ...@@ -180,7 +180,7 @@ describe MergeRequests::ResolveService do
} }
end end
let(:service) { MergeRequests::ResolveService.new(project, user, invalid_params) } let(:service) { described_class.new(project, user, invalid_params) }
it 'raises a MissingResolution error' do it 'raises a MissingResolution error' do
expect { service.execute(merge_request) }. expect { service.execute(merge_request) }.
...@@ -202,7 +202,7 @@ describe MergeRequests::ResolveService do ...@@ -202,7 +202,7 @@ describe MergeRequests::ResolveService do
} }
end end
let(:service) { MergeRequests::ResolveService.new(project, user, invalid_params) } let(:service) { described_class.new(project, user, invalid_params) }
it 'raises a MissingFiles error' do it 'raises a MissingFiles error' do
expect { service.execute(merge_request) }. expect { service.execute(merge_request) }.
......
require 'spec_helper' require 'spec_helper'
describe Projects::HousekeepingService do describe Projects::HousekeepingService do
subject { Projects::HousekeepingService.new(project) } subject { described_class.new(project) }
let(:project) { create(:project, :repository) } let(:project) { create(:project, :repository) }
before do before do
......
...@@ -5,11 +5,11 @@ describe ConfigLint do ...@@ -5,11 +5,11 @@ describe ConfigLint do
let(:files){ ['lib/support/fake.sh'] } let(:files){ ['lib/support/fake.sh'] }
it 'errors out if any bash scripts have errors' do it 'errors out if any bash scripts have errors' do
expect { ConfigLint.run(files){ system('exit 1') } }.to raise_error(SystemExit) expect { described_class.run(files){ system('exit 1') } }.to raise_error(SystemExit)
end end
it 'passes if all scripts are fine' do it 'passes if all scripts are fine' do
expect { ConfigLint.run(files){ system('exit 0') } }.not_to raise_error expect { described_class.run(files){ system('exit 0') } }.not_to raise_error
end end
end end
......
...@@ -8,13 +8,13 @@ describe DeleteUserWorker do ...@@ -8,13 +8,13 @@ describe DeleteUserWorker do
expect_any_instance_of(Users::DestroyService).to receive(:execute). expect_any_instance_of(Users::DestroyService).to receive(:execute).
with(user, {}) with(user, {})
DeleteUserWorker.new.perform(current_user.id, user.id) described_class.new.perform(current_user.id, user.id)
end end
it "uses symbolized keys" do it "uses symbolized keys" do
expect_any_instance_of(Users::DestroyService).to receive(:execute). expect_any_instance_of(Users::DestroyService).to receive(:execute).
with(user, test: "test") with(user, test: "test")
DeleteUserWorker.new.perform(current_user.id, user.id, "test" => "test") described_class.new.perform(current_user.id, user.id, "test" => "test")
end end
end end
...@@ -12,7 +12,7 @@ describe EmailsOnPushWorker do ...@@ -12,7 +12,7 @@ describe EmailsOnPushWorker do
let(:perform) { subject.perform(project.id, recipients, data.stringify_keys) } let(:perform) { subject.perform(project.id, recipients, data.stringify_keys) }
let(:email) { ActionMailer::Base.deliveries.last } let(:email) { ActionMailer::Base.deliveries.last }
subject { EmailsOnPushWorker.new } subject { described_class.new }
describe "#perform" do describe "#perform" do
context "when push is a new branch" do context "when push is a new branch" do
......
...@@ -6,7 +6,7 @@ describe GitGarbageCollectWorker do ...@@ -6,7 +6,7 @@ describe GitGarbageCollectWorker do
let(:project) { create(:project, :repository) } let(:project) { create(:project, :repository) }
let(:shell) { Gitlab::Shell.new } let(:shell) { Gitlab::Shell.new }
subject { GitGarbageCollectWorker.new } subject { described_class.new }
describe "#perform" do describe "#perform" do
it "flushes ref caches when the task is 'gc'" do it "flushes ref caches when the task is 'gc'" do
......
require 'spec_helper' require 'spec_helper'
describe GitlabUsagePingWorker do describe GitlabUsagePingWorker do
subject { GitlabUsagePingWorker.new } subject { described_class.new }
it "sends POST request" do it "sends POST request" do
stub_application_setting(usage_ping_enabled: true) stub_application_setting(usage_ping_enabled: true)
......
...@@ -5,7 +5,7 @@ describe GroupDestroyWorker do ...@@ -5,7 +5,7 @@ describe GroupDestroyWorker do
let(:user) { create(:admin) } let(:user) { create(:admin) }
let!(:project) { create(:empty_project, namespace: group) } let!(:project) { create(:empty_project, namespace: group) }
subject { GroupDestroyWorker.new } subject { described_class.new }
describe "#perform" do describe "#perform" do
it "deletes the project" do it "deletes the project" do
......
...@@ -15,7 +15,7 @@ describe MergeWorker do ...@@ -15,7 +15,7 @@ describe MergeWorker do
it 'clears cache of source repo after removing source branch' do it 'clears cache of source repo after removing source branch' do
expect(source_project.repository.branch_names).to include('markdown') expect(source_project.repository.branch_names).to include('markdown')
MergeWorker.new.perform( described_class.new.perform(
merge_request.id, merge_request.author_id, merge_request.id, merge_request.author_id,
commit_message: 'wow such merge', commit_message: 'wow such merge',
should_remove_source_branch: true) should_remove_source_branch: true)
......
...@@ -10,7 +10,7 @@ describe PostReceive do ...@@ -10,7 +10,7 @@ describe PostReceive do
context "as a resque worker" do context "as a resque worker" do
it "reponds to #perform" do it "reponds to #perform" do
expect(PostReceive.new).to respond_to(:perform) expect(described_class.new).to respond_to(:perform)
end end
end end
...@@ -25,7 +25,7 @@ describe PostReceive do ...@@ -25,7 +25,7 @@ describe PostReceive do
it "calls GitTagPushService" do it "calls GitTagPushService" do
expect_any_instance_of(GitPushService).to receive(:execute).and_return(true) expect_any_instance_of(GitPushService).to receive(:execute).and_return(true)
expect_any_instance_of(GitTagPushService).not_to receive(:execute) expect_any_instance_of(GitTagPushService).not_to receive(:execute)
PostReceive.new.perform(pwd(project), key_id, base64_changes) described_class.new.perform(pwd(project), key_id, base64_changes)
end end
end end
...@@ -35,7 +35,7 @@ describe PostReceive do ...@@ -35,7 +35,7 @@ describe PostReceive do
it "calls GitTagPushService" do it "calls GitTagPushService" do
expect_any_instance_of(GitPushService).not_to receive(:execute) expect_any_instance_of(GitPushService).not_to receive(:execute)
expect_any_instance_of(GitTagPushService).to receive(:execute).and_return(true) expect_any_instance_of(GitTagPushService).to receive(:execute).and_return(true)
PostReceive.new.perform(pwd(project), key_id, base64_changes) described_class.new.perform(pwd(project), key_id, base64_changes)
end end
end end
...@@ -45,12 +45,12 @@ describe PostReceive do ...@@ -45,12 +45,12 @@ describe PostReceive do
it "does not call any of the services" do it "does not call any of the services" do
expect_any_instance_of(GitPushService).not_to receive(:execute) expect_any_instance_of(GitPushService).not_to receive(:execute)
expect_any_instance_of(GitTagPushService).not_to receive(:execute) expect_any_instance_of(GitTagPushService).not_to receive(:execute)
PostReceive.new.perform(pwd(project), key_id, base64_changes) described_class.new.perform(pwd(project), key_id, base64_changes)
end end
end end
context "gitlab-ci.yml" do context "gitlab-ci.yml" do
subject { PostReceive.new.perform(pwd(project), key_id, base64_changes) } subject { described_class.new.perform(pwd(project), key_id, base64_changes) }
context "creates a Ci::Pipeline for every change" do context "creates a Ci::Pipeline for every change" do
before do before do
...@@ -75,7 +75,7 @@ describe PostReceive do ...@@ -75,7 +75,7 @@ describe PostReceive do
context "webhook" do context "webhook" do
it "fetches the correct project" do it "fetches the correct project" do
expect(Project).to receive(:find_by_full_path).with(project.path_with_namespace).and_return(project) expect(Project).to receive(:find_by_full_path).with(project.path_with_namespace).and_return(project)
PostReceive.new.perform(pwd(project), key_id, base64_changes) described_class.new.perform(pwd(project), key_id, base64_changes)
end end
it "does not run if the author is not in the project" do it "does not run if the author is not in the project" do
...@@ -85,7 +85,7 @@ describe PostReceive do ...@@ -85,7 +85,7 @@ describe PostReceive do
expect(project).not_to receive(:execute_hooks) expect(project).not_to receive(:execute_hooks)
expect(PostReceive.new.perform(pwd(project), key_id, base64_changes)).to be_falsey expect(described_class.new.perform(pwd(project), key_id, base64_changes)).to be_falsey
end end
it "asks the project to trigger all hooks" do it "asks the project to trigger all hooks" do
...@@ -93,14 +93,14 @@ describe PostReceive do ...@@ -93,14 +93,14 @@ describe PostReceive do
expect(project).to receive(:execute_hooks).twice expect(project).to receive(:execute_hooks).twice
expect(project).to receive(:execute_services).twice expect(project).to receive(:execute_services).twice
PostReceive.new.perform(pwd(project), key_id, base64_changes) described_class.new.perform(pwd(project), key_id, base64_changes)
end end
it "enqueues a UpdateMergeRequestsWorker job" do it "enqueues a UpdateMergeRequestsWorker job" do
allow(Project).to receive(:find_by_full_path).and_return(project) allow(Project).to receive(:find_by_full_path).and_return(project)
expect(UpdateMergeRequestsWorker).to receive(:perform_async).with(project.id, project.owner.id, any_args) expect(UpdateMergeRequestsWorker).to receive(:perform_async).with(project.id, project.owner.id, any_args)
PostReceive.new.perform(pwd(project), key_id, base64_changes) described_class.new.perform(pwd(project), key_id, base64_changes)
end end
end end
......
...@@ -4,7 +4,7 @@ describe ProjectDestroyWorker do ...@@ -4,7 +4,7 @@ describe ProjectDestroyWorker do
let(:project) { create(:project, :repository) } let(:project) { create(:project, :repository) }
let(:path) { project.repository.path_to_repo } let(:path) { project.repository.path_to_repo }
subject { ProjectDestroyWorker.new } subject { described_class.new }
describe "#perform" do describe "#perform" do
it "deletes the project" do it "deletes the project" do
......
require 'spec_helper' require 'spec_helper'
describe RemoveExpiredMembersWorker do describe RemoveExpiredMembersWorker do
let(:worker) { RemoveExpiredMembersWorker.new } let(:worker) { described_class.new }
describe '#perform' do describe '#perform' do
context 'project members' do context 'project members' do
......
require 'spec_helper' require 'spec_helper'
describe RemoveUnreferencedLfsObjectsWorker do describe RemoveUnreferencedLfsObjectsWorker do
let(:worker) { RemoveUnreferencedLfsObjectsWorker.new } let(:worker) { described_class.new }
describe '#perform' do describe '#perform' do
let!(:unreferenced_lfs_object1) { create(:lfs_object, oid: '1') } let!(:unreferenced_lfs_object1) { create(:lfs_object, oid: '1') }
......
...@@ -5,7 +5,7 @@ describe RepositoryForkWorker do ...@@ -5,7 +5,7 @@ describe RepositoryForkWorker do
let(:fork_project) { create(:project, :repository, forked_from_project: project) } let(:fork_project) { create(:project, :repository, forked_from_project: project) }
let(:shell) { Gitlab::Shell.new } let(:shell) { Gitlab::Shell.new }
subject { RepositoryForkWorker.new } subject { described_class.new }
before do before do
allow(subject).to receive(:gitlab_shell).and_return(shell) allow(subject).to receive(:gitlab_shell).and_return(shell)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment