Enable the Layout/SpaceBeforeBlockBraces cop

Signed-off-by: Rémy Coutable <remy@rymai.me>
This commit is contained in:
Rémy Coutable 2017-08-09 11:52:22 +02:00
parent 932a6e69b8
commit c946ee1282
No known key found for this signature in database
GPG Key ID: 46DF07E5CD9E96AB
81 changed files with 166 additions and 166 deletions

View File

@ -207,6 +207,13 @@ Layout/SpaceAroundKeyword:
Layout/SpaceAroundOperators: Layout/SpaceAroundOperators:
Enabled: true Enabled: true
# Checks that block braces have or don't have a space before the opening
# brace depending on configuration.
# Configuration parameters: EnforcedStyle, SupportedStyles.
# SupportedStyles: space, no_space
Layout/SpaceBeforeBlockBraces:
Enabled: true
# No spaces before commas. # No spaces before commas.
Layout/SpaceBeforeComma: Layout/SpaceBeforeComma:
Enabled: true Enabled: true

View File

@ -26,13 +26,6 @@ Layout/IndentArray:
Layout/IndentHash: Layout/IndentHash:
Enabled: false Enabled: false
# Offense count: 174
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles.
# SupportedStyles: space, no_space
Layout/SpaceBeforeBlockBraces:
Enabled: false
# Offense count: 8 # Offense count: 8
# Cop supports --auto-correct. # Cop supports --auto-correct.
# Configuration parameters: AllowForAlignment. # Configuration parameters: AllowForAlignment.

View File

@ -117,7 +117,7 @@ class ApplicationController < ActionController::Base
Raven.capture_exception(exception) if sentry_enabled? Raven.capture_exception(exception) if sentry_enabled?
application_trace = ActionDispatch::ExceptionWrapper.new(env, exception).application_trace application_trace = ActionDispatch::ExceptionWrapper.new(env, exception).application_trace
application_trace.map!{ |t| " #{t}\n" } application_trace.map! { |t| " #{t}\n" }
logger.error "\n#{exception.class.name} (#{exception.message}):\n#{application_trace.join}" logger.error "\n#{exception.class.name} (#{exception.message}):\n#{application_trace.join}"
end end

View File

@ -15,7 +15,7 @@ class Import::GitlabController < Import::BaseController
@already_added_projects = current_user.created_projects.where(import_type: "gitlab") @already_added_projects = current_user.created_projects.where(import_type: "gitlab")
already_added_projects_names = @already_added_projects.pluck(:import_source) already_added_projects_names = @already_added_projects.pluck(:import_source)
@repos = @repos.to_a.reject{ |repo| already_added_projects_names.include? repo["path_with_namespace"] } @repos = @repos.to_a.reject { |repo| already_added_projects_names.include? repo["path_with_namespace"] }
end end
def jobs def jobs

View File

@ -3,7 +3,7 @@ module GraphHelper
refs = "" refs = ""
# Commit::ref_names already strips the refs/XXX from important refs (e.g. refs/heads/XXX) # Commit::ref_names already strips the refs/XXX from important refs (e.g. refs/heads/XXX)
# so anything leftover is internally used by GitLab # so anything leftover is internally used by GitLab
commit_refs = commit.ref_names(repo).reject{ |name| name.starts_with?('refs/') } commit_refs = commit.ref_names(repo).reject { |name| name.starts_with?('refs/') }
refs << commit_refs.join(' ') refs << commit_refs.join(' ')
# append note count # append note count

View File

@ -151,7 +151,7 @@ module IssuablesHelper
end end
def issuable_labels_tooltip(labels, limit: 5) def issuable_labels_tooltip(labels, limit: 5)
first, last = labels.partition.with_index{ |_, i| i < limit } first, last = labels.partition.with_index { |_, i| i < limit }
label_names = first.collect(&:name) label_names = first.collect(&:name)
label_names << "and #{last.size} more" unless last.empty? label_names << "and #{last.size} more" unless last.empty?
@ -329,7 +329,7 @@ module IssuablesHelper
end end
def selected_template(issuable) def selected_template(issuable)
params[:issuable_template] if issuable_templates(issuable).any?{ |template| template[:name] == params[:issuable_template] } params[:issuable_template] if issuable_templates(issuable).any? { |template| template[:name] == params[:issuable_template] }
end end
def issuable_todo_button_data(issuable, todo, is_collapsed) def issuable_todo_button_data(issuable, todo, is_collapsed)

View File

@ -206,7 +206,7 @@ module Network
# Visit branching chains # Visit branching chains
leaves.each do |l| leaves.each do |l|
parents = l.parents(@map).select{|p| p.space.zero?} parents = l.parents(@map).select {|p| p.space.zero?}
parents.each do |p| parents.each do |p|
place_chain(p, l.time) place_chain(p, l.time)
end end

View File

@ -77,20 +77,20 @@ class Note < ActiveRecord::Base
# Scopes # Scopes
scope :for_commit_id, ->(commit_id) { where(noteable_type: "Commit", commit_id: commit_id) } scope :for_commit_id, ->(commit_id) { where(noteable_type: "Commit", commit_id: commit_id) }
scope :system, ->{ where(system: true) } scope :system, -> { where(system: true) }
scope :user, ->{ where(system: false) } scope :user, -> { where(system: false) }
scope :common, ->{ where(noteable_type: ["", nil]) } scope :common, -> { where(noteable_type: ["", nil]) }
scope :fresh, ->{ order(created_at: :asc, id: :asc) } scope :fresh, -> { order(created_at: :asc, id: :asc) }
scope :updated_after, ->(time){ where('updated_at > ?', time) } scope :updated_after, ->(time) { where('updated_at > ?', time) }
scope :inc_author_project, ->{ includes(:project, :author) } scope :inc_author_project, -> { includes(:project, :author) }
scope :inc_author, ->{ includes(:author) } scope :inc_author, -> { includes(:author) }
scope :inc_relations_for_view, -> do scope :inc_relations_for_view, -> do
includes(:project, :author, :updated_by, :resolved_by, :award_emoji, :system_note_metadata) includes(:project, :author, :updated_by, :resolved_by, :award_emoji, :system_note_metadata)
end end
scope :diff_notes, ->{ where(type: %w(LegacyDiffNote DiffNote)) } scope :diff_notes, -> { where(type: %w(LegacyDiffNote DiffNote)) }
scope :new_diff_notes, ->{ where(type: 'DiffNote') } scope :new_diff_notes, -> { where(type: 'DiffNote') }
scope :non_diff_notes, ->{ where(type: ['Note', 'DiscussionNote', nil]) } scope :non_diff_notes, -> { where(type: ['Note', 'DiscussionNote', nil]) }
scope :with_associations, -> do scope :with_associations, -> do
# FYI noteable cannot be loaded for LegacyDiffNote for commits # FYI noteable cannot be loaded for LegacyDiffNote for commits

View File

@ -71,7 +71,7 @@ class Settings < Settingslogic
# check that `current` (string or integer) is a contant in `modul`. # check that `current` (string or integer) is a contant in `modul`.
def verify_constant(modul, current, default) def verify_constant(modul, current, default)
constant = modul.constants.find{ |name| modul.const_get(name) == current } constant = modul.constants.find { |name| modul.const_get(name) == current }
value = constant.nil? ? default : modul.const_get(constant) value = constant.nil? ? default : modul.const_get(constant)
if current.is_a? String if current.is_a? String
value = modul.const_get(current.upcase) rescue default value = modul.const_get(current.upcase) rescue default

View File

@ -10,7 +10,7 @@ class AddUniqueIndexToLabels < ActiveRecord::Migration
def up def up
select_all('SELECT title, project_id, COUNT(id) as cnt FROM labels GROUP BY project_id, title HAVING COUNT(id) > 1').each do |label| select_all('SELECT title, project_id, COUNT(id) as cnt FROM labels GROUP BY project_id, title HAVING COUNT(id) > 1').each do |label|
label_title = quote_string(label['title']) label_title = quote_string(label['title'])
duplicated_ids = select_all("SELECT id FROM labels WHERE project_id = #{label['project_id']} AND title = '#{label_title}' ORDER BY id ASC").map{ |label| label['id'] } duplicated_ids = select_all("SELECT id FROM labels WHERE project_id = #{label['project_id']} AND title = '#{label_title}' ORDER BY id ASC").map { |label| label['id'] }
label_id = duplicated_ids.first label_id = duplicated_ids.first
duplicated_ids.delete(label_id) duplicated_ids.delete(label_id)

View File

@ -30,7 +30,7 @@ class CleanupNamespacelessPendingDeleteProjects < ActiveRecord::Migration
private private
def pending_delete_batch def pending_delete_batch
connection.exec_query(find_batch).map{ |row| row['id'].to_i } connection.exec_query(find_batch).map { |row| row['id'].to_i }
end end
BATCH_SIZE = 5000 BATCH_SIZE = 5000

View File

@ -132,7 +132,7 @@ module API
expose :lfs_enabled?, as: :lfs_enabled expose :lfs_enabled?, as: :lfs_enabled
expose :creator_id expose :creator_id
expose :namespace, using: 'API::Entities::Namespace' expose :namespace, using: 'API::Entities::Namespace'
expose :forked_from_project, using: Entities::BasicProjectDetails, if: lambda{ |project, options| project.forked? } expose :forked_from_project, using: Entities::BasicProjectDetails, if: lambda { |project, options| project.forked? }
expose :import_status expose :import_status
expose :import_error, if: lambda { |_project, options| options[:user_can_admin_project] } expose :import_error, if: lambda { |_project, options| options[:user_can_admin_project] }
expose :avatar_url do |user, options| expose :avatar_url do |user, options|

View File

@ -68,7 +68,7 @@ module API
expose :lfs_enabled?, as: :lfs_enabled expose :lfs_enabled?, as: :lfs_enabled
expose :creator_id expose :creator_id
expose :namespace, using: 'API::Entities::Namespace' expose :namespace, using: 'API::Entities::Namespace'
expose :forked_from_project, using: ::API::Entities::BasicProjectDetails, if: lambda{ |project, options| project.forked? } expose :forked_from_project, using: ::API::Entities::BasicProjectDetails, if: lambda { |project, options| project.forked? }
expose :avatar_url do |user, options| expose :avatar_url do |user, options|
user.avatar_url(only_path: false) user.avatar_url(only_path: false)
end end

View File

@ -198,11 +198,11 @@ module Backup
end end
def archives_to_backup def archives_to_backup
ARCHIVES_TO_BACKUP.map{ |name| (name + ".tar.gz") unless skipped?(name) }.compact ARCHIVES_TO_BACKUP.map { |name| (name + ".tar.gz") unless skipped?(name) }.compact
end end
def folders_to_backup def folders_to_backup
FOLDERS_TO_BACKUP.reject{ |name| skipped?(name) } FOLDERS_TO_BACKUP.reject { |name| skipped?(name) }
end end
def disabled_features def disabled_features

View File

@ -71,7 +71,7 @@ module Gitlab
end end
def config def config
Gitlab.config.omniauth.providers.find{|provider| provider.name == "gitlab"} Gitlab.config.omniauth.providers.find {|provider| provider.name == "gitlab"}
end end
def gitlab_options def gitlab_options

View File

@ -127,7 +127,7 @@ describe Admin::UsersController do
describe 'POST create' do describe 'POST create' do
it 'creates the user' do it 'creates the user' do
expect{ post :create, user: attributes_for(:user) }.to change{ User.count }.by(1) expect { post :create, user: attributes_for(:user) }.to change { User.count }.by(1)
end end
it 'shows only one error message for an invalid email' do it 'shows only one error message for an invalid email' do

View File

@ -24,7 +24,7 @@ describe InvitesController do
describe 'GET #decline' do describe 'GET #decline' do
it 'declines user' do it 'declines user' do
get :decline, id: token get :decline, id: token
expect{member.reload}.to raise_error ActiveRecord::RecordNotFound expect {member.reload}.to raise_error ActiveRecord::RecordNotFound
expect(response).to have_http_status(302) expect(response).to have_http_status(302)
expect(flash[:notice]).to include 'You have declined the invitation to join' expect(flash[:notice]).to include 'You have declined the invitation to join'

View File

@ -292,13 +292,13 @@ describe Projects::IssuesController do
it 'rejects an issue recognized as a spam' do it 'rejects an issue recognized as a spam' do
expect(Gitlab::Recaptcha).to receive(:load_configurations!).and_return(true) expect(Gitlab::Recaptcha).to receive(:load_configurations!).and_return(true)
expect { update_spam_issue }.not_to change{ issue.reload.title } expect { update_spam_issue }.not_to change { issue.reload.title }
end end
it 'rejects an issue recognized as a spam when recaptcha disabled' do it 'rejects an issue recognized as a spam when recaptcha disabled' do
stub_application_setting(recaptcha_enabled: false) stub_application_setting(recaptcha_enabled: false)
expect { update_spam_issue }.not_to change{ issue.reload.title } expect { update_spam_issue }.not_to change { issue.reload.title }
end end
it 'creates a spam log' do it 'creates a spam log' do
@ -358,7 +358,7 @@ describe Projects::IssuesController do
end end
it 'accepts an issue after recaptcha is verified' do it 'accepts an issue after recaptcha is verified' do
expect{ update_verified_issue }.to change{ issue.reload.title }.to(spammy_title) expect { update_verified_issue }.to change { issue.reload.title }.to(spammy_title)
end end
it 'marks spam log as recaptcha_verified' do it 'marks spam log as recaptcha_verified' do

View File

@ -67,7 +67,7 @@ describe Projects::TodosController do
end end
it "doesn't create todo" do it "doesn't create todo" do
expect{ go }.not_to change { user.todos.count } expect { go }.not_to change { user.todos.count }
expect(response).to have_http_status(404) expect(response).to have_http_status(404)
end end
end end
@ -135,7 +135,7 @@ describe Projects::TodosController do
end end
it "doesn't create todo" do it "doesn't create todo" do
expect{ go }.not_to change { user.todos.count } expect { go }.not_to change { user.todos.count }
expect(response).to have_http_status(404) expect(response).to have_http_status(404)
end end
end end

View File

@ -15,7 +15,7 @@ describe RegistrationsController do
it 'signs the user in' do it 'signs the user in' do
allow_any_instance_of(ApplicationSetting).to receive(:send_user_confirmation_email).and_return(false) allow_any_instance_of(ApplicationSetting).to receive(:send_user_confirmation_email).and_return(false)
expect { post(:create, user_params) }.not_to change{ ActionMailer::Base.deliveries.size } expect { post(:create, user_params) }.not_to change { ActionMailer::Base.deliveries.size }
expect(subject.current_user).not_to be_nil expect(subject.current_user).not_to be_nil
end end
end end

View File

@ -138,7 +138,7 @@ describe Snippets::NotesController do
end end
it "deletes the note" do it "deletes the note" do
expect{ delete :destroy, request_params }.to change{ Note.count }.from(1).to(0) expect { delete :destroy, request_params }.to change { Note.count }.from(1).to(0)
end end
context 'system note' do context 'system note' do
@ -147,7 +147,7 @@ describe Snippets::NotesController do
end end
it "does not delete the note" do it "does not delete the note" do
expect{ delete :destroy, request_params }.not_to change{ Note.count } expect { delete :destroy, request_params }.not_to change { Note.count }
end end
end end
end end
@ -166,7 +166,7 @@ describe Snippets::NotesController do
end end
it "does not update the note" do it "does not update the note" do
expect{ delete :destroy, request_params }.not_to change{ Note.count } expect { delete :destroy, request_params }.not_to change { Note.count }
end end
end end
end end

View File

@ -16,7 +16,7 @@ feature 'Password reset' do
user.send_reset_password_instructions user.send_reset_password_instructions
user.update_attribute(:reset_password_sent_at, 5.minutes.ago) user.update_attribute(:reset_password_sent_at, 5.minutes.ago)
expect{ forgot_password(user) }.to change{ user.reset_password_sent_at } expect { forgot_password(user) }.to change { user.reset_password_sent_at }
expect(page).to have_content(I18n.t('devise.passwords.send_paranoid_instructions')) expect(page).to have_content(I18n.t('devise.passwords.send_paranoid_instructions'))
expect(current_path).to eq new_user_session_path expect(current_path).to eq new_user_session_path
end end
@ -27,7 +27,7 @@ feature 'Password reset' do
# Reload because PG handles datetime less precisely than Ruby/Rails # Reload because PG handles datetime less precisely than Ruby/Rails
user.reload user.reload
expect{ forgot_password(user) }.not_to change{ user.reset_password_sent_at } expect { forgot_password(user) }.not_to change { user.reset_password_sent_at }
expect(page).to have_content(I18n.t('devise.passwords.send_paranoid_instructions')) expect(page).to have_content(I18n.t('devise.passwords.send_paranoid_instructions'))
expect(current_path).to eq new_user_session_path expect(current_path).to eq new_user_session_path
end end

View File

@ -104,7 +104,7 @@ feature 'Users', js: true do
end end
def errors_on_page(page) def errors_on_page(page)
page.find('#error_explanation').find('ul').all('li').map{ |item| item.text }.join("\n") page.find('#error_explanation').find('ul').all('li').map { |item| item.text }.join("\n")
end end
def number_of_errors_on_page(page) def number_of_errors_on_page(page)

View File

@ -15,7 +15,7 @@ describe Bitbucket::Paginator do
expect(paginator.items).to match(['item_2']) expect(paginator.items).to match(['item_2'])
allow(paginator).to receive(:fetch_next_page).and_return(nil) allow(paginator).to receive(:fetch_next_page).and_return(nil)
expect{ paginator.items }.to raise_error(StopIteration) expect { paginator.items }.to raise_error(StopIteration)
end end
end end
end end

View File

@ -1323,11 +1323,11 @@ EOT
describe "Error handling" do describe "Error handling" do
it "fails to parse YAML" do it "fails to parse YAML" do
expect{GitlabCiYamlProcessor.new("invalid: yaml: test")}.to raise_error(Psych::SyntaxError) expect {GitlabCiYamlProcessor.new("invalid: yaml: test")}.to raise_error(Psych::SyntaxError)
end end
it "indicates that object is invalid" do it "indicates that object is invalid" do
expect{GitlabCiYamlProcessor.new("invalid_yaml")}.to raise_error(GitlabCiYamlProcessor::ValidationError) expect {GitlabCiYamlProcessor.new("invalid_yaml")}.to raise_error(GitlabCiYamlProcessor::ValidationError)
end end
it "returns errors if tags parameter is invalid" do it "returns errors if tags parameter is invalid" do

View File

@ -56,7 +56,7 @@ describe ExtractsPath do
context 'subclass overrides get_id' do context 'subclass overrides get_id' do
it 'uses ref returned by get_id' do it 'uses ref returned by get_id' do
allow_any_instance_of(self.class).to receive(:get_id){ '38008cb17ce1466d8fec2dfa6f6ab8dcfe5cf49e' } allow_any_instance_of(self.class).to receive(:get_id) { '38008cb17ce1466d8fec2dfa6f6ab8dcfe5cf49e' }
assign_ref_vars assign_ref_vars

View File

@ -15,7 +15,7 @@ describe Gitlab::BitbucketImport::ProjectCreator do
has_wiki?: false) has_wiki?: false)
end end
let(:namespace){ create(:group, owner: user) } let(:namespace) { create(:group, owner: user) }
let(:token) { "asdasd12345" } let(:token) { "asdasd12345" }
let(:secret) { "sekrettt" } let(:secret) { "sekrettt" }
let(:access_params) { { bitbucket_access_token: token, bitbucket_access_token_secret: secret } } let(:access_params) { { bitbucket_access_token: token, bitbucket_access_token_secret: secret } }

View File

@ -422,11 +422,11 @@ describe Gitlab::Git::Repository, seed_helper: true do
it "should fail if we create an existing branch" do it "should fail if we create an existing branch" do
@repo.create_branch('duplicated_branch', 'master') @repo.create_branch('duplicated_branch', 'master')
expect{@repo.create_branch('duplicated_branch', 'master')}.to raise_error("Branch duplicated_branch already exists") expect {@repo.create_branch('duplicated_branch', 'master')}.to raise_error("Branch duplicated_branch already exists")
end end
it "should fail if we create a branch from a non existing ref" do it "should fail if we create a branch from a non existing ref" do
expect{@repo.create_branch('branch_based_in_wrong_ref', 'master_2_the_revenge')}.to raise_error("Invalid reference master_2_the_revenge") expect {@repo.create_branch('branch_based_in_wrong_ref', 'master_2_the_revenge')}.to raise_error("Invalid reference master_2_the_revenge")
end end
after(:all) do after(:all) do

View File

@ -12,7 +12,7 @@ describe Gitlab::GitlabImport::ProjectCreator do
owner: { name: "john" } owner: { name: "john" }
}.with_indifferent_access }.with_indifferent_access
end end
let(:namespace){ create(:group, owner: user) } let(:namespace) { create(:group, owner: user) }
let(:token) { "asdffg" } let(:token) { "asdffg" }
let(:access_params) { { gitlab_access_token: token } } let(:access_params) { { gitlab_access_token: token } }

View File

@ -9,7 +9,7 @@ describe Gitlab::GoogleCodeImport::ProjectCreator do
"repositoryUrls" => ["https://vim.googlecode.com/git/"] "repositoryUrls" => ["https://vim.googlecode.com/git/"]
) )
end end
let(:namespace){ create(:group, owner: user) } let(:namespace) { create(:group, owner: user) }
before do before do
namespace.add_owner(user) namespace.add_owner(user)

View File

@ -1,7 +1,7 @@
require 'spec_helper' require 'spec_helper'
describe Gitlab::ImportExport::AttributeCleaner do describe Gitlab::ImportExport::AttributeCleaner do
let(:relation_class){ double('relation_class').as_null_object } let(:relation_class) { double('relation_class').as_null_object }
let(:unsafe_hash) do let(:unsafe_hash) do
{ {
'id' => 101, 'id' => 101,

View File

@ -7,7 +7,7 @@ describe Gitlab::LDAP::Config do
describe '#initialize' do describe '#initialize' do
it 'requires a provider' do it 'requires a provider' do
expect{ described_class.new }.to raise_error ArgumentError expect { described_class.new }.to raise_error ArgumentError
end end
it 'works' do it 'works' do
@ -15,7 +15,7 @@ describe Gitlab::LDAP::Config do
end end
it 'raises an error if a unknown provider is used' do it 'raises an error if a unknown provider is used' do
expect{ described_class.new 'unknown' }.to raise_error(RuntimeError) expect { described_class.new 'unknown' }.to raise_error(RuntimeError)
end end
end end

View File

@ -61,12 +61,12 @@ describe Gitlab::LDAP::User do
it "finds the user if already existing" do it "finds the user if already existing" do
create(:omniauth_user, extern_uid: 'my-uid', provider: 'ldapmain') create(:omniauth_user, extern_uid: 'my-uid', provider: 'ldapmain')
expect{ ldap_user.save }.not_to change{ User.count } expect { ldap_user.save }.not_to change { User.count }
end end
it "connects to existing non-ldap user if the email matches" do it "connects to existing non-ldap user if the email matches" do
existing_user = create(:omniauth_user, email: 'john@example.com', provider: "twitter") existing_user = create(:omniauth_user, email: 'john@example.com', provider: "twitter")
expect{ ldap_user.save }.not_to change{ User.count } expect { ldap_user.save }.not_to change { User.count }
existing_user.reload existing_user.reload
expect(existing_user.ldap_identity.extern_uid).to eql 'my-uid' expect(existing_user.ldap_identity.extern_uid).to eql 'my-uid'
@ -75,7 +75,7 @@ describe Gitlab::LDAP::User do
it 'connects to existing ldap user if the extern_uid changes' do it 'connects to existing ldap user if the extern_uid changes' do
existing_user = create(:omniauth_user, email: 'john@example.com', extern_uid: 'old-uid', provider: 'ldapmain') existing_user = create(:omniauth_user, email: 'john@example.com', extern_uid: 'old-uid', provider: 'ldapmain')
expect{ ldap_user.save }.not_to change{ User.count } expect { ldap_user.save }.not_to change { User.count }
existing_user.reload existing_user.reload
expect(existing_user.ldap_identity.extern_uid).to eql 'my-uid' expect(existing_user.ldap_identity.extern_uid).to eql 'my-uid'
@ -85,7 +85,7 @@ describe Gitlab::LDAP::User do
it 'connects to existing ldap user if the extern_uid changes and email address has upper case characters' do it 'connects to existing ldap user if the extern_uid changes and email address has upper case characters' do
existing_user = create(:omniauth_user, email: 'john@example.com', extern_uid: 'old-uid', provider: 'ldapmain') existing_user = create(:omniauth_user, email: 'john@example.com', extern_uid: 'old-uid', provider: 'ldapmain')
expect{ ldap_user_upper_case.save }.not_to change{ User.count } expect { ldap_user_upper_case.save }.not_to change { User.count }
existing_user.reload existing_user.reload
expect(existing_user.ldap_identity.extern_uid).to eql 'my-uid' expect(existing_user.ldap_identity.extern_uid).to eql 'my-uid'
@ -106,7 +106,7 @@ describe Gitlab::LDAP::User do
end end
it "creates a new user if not found" do it "creates a new user if not found" do
expect{ ldap_user.save }.to change{ User.count }.by(1) expect { ldap_user.save }.to change { User.count }.by(1)
end end
context 'when signup is disabled' do context 'when signup is disabled' do

View File

@ -147,7 +147,7 @@ describe Gitlab::OAuth::User do
end end
it 'throws an error' do it 'throws an error' do
expect{ oauth_user.save }.to raise_error StandardError expect { oauth_user.save }.to raise_error StandardError
end end
end end
@ -157,7 +157,7 @@ describe Gitlab::OAuth::User do
end end
it 'throws an error' do it 'throws an error' do
expect{ oauth_user.save }.to raise_error StandardError expect { oauth_user.save }.to raise_error StandardError
end end
end end
end end

View File

@ -109,7 +109,7 @@ describe Gitlab::Saml::User do
end end
it 'does not throw an error' do it 'does not throw an error' do
expect{ saml_user.save }.not_to raise_error expect { saml_user.save }.not_to raise_error
end end
end end
@ -119,7 +119,7 @@ describe Gitlab::Saml::User do
end end
it 'throws an error' do it 'throws an error' do
expect{ saml_user.save }.to raise_error StandardError expect { saml_user.save }.to raise_error StandardError
end end
end end
end end

View File

@ -19,7 +19,7 @@ describe Gitlab::SQL::Union do
empty_relation = User.none empty_relation = User.none
union = described_class.new([empty_relation, relation_1, relation_2]) union = described_class.new([empty_relation, relation_1, relation_2])
expect{User.where("users.id IN (#{union.to_sql})").to_a}.not_to raise_error expect {User.where("users.id IN (#{union.to_sql})").to_a}.not_to raise_error
expect(union.to_sql).to eq("#{to_sql(relation_1)}\nUNION\n#{to_sql(relation_2)}") expect(union.to_sql).to eq("#{to_sql(relation_1)}\nUNION\n#{to_sql(relation_2)}")
end end
end end

View File

@ -50,8 +50,8 @@ describe 'Gitlab::VersionInfo' do
context 'unknown' do context 'unknown' do
it { expect(@unknown).not_to be @v0_0_1 } it { expect(@unknown).not_to be @v0_0_1 }
it { expect(@unknown).not_to be Gitlab::VersionInfo.new } it { expect(@unknown).not_to be Gitlab::VersionInfo.new }
it { expect{@unknown > @v0_0_1}.to raise_error(ArgumentError) } it { expect {@unknown > @v0_0_1}.to raise_error(ArgumentError) }
it { expect{@unknown < @v0_0_1}.to raise_error(ArgumentError) } it { expect {@unknown < @v0_0_1}.to raise_error(ArgumentError) }
end end
context 'parse' do context 'parse' do

View File

@ -27,7 +27,7 @@ describe JSONWebToken::RSAToken do
subject { JWT.decode(rsa_encoded, rsa_key) } subject { JWT.decode(rsa_encoded, rsa_key) }
it { expect{subject}.not_to raise_error } it { expect {subject}.not_to raise_error }
it { expect(subject.first).to include('key' => 'value') } it { expect(subject.first).to include('key' => 'value') }
it do it do
expect(subject.second).to eq( expect(subject.second).to eq(
@ -41,7 +41,7 @@ describe JSONWebToken::RSAToken do
let(:new_key) { OpenSSL::PKey::RSA.generate(512) } let(:new_key) { OpenSSL::PKey::RSA.generate(512) }
subject { JWT.decode(rsa_encoded, new_key) } subject { JWT.decode(rsa_encoded, new_key) }
it { expect{subject}.to raise_error(JWT::DecodeError) } it { expect {subject}.to raise_error(JWT::DecodeError) }
end end
end end
end end

View File

@ -240,7 +240,7 @@ describe SystemCheck::SimpleExecutor do
context 'when there is an exception' do context 'when there is an exception' do
it 'rescues the exception' do it 'rescues the exception' do
expect{ subject.run_check(BugousCheck) }.not_to raise_exception expect { subject.run_check(BugousCheck) }.not_to raise_exception
end end
end end
end end

View File

@ -425,7 +425,7 @@ describe CommitStatus do
end end
it "raise exception when trying to update" do it "raise exception when trying to update" do
expect{ commit_status.save }.to raise_error(ActiveRecord::StaleObjectError) expect { commit_status.save }.to raise_error(ActiveRecord::StaleObjectError)
end end
end end

View File

@ -350,7 +350,7 @@ describe Issue do
subject { create(:issue, project: create(:project, :repository)) } subject { create(:issue, project: create(:project, :repository)) }
let(:backref_text) { "issue #{subject.to_reference}" } let(:backref_text) { "issue #{subject.to_reference}" }
let(:set_mentionable_text) { ->(txt){ subject.description = txt } } let(:set_mentionable_text) { ->(txt) { subject.description = txt } }
end end
it_behaves_like 'a Taskable' do it_behaves_like 'a Taskable' do

View File

@ -681,7 +681,7 @@ describe MergeRequest do
end end
it 'does not crash' do it 'does not crash' do
expect{ subject.diverged_commits_count }.not_to raise_error expect { subject.diverged_commits_count }.not_to raise_error
end end
it 'returns 0' do it 'returns 0' do
@ -753,7 +753,7 @@ describe MergeRequest do
subject { create(:merge_request, :simple) } subject { create(:merge_request, :simple) }
let(:backref_text) { "merge request #{subject.to_reference}" } let(:backref_text) { "merge request #{subject.to_reference}" }
let(:set_mentionable_text) { ->(txt){ subject.description = txt } } let(:set_mentionable_text) { ->(txt) { subject.description = txt } }
end end
it_behaves_like 'a Taskable' do it_behaves_like 'a Taskable' do

View File

@ -1301,7 +1301,7 @@ describe Project do
subject { project.rename_repo } subject { project.rename_repo }
it { expect{subject}.to raise_error(StandardError) } it { expect {subject}.to raise_error(StandardError) }
end end
end end

View File

@ -1224,7 +1224,7 @@ describe Repository, models: true do
end end
describe 'skip_merges option' do describe 'skip_merges option' do
subject { repository.commits(Gitlab::Git::BRANCH_REF_PREFIX + "'test'", limit: 100, skip_merges: true).map{ |k| k.id } } subject { repository.commits(Gitlab::Git::BRANCH_REF_PREFIX + "'test'", limit: 100, skip_merges: true).map { |k| k.id } }
it { is_expected.not_to include('e56497bb5f03a90a51293fc6d516788730953899') } it { is_expected.not_to include('e56497bb5f03a90a51293fc6d516788730953899') }
end end

View File

@ -44,8 +44,8 @@ describe API::CommitStatuses do
expect(response).to include_pagination_headers expect(response).to include_pagination_headers
expect(json_response).to be_an Array expect(json_response).to be_an Array
expect(statuses_id).to contain_exactly(status3.id, status4.id, status5.id, status6.id) expect(statuses_id).to contain_exactly(status3.id, status4.id, status5.id, status6.id)
json_response.sort_by!{ |status| status['id'] } json_response.sort_by! { |status| status['id'] }
expect(json_response.map{ |status| status['allow_failure'] }).to eq([true, false, false, false]) expect(json_response.map { |status| status['allow_failure'] }).to eq([true, false, false, false])
end end
end end

View File

@ -182,7 +182,7 @@ describe API::DeployKeys do
delete api("/projects/#{project.id}/deploy_keys/#{deploy_key.id}", admin) delete api("/projects/#{project.id}/deploy_keys/#{deploy_key.id}", admin)
expect(response).to have_http_status(204) expect(response).to have_http_status(204)
end.to change{ project.deploy_keys.count }.by(-1) end.to change { project.deploy_keys.count }.by(-1)
end end
it 'returns 404 Not Found with invalid ID' do it 'returns 404 Not Found with invalid ID' do

View File

@ -88,7 +88,7 @@ describe API::GroupVariables do
it 'creates variable' do it 'creates variable' do
expect do expect do
post api("/groups/#{group.id}/variables", user), key: 'TEST_VARIABLE_2', value: 'VALUE_2', protected: true post api("/groups/#{group.id}/variables", user), key: 'TEST_VARIABLE_2', value: 'VALUE_2', protected: true
end.to change{group.variables.count}.by(1) end.to change {group.variables.count}.by(1)
expect(response).to have_http_status(201) expect(response).to have_http_status(201)
expect(json_response['key']).to eq('TEST_VARIABLE_2') expect(json_response['key']).to eq('TEST_VARIABLE_2')
@ -99,7 +99,7 @@ describe API::GroupVariables do
it 'creates variable with optional attributes' do it 'creates variable with optional attributes' do
expect do expect do
post api("/groups/#{group.id}/variables", user), key: 'TEST_VARIABLE_2', value: 'VALUE_2' post api("/groups/#{group.id}/variables", user), key: 'TEST_VARIABLE_2', value: 'VALUE_2'
end.to change{group.variables.count}.by(1) end.to change {group.variables.count}.by(1)
expect(response).to have_http_status(201) expect(response).to have_http_status(201)
expect(json_response['key']).to eq('TEST_VARIABLE_2') expect(json_response['key']).to eq('TEST_VARIABLE_2')
@ -110,7 +110,7 @@ describe API::GroupVariables do
it 'does not allow to duplicate variable key' do it 'does not allow to duplicate variable key' do
expect do expect do
post api("/groups/#{group.id}/variables", user), key: variable.key, value: 'VALUE_2' post api("/groups/#{group.id}/variables", user), key: variable.key, value: 'VALUE_2'
end.to change{group.variables.count}.by(0) end.to change {group.variables.count}.by(0)
expect(response).to have_http_status(400) expect(response).to have_http_status(400)
end end
@ -192,7 +192,7 @@ describe API::GroupVariables do
delete api("/groups/#{group.id}/variables/#{variable.key}", user) delete api("/groups/#{group.id}/variables/#{variable.key}", user)
expect(response).to have_http_status(204) expect(response).to have_http_status(204)
end.to change{group.variables.count}.by(-1) end.to change {group.variables.count}.by(-1)
end end
it 'responds with 404 Not Found if requesting non-existing variable' do it 'responds with 404 Not Found if requesting non-existing variable' do

View File

@ -56,7 +56,7 @@ describe API::Helpers do
end end
def doorkeeper_guard_returns(value) def doorkeeper_guard_returns(value)
allow_any_instance_of(self.class).to receive(:doorkeeper_guard){ value } allow_any_instance_of(self.class).to receive(:doorkeeper_guard) { value }
end end
def error!(message, status, header) def error!(message, status, header)
@ -161,7 +161,7 @@ describe API::Helpers do
describe "when authenticating using a user's private token" do describe "when authenticating using a user's private token" do
it "returns nil for an invalid token" do it "returns nil for an invalid token" do
env[API::APIGuard::PRIVATE_TOKEN_HEADER] = 'invalid token' env[API::APIGuard::PRIVATE_TOKEN_HEADER] = 'invalid token'
allow_any_instance_of(self.class).to receive(:doorkeeper_guard){ false } allow_any_instance_of(self.class).to receive(:doorkeeper_guard) { false }
expect(current_user).to be_nil expect(current_user).to be_nil
end end

View File

@ -326,7 +326,7 @@ describe API::MergeRequests do
expect(response).to include_pagination_headers expect(response).to include_pagination_headers
expect(json_response).to be_an Array expect(json_response).to be_an Array
expect(json_response.length).to eq(3) expect(json_response.length).to eq(3)
response_dates = json_response.map{ |merge_request| merge_request['created_at'] } response_dates = json_response.map { |merge_request| merge_request['created_at'] }
expect(response_dates).to eq(response_dates.sort) expect(response_dates).to eq(response_dates.sort)
end end
@ -337,7 +337,7 @@ describe API::MergeRequests do
expect(response).to include_pagination_headers expect(response).to include_pagination_headers
expect(json_response).to be_an Array expect(json_response).to be_an Array
expect(json_response.length).to eq(3) expect(json_response.length).to eq(3)
response_dates = json_response.map{ |merge_request| merge_request['created_at'] } response_dates = json_response.map { |merge_request| merge_request['created_at'] }
expect(response_dates).to eq(response_dates.sort.reverse) expect(response_dates).to eq(response_dates.sort.reverse)
end end
@ -348,7 +348,7 @@ describe API::MergeRequests do
expect(response).to include_pagination_headers expect(response).to include_pagination_headers
expect(json_response).to be_an Array expect(json_response).to be_an Array
expect(json_response.length).to eq(3) expect(json_response.length).to eq(3)
response_dates = json_response.map{ |merge_request| merge_request['updated_at'] } response_dates = json_response.map { |merge_request| merge_request['updated_at'] }
expect(response_dates).to eq(response_dates.sort.reverse) expect(response_dates).to eq(response_dates.sort.reverse)
end end
@ -359,7 +359,7 @@ describe API::MergeRequests do
expect(response).to include_pagination_headers expect(response).to include_pagination_headers
expect(json_response).to be_an Array expect(json_response).to be_an Array
expect(json_response.length).to eq(3) expect(json_response.length).to eq(3)
response_dates = json_response.map{ |merge_request| merge_request['created_at'] } response_dates = json_response.map { |merge_request| merge_request['created_at'] }
expect(response_dates).to eq(response_dates.sort) expect(response_dates).to eq(response_dates.sort)
end end
end end

View File

@ -53,7 +53,7 @@ describe API::PipelineSchedules do
it 'returns matched pipeline schedules' do it 'returns matched pipeline schedules' do
get api("/projects/#{project.id}/pipeline_schedules", developer), scope: target get api("/projects/#{project.id}/pipeline_schedules", developer), scope: target
expect(json_response.map{ |r| r['active'] }).to all(eq(active?(target))) expect(json_response.map { |r| r['active'] }).to all(eq(active?(target)))
end end
end end

View File

@ -683,7 +683,7 @@ describe API::Runner do
end end
context 'when job has been updated recently' do context 'when job has been updated recently' do
it { expect{ patch_the_trace }.not_to change { job.updated_at }} it { expect { patch_the_trace }.not_to change { job.updated_at }}
it "changes the job's trace" do it "changes the job's trace" do
patch_the_trace patch_the_trace
@ -692,7 +692,7 @@ describe API::Runner do
end end
context 'when Runner makes a force-patch' do context 'when Runner makes a force-patch' do
it { expect{ force_patch_the_trace }.not_to change { job.updated_at }} it { expect { force_patch_the_trace }.not_to change { job.updated_at }}
it "doesn't change the build.trace" do it "doesn't change the build.trace" do
force_patch_the_trace force_patch_the_trace

View File

@ -36,7 +36,7 @@ describe API::Runners do
it 'returns user available runners' do it 'returns user available runners' do
get api('/runners', user) get api('/runners', user)
shared = json_response.any?{ |r| r['is_shared'] } shared = json_response.any? { |r| r['is_shared'] }
expect(response).to have_http_status(200) expect(response).to have_http_status(200)
expect(response).to include_pagination_headers expect(response).to include_pagination_headers
expect(json_response).to be_an Array expect(json_response).to be_an Array
@ -46,7 +46,7 @@ describe API::Runners do
it 'filters runners by scope' do it 'filters runners by scope' do
get api('/runners?scope=active', user) get api('/runners?scope=active', user)
shared = json_response.any?{ |r| r['is_shared'] } shared = json_response.any? { |r| r['is_shared'] }
expect(response).to have_http_status(200) expect(response).to have_http_status(200)
expect(response).to include_pagination_headers expect(response).to include_pagination_headers
expect(json_response).to be_an Array expect(json_response).to be_an Array
@ -74,7 +74,7 @@ describe API::Runners do
it 'returns all runners' do it 'returns all runners' do
get api('/runners/all', admin) get api('/runners/all', admin)
shared = json_response.any?{ |r| r['is_shared'] } shared = json_response.any? { |r| r['is_shared'] }
expect(response).to have_http_status(200) expect(response).to have_http_status(200)
expect(response).to include_pagination_headers expect(response).to include_pagination_headers
expect(json_response).to be_an Array expect(json_response).to be_an Array
@ -93,7 +93,7 @@ describe API::Runners do
it 'filters runners by scope' do it 'filters runners by scope' do
get api('/runners/all?scope=specific', admin) get api('/runners/all?scope=specific', admin)
shared = json_response.any?{ |r| r['is_shared'] } shared = json_response.any? { |r| r['is_shared'] }
expect(response).to have_http_status(200) expect(response).to have_http_status(200)
expect(response).to include_pagination_headers expect(response).to include_pagination_headers
expect(json_response).to be_an Array expect(json_response).to be_an Array
@ -277,7 +277,7 @@ describe API::Runners do
delete api("/runners/#{shared_runner.id}", admin) delete api("/runners/#{shared_runner.id}", admin)
expect(response).to have_http_status(204) expect(response).to have_http_status(204)
end.to change{ Ci::Runner.shared.count }.by(-1) end.to change { Ci::Runner.shared.count }.by(-1)
end end
end end
@ -287,7 +287,7 @@ describe API::Runners do
delete api("/runners/#{unused_specific_runner.id}", admin) delete api("/runners/#{unused_specific_runner.id}", admin)
expect(response).to have_http_status(204) expect(response).to have_http_status(204)
end.to change{ Ci::Runner.specific.count }.by(-1) end.to change { Ci::Runner.specific.count }.by(-1)
end end
it 'deletes used runner' do it 'deletes used runner' do
@ -295,7 +295,7 @@ describe API::Runners do
delete api("/runners/#{specific_runner.id}", admin) delete api("/runners/#{specific_runner.id}", admin)
expect(response).to have_http_status(204) expect(response).to have_http_status(204)
end.to change{ Ci::Runner.specific.count }.by(-1) end.to change { Ci::Runner.specific.count }.by(-1)
end end
end end
@ -330,7 +330,7 @@ describe API::Runners do
delete api("/runners/#{specific_runner.id}", user) delete api("/runners/#{specific_runner.id}", user)
expect(response).to have_http_status(204) expect(response).to have_http_status(204)
end.to change{ Ci::Runner.specific.count }.by(-1) end.to change { Ci::Runner.specific.count }.by(-1)
end end
end end
end end
@ -349,7 +349,7 @@ describe API::Runners do
it "returns project's runners" do it "returns project's runners" do
get api("/projects/#{project.id}/runners", user) get api("/projects/#{project.id}/runners", user)
shared = json_response.any?{ |r| r['is_shared'] } shared = json_response.any? { |r| r['is_shared'] }
expect(response).to have_http_status(200) expect(response).to have_http_status(200)
expect(response).to include_pagination_headers expect(response).to include_pagination_headers
expect(json_response).to be_an Array expect(json_response).to be_an Array
@ -385,14 +385,14 @@ describe API::Runners do
it 'enables specific runner' do it 'enables specific runner' do
expect do expect do
post api("/projects/#{project.id}/runners", user), runner_id: specific_runner2.id post api("/projects/#{project.id}/runners", user), runner_id: specific_runner2.id
end.to change{ project.runners.count }.by(+1) end.to change { project.runners.count }.by(+1)
expect(response).to have_http_status(201) expect(response).to have_http_status(201)
end end
it 'avoids changes when enabling already enabled runner' do it 'avoids changes when enabling already enabled runner' do
expect do expect do
post api("/projects/#{project.id}/runners", user), runner_id: specific_runner.id post api("/projects/#{project.id}/runners", user), runner_id: specific_runner.id
end.to change{ project.runners.count }.by(0) end.to change { project.runners.count }.by(0)
expect(response).to have_http_status(409) expect(response).to have_http_status(409)
end end
@ -401,7 +401,7 @@ describe API::Runners do
expect do expect do
post api("/projects/#{project.id}/runners", user), runner_id: specific_runner2.id post api("/projects/#{project.id}/runners", user), runner_id: specific_runner2.id
end.to change{ project.runners.count }.by(0) end.to change { project.runners.count }.by(0)
expect(response).to have_http_status(403) expect(response).to have_http_status(403)
end end
@ -416,7 +416,7 @@ describe API::Runners do
it 'enables any specific runner' do it 'enables any specific runner' do
expect do expect do
post api("/projects/#{project.id}/runners", admin), runner_id: unused_specific_runner.id post api("/projects/#{project.id}/runners", admin), runner_id: unused_specific_runner.id
end.to change{ project.runners.count }.by(+1) end.to change { project.runners.count }.by(+1)
expect(response).to have_http_status(201) expect(response).to have_http_status(201)
end end
end end
@ -461,7 +461,7 @@ describe API::Runners do
delete api("/projects/#{project.id}/runners/#{two_projects_runner.id}", user) delete api("/projects/#{project.id}/runners/#{two_projects_runner.id}", user)
expect(response).to have_http_status(204) expect(response).to have_http_status(204)
end.to change{ project.runners.count }.by(-1) end.to change { project.runners.count }.by(-1)
end end
end end
@ -469,7 +469,7 @@ describe API::Runners do
it "does not disable project's runner" do it "does not disable project's runner" do
expect do expect do
delete api("/projects/#{project.id}/runners/#{specific_runner.id}", user) delete api("/projects/#{project.id}/runners/#{specific_runner.id}", user)
end.to change{ project.runners.count }.by(0) end.to change { project.runners.count }.by(0)
expect(response).to have_http_status(403) expect(response).to have_http_status(403)
end end
end end

View File

@ -52,10 +52,10 @@ describe API::Snippets do
expect(json_response.map { |snippet| snippet['id']} ).to contain_exactly( expect(json_response.map { |snippet| snippet['id']} ).to contain_exactly(
public_snippet.id, public_snippet.id,
public_snippet_other.id) public_snippet_other.id)
expect(json_response.map{ |snippet| snippet['web_url']} ).to include( expect(json_response.map { |snippet| snippet['web_url']} ).to include(
"http://localhost/snippets/#{public_snippet.id}", "http://localhost/snippets/#{public_snippet.id}",
"http://localhost/snippets/#{public_snippet_other.id}") "http://localhost/snippets/#{public_snippet_other.id}")
expect(json_response.map{ |snippet| snippet['raw_url']} ).to include( expect(json_response.map { |snippet| snippet['raw_url']} ).to include(
"http://localhost/snippets/#{public_snippet.id}/raw", "http://localhost/snippets/#{public_snippet.id}/raw",
"http://localhost/snippets/#{public_snippet_other.id}/raw") "http://localhost/snippets/#{public_snippet_other.id}/raw")
end end

View File

@ -185,7 +185,7 @@ describe API::Triggers do
expect do expect do
post api("/projects/#{project.id}/triggers", user), post api("/projects/#{project.id}/triggers", user),
description: 'trigger' description: 'trigger'
end.to change{project.triggers.count}.by(1) end.to change {project.triggers.count}.by(1)
expect(response).to have_http_status(201) expect(response).to have_http_status(201)
expect(json_response).to include('description' => 'trigger') expect(json_response).to include('description' => 'trigger')
@ -288,7 +288,7 @@ describe API::Triggers do
delete api("/projects/#{project.id}/triggers/#{trigger.id}", user) delete api("/projects/#{project.id}/triggers/#{trigger.id}", user)
expect(response).to have_http_status(204) expect(response).to have_http_status(204)
end.to change{project.triggers.count}.by(-1) end.to change {project.triggers.count}.by(-1)
end end
it 'responds with 404 Not Found if requesting non-existing trigger' do it 'responds with 404 Not Found if requesting non-existing trigger' do

View File

@ -87,7 +87,7 @@ describe API::V3::DeployKeys do
expect do expect do
post v3_api("/projects/#{project.id}/#{path}", admin), key_attrs post v3_api("/projects/#{project.id}/#{path}", admin), key_attrs
end.to change{ project.deploy_keys.count }.by(1) end.to change { project.deploy_keys.count }.by(1)
end end
it 'returns an existing ssh key when attempting to add a duplicate' do it 'returns an existing ssh key when attempting to add a duplicate' do
@ -122,7 +122,7 @@ describe API::V3::DeployKeys do
it 'should delete existing key' do it 'should delete existing key' do
expect do expect do
delete v3_api("/projects/#{project.id}/#{path}/#{deploy_key.id}", admin) delete v3_api("/projects/#{project.id}/#{path}/#{deploy_key.id}", admin)
end.to change{ project.deploy_keys.count }.by(-1) end.to change { project.deploy_keys.count }.by(-1)
end end
it 'should return 404 Not Found with invalid ID' do it 'should return 404 Not Found with invalid ID' do

View File

@ -90,7 +90,7 @@ describe API::MergeRequests do
expect(response).to have_http_status(200) expect(response).to have_http_status(200)
expect(json_response).to be_an Array expect(json_response).to be_an Array
expect(json_response.length).to eq(3) expect(json_response.length).to eq(3)
response_dates = json_response.map{ |merge_request| merge_request['created_at'] } response_dates = json_response.map { |merge_request| merge_request['created_at'] }
expect(response_dates).to eq(response_dates.sort) expect(response_dates).to eq(response_dates.sort)
end end
@ -99,7 +99,7 @@ describe API::MergeRequests do
expect(response).to have_http_status(200) expect(response).to have_http_status(200)
expect(json_response).to be_an Array expect(json_response).to be_an Array
expect(json_response.length).to eq(3) expect(json_response.length).to eq(3)
response_dates = json_response.map{ |merge_request| merge_request['created_at'] } response_dates = json_response.map { |merge_request| merge_request['created_at'] }
expect(response_dates).to eq(response_dates.sort.reverse) expect(response_dates).to eq(response_dates.sort.reverse)
end end
@ -108,7 +108,7 @@ describe API::MergeRequests do
expect(response).to have_http_status(200) expect(response).to have_http_status(200)
expect(json_response).to be_an Array expect(json_response).to be_an Array
expect(json_response.length).to eq(3) expect(json_response.length).to eq(3)
response_dates = json_response.map{ |merge_request| merge_request['updated_at'] } response_dates = json_response.map { |merge_request| merge_request['updated_at'] }
expect(response_dates).to eq(response_dates.sort.reverse) expect(response_dates).to eq(response_dates.sort.reverse)
end end
@ -117,7 +117,7 @@ describe API::MergeRequests do
expect(response).to have_http_status(200) expect(response).to have_http_status(200)
expect(json_response).to be_an Array expect(json_response).to be_an Array
expect(json_response.length).to eq(3) expect(json_response.length).to eq(3)
response_dates = json_response.map{ |merge_request| merge_request['created_at'] } response_dates = json_response.map { |merge_request| merge_request['created_at'] }
expect(response_dates).to eq(response_dates.sort) expect(response_dates).to eq(response_dates.sort)
end end
end end

View File

@ -30,7 +30,7 @@ describe API::ProjectSnippets do
expect(response).to have_http_status(200) expect(response).to have_http_status(200)
expect(json_response.size).to eq(3) expect(json_response.size).to eq(3)
expect(json_response.map{ |snippet| snippet['id']} ).to include(public_snippet.id, internal_snippet.id, private_snippet.id) expect(json_response.map { |snippet| snippet['id']} ).to include(public_snippet.id, internal_snippet.id, private_snippet.id)
expect(json_response.last).to have_key('web_url') expect(json_response.last).to have_key('web_url')
end end

View File

@ -38,7 +38,7 @@ describe API::V3::Runners do
delete v3_api("/runners/#{shared_runner.id}", admin) delete v3_api("/runners/#{shared_runner.id}", admin)
expect(response).to have_http_status(200) expect(response).to have_http_status(200)
end.to change{ Ci::Runner.shared.count }.by(-1) end.to change { Ci::Runner.shared.count }.by(-1)
end end
end end
@ -48,7 +48,7 @@ describe API::V3::Runners do
delete v3_api("/runners/#{unused_specific_runner.id}", admin) delete v3_api("/runners/#{unused_specific_runner.id}", admin)
expect(response).to have_http_status(200) expect(response).to have_http_status(200)
end.to change{ Ci::Runner.specific.count }.by(-1) end.to change { Ci::Runner.specific.count }.by(-1)
end end
it 'deletes used runner' do it 'deletes used runner' do
@ -56,7 +56,7 @@ describe API::V3::Runners do
delete v3_api("/runners/#{specific_runner.id}", admin) delete v3_api("/runners/#{specific_runner.id}", admin)
expect(response).to have_http_status(200) expect(response).to have_http_status(200)
end.to change{ Ci::Runner.specific.count }.by(-1) end.to change { Ci::Runner.specific.count }.by(-1)
end end
end end
@ -91,7 +91,7 @@ describe API::V3::Runners do
delete v3_api("/runners/#{specific_runner.id}", user) delete v3_api("/runners/#{specific_runner.id}", user)
expect(response).to have_http_status(200) expect(response).to have_http_status(200)
end.to change{ Ci::Runner.specific.count }.by(-1) end.to change { Ci::Runner.specific.count }.by(-1)
end end
end end
end end
@ -113,7 +113,7 @@ describe API::V3::Runners do
delete v3_api("/projects/#{project.id}/runners/#{two_projects_runner.id}", user) delete v3_api("/projects/#{project.id}/runners/#{two_projects_runner.id}", user)
expect(response).to have_http_status(200) expect(response).to have_http_status(200)
end.to change{ project.runners.count }.by(-1) end.to change { project.runners.count }.by(-1)
end end
end end
@ -121,7 +121,7 @@ describe API::V3::Runners do
it "does not disable project's runner" do it "does not disable project's runner" do
expect do expect do
delete v3_api("/projects/#{project.id}/runners/#{specific_runner.id}", user) delete v3_api("/projects/#{project.id}/runners/#{specific_runner.id}", user)
end.to change{ project.runners.count }.by(0) end.to change { project.runners.count }.by(0)
expect(response).to have_http_status(403) expect(response).to have_http_status(403)
end end
end end

View File

@ -45,10 +45,10 @@ describe API::V3::Snippets do
expect(json_response.map { |snippet| snippet['id']} ).to contain_exactly( expect(json_response.map { |snippet| snippet['id']} ).to contain_exactly(
public_snippet.id, public_snippet.id,
public_snippet_other.id) public_snippet_other.id)
expect(json_response.map{ |snippet| snippet['web_url']} ).to include( expect(json_response.map { |snippet| snippet['web_url']} ).to include(
"http://localhost/snippets/#{public_snippet.id}", "http://localhost/snippets/#{public_snippet.id}",
"http://localhost/snippets/#{public_snippet_other.id}") "http://localhost/snippets/#{public_snippet_other.id}")
expect(json_response.map{ |snippet| snippet['raw_url']} ).to include( expect(json_response.map { |snippet| snippet['raw_url']} ).to include(
"http://localhost/snippets/#{public_snippet.id}/raw", "http://localhost/snippets/#{public_snippet.id}/raw",
"http://localhost/snippets/#{public_snippet_other.id}/raw") "http://localhost/snippets/#{public_snippet_other.id}/raw")
end end

View File

@ -171,7 +171,7 @@ describe API::V3::Triggers do
it 'creates trigger' do it 'creates trigger' do
expect do expect do
post v3_api("/projects/#{project.id}/triggers", user) post v3_api("/projects/#{project.id}/triggers", user)
end.to change{project.triggers.count}.by(1) end.to change {project.triggers.count}.by(1)
expect(response).to have_http_status(201) expect(response).to have_http_status(201)
expect(json_response).to be_a(Hash) expect(json_response).to be_a(Hash)
@ -202,7 +202,7 @@ describe API::V3::Triggers do
delete v3_api("/projects/#{project.id}/triggers/#{trigger.token}", user) delete v3_api("/projects/#{project.id}/triggers/#{trigger.token}", user)
expect(response).to have_http_status(200) expect(response).to have_http_status(200)
end.to change{project.triggers.count}.by(-1) end.to change {project.triggers.count}.by(-1)
end end
it 'responds with 404 Not Found if requesting non-existing trigger' do it 'responds with 404 Not Found if requesting non-existing trigger' do

View File

@ -74,7 +74,7 @@ describe API::Variables do
it 'creates variable' do it 'creates variable' do
expect do expect do
post api("/projects/#{project.id}/variables", user), key: 'TEST_VARIABLE_2', value: 'VALUE_2', protected: true post api("/projects/#{project.id}/variables", user), key: 'TEST_VARIABLE_2', value: 'VALUE_2', protected: true
end.to change{project.variables.count}.by(1) end.to change {project.variables.count}.by(1)
expect(response).to have_http_status(201) expect(response).to have_http_status(201)
expect(json_response['key']).to eq('TEST_VARIABLE_2') expect(json_response['key']).to eq('TEST_VARIABLE_2')
@ -85,7 +85,7 @@ describe API::Variables do
it 'creates variable with optional attributes' do it 'creates variable with optional attributes' do
expect do expect do
post api("/projects/#{project.id}/variables", user), key: 'TEST_VARIABLE_2', value: 'VALUE_2' post api("/projects/#{project.id}/variables", user), key: 'TEST_VARIABLE_2', value: 'VALUE_2'
end.to change{project.variables.count}.by(1) end.to change {project.variables.count}.by(1)
expect(response).to have_http_status(201) expect(response).to have_http_status(201)
expect(json_response['key']).to eq('TEST_VARIABLE_2') expect(json_response['key']).to eq('TEST_VARIABLE_2')
@ -96,7 +96,7 @@ describe API::Variables do
it 'does not allow to duplicate variable key' do it 'does not allow to duplicate variable key' do
expect do expect do
post api("/projects/#{project.id}/variables", user), key: variable.key, value: 'VALUE_2' post api("/projects/#{project.id}/variables", user), key: variable.key, value: 'VALUE_2'
end.to change{project.variables.count}.by(0) end.to change {project.variables.count}.by(0)
expect(response).to have_http_status(400) expect(response).to have_http_status(400)
end end
@ -166,7 +166,7 @@ describe API::Variables do
delete api("/projects/#{project.id}/variables/#{variable.key}", user) delete api("/projects/#{project.id}/variables/#{variable.key}", user)
expect(response).to have_http_status(204) expect(response).to have_http_status(204)
end.to change{project.variables.count}.by(-1) end.to change {project.variables.count}.by(-1)
end end
it 'responds with 404 Not Found if requesting non-existing variable' do it 'responds with 404 Not Found if requesting non-existing variable' do

View File

@ -421,7 +421,7 @@ describe Ci::API::Builds do
end end
context 'when build has been updated recently' do context 'when build has been updated recently' do
it { expect{ patch_the_trace }.not_to change { build.updated_at }} it { expect { patch_the_trace }.not_to change { build.updated_at }}
it 'changes the build trace' do it 'changes the build trace' do
patch_the_trace patch_the_trace
@ -430,7 +430,7 @@ describe Ci::API::Builds do
end end
context 'when Runner makes a force-patch' do context 'when Runner makes a force-patch' do
it { expect{ force_patch_the_trace }.not_to change { build.updated_at }} it { expect { force_patch_the_trace }.not_to change { build.updated_at }}
it "doesn't change the build.trace" do it "doesn't change the build.trace" do
force_patch_the_trace force_patch_the_trace

View File

@ -47,7 +47,7 @@ describe AnalyticsBuildEntity do
let(:finished_at) { nil } let(:finished_at) { nil }
it 'does not blow up' do it 'does not blow up' do
expect{ subject[:date] }.not_to raise_error expect { subject[:date] }.not_to raise_error
end end
it 'shows the right message' do it 'shows the right message' do
@ -63,7 +63,7 @@ describe AnalyticsBuildEntity do
let(:started_at) { nil } let(:started_at) { nil }
it 'does not blow up' do it 'does not blow up' do
expect{ subject[:date] }.not_to raise_error expect { subject[:date] }.not_to raise_error
end end
it 'shows the right message' do it 'shows the right message' do
@ -79,7 +79,7 @@ describe AnalyticsBuildEntity do
let(:finished_at) { nil } let(:finished_at) { nil }
it 'does not blow up' do it 'does not blow up' do
expect{ subject[:date] }.not_to raise_error expect { subject[:date] }.not_to raise_error
end end
it 'shows the right message' do it 'shows the right message' do

View File

@ -132,7 +132,7 @@ describe GitPushService, services: true do
end end
it "creates a new pipeline" do it "creates a new pipeline" do
expect{ subject }.to change{ Ci::Pipeline.count } expect { subject }.to change { Ci::Pipeline.count }
expect(Ci::Pipeline.last).to be_push expect(Ci::Pipeline.last).to be_push
end end
end end

View File

@ -39,7 +39,7 @@ describe GitTagPushService do
end end
it "creates a new pipeline" do it "creates a new pipeline" do
expect{ subject }.to change{ Ci::Pipeline.count } expect { subject }.to change { Ci::Pipeline.count }
expect(Ci::Pipeline.last).to be_push expect(Ci::Pipeline.last).to be_push
end end
end end

View File

@ -118,7 +118,7 @@ describe Issuable::BulkUpdateService do
context 'when the new assignee ID is not present' do context 'when the new assignee ID is not present' do
it 'does not unassign' do it 'does not unassign' do
expect { bulk_update(issue, assignee_ids: []) } expect { bulk_update(issue, assignee_ids: []) }
.not_to change{ issue.reload.assignees } .not_to change { issue.reload.assignees }
end end
end end
end end

View File

@ -351,14 +351,14 @@ describe Issues::CreateService do
end end
it 'marks related spam_log as recaptcha_verified' do it 'marks related spam_log as recaptcha_verified' do
expect { issue }.to change{SpamLog.last.recaptcha_verified}.from(false).to(true) expect { issue }.to change {SpamLog.last.recaptcha_verified}.from(false).to(true)
end end
context 'when spam log does not belong to a user' do context 'when spam log does not belong to a user' do
let(:log_user) { create(:user) } let(:log_user) { create(:user) }
it 'does not mark spam_log as recaptcha_verified' do it 'does not mark spam_log as recaptcha_verified' do
expect { issue }.not_to change{SpamLog.last.recaptcha_verified} expect { issue }.not_to change {SpamLog.last.recaptcha_verified}
end end
end end
end end
@ -378,7 +378,7 @@ describe Issues::CreateService do
end end
it 'creates a new spam_log' do it 'creates a new spam_log' do
expect{issue}.to change{SpamLog.count}.from(0).to(1) expect {issue}.to change {SpamLog.count}.from(0).to(1)
end end
it 'assigns a spam_log to an issue' do it 'assigns a spam_log to an issue' do

View File

@ -478,7 +478,7 @@ describe Issues::UpdateService, :mailer do
feature_visibility_attr = :"#{issue.model_name.plural}_access_level" feature_visibility_attr = :"#{issue.model_name.plural}_access_level"
project.project_feature.update_attribute(feature_visibility_attr, ProjectFeature::PRIVATE) project.project_feature.update_attribute(feature_visibility_attr, ProjectFeature::PRIVATE)
expect{ update_issue(assignee_ids: [assignee.id]) }.not_to change{ issue.assignees } expect { update_issue(assignee_ids: [assignee.id]) }.not_to change { issue.assignees }
end end
end end
end end

View File

@ -509,7 +509,7 @@ describe MergeRequests::UpdateService, :mailer do
feature_visibility_attr = :"#{merge_request.model_name.plural}_access_level" feature_visibility_attr = :"#{merge_request.model_name.plural}_access_level"
project.project_feature.update_attribute(feature_visibility_attr, ProjectFeature::PRIVATE) project.project_feature.update_attribute(feature_visibility_attr, ProjectFeature::PRIVATE)
expect{ update_merge_request(assignee_id: assignee) }.not_to change{ merge_request.assignee } expect { update_merge_request(assignee_id: assignee) }.not_to change { merge_request.assignee }
end end
end end
end end

View File

@ -85,7 +85,7 @@ describe NotificationService, :mailer do
it { expect(notification.new_key(key)).to be_truthy } it { expect(notification.new_key(key)).to be_truthy }
it 'sends email to key owner' do it 'sends email to key owner' do
expect{ notification.new_key(key) }.to change{ ActionMailer::Base.deliveries.size }.by(1) expect { notification.new_key(key) }.to change { ActionMailer::Base.deliveries.size }.by(1)
end end
end end
end end
@ -97,7 +97,7 @@ describe NotificationService, :mailer do
it { expect(notification.new_gpg_key(key)).to be_truthy } it { expect(notification.new_gpg_key(key)).to be_truthy }
it 'sends email to key owner' do it 'sends email to key owner' do
expect{ notification.new_gpg_key(key) }.to change{ ActionMailer::Base.deliveries.size }.by(1) expect { notification.new_gpg_key(key) }.to change { ActionMailer::Base.deliveries.size }.by(1)
end end
end end
end end
@ -109,7 +109,7 @@ describe NotificationService, :mailer do
it { expect(notification.new_email(email)).to be_truthy } it { expect(notification.new_email(email)).to be_truthy }
it 'sends email to email owner' do it 'sends email to email owner' do
expect{ notification.new_email(email) }.to change{ ActionMailer::Base.deliveries.size }.by(1) expect { notification.new_email(email) }.to change { ActionMailer::Base.deliveries.size }.by(1)
end end
end end
end end

View File

@ -19,7 +19,7 @@ describe ProtectedBranches::UpdateService do
let(:user) { create(:user) } let(:user) { create(:user) }
it "raises error" do it "raises error" do
expect{ service.execute(protected_branch) }.to raise_error(Gitlab::Access::AccessDeniedError) expect { service.execute(protected_branch) }.to raise_error(Gitlab::Access::AccessDeniedError)
end end
end end
end end

View File

@ -19,7 +19,7 @@ describe ProtectedTags::UpdateService do
let(:user) { create(:user) } let(:user) { create(:user) }
it "raises error" do it "raises error" do
expect{ service.execute(protected_tag) }.to raise_error(Gitlab::Access::AccessDeniedError) expect { service.execute(protected_tag) }.to raise_error(Gitlab::Access::AccessDeniedError)
end end
end end
end end

View File

@ -35,7 +35,7 @@ describe SystemNoteService do
context 'metadata' do context 'metadata' do
it 'creates a new system note metadata record' do it 'creates a new system note metadata record' do
expect { subject }.to change{ SystemNoteMetadata.count }.from(0).to(1) expect { subject }.to change { SystemNoteMetadata.count }.from(0).to(1)
end end
it 'creates a record correctly' do it 'creates a record correctly' do
@ -477,7 +477,7 @@ describe SystemNoteService do
end end
it 'does not create a system note metadata record' do it 'does not create a system note metadata record' do
expect { subject }.not_to change{ SystemNoteMetadata.count } expect { subject }.not_to change { SystemNoteMetadata.count }
end end
end end

View File

@ -586,13 +586,13 @@ describe TodoService do
it 'does not create a directly addressed todo if user was already mentioned or addressed and todo is pending' do it 'does not create a directly addressed todo if user was already mentioned or addressed and todo is pending' do
create(:todo, :directly_addressed, user: member, project: project, target: addressed_mr_assigned, author: author) create(:todo, :directly_addressed, user: member, project: project, target: addressed_mr_assigned, author: author)
expect{ service.update_merge_request(addressed_mr_assigned, author) }.not_to change(member.todos, :count) expect { service.update_merge_request(addressed_mr_assigned, author) }.not_to change(member.todos, :count)
end end
it 'does not create a directly addressed todo if user was already mentioned or addressed and todo is done' do it 'does not create a directly addressed todo if user was already mentioned or addressed and todo is done' do
create(:todo, :directly_addressed, user: skipped, project: project, target: addressed_mr_assigned, author: author) create(:todo, :directly_addressed, user: skipped, project: project, target: addressed_mr_assigned, author: author)
expect{ service.update_merge_request(addressed_mr_assigned, author, skip_users) }.not_to change(skipped.todos, :count) expect { service.update_merge_request(addressed_mr_assigned, author, skip_users) }.not_to change(skipped.todos, :count)
end end
context 'with a task list' do context 'with a task list' do

View File

@ -50,7 +50,7 @@ shared_examples_for 'group and project milestones' do |route_definition|
expect(response).to have_http_status(200) expect(response).to have_http_status(200)
expect(json_response).to be_an Array expect(json_response).to be_an Array
expect(json_response.length).to eq(2) expect(json_response.length).to eq(2)
expect(json_response.map{ |m| m['id'] }).to match_array([closed_milestone.id, other_milestone.id]) expect(json_response.map { |m| m['id'] }).to match_array([closed_milestone.id, other_milestone.id])
end end
it 'does not return any milestone if none found' do it 'does not return any milestone if none found' do

View File

@ -28,6 +28,6 @@ RSpec::Matchers.define :make_queries_matching do |matcher, expected_count = nil|
def query_count(regex, &block) def query_count(regex, &block)
@recorder = ActiveRecord::QueryRecorder.new(&block).log @recorder = ActiveRecord::QueryRecorder.new(&block).log
@recorder.select{ |q| q.match(regex) } @recorder.select { |q| q.match(regex) }
end end
end end

View File

@ -2,14 +2,14 @@ require 'rake_helper'
Rake.application.rake_require 'tasks/config_lint' Rake.application.rake_require 'tasks/config_lint'
describe ConfigLint do 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 { described_class.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 { described_class.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

View File

@ -41,7 +41,7 @@ describe NewIssueWorker do
let(:issue) { create(:issue, project: project, description: "issue for #{mentioned.to_reference}") } let(:issue) { create(:issue, project: project, description: "issue for #{mentioned.to_reference}") }
it 'creates a new event record' do it 'creates a new event record' do
expect{ worker.perform(issue.id, user.id) }.to change { Event.count }.from(0).to(1) expect { worker.perform(issue.id, user.id) }.to change { Event.count }.from(0).to(1)
end end
it 'creates a notification for the assignee' do it 'creates a notification for the assignee' do

View File

@ -43,7 +43,7 @@ describe NewMergeRequestWorker do
end end
it 'creates a new event record' do it 'creates a new event record' do
expect{ worker.perform(merge_request.id, user.id) }.to change { Event.count }.from(0).to(1) expect { worker.perform(merge_request.id, user.id) }.to change { Event.count }.from(0).to(1)
end end
it 'creates a notification for the assignee' do it 'creates a notification for the assignee' do

View File

@ -23,7 +23,7 @@ describe PipelineScheduleWorker do
context 'when there is a scheduled pipeline within next_run_at' do context 'when there is a scheduled pipeline within next_run_at' do
it 'creates a new pipeline' do it 'creates a new pipeline' do
expect{ subject }.to change { project.pipelines.count }.by(1) expect { subject }.to change { project.pipelines.count }.by(1)
expect(Ci::Pipeline.last).to be_schedule expect(Ci::Pipeline.last).to be_schedule
end end

View File

@ -78,7 +78,7 @@ describe PostReceive do
stub_ci_pipeline_to_return_yaml_file stub_ci_pipeline_to_return_yaml_file
end end
it { expect{ subject }.to change{ Ci::Pipeline.count }.by(2) } it { expect { subject }.to change { Ci::Pipeline.count }.by(2) }
end end
context "does not create a Ci::Pipeline" do context "does not create a Ci::Pipeline" do
@ -86,7 +86,7 @@ describe PostReceive do
stub_ci_pipeline_yaml_file(nil) stub_ci_pipeline_yaml_file(nil)
end end
it { expect{ subject }.not_to change{ Ci::Pipeline.count } } it { expect { subject }.not_to change { Ci::Pipeline.count } }
end end
end end