diff --git a/.rubocop.yml b/.rubocop.yml
index 70e11be29cf..2ce32ca5002 100644
--- a/.rubocop.yml
+++ b/.rubocop.yml
@@ -138,7 +138,7 @@ Style/Documentation:
Style/DotPosition:
Enabled: true
- EnforcedStyle: trailing
+ EnforcedStyle: leading
# Align elses and elsifs correctly.
Style/ElseAlignment:
diff --git a/app/controllers/admin/application_settings_controller.rb b/app/controllers/admin/application_settings_controller.rb
index f801fac1839..b0f5d4a9933 100644
--- a/app/controllers/admin/application_settings_controller.rb
+++ b/app/controllers/admin/application_settings_controller.rb
@@ -5,9 +5,9 @@ class Admin::ApplicationSettingsController < Admin::ApplicationController
end
def update
- successful = ApplicationSettings::UpdateService.
- new(@application_setting, current_user, application_setting_params).
- execute
+ successful = ApplicationSettings::UpdateService
+ .new(@application_setting, current_user, application_setting_params)
+ .execute
if successful
redirect_to admin_application_settings_path,
diff --git a/app/controllers/concerns/creates_commit.rb b/app/controllers/concerns/creates_commit.rb
index 2fe03020d2d..41c660be378 100644
--- a/app/controllers/concerns/creates_commit.rb
+++ b/app/controllers/concerns/creates_commit.rb
@@ -83,8 +83,8 @@ module CreatesCommit
def merge_request_exists?
return @merge_request if defined?(@merge_request)
- @merge_request = MergeRequestsFinder.new(current_user, project_id: @mr_target_project.id).execute.opened.
- find_by(source_branch: @mr_source_branch, target_branch: @mr_target_branch, source_project_id: @mr_source_project)
+ @merge_request = MergeRequestsFinder.new(current_user, project_id: @mr_target_project.id).execute.opened
+ .find_by(source_branch: @mr_source_branch, target_branch: @mr_target_branch, source_project_id: @mr_source_project)
end
def different_project?
diff --git a/app/controllers/concerns/issues_action.rb b/app/controllers/concerns/issues_action.rb
index 8b985b6d003..b17c138d5c7 100644
--- a/app/controllers/concerns/issues_action.rb
+++ b/app/controllers/concerns/issues_action.rb
@@ -5,9 +5,9 @@ module IssuesAction
def issues
@label = issues_finder.labels.first
- @issues = issues_collection.
- non_archived.
- page(params[:page])
+ @issues = issues_collection
+ .non_archived
+ .page(params[:page])
@collection_type = "Issue"
@issuable_meta_data = issuable_meta_data(@issues, @collection_type)
diff --git a/app/controllers/concerns/membership_actions.rb b/app/controllers/concerns/membership_actions.rb
index c13333641d3..43ca4b6ac02 100644
--- a/app/controllers/concerns/membership_actions.rb
+++ b/app/controllers/concerns/membership_actions.rb
@@ -15,8 +15,8 @@ module MembershipActions
end
def leave
- member = Members::DestroyService.new(membershipable, current_user, user_id: current_user.id).
- execute(:all)
+ member = Members::DestroyService.new(membershipable, current_user, user_id: current_user.id)
+ .execute(:all)
source_type = membershipable.class.to_s.humanize(capitalize: false)
notice =
diff --git a/app/controllers/concerns/merge_requests_action.rb b/app/controllers/concerns/merge_requests_action.rb
index 28e34cffc24..d3c8e4888bc 100644
--- a/app/controllers/concerns/merge_requests_action.rb
+++ b/app/controllers/concerns/merge_requests_action.rb
@@ -5,8 +5,8 @@ module MergeRequestsAction
def merge_requests
@label = merge_requests_finder.labels.first
- @merge_requests = merge_requests_collection.
- page(params[:page])
+ @merge_requests = merge_requests_collection
+ .page(params[:page])
@collection_type = "MergeRequest"
@issuable_meta_data = issuable_meta_data(@merge_requests, @collection_type)
diff --git a/app/controllers/import/bitbucket_controller.rb b/app/controllers/import/bitbucket_controller.rb
index cd5cef2c20f..8e42cdf415f 100644
--- a/app/controllers/import/bitbucket_controller.rb
+++ b/app/controllers/import/bitbucket_controller.rb
@@ -29,9 +29,9 @@ class Import::BitbucketController < Import::BaseController
end
def jobs
- render json: current_user.created_projects.
- where(import_type: 'bitbucket').
- to_json(only: [:id, :import_status])
+ render json: current_user.created_projects
+ .where(import_type: 'bitbucket')
+ .to_json(only: [:id, :import_status])
end
def create
diff --git a/app/controllers/jwt_controller.rb b/app/controllers/jwt_controller.rb
index cc3df3bd127..3eac6285394 100644
--- a/app/controllers/jwt_controller.rb
+++ b/app/controllers/jwt_controller.rb
@@ -11,8 +11,8 @@ class JwtController < ApplicationController
service = SERVICES[params[:service]]
return head :not_found unless service
- result = service.new(@authentication_result.project, @authentication_result.actor, auth_params).
- execute(authentication_abilities: @authentication_result.authentication_abilities)
+ result = service.new(@authentication_result.project, @authentication_result.actor, auth_params)
+ .execute(authentication_abilities: @authentication_result.authentication_abilities)
render json: result, status: result[:http_status]
end
diff --git a/app/controllers/omniauth_callbacks_controller.rb b/app/controllers/omniauth_callbacks_controller.rb
index 58d50ad647b..0faa446aff9 100644
--- a/app/controllers/omniauth_callbacks_controller.rb
+++ b/app/controllers/omniauth_callbacks_controller.rb
@@ -144,7 +144,7 @@ class OmniauthCallbacksController < Devise::OmniauthCallbacksController
end
def log_audit_event(user, options = {})
- AuditEventService.new(user, user, options).
- for_authentication.security_event
+ AuditEventService.new(user, user, options)
+ .for_authentication.security_event
end
end
diff --git a/app/controllers/profiles_controller.rb b/app/controllers/profiles_controller.rb
index f0c71725ea8..cc500af81db 100644
--- a/app/controllers/profiles_controller.rb
+++ b/app/controllers/profiles_controller.rb
@@ -41,9 +41,9 @@ class ProfilesController < Profiles::ApplicationController
end
def audit_log
- @events = AuditEvent.where(entity_type: "User", entity_id: current_user.id).
- order("created_at DESC").
- page(params[:page])
+ @events = AuditEvent.where(entity_type: "User", entity_id: current_user.id)
+ .order("created_at DESC")
+ .page(params[:page])
end
def update_username
diff --git a/app/controllers/projects/badges_controller.rb b/app/controllers/projects/badges_controller.rb
index c1727d9fa28..6c25cd83a24 100644
--- a/app/controllers/projects/badges_controller.rb
+++ b/app/controllers/projects/badges_controller.rb
@@ -4,15 +4,15 @@ class Projects::BadgesController < Projects::ApplicationController
before_action :no_cache_headers, except: [:index]
def build
- build_status = Gitlab::Badge::Build::Status.
- new(project, params[:ref])
+ build_status = Gitlab::Badge::Build::Status
+ .new(project, params[:ref])
render_badge build_status
end
def coverage
- coverage_report = Gitlab::Badge::Coverage::Report.
- new(project, params[:ref], params[:job])
+ coverage_report = Gitlab::Badge::Coverage::Report
+ .new(project, params[:ref], params[:job])
render_badge coverage_report
end
diff --git a/app/controllers/projects/blob_controller.rb b/app/controllers/projects/blob_controller.rb
index 39ba815cfca..647faca40a0 100644
--- a/app/controllers/projects/blob_controller.rb
+++ b/app/controllers/projects/blob_controller.rb
@@ -164,7 +164,7 @@ class Projects::BlobController < Projects::ApplicationController
end
def set_last_commit_sha
- @last_commit_sha = Gitlab::Git::Commit.
- last_for_path(@repository, @ref, @path).sha
+ @last_commit_sha = Gitlab::Git::Commit
+ .last_for_path(@repository, @ref, @path).sha
end
end
diff --git a/app/controllers/projects/boards/issues_controller.rb b/app/controllers/projects/boards/issues_controller.rb
index 8bcf18642cf..61fef4dc133 100644
--- a/app/controllers/projects/boards/issues_controller.rb
+++ b/app/controllers/projects/boards/issues_controller.rb
@@ -40,10 +40,10 @@ module Projects
def issue
@issue ||=
- IssuesFinder.new(current_user, project_id: project.id).
- execute.
- where(iid: params[:id]).
- first!
+ IssuesFinder.new(current_user, project_id: project.id)
+ .execute
+ .where(iid: params[:id])
+ .first!
end
def authorize_read_issue!
diff --git a/app/controllers/projects/branches_controller.rb b/app/controllers/projects/branches_controller.rb
index 89d84809e3a..c37a0653ff9 100644
--- a/app/controllers/projects/branches_controller.rb
+++ b/app/controllers/projects/branches_controller.rb
@@ -32,8 +32,8 @@ class Projects::BranchesController < Projects::ApplicationController
branch_name = sanitize(strip_tags(params[:branch_name]))
branch_name = Addressable::URI.unescape(branch_name)
- result = CreateBranchService.new(project, current_user).
- execute(branch_name, ref)
+ result = CreateBranchService.new(project, current_user)
+ .execute(branch_name, ref)
if params[:issue_iid]
issue = IssuesFinder.new(current_user, project_id: @project.id).find_by(iid: params[:issue_iid])
diff --git a/app/controllers/projects/builds_controller.rb b/app/controllers/projects/builds_controller.rb
index 886934a3f67..0db18d444f7 100644
--- a/app/controllers/projects/builds_controller.rb
+++ b/app/controllers/projects/builds_controller.rb
@@ -48,8 +48,8 @@ class Projects::BuildsController < Projects::ApplicationController
respond_to do |format|
format.json do
state = params[:state].presence
- render json: @build.trace_with_state(state: state).
- merge!(id: @build.id, status: @build.status)
+ render json: @build.trace_with_state(state: state)
+ .merge!(id: @build.id, status: @build.status)
end
end
end
diff --git a/app/controllers/projects/commit_controller.rb b/app/controllers/projects/commit_controller.rb
index 23466dda981..e10d7992db7 100644
--- a/app/controllers/projects/commit_controller.rb
+++ b/app/controllers/projects/commit_controller.rb
@@ -35,9 +35,9 @@ class Projects::CommitController < Projects::ApplicationController
respond_to do |format|
format.html
format.json do
- render json: PipelineSerializer.
- new(project: @project, user: @current_user).
- represent(@pipelines)
+ render json: PipelineSerializer
+ .new(project: @project, user: @current_user)
+ .represent(@pipelines)
end
end
end
diff --git a/app/controllers/projects/commits_controller.rb b/app/controllers/projects/commits_controller.rb
index ad92f05a42d..855147c8984 100644
--- a/app/controllers/projects/commits_controller.rb
+++ b/app/controllers/projects/commits_controller.rb
@@ -18,11 +18,11 @@ class Projects::CommitsController < Projects::ApplicationController
@repository.commits(@ref, path: @path, limit: @limit, offset: @offset)
end
- @note_counts = project.notes.where(commit_id: @commits.map(&:id)).
- group(:commit_id).count
+ @note_counts = project.notes.where(commit_id: @commits.map(&:id))
+ .group(:commit_id).count
- @merge_request = MergeRequestsFinder.new(current_user, project_id: @project.id).execute.opened.
- find_by(source_project: @project, source_branch: @ref, target_branch: @repository.root_ref)
+ @merge_request = MergeRequestsFinder.new(current_user, project_id: @project.id).execute.opened
+ .find_by(source_project: @project, source_branch: @ref, target_branch: @repository.root_ref)
respond_to do |format|
format.html
diff --git a/app/controllers/projects/compare_controller.rb b/app/controllers/projects/compare_controller.rb
index 99204c82784..7ef2f90ef01 100644
--- a/app/controllers/projects/compare_controller.rb
+++ b/app/controllers/projects/compare_controller.rb
@@ -46,8 +46,8 @@ class Projects::CompareController < Projects::ApplicationController
end
def define_diff_vars
- @compare = CompareService.new(@project, @head_ref).
- execute(@project, @start_ref)
+ @compare = CompareService.new(@project, @head_ref)
+ .execute(@project, @start_ref)
if @compare
@commits = @compare.commits
@@ -66,7 +66,7 @@ class Projects::CompareController < Projects::ApplicationController
end
def merge_request
- @merge_request ||= MergeRequestsFinder.new(current_user, project_id: @project.id).execute.opened.
- find_by(source_project: @project, source_branch: @head_ref, target_branch: @start_ref)
+ @merge_request ||= MergeRequestsFinder.new(current_user, project_id: @project.id).execute.opened
+ .find_by(source_project: @project, source_branch: @head_ref, target_branch: @start_ref)
end
end
diff --git a/app/controllers/projects/environments_controller.rb b/app/controllers/projects/environments_controller.rb
index 2bbd8c6d046..fed75396d6e 100644
--- a/app/controllers/projects/environments_controller.rb
+++ b/app/controllers/projects/environments_controller.rb
@@ -9,18 +9,18 @@ class Projects::EnvironmentsController < Projects::ApplicationController
before_action :verify_api_request!, only: :terminal_websocket_authorize
def index
- @environments = project.environments.
- with_state(params[:scope] || :available)
+ @environments = project.environments
+ .with_state(params[:scope] || :available)
respond_to do |format|
format.html
format.json do
render json: {
- environments: EnvironmentSerializer.
- new(project: @project, user: @current_user).
- with_pagination(request, response).
- within_folders.
- represent(@environments),
+ environments: EnvironmentSerializer
+ .new(project: @project, user: @current_user)
+ .with_pagination(request, response)
+ .within_folders
+ .represent(@environments),
available_count: project.environments.available.count,
stopped_count: project.environments.stopped.count
}
@@ -36,10 +36,10 @@ class Projects::EnvironmentsController < Projects::ApplicationController
format.html
format.json do
render json: {
- environments: EnvironmentSerializer.
- new(project: @project, user: @current_user).
- with_pagination(request, response).
- represent(@environments),
+ environments: EnvironmentSerializer
+ .new(project: @project, user: @current_user)
+ .with_pagination(request, response)
+ .represent(@environments),
available_count: folder_environments.available.count,
stopped_count: folder_environments.stopped.count
}
diff --git a/app/controllers/projects/issues_controller.rb b/app/controllers/projects/issues_controller.rb
index ca5e81100da..4c009dd238c 100644
--- a/app/controllers/projects/issues_controller.rb
+++ b/app/controllers/projects/issues_controller.rb
@@ -77,8 +77,8 @@ class Projects::IssuesController < Projects::ApplicationController
def show
raw_notes = @issue.notes.inc_relations_for_view.fresh
- @notes = Banzai::NoteRenderer.
- render(raw_notes, @project, current_user, @path, @project_wiki, @ref)
+ @notes = Banzai::NoteRenderer
+ .render(raw_notes, @project, current_user, @path, @project_wiki, @ref)
@note = @project.notes.new(noteable: @issue)
@noteable = @issue
@@ -189,9 +189,9 @@ class Projects::IssuesController < Projects::ApplicationController
def merge_request_for_resolving_discussions
return unless merge_request_iid = params[:merge_request_for_resolving_discussions]
- @merge_request_for_resolving_discussions ||= MergeRequestsFinder.new(current_user, project_id: project.id).
- execute.
- find_by(iid: merge_request_iid)
+ @merge_request_for_resolving_discussions ||= MergeRequestsFinder.new(current_user, project_id: project.id)
+ .execute
+ .find_by(iid: merge_request_iid)
end
def authorize_read_issue!
diff --git a/app/controllers/projects/merge_requests_controller.rb b/app/controllers/projects/merge_requests_controller.rb
index 5ee7972e29e..1f228d28f80 100644
--- a/app/controllers/projects/merge_requests_controller.rb
+++ b/app/controllers/projects/merge_requests_controller.rb
@@ -162,8 +162,8 @@ class Projects::MergeRequestsController < Projects::ApplicationController
# Get commits from repository
# or from cache if already merged
@commits = @merge_request.commits
- @note_counts = Note.where(commit_id: @commits.map(&:id)).
- group(:commit_id).count
+ @note_counts = Note.where(commit_id: @commits.map(&:id))
+ .group(:commit_id).count
render json: { html: view_to_html_string('projects/merge_requests/show/_commits') }
end
@@ -232,9 +232,9 @@ class Projects::MergeRequestsController < Projects::ApplicationController
end
format.json do
- render json: PipelineSerializer.
- new(project: @project, user: @current_user).
- represent(@pipelines)
+ render json: PipelineSerializer
+ .new(project: @project, user: @current_user)
+ .represent(@pipelines)
end
end
end
@@ -245,9 +245,9 @@ class Projects::MergeRequestsController < Projects::ApplicationController
format.json do
define_pipelines_vars
- render json: PipelineSerializer.
- new(project: @project, user: @current_user).
- represent(@pipelines)
+ render json: PipelineSerializer
+ .new(project: @project, user: @current_user)
+ .represent(@pipelines)
end
end
end
@@ -332,9 +332,9 @@ class Projects::MergeRequestsController < Projects::ApplicationController
return access_denied!
end
- MergeRequests::MergeWhenPipelineSucceedsService.
- new(@project, current_user).
- cancel(@merge_request)
+ MergeRequests::MergeWhenPipelineSucceedsService
+ .new(@project, current_user)
+ .cancel(@merge_request)
end
def merge
@@ -361,9 +361,9 @@ class Projects::MergeRequestsController < Projects::ApplicationController
end
if @merge_request.head_pipeline.active?
- MergeRequests::MergeWhenPipelineSucceedsService.
- new(@project, current_user, merge_params).
- execute(@merge_request)
+ MergeRequests::MergeWhenPipelineSucceedsService
+ .new(@project, current_user, merge_params)
+ .execute(@merge_request)
@status = :merge_when_build_succeeds
elsif @merge_request.head_pipeline.success?
@@ -624,8 +624,8 @@ class Projects::MergeRequestsController < Projects::ApplicationController
@commit = @merge_request.diff_head_commit
@base_commit = @merge_request.diff_base_commit
- @note_counts = Note.where(commit_id: @commits.map(&:id)).
- group(:commit_id).count
+ @note_counts = Note.where(commit_id: @commits.map(&:id))
+ .group(:commit_id).count
@labels = LabelsFinder.new(current_user, project_id: @project.id).execute
@@ -640,8 +640,8 @@ class Projects::MergeRequestsController < Projects::ApplicationController
end
def merge_request_params
- params.require(:merge_request).
- permit(merge_request_params_ce)
+ params.require(:merge_request)
+ .permit(merge_request_params_ce)
end
def merge_request_params_ce
diff --git a/app/controllers/projects/pipelines_controller.rb b/app/controllers/projects/pipelines_controller.rb
index 0f2b7b2a4c8..e436c6666c3 100644
--- a/app/controllers/projects/pipelines_controller.rb
+++ b/app/controllers/projects/pipelines_controller.rb
@@ -7,11 +7,11 @@ class Projects::PipelinesController < Projects::ApplicationController
def index
@scope = params[:scope]
- @pipelines = PipelinesFinder.
- new(project).
- execute(scope: @scope).
- page(params[:page]).
- per(30)
+ @pipelines = PipelinesFinder
+ .new(project)
+ .execute(scope: @scope)
+ .page(params[:page])
+ .per(30)
@running_count = PipelinesFinder.
.new(project).execute(scope: 'running').count
@@ -29,10 +29,10 @@ class Projects::PipelinesController < Projects::ApplicationController
format.html
format.json do
render json: {
- pipelines: PipelineSerializer.
- new(project: @project, user: @current_user).
- with_pagination(request, response).
- represent(@pipelines),
+ pipelines: PipelineSerializer
+ .new(project: @project, user: @current_user)
+ .with_pagination(request, response)
+ .represent(@pipelines),
count: {
all: @pipelines_count,
running: @running_count,
@@ -49,9 +49,9 @@ class Projects::PipelinesController < Projects::ApplicationController
end
def create
- @pipeline = Ci::CreatePipelineService.
- new(project, current_user, create_params).
- execute(ignore_skip_ci: true, save_on_errors: false)
+ @pipeline = Ci::CreatePipelineService
+ .new(project, current_user, create_params)
+ .execute(ignore_skip_ci: true, save_on_errors: false)
unless @pipeline.persisted?
render 'new'
return
diff --git a/app/controllers/projects/project_members_controller.rb b/app/controllers/projects/project_members_controller.rb
index 6e158e685e9..3c582d15a4c 100644
--- a/app/controllers/projects/project_members_controller.rb
+++ b/app/controllers/projects/project_members_controller.rb
@@ -31,8 +31,8 @@ class Projects::ProjectMembersController < Projects::ApplicationController
end
def destroy
- Members::DestroyService.new(@project, current_user, params).
- execute(:all)
+ Members::DestroyService.new(@project, current_user, params)
+ .execute(:all)
respond_to do |format|
format.html do
diff --git a/app/controllers/projects/settings/ci_cd_controller.rb b/app/controllers/projects/settings/ci_cd_controller.rb
index 6f009d61950..24fe78bc1bd 100644
--- a/app/controllers/projects/settings/ci_cd_controller.rb
+++ b/app/controllers/projects/settings/ci_cd_controller.rb
@@ -14,8 +14,8 @@ module Projects
def define_runners_variables
@project_runners = @project.runners.ordered
- @assignable_runners = current_user.ci_authorized_runners.
- assignable_for(project).ordered.page(params[:page]).per(20)
+ @assignable_runners = current_user.ci_authorized_runners
+ .assignable_for(project).ordered.page(params[:page]).per(20)
@shared_runners = Ci::Runner.shared.active
@shared_runners_count = @shared_runners.count(:all)
end
diff --git a/app/controllers/projects/settings/members_controller.rb b/app/controllers/projects/settings/members_controller.rb
index 5735e281f66..f4c79b796fd 100644
--- a/app/controllers/projects/settings/members_controller.rb
+++ b/app/controllers/projects/settings/members_controller.rb
@@ -41,10 +41,10 @@ module Projects
wheres = ["members.id IN (#{@project_members.select(:id).to_sql})"]
wheres << "members.id IN (#{group_members.select(:id).to_sql})" if group_members
- @project_members = Member.
- where(wheres.join(' OR ')).
- sort(@sort).
- page(params[:page])
+ @project_members = Member
+ .where(wheres.join(' OR '))
+ .sort(@sort)
+ .page(params[:page])
@requesters = AccessRequestsFinder.new(@project).execute(current_user)
diff --git a/app/controllers/projects/tags_controller.rb b/app/controllers/projects/tags_controller.rb
index 33379659d73..5aaec97a082 100644
--- a/app/controllers/projects/tags_controller.rb
+++ b/app/controllers/projects/tags_controller.rb
@@ -27,8 +27,8 @@ class Projects::TagsController < Projects::ApplicationController
end
def create
- result = Tags::CreateService.new(@project, current_user).
- execute(params[:tag_name], params[:ref], params[:message], params[:release_description])
+ result = Tags::CreateService.new(@project, current_user)
+ .execute(params[:tag_name], params[:ref], params[:message], params[:release_description])
if result[:status] == :success
@tag = result[:tag]
diff --git a/app/controllers/projects/uploads_controller.rb b/app/controllers/projects/uploads_controller.rb
index 61686499bd3..1e7d72f5faa 100644
--- a/app/controllers/projects/uploads_controller.rb
+++ b/app/controllers/projects/uploads_controller.rb
@@ -5,8 +5,8 @@ class Projects::UploadsController < Projects::ApplicationController
before_action :authorize_upload_file!, only: [:create]
def create
- link_to_file = ::Projects::UploadService.new(project, params[:file]).
- execute
+ link_to_file = ::Projects::UploadService.new(project, params[:file])
+ .execute
respond_to do |format|
if link_to_file
diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb
index 9ffb8152e32..acca821782c 100644
--- a/app/controllers/projects_controller.rb
+++ b/app/controllers/projects_controller.rb
@@ -293,8 +293,8 @@ class ProjectsController < Projects::ApplicationController
end
def project_params
- params.require(:project).
- permit(project_params_ce)
+ params.require(:project)
+ .permit(project_params_ce)
end
def project_params_ce
diff --git a/app/controllers/sessions_controller.rb b/app/controllers/sessions_controller.rb
index 7d81c96262f..b632bbaaf78 100644
--- a/app/controllers/sessions_controller.rb
+++ b/app/controllers/sessions_controller.rb
@@ -119,8 +119,8 @@ class SessionsController < Devise::SessionsController
end
def log_audit_event(user, options = {})
- AuditEventService.new(user, user, options).
- for_authentication.security_event
+ AuditEventService.new(user, user, options)
+ .for_authentication.security_event
end
def load_recaptcha
diff --git a/app/controllers/sherlock/application_controller.rb b/app/controllers/sherlock/application_controller.rb
index 682ca5e3821..6bdd3568a78 100644
--- a/app/controllers/sherlock/application_controller.rb
+++ b/app/controllers/sherlock/application_controller.rb
@@ -4,8 +4,8 @@ module Sherlock
def find_transaction
if params[:transaction_id]
- @transaction = Gitlab::Sherlock.collection.
- find_transaction(params[:transaction_id])
+ @transaction = Gitlab::Sherlock.collection
+ .find_transaction(params[:transaction_id])
end
end
end
diff --git a/app/controllers/snippets_controller.rb b/app/controllers/snippets_controller.rb
index 2d26718873f..d22a0ffd88a 100644
--- a/app/controllers/snippets_controller.rb
+++ b/app/controllers/snippets_controller.rb
@@ -28,8 +28,8 @@ class SnippetsController < ApplicationController
@snippets = SnippetsFinder.new.execute(current_user, {
filter: :by_user,
user: @user,
- scope: params[:scope] }).
- page(params[:page])
+ scope: params[:scope] })
+ .page(params[:page])
render 'index'
else
@@ -82,8 +82,8 @@ class SnippetsController < ApplicationController
@snippet ||= if current_user
PersonalSnippet.where("author_id = ? OR visibility_level IN (?)",
current_user.id,
- [Snippet::PUBLIC, Snippet::INTERNAL]).
- find(params[:id])
+ [Snippet::PUBLIC, Snippet::INTERNAL])
+ .find(params[:id])
else
PersonalSnippet.find(params[:id])
end
diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb
index c92594d4097..73056df5bef 100644
--- a/app/controllers/users_controller.rb
+++ b/app/controllers/users_controller.rb
@@ -109,17 +109,17 @@ class UsersController < ApplicationController
def load_events
# Get user activity feed for projects common for both users
- @events = user.recent_events.
- merge(projects_for_current_user).
- references(:project).
- with_associations.
- limit_recent(20, params[:offset])
+ @events = user.recent_events
+ .merge(projects_for_current_user)
+ .references(:project)
+ .with_associations
+ .limit_recent(20, params[:offset])
end
def load_projects
@projects =
- PersonalProjectsFinder.new(user).execute(current_user).
- page(params[:page])
+ PersonalProjectsFinder.new(user).execute(current_user)
+ .page(params[:page])
end
def load_contributed_projects
diff --git a/app/finders/environments_finder.rb b/app/finders/environments_finder.rb
index 52c73abc31d..a59f8c1efa3 100644
--- a/app/finders/environments_finder.rb
+++ b/app/finders/environments_finder.rb
@@ -17,12 +17,12 @@ class EnvironmentsFinder
deployments.none
end
- environment_ids = deployments.
- group(:environment_id).
- select(:environment_id)
+ environment_ids = deployments
+ .group(:environment_id)
+ .select(:environment_id)
- environments = project.environments.available.
- where(id: environment_ids).order_by_last_deployed_at.to_a
+ environments = project.environments.available
+ .where(id: environment_ids).order_by_last_deployed_at.to_a
environments.select! do |environment|
Ability.allowed?(current_user, :read_environment, environment)
diff --git a/app/finders/group_members_finder.rb b/app/finders/group_members_finder.rb
index 9f2206346ce..873a253e2b5 100644
--- a/app/finders/group_members_finder.rb
+++ b/app/finders/group_members_finder.rb
@@ -8,9 +8,9 @@ class GroupMembersFinder < Projects::ApplicationController
return group_members unless @group.parent
- parents_members = GroupMember.non_request.
- where(source_id: @group.ancestors.select(:id)).
- where.not(user_id: @group.users.select(:id))
+ parents_members = GroupMember.non_request
+ .where(source_id: @group.ancestors.select(:id))
+ .where.not(user_id: @group.users.select(:id))
wheres = ["members.id IN (#{group_members.select(:id).to_sql})"]
wheres << "members.id IN (#{parents_members.select(:id).to_sql})"
diff --git a/app/helpers/form_helper.rb b/app/helpers/form_helper.rb
index 1182939f656..913db3a3e26 100644
--- a/app/helpers/form_helper.rb
+++ b/app/helpers/form_helper.rb
@@ -8,10 +8,10 @@ module FormHelper
content_tag(:div, class: 'alert alert-danger', id: 'error_explanation') do
content_tag(:h4, headline) <<
content_tag(:ul) do
- model.errors.full_messages.
- map { |msg| content_tag(:li, msg) }.
- join.
- html_safe
+ model.errors.full_messages
+ .map { |msg| content_tag(:li, msg) }
+ .join
+ .html_safe
end
end
end
diff --git a/app/helpers/search_helper.rb b/app/helpers/search_helper.rb
index 8ff8db16514..7a164cfd26d 100644
--- a/app/helpers/search_helper.rb
+++ b/app/helpers/search_helper.rb
@@ -97,8 +97,8 @@ module SearchHelper
# Autocomplete results for the current user's projects
def projects_autocomplete(term, limit = 5)
- current_user.authorized_projects.search_by_title(term).
- sorted_by_stars.non_archived.limit(limit).map do |p|
+ current_user.authorized_projects.search_by_title(term)
+ .sorted_by_stars.non_archived.limit(limit).map do |p|
{
category: "Projects",
id: p.id,
diff --git a/app/helpers/wiki_helper.rb b/app/helpers/wiki_helper.rb
index 3e3f6246fc5..99212a3438f 100644
--- a/app/helpers/wiki_helper.rb
+++ b/app/helpers/wiki_helper.rb
@@ -6,8 +6,8 @@ module WikiHelper
# Returns a String composed of the capitalized name of each directory and the
# capitalized name of the page itself.
def breadcrumb(page_slug)
- page_slug.split('/').
- map { |dir_or_page| WikiPage.unhyphenize(dir_or_page).capitalize }.
- join(' / ')
+ page_slug.split('/')
+ .map { |dir_or_page| WikiPage.unhyphenize(dir_or_page).capitalize }
+ .join(' / ')
end
end
diff --git a/app/models/award_emoji.rb b/app/models/award_emoji.rb
index 6937ad3bdd9..2eedbf3ffde 100644
--- a/app/models/award_emoji.rb
+++ b/app/models/award_emoji.rb
@@ -18,9 +18,9 @@ class AwardEmoji < ActiveRecord::Base
class << self
def votes_for_collection(ids, type)
- select('name', 'awardable_id', 'COUNT(*) as count').
- where('name IN (?) AND awardable_type = ? AND awardable_id IN (?)', [DOWNVOTE_NAME, UPVOTE_NAME], type, ids).
- group('name', 'awardable_id')
+ select('name', 'awardable_id', 'COUNT(*) as count')
+ .where('name IN (?) AND awardable_type = ? AND awardable_id IN (?)', [DOWNVOTE_NAME, UPVOTE_NAME], type, ids)
+ .group('name', 'awardable_id')
end
end
diff --git a/app/models/ci/build.rb b/app/models/ci/build.rb
index f9592873ea0..de9fe352059 100644
--- a/app/models/ci/build.rb
+++ b/app/models/ci/build.rb
@@ -63,9 +63,9 @@ module Ci
end
def retry(build, current_user)
- Ci::RetryBuildService.
- new(build.project, current_user).
- execute(build)
+ Ci::RetryBuildService
+ .new(build.project, current_user)
+ .execute(build)
end
end
@@ -96,9 +96,9 @@ module Ci
end
def detailed_status(current_user)
- Gitlab::Ci::Status::Build::Factory.
- new(self, current_user).
- fabricate!
+ Gitlab::Ci::Status::Build::Factory
+ .new(self, current_user)
+ .fabricate!
end
def manual?
@@ -220,9 +220,9 @@ module Ci
end
def merge_request
- merge_requests = MergeRequest.includes(:merge_request_diff).
- where(source_branch: ref, source_project_id: pipeline.gl_project_id).
- reorder(iid: :asc)
+ merge_requests = MergeRequest.includes(:merge_request_diff)
+ .where(source_branch: ref, source_project_id: pipeline.gl_project_id)
+ .reorder(iid: :asc)
merge_requests.find do |merge_request|
merge_request.commits_sha.include?(pipeline.sha)
@@ -278,8 +278,8 @@ module Ci
def raw_trace(last_lines: nil)
if File.exist?(trace_file_path)
- Gitlab::Ci::TraceReader.new(trace_file_path).
- read(last_lines: last_lines)
+ Gitlab::Ci::TraceReader.new(trace_file_path)
+ .read(last_lines: last_lines)
else
# backward compatibility
read_attribute :trace
diff --git a/app/models/ci/pipeline.rb b/app/models/ci/pipeline.rb
index 673647f284a..999720d2ea3 100644
--- a/app/models/ci/pipeline.rb
+++ b/app/models/ci/pipeline.rb
@@ -89,9 +89,9 @@ module Ci
# ref can't be HEAD or SHA, can only be branch/tag name
scope :latest, ->(ref = nil) do
- max_id = unscope(:select).
- select("max(#{quoted_table_name}.id)").
- group(:ref, :sha)
+ max_id = unscope(:select)
+ .select("max(#{quoted_table_name}.id)")
+ .group(:ref, :sha)
if ref
where(ref: ref, id: max_id.where(ref: ref))
@@ -126,23 +126,23 @@ module Ci
end
def stages_name
- statuses.order(:stage_idx).distinct.
- pluck(:stage, :stage_idx).map(&:first)
+ statuses.order(:stage_idx).distinct
+ .pluck(:stage, :stage_idx).map(&:first)
end
def stages
# TODO, this needs refactoring, see gitlab-ce#26481.
- stages_query = statuses.
- group('stage').select(:stage).order('max(stage_idx)')
+ stages_query = statuses
+ .group('stage').select(:stage).order('max(stage_idx)')
status_sql = statuses.latest.where('stage=sg.stage').status_sql
- warnings_sql = statuses.latest.select('COUNT(*) > 0').
- where('stage=sg.stage').failed_but_allowed.to_sql
+ warnings_sql = statuses.latest.select('COUNT(*) > 0')
+ .where('stage=sg.stage').failed_but_allowed.to_sql
- stages_with_statuses = CommitStatus.from(stages_query, :sg).
- pluck('sg.stage', status_sql, "(#{warnings_sql})")
+ stages_with_statuses = CommitStatus.from(stages_query, :sg)
+ .pluck('sg.stage', status_sql, "(#{warnings_sql})")
stages_with_statuses.map do |stage|
Ci::Stage.new(self, Hash[%i[name status warnings].zip(stage)])
@@ -222,8 +222,8 @@ module Ci
end
def retry_failed(current_user)
- Ci::RetryPipelineService.new(project, current_user).
- execute(self)
+ Ci::RetryPipelineService.new(project, current_user)
+ .execute(self)
end
def mark_as_processable_after_stage(stage_idx)
@@ -255,9 +255,9 @@ module Ci
def config_builds_attributes
return [] unless config_processor
- config_processor.
- builds_for_ref(ref, tag?, trigger_requests.first).
- sort_by { |build| build[:stage_idx] }
+ config_processor
+ .builds_for_ref(ref, tag?, trigger_requests.first)
+ .sort_by { |build| build[:stage_idx] }
end
def has_warnings?
@@ -355,15 +355,15 @@ module Ci
# Merge requests for which the current pipeline is running against
# the merge request's latest commit.
def merge_requests
- @merge_requests ||= project.merge_requests.
- where(source_branch: self.ref).
- select { |merge_request| merge_request.head_pipeline.try(:id) == self.id }
+ @merge_requests ||= project.merge_requests
+ .where(source_branch: self.ref)
+ .select { |merge_request| merge_request.head_pipeline.try(:id) == self.id }
end
def detailed_status(current_user)
- Gitlab::Ci::Status::Pipeline::Factory.
- new(self, current_user).
- fabricate!
+ Gitlab::Ci::Status::Pipeline::Factory
+ .new(self, current_user)
+ .fabricate!
end
private
diff --git a/app/models/ci/runner.rb b/app/models/ci/runner.rb
index a120112e882..9cf6164e8dd 100644
--- a/app/models/ci/runner.rb
+++ b/app/models/ci/runner.rb
@@ -23,15 +23,15 @@ module Ci
scope :ordered, ->() { order(id: :desc) }
scope :owned_or_shared, ->(project_id) do
- joins('LEFT JOIN ci_runner_projects ON ci_runner_projects.runner_id = ci_runners.id').
- where("ci_runner_projects.gl_project_id = :project_id OR ci_runners.is_shared = true", project_id: project_id)
+ joins('LEFT JOIN ci_runner_projects ON ci_runner_projects.runner_id = ci_runners.id')
+ .where("ci_runner_projects.gl_project_id = :project_id OR ci_runners.is_shared = true", project_id: project_id)
end
scope :assignable_for, ->(project) do
# FIXME: That `to_sql` is needed to workaround a weird Rails bug.
# Without that, placeholders would miss one and couldn't match.
- where(locked: false).
- where.not("id IN (#{project.runners.select(:id).to_sql})").specific
+ where(locked: false)
+ .where.not("id IN (#{project.runners.select(:id).to_sql})").specific
end
validate :tag_constraints
diff --git a/app/models/ci/stage.rb b/app/models/ci/stage.rb
index 0751ab1b7d8..ca74c91b062 100644
--- a/app/models/ci/stage.rb
+++ b/app/models/ci/stage.rb
@@ -28,9 +28,9 @@ module Ci
end
def detailed_status(current_user)
- Gitlab::Ci::Status::Stage::Factory.
- new(self, current_user).
- fabricate!
+ Gitlab::Ci::Status::Stage::Factory
+ .new(self, current_user)
+ .fabricate!
end
def statuses
diff --git a/app/models/commit_status.rb b/app/models/commit_status.rb
index ef5e6202519..df835b99189 100644
--- a/app/models/commit_status.rb
+++ b/app/models/commit_status.rb
@@ -96,8 +96,8 @@ class CommitStatus < ActiveRecord::Base
after_transition any => :failed do |commit_status|
commit_status.run_after_commit do
- MergeRequests::AddTodoWhenBuildFailsService.
- new(pipeline.project, nil).execute(self)
+ MergeRequests::AddTodoWhenBuildFailsService
+ .new(pipeline.project, nil).execute(self)
end
end
end
@@ -133,9 +133,9 @@ class CommitStatus < ActiveRecord::Base
end
def detailed_status(current_user)
- Gitlab::Ci::Status::Factory.
- new(self, current_user).
- fabricate!
+ Gitlab::Ci::Status::Factory
+ .new(self, current_user)
+ .fabricate!
end
def sortable_name
diff --git a/app/models/concerns/issuable.rb b/app/models/concerns/issuable.rb
index 768baa80c01..303d4910ee1 100644
--- a/app/models/concerns/issuable.rb
+++ b/app/models/concerns/issuable.rb
@@ -162,9 +162,9 @@ module Issuable
highest_priority = highest_label_priority(params).to_sql
- select("#{table_name}.*, (#{highest_priority}) AS highest_priority").
- group(arel_table[:id]).
- reorder(Gitlab::Database.nulls_last_order('highest_priority', 'ASC'))
+ select("#{table_name}.*, (#{highest_priority}) AS highest_priority")
+ .group(arel_table[:id])
+ .reorder(Gitlab::Database.nulls_last_order('highest_priority', 'ASC'))
end
def with_label(title, sort = nil)
diff --git a/app/models/concerns/mentionable.rb b/app/models/concerns/mentionable.rb
index 7e56e371b27..a8ce36e51fc 100644
--- a/app/models/concerns/mentionable.rb
+++ b/app/models/concerns/mentionable.rb
@@ -48,8 +48,8 @@ module Mentionable
if extractor
@extractor = extractor
else
- @extractor ||= Gitlab::ReferenceExtractor.
- new(project, current_user)
+ @extractor ||= Gitlab::ReferenceExtractor
+ .new(project, current_user)
@extractor.reset_memoized_values
end
diff --git a/app/models/concerns/milestoneish.rb b/app/models/concerns/milestoneish.rb
index 870a6fbaa90..f449229864d 100644
--- a/app/models/concerns/milestoneish.rb
+++ b/app/models/concerns/milestoneish.rb
@@ -39,8 +39,8 @@ module Milestoneish
def issues_visible_to_user(user)
memoize_per_user(user, :issues_visible_to_user) do
- IssuesFinder.new(user, issues_finder_params).
- execute.where(milestone_id: milestoneish_ids)
+ IssuesFinder.new(user, issues_finder_params)
+ .execute.where(milestone_id: milestoneish_ids)
end
end
diff --git a/app/models/concerns/presentable.rb b/app/models/concerns/presentable.rb
index d0f84831d71..7b33b837004 100644
--- a/app/models/concerns/presentable.rb
+++ b/app/models/concerns/presentable.rb
@@ -1,7 +1,7 @@
module Presentable
def present(**attributes)
- Gitlab::View::Presenter::Factory.
- new(self, attributes).
- fabricate!
+ Gitlab::View::Presenter::Factory
+ .new(self, attributes)
+ .fabricate!
end
end
diff --git a/app/models/concerns/routable.rb b/app/models/concerns/routable.rb
index 9f6d215ceb3..c2373de32c5 100644
--- a/app/models/concerns/routable.rb
+++ b/app/models/concerns/routable.rb
@@ -75,11 +75,11 @@ module Routable
#
# Returns an ActiveRecord::Relation.
def member_descendants(user_id)
- joins(:route).
- joins("INNER JOIN routes r2 ON routes.path LIKE CONCAT(r2.path, '/%')
+ joins(:route)
+ .joins("INNER JOIN routes r2 ON routes.path LIKE CONCAT(r2.path, '/%')
INNER JOIN members ON members.source_id = r2.source_id
- AND members.source_type = r2.source_type").
- where('members.user_id = ?', user_id)
+ AND members.source_type = r2.source_type")
+ .where('members.user_id = ?', user_id)
end
end
diff --git a/app/models/concerns/sortable.rb b/app/models/concerns/sortable.rb
index b9a2d812edd..a155a064032 100644
--- a/app/models/concerns/sortable.rb
+++ b/app/models/concerns/sortable.rb
@@ -39,12 +39,12 @@ module Sortable
private
def highest_label_priority(target_type_column: nil, target_type: nil, target_column:, project_column:, excluded_labels: [])
- query = Label.select(LabelPriority.arel_table[:priority].minimum).
- left_join_priorities.
- joins(:label_links).
- where("label_priorities.project_id = #{project_column}").
- where("label_links.target_id = #{target_column}").
- reorder(nil)
+ query = Label.select(LabelPriority.arel_table[:priority].minimum)
+ .left_join_priorities
+ .joins(:label_links)
+ .where("label_priorities.project_id = #{project_column}")
+ .where("label_links.target_id = #{target_column}")
+ .reorder(nil)
query =
if target_type_column
diff --git a/app/models/concerns/subscribable.rb b/app/models/concerns/subscribable.rb
index e4f5818d0e3..f60a0f8f438 100644
--- a/app/models/concerns/subscribable.rb
+++ b/app/models/concerns/subscribable.rb
@@ -27,30 +27,30 @@ module Subscribable
end
def subscribers(project)
- subscriptions_available(project).
- where(subscribed: true).
- map(&:user)
+ subscriptions_available(project)
+ .where(subscribed: true)
+ .map(&:user)
end
def toggle_subscription(user, project = nil)
unsubscribe_from_other_levels(user, project)
- find_or_initialize_subscription(user, project).
- update(subscribed: !subscribed?(user, project))
+ find_or_initialize_subscription(user, project)
+ .update(subscribed: !subscribed?(user, project))
end
def subscribe(user, project = nil)
unsubscribe_from_other_levels(user, project)
- find_or_initialize_subscription(user, project).
- update(subscribed: true)
+ find_or_initialize_subscription(user, project)
+ .update(subscribed: true)
end
def unsubscribe(user, project = nil)
unsubscribe_from_other_levels(user, project)
- find_or_initialize_subscription(user, project).
- update(subscribed: false)
+ find_or_initialize_subscription(user, project)
+ .update(subscribed: false)
end
private
@@ -69,14 +69,14 @@ module Subscribable
end
def find_or_initialize_subscription(user, project)
- subscriptions.
- find_or_initialize_by(user_id: user.id, project_id: project.try(:id))
+ subscriptions
+ .find_or_initialize_by(user_id: user.id, project_id: project.try(:id))
end
def subscriptions_available(project)
t = Subscription.arel_table
- subscriptions.
- where(t[:project_id].eq(nil).or(t[:project_id].eq(project.try(:id))))
+ subscriptions
+ .where(t[:project_id].eq(nil).or(t[:project_id].eq(project.try(:id))))
end
end
diff --git a/app/models/deployment.rb b/app/models/deployment.rb
index afad001d50f..43f7460bd5d 100644
--- a/app/models/deployment.rb
+++ b/app/models/deployment.rb
@@ -53,10 +53,10 @@ class Deployment < ActiveRecord::Base
def update_merge_request_metrics!
return unless environment.update_merge_request_metrics?
- merge_requests = project.merge_requests.
- joins(:metrics).
- where(target_branch: self.ref, merge_request_metrics: { first_deployed_to_production_at: nil }).
- where("merge_request_metrics.merged_at <= ?", self.created_at)
+ merge_requests = project.merge_requests
+ .joins(:metrics)
+ .where(target_branch: self.ref, merge_request_metrics: { first_deployed_to_production_at: nil })
+ .where("merge_request_metrics.merged_at <= ?", self.created_at)
if previous_deployment
merge_requests = merge_requests.where("merge_request_metrics.merged_at >= ?", previous_deployment.created_at)
@@ -71,17 +71,17 @@ class Deployment < ActiveRecord::Base
merge_requests.map(&:id)
end
- MergeRequest::Metrics.
- where(merge_request_id: merge_request_ids, first_deployed_to_production_at: nil).
- update_all(first_deployed_to_production_at: self.created_at)
+ MergeRequest::Metrics
+ .where(merge_request_id: merge_request_ids, first_deployed_to_production_at: nil)
+ .update_all(first_deployed_to_production_at: self.created_at)
end
def previous_deployment
@previous_deployment ||=
- project.deployments.joins(:environment).
- where(environments: { name: self.environment.name }, ref: self.ref).
- where.not(id: self.id).
- take
+ project.deployments.joins(:environment)
+ .where(environments: { name: self.environment.name }, ref: self.ref)
+ .where.not(id: self.id)
+ .take
end
def stop_action
diff --git a/app/models/environment.rb b/app/models/environment.rb
index 1a21b5e52b5..f917f52f832 100644
--- a/app/models/environment.rb
+++ b/app/models/environment.rb
@@ -40,9 +40,9 @@ class Environment < ActiveRecord::Base
scope :stopped, -> { with_state(:stopped) }
scope :order_by_last_deployed_at, -> do
max_deployment_id_sql =
- Deployment.select(Deployment.arel_table[:id].maximum).
- where(Deployment.arel_table[:environment_id].eq(arel_table[:id])).
- to_sql
+ Deployment.select(Deployment.arel_table[:id].maximum)
+ .where(Deployment.arel_table[:environment_id].eq(arel_table[:id]))
+ .to_sql
order(Gitlab::Database.nulls_first_order("(#{max_deployment_id_sql})", 'ASC'))
end
diff --git a/app/models/event.rb b/app/models/event.rb
index e5027df3f8a..42c4a233ce3 100644
--- a/app/models/event.rb
+++ b/app/models/event.rb
@@ -343,9 +343,9 @@ class Event < ActiveRecord::Base
# At this point it's possible for multiple threads/processes to try to
# update the project. Only one query should actually perform the update,
# hence we add the extra WHERE clause for last_activity_at.
- Project.unscoped.where(id: project_id).
- where('last_activity_at <= ?', RESET_PROJECT_ACTIVITY_INTERVAL.ago).
- update_all(last_activity_at: created_at)
+ Project.unscoped.where(id: project_id)
+ .where('last_activity_at <= ?', RESET_PROJECT_ACTIVITY_INTERVAL.ago)
+ .update_all(last_activity_at: created_at)
end
def authored_by?(user)
diff --git a/app/models/generic_commit_status.rb b/app/models/generic_commit_status.rb
index 36b8568871b..8867ba0d2ff 100644
--- a/app/models/generic_commit_status.rb
+++ b/app/models/generic_commit_status.rb
@@ -18,8 +18,8 @@ class GenericCommitStatus < CommitStatus
end
def detailed_status(current_user)
- Gitlab::Ci::Status::External::Factory.
- new(self, current_user).
- fabricate!
+ Gitlab::Ci::Status::External::Factory
+ .new(self, current_user)
+ .fabricate!
end
end
diff --git a/app/models/global_milestone.rb b/app/models/global_milestone.rb
index 84deb67ba9b..b991d78e27f 100644
--- a/app/models/global_milestone.rb
+++ b/app/models/global_milestone.rb
@@ -76,8 +76,8 @@ class GlobalMilestone
end
def labels
- @labels ||= GlobalLabel.build_collection(milestones.includes(:labels).map(&:labels).flatten).
- sort_by!(&:title)
+ @labels ||= GlobalLabel.build_collection(milestones.includes(:labels).map(&:labels).flatten)
+ .sort_by!(&:title)
end
def due_date
diff --git a/app/models/group.rb b/app/models/group.rb
index 1835ce118a1..5ef3f9513fc 100644
--- a/app/models/group.rb
+++ b/app/models/group.rb
@@ -71,9 +71,9 @@ class Group < Namespace
def select_for_project_authorization
if current_scope.joins_values.include?(:shared_projects)
- joins('INNER JOIN namespaces project_namespace ON project_namespace.id = projects.namespace_id').
- where('project_namespace.share_with_group_lock = ?', false).
- select("members.user_id, projects.id AS project_id, LEAST(project_group_links.group_access, members.access_level) AS access_level")
+ joins('INNER JOIN namespaces project_namespace ON project_namespace.id = projects.namespace_id')
+ .where('project_namespace.share_with_group_lock = ?', false)
+ .select("members.user_id, projects.id AS project_id, LEAST(project_group_links.group_access, members.access_level) AS access_level")
else
super
end
@@ -197,8 +197,8 @@ class Group < Namespace
end
def refresh_members_authorized_projects
- UserProjectAccessChangedService.new(user_ids_for_project_authorizations).
- execute
+ UserProjectAccessChangedService.new(user_ids_for_project_authorizations)
+ .execute
end
def user_ids_for_project_authorizations
diff --git a/app/models/issue_collection.rb b/app/models/issue_collection.rb
index f0b7d9914c8..49f011c113f 100644
--- a/app/models/issue_collection.rb
+++ b/app/models/issue_collection.rb
@@ -17,9 +17,9 @@ class IssueCollection
# Given all the issue projects we get a list of projects that the current
# user has at least reporter access to.
- projects_with_reporter_access = user.
- projects_with_reporter_access_limited_to(project_ids).
- pluck(:id)
+ projects_with_reporter_access = user
+ .projects_with_reporter_access_limited_to(project_ids)
+ .pluck(:id)
collection.select do |issue|
if projects_with_reporter_access.include?(issue.project_id)
diff --git a/app/models/label.rb b/app/models/label.rb
index 27429e60e4a..e97e53301cc 100644
--- a/app/models/label.rb
+++ b/app/models/label.rb
@@ -34,18 +34,18 @@ class Label < ActiveRecord::Base
scope :with_title, ->(title) { where(title: title) }
def self.prioritized(project)
- joins(:priorities).
- where(label_priorities: { project_id: project }).
- reorder('label_priorities.priority ASC, labels.title ASC')
+ joins(:priorities)
+ .where(label_priorities: { project_id: project })
+ .reorder('label_priorities.priority ASC, labels.title ASC')
end
def self.unprioritized(project)
labels = Label.arel_table
priorities = LabelPriority.arel_table
- label_priorities = labels.join(priorities, Arel::Nodes::OuterJoin).
- on(labels[:id].eq(priorities[:label_id]).and(priorities[:project_id].eq(project.id))).
- join_sources
+ label_priorities = labels.join(priorities, Arel::Nodes::OuterJoin)
+ .on(labels[:id].eq(priorities[:label_id]).and(priorities[:project_id].eq(project.id)))
+ .join_sources
joins(label_priorities).where(priorities[:priority].eq(nil))
end
@@ -54,9 +54,9 @@ class Label < ActiveRecord::Base
labels = Label.arel_table
priorities = LabelPriority.arel_table
- label_priorities = labels.join(priorities, Arel::Nodes::OuterJoin).
- on(labels[:id].eq(priorities[:label_id])).
- join_sources
+ label_priorities = labels.join(priorities, Arel::Nodes::OuterJoin)
+ .on(labels[:id].eq(priorities[:label_id]))
+ .join_sources
joins(label_priorities)
end
diff --git a/app/models/lfs_object.rb b/app/models/lfs_object.rb
index ee9ac282e39..7712d5783e0 100644
--- a/app/models/lfs_object.rb
+++ b/app/models/lfs_object.rb
@@ -19,8 +19,8 @@ class LfsObject < ActiveRecord::Base
end
def self.destroy_unreferenced
- joins("LEFT JOIN lfs_objects_projects ON lfs_objects_projects.lfs_object_id = #{table_name}.id").
- where(lfs_objects_projects: { id: nil }).
- destroy_all
+ joins("LEFT JOIN lfs_objects_projects ON lfs_objects_projects.lfs_object_id = #{table_name}.id")
+ .where(lfs_objects_projects: { id: nil })
+ .destroy_all
end
end
diff --git a/app/models/member.rb b/app/models/member.rb
index 0f6b75b0b93..2ea4abacea4 100644
--- a/app/models/member.rb
+++ b/app/models/member.rb
@@ -39,9 +39,9 @@ class Member < ActiveRecord::Base
is_external_invite = arel_table[:user_id].eq(nil).and(arel_table[:invite_token].not_eq(nil))
user_is_active = User.arel_table[:state].eq(:active)
- includes(:user).references(:users).
- where(is_external_invite.or(user_is_active)).
- where(requested_at: nil)
+ includes(:user).references(:users)
+ .where(is_external_invite.or(user_is_active))
+ .where(requested_at: nil)
end
scope :invite, -> { where.not(invite_token: nil) }
@@ -99,9 +99,9 @@ class Member < ActiveRecord::Base
users = User.arel_table
members = Member.arel_table
- member_users = members.join(users, Arel::Nodes::OuterJoin).
- on(members[:user_id].eq(users[:id])).
- join_sources
+ member_users = members.join(users, Arel::Nodes::OuterJoin)
+ .on(members[:user_id].eq(users[:id]))
+ .join_sources
joins(member_users)
end
diff --git a/app/models/merge_request.rb b/app/models/merge_request.rb
index ea784f77015..c4520c16a43 100644
--- a/app/models/merge_request.rb
+++ b/app/models/merge_request.rb
@@ -475,10 +475,10 @@ class MergeRequest < ActiveRecord::Base
end
def discussions
- @discussions ||= self.related_notes.
- inc_relations_for_view.
- fresh.
- discussions
+ @discussions ||= self.related_notes
+ .inc_relations_for_view
+ .fresh
+ .discussions
end
def diff_discussions
@@ -564,8 +564,8 @@ class MergeRequest < ActiveRecord::Base
messages = [title, description]
messages.concat(commits.map(&:safe_message)) if merge_request_diff
- Gitlab::ClosingIssueExtractor.new(project, current_user).
- closed_by_message(messages.join("\n"))
+ Gitlab::ClosingIssueExtractor.new(project, current_user)
+ .closed_by_message(messages.join("\n"))
else
[]
end
@@ -813,9 +813,9 @@ class MergeRequest < ActiveRecord::Base
def all_pipelines
return Ci::Pipeline.none unless source_project
- @all_pipelines ||= source_project.pipelines.
- where(sha: all_commits_sha, ref: source_branch).
- order(id: :desc)
+ @all_pipelines ||= source_project.pipelines
+ .where(sha: all_commits_sha, ref: source_branch)
+ .order(id: :desc)
end
# Note that this could also return SHA from now dangling commits
diff --git a/app/models/merge_request_diff.rb b/app/models/merge_request_diff.rb
index 53d08488788..baee00b8fcd 100644
--- a/app/models/merge_request_diff.rb
+++ b/app/models/merge_request_diff.rb
@@ -169,8 +169,8 @@ class MergeRequestDiff < ActiveRecord::Base
# When compare merge request versions we want diff A..B instead of A...B
# so we handle cases when user does squash and rebase of the commits between versions.
# For this reason we set straight to true by default.
- CompareService.new(project, head_commit_sha).
- execute(project, sha, straight: straight)
+ CompareService.new(project, head_commit_sha)
+ .execute(project, sha, straight: straight)
end
def commits_count
diff --git a/app/models/merge_requests_closing_issues.rb b/app/models/merge_requests_closing_issues.rb
index daafb137be4..7f7c114803d 100644
--- a/app/models/merge_requests_closing_issues.rb
+++ b/app/models/merge_requests_closing_issues.rb
@@ -7,9 +7,9 @@ class MergeRequestsClosingIssues < ActiveRecord::Base
class << self
def count_for_collection(ids)
- group(:issue_id).
- where(issue_id: ids).
- pluck('issue_id', 'COUNT(*) as count')
+ group(:issue_id)
+ .where(issue_id: ids)
+ .pluck('issue_id', 'COUNT(*) as count')
end
end
end
diff --git a/app/models/milestone.rb b/app/models/milestone.rb
index 7331000a9f2..30e5dfd096e 100644
--- a/app/models/milestone.rb
+++ b/app/models/milestone.rb
@@ -98,11 +98,11 @@ class Milestone < ActiveRecord::Base
if Gitlab::Database.postgresql?
rel.order(:project_id, :due_date).select('DISTINCT ON (project_id) id')
else
- rel.
- group(:project_id).
- having('due_date = MIN(due_date)').
- pluck(:id, :project_id, :due_date).
- map(&:first)
+ rel
+ .group(:project_id)
+ .having('due_date = MIN(due_date)')
+ .pluck(:id, :project_id, :due_date)
+ .map(&:first)
end
end
@@ -177,8 +177,8 @@ class Milestone < ActiveRecord::Base
conditions = 'WHEN id = ? THEN ? ' * ids.length
- issues.where(id: ids).
- update_all(["position = CASE #{conditions} ELSE position END", *pairs])
+ issues.where(id: ids)
+ .update_all(["position = CASE #{conditions} ELSE position END", *pairs])
end
private
diff --git a/app/models/namespace.rb b/app/models/namespace.rb
index e207ac3db4e..9334b7d9e61 100644
--- a/app/models/namespace.rb
+++ b/app/models/namespace.rb
@@ -48,9 +48,9 @@ class Namespace < ActiveRecord::Base
scope :root, -> { where('type IS NULL') }
scope :with_statistics, -> do
- joins('LEFT JOIN project_statistics ps ON ps.namespace_id = namespaces.id').
- group('namespaces.id').
- select(
+ joins('LEFT JOIN project_statistics ps ON ps.namespace_id = namespaces.id')
+ .group('namespaces.id')
+ .select(
'namespaces.*',
'COALESCE(SUM(ps.storage_size), 0) AS storage_size',
'COALESCE(SUM(ps.repository_size), 0) AS repository_size',
@@ -251,10 +251,10 @@ class Namespace < ActiveRecord::Base
end
def refresh_access_of_projects_invited_groups
- Group.
- joins(project_group_links: :project).
- where(projects: { namespace_id: id }).
- find_each(&:refresh_members_authorized_projects)
+ Group
+ .joins(project_group_links: :project)
+ .where(projects: { namespace_id: id })
+ .find_each(&:refresh_members_authorized_projects)
end
def remove_exports!
diff --git a/app/models/network/commit.rb b/app/models/network/commit.rb
index a48e872ad84..8417f200e36 100644
--- a/app/models/network/commit.rb
+++ b/app/models/network/commit.rb
@@ -28,8 +28,8 @@ module Network
if map.include?(p.id)
map[p.id]
end
- end.
- compact
+ end
+ .compact
end
end
end
diff --git a/app/models/network/graph.rb b/app/models/network/graph.rb
index 2a7fa7d0607..0bbc9451ffd 100644
--- a/app/models/network/graph.rb
+++ b/app/models/network/graph.rb
@@ -23,12 +23,12 @@ module Network
def collect_notes
h = Hash.new(0)
- @project.
- notes.
- where('noteable_type = ?', 'Commit').
- group('notes.commit_id').
- select('notes.commit_id, count(notes.id) as note_count').
- each do |item|
+ @project
+ .notes
+ .where('noteable_type = ?', 'Commit')
+ .group('notes.commit_id')
+ .select('notes.commit_id, count(notes.id) as note_count')
+ .each do |item|
h[item.commit_id] = item.note_count.to_i
end
diff --git a/app/models/note.rb b/app/models/note.rb
index 029fe667a45..4f87b9a4dc2 100644
--- a/app/models/note.rb
+++ b/app/models/note.rb
@@ -105,14 +105,14 @@ class Note < ActiveRecord::Base
def grouped_diff_discussions
active_notes = diff_notes.fresh.select(&:active?)
- Discussion.for_diff_notes(active_notes).
- map { |d| [d.line_code, d] }.to_h
+ Discussion.for_diff_notes(active_notes)
+ .map { |d| [d.line_code, d] }.to_h
end
def count_for_collection(ids, type)
- user.select('noteable_id', 'COUNT(*) as count').
- group(:noteable_id).
- where(noteable_type: type, noteable_id: ids)
+ user.select('noteable_id', 'COUNT(*) as count')
+ .group(:noteable_id)
+ .where(noteable_type: type, noteable_id: ids)
end
end
diff --git a/app/models/project.rb b/app/models/project.rb
index e75ba3abb98..f2be9e6a80c 100644
--- a/app/models/project.rb
+++ b/app/models/project.rb
@@ -233,8 +233,8 @@ class Project < ActiveRecord::Base
scope :inside_path, ->(path) do
# We need routes alias rs for JOIN so it does not conflict with
# includes(:route) which we use in ProjectsFinder.
- joins("INNER JOIN routes rs ON rs.source_id = projects.id AND rs.source_type = 'Project'").
- where('rs.path LIKE ?', "#{path}/%")
+ joins("INNER JOIN routes rs ON rs.source_id = projects.id AND rs.source_type = 'Project'")
+ .where('rs.path LIKE ?', "#{path}/%")
end
# "enabled" here means "not disabled". It includes private features!
@@ -311,9 +311,9 @@ class Project < ActiveRecord::Base
pattern = "%#{query}%"
projects = select(:id).where(
- ptable[:path].matches(pattern).
- or(ptable[:name].matches(pattern)).
- or(ptable[:description].matches(pattern))
+ ptable[:path].matches(pattern)
+ .or(ptable[:name].matches(pattern))
+ .or(ptable[:description].matches(pattern))
)
# We explicitly remove any eager loading clauses as they're:
@@ -322,10 +322,10 @@ class Project < ActiveRecord::Base
# 2. Combined with .joins(:namespace) lead to all columns from the
# projects & namespaces tables being selected, leading to a SQL error
# due to the columns of all UNION'd queries no longer being the same.
- namespaces = select(:id).
- except(:includes).
- joins(:namespace).
- where(ntable[:name].matches(pattern))
+ namespaces = select(:id)
+ .except(:includes)
+ .joins(:namespace)
+ .where(ntable[:name].matches(pattern))
union = Gitlab::SQL::Union.new([projects, namespaces])
@@ -367,8 +367,8 @@ class Project < ActiveRecord::Base
end
def trending
- joins('INNER JOIN trending_projects ON projects.id = trending_projects.project_id').
- reorder('trending_projects.id ASC')
+ joins('INNER JOIN trending_projects ON projects.id = trending_projects.project_id')
+ .reorder('trending_projects.id ASC')
end
def cached_count
diff --git a/app/models/project_services/kubernetes_service.rb b/app/models/project_services/kubernetes_service.rb
index eb5019c08b5..caf71676837 100644
--- a/app/models/project_services/kubernetes_service.rb
+++ b/app/models/project_services/kubernetes_service.rb
@@ -109,9 +109,9 @@ class KubernetesService < DeploymentService
def terminals(environment)
with_reactive_cache do |data|
pods = data.fetch(:pods, nil)
- filter_pods(pods, app: environment.slug).
- flat_map { |pod| terminals_for_pod(api_url, namespace, pod) }.
- each { |terminal| add_terminal_auth(terminal, terminal_auth) }
+ filter_pods(pods, app: environment.slug)
+ .flat_map { |pod| terminals_for_pod(api_url, namespace, pod) }
+ .each { |terminal| add_terminal_auth(terminal, terminal_auth) }
end
end
diff --git a/app/models/project_services/mattermost_slash_commands_service.rb b/app/models/project_services/mattermost_slash_commands_service.rb
index 56f42d63b2d..26376fd87ff 100644
--- a/app/models/project_services/mattermost_slash_commands_service.rb
+++ b/app/models/project_services/mattermost_slash_commands_service.rb
@@ -20,8 +20,8 @@ class MattermostSlashCommandsService < ChatSlashCommandsService
end
def configure(user, params)
- token = Mattermost::Command.new(user).
- create(command(params))
+ token = Mattermost::Command.new(user)
+ .create(command(params))
update(active: true, token: token) if token
rescue Mattermost::Error => e
diff --git a/app/models/project_team.rb b/app/models/project_team.rb
index 8a53e974b6f..67cc06642f1 100644
--- a/app/models/project_team.rb
+++ b/app/models/project_team.rb
@@ -169,10 +169,10 @@ class ProjectTeam
# Lookup only the IDs we need
user_ids = user_ids - access.keys
- users_access = project.project_authorizations.
- where(user: user_ids).
- group(:user_id).
- maximum(:access_level)
+ users_access = project.project_authorizations
+ .where(user: user_ids)
+ .group(:user_id)
+ .maximum(:access_level)
access.merge!(users_access)
access
diff --git a/app/models/repository.rb b/app/models/repository.rb
index 32252957a84..7113879417e 100644
--- a/app/models/repository.rb
+++ b/app/models/repository.rb
@@ -249,11 +249,11 @@ class Repository
cache.fetch(:"diverging_commit_counts_#{branch.name}") do
# Rugged seems to throw a `ReferenceError` when given branch_names rather
# than SHA-1 hashes
- number_commits_behind = raw_repository.
- count_commits_between(branch.dereferenced_target.sha, root_ref_hash)
+ number_commits_behind = raw_repository
+ .count_commits_between(branch.dereferenced_target.sha, root_ref_hash)
- number_commits_ahead = raw_repository.
- count_commits_between(root_ref_hash, branch.dereferenced_target.sha)
+ number_commits_ahead = raw_repository
+ .count_commits_between(root_ref_hash, branch.dereferenced_target.sha)
{ behind: number_commits_behind, ahead: number_commits_ahead }
end
@@ -759,8 +759,8 @@ class Repository
check_tree_entry_for_dir(branch_name, path)
if start_branch_name
- start_project.repository.
- check_tree_entry_for_dir(start_branch_name, path)
+ start_project.repository
+ .check_tree_entry_for_dir(start_branch_name, path)
end
commit_file(
diff --git a/app/models/todo.rb b/app/models/todo.rb
index 47789a21133..32bb9bf2045 100644
--- a/app/models/todo.rb
+++ b/app/models/todo.rb
@@ -64,9 +64,9 @@ class Todo < ActiveRecord::Base
highest_priority = highest_label_priority(params).to_sql
- select("#{table_name}.*, (#{highest_priority}) AS highest_priority").
- order(Gitlab::Database.nulls_last_order('highest_priority', 'ASC')).
- order('todos.created_at')
+ select("#{table_name}.*, (#{highest_priority}) AS highest_priority")
+ .order(Gitlab::Database.nulls_last_order('highest_priority', 'ASC'))
+ .order('todos.created_at')
end
end
diff --git a/app/models/user.rb b/app/models/user.rb
index f37735c5eba..296bcc699a9 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -197,13 +197,13 @@ class User < ActiveRecord::Base
scope :order_oldest_sign_in, -> { reorder(Gitlab::Database.nulls_last_order('last_sign_in_at', 'ASC')) }
def self.with_two_factor
- joins("LEFT OUTER JOIN u2f_registrations AS u2f ON u2f.user_id = users.id").
- where("u2f.id IS NOT NULL OR otp_required_for_login = ?", true).distinct(arel_table[:id])
+ joins("LEFT OUTER JOIN u2f_registrations AS u2f ON u2f.user_id = users.id")
+ .where("u2f.id IS NOT NULL OR otp_required_for_login = ?", true).distinct(arel_table[:id])
end
def self.without_two_factor
- joins("LEFT OUTER JOIN u2f_registrations AS u2f ON u2f.user_id = users.id").
- where("u2f.id IS NULL AND otp_required_for_login = ?", false)
+ joins("LEFT OUTER JOIN u2f_registrations AS u2f ON u2f.user_id = users.id")
+ .where("u2f.id IS NULL AND otp_required_for_login = ?", false)
end
#
@@ -274,9 +274,9 @@ class User < ActiveRecord::Base
pattern = "%#{query}%"
where(
- table[:name].matches(pattern).
- or(table[:email].matches(pattern)).
- or(table[:username].matches(pattern))
+ table[:name].matches(pattern)
+ .or(table[:email].matches(pattern))
+ .or(table[:username].matches(pattern))
)
end
@@ -291,10 +291,10 @@ class User < ActiveRecord::Base
matched_by_emails_user_ids = email_table.project(email_table[:user_id]).where(email_table[:email].matches(pattern))
where(
- table[:name].matches(pattern).
- or(table[:email].matches(pattern)).
- or(table[:username].matches(pattern)).
- or(table[:id].in(matched_by_emails_user_ids))
+ table[:name].matches(pattern)
+ .or(table[:email].matches(pattern))
+ .or(table[:username].matches(pattern))
+ .or(table[:id].in(matched_by_emails_user_ids))
)
end
@@ -447,8 +447,8 @@ class User < ActiveRecord::Base
# Returns the groups a user has access to
def authorized_groups
- union = Gitlab::SQL::Union.
- new([groups.select(:id), authorized_projects.select(:namespace_id)])
+ union = Gitlab::SQL::Union
+ .new([groups.select(:id), authorized_projects.select(:namespace_id)])
Group.where("namespaces.id IN (#{union.to_sql})")
end
@@ -458,8 +458,8 @@ class User < ActiveRecord::Base
end
def nested_projects
- Project.joins(:namespace).where('namespaces.parent_id IS NOT NULL').
- member_descendants(id)
+ Project.joins(:namespace).where('namespaces.parent_id IS NOT NULL')
+ .member_descendants(id)
end
def refresh_authorized_projects
@@ -579,8 +579,8 @@ class User < ActiveRecord::Base
next unless project
if project.repository.branch_exists?(event.branch_name)
- merge_requests = MergeRequest.where("created_at >= ?", event.created_at).
- where(source_project_id: project.id,
+ merge_requests = MergeRequest.where("created_at >= ?", event.created_at)
+ .where(source_project_id: project.id,
source_branch: event.branch_name)
merge_requests.empty?
end
@@ -793,8 +793,8 @@ class User < ActiveRecord::Base
def toggle_star(project)
UsersStarProject.transaction do
- user_star_project = users_star_projects.
- where(project: project, user: self).lock(true).first
+ user_star_project = users_star_projects
+ .where(project: project, user: self).lock(true).first
if user_star_project
user_star_project.destroy
@@ -830,11 +830,11 @@ class User < ActiveRecord::Base
# ms on a database with a similar size to GitLab.com's database. On the other
# hand, using a subquery means we can get the exact same data in about 40 ms.
def contributed_projects
- events = Event.select(:project_id).
- contributions.where(author_id: self).
- where("created_at > ?", Time.now - 1.year).
- uniq.
- reorder(nil)
+ events = Event.select(:project_id)
+ .contributions.where(author_id: self)
+ .where("created_at > ?", Time.now - 1.year)
+ .uniq
+ .reorder(nil)
Project.where(id: events)
end
@@ -845,9 +845,9 @@ class User < ActiveRecord::Base
def ci_authorized_runners
@ci_authorized_runners ||= begin
- runner_ids = Ci::RunnerProject.
- where("ci_runner_projects.gl_project_id IN (#{ci_projects_union.to_sql})").
- select(:runner_id)
+ runner_ids = Ci::RunnerProject
+ .where("ci_runner_projects.gl_project_id IN (#{ci_projects_union.to_sql})")
+ .select(:runner_id)
Ci::Runner.specific.where(id: runner_ids)
end
end
diff --git a/app/models/wiki_page.rb b/app/models/wiki_page.rb
index 2caebb496db..0fa9d77a771 100644
--- a/app/models/wiki_page.rb
+++ b/app/models/wiki_page.rb
@@ -22,16 +22,16 @@ class WikiPage
def self.group_by_directory(pages)
return [] if pages.blank?
- pages.sort_by { |page| [page.directory, page.slug] }.
- group_by(&:directory).
- map do |dir, pages|
+ pages.sort_by { |page| [page.directory, page.slug] }
+ .group_by(&:directory)
+ .map do |dir, pages|
if dir.present?
WikiDirectory.new(dir, pages)
else
pages
end
- end.
- flatten
+ end
+ .flatten
end
def self.unhyphenize(name)
diff --git a/app/serializers/base_serializer.rb b/app/serializers/base_serializer.rb
index 032c44274ef..311ee9c96be 100644
--- a/app/serializers/base_serializer.rb
+++ b/app/serializers/base_serializer.rb
@@ -4,9 +4,9 @@ class BaseSerializer
end
def represent(resource, opts = {})
- self.class.entity_class.
- represent(resource, opts.merge(request: @request)).
- as_json
+ self.class.entity_class
+ .represent(resource, opts.merge(request: @request))
+ .as_json
end
def self.entity(entity_class)
diff --git a/app/serializers/environment_serializer.rb b/app/serializers/environment_serializer.rb
index ffc4fd34c75..d0a60f134da 100644
--- a/app/serializers/environment_serializer.rb
+++ b/app/serializers/environment_serializer.rb
@@ -36,9 +36,9 @@ class EnvironmentSerializer < BaseSerializer
private
def itemize(resource)
- items = resource.order('folder_name ASC').
- group('COALESCE(environment_type, name)').
- select('COALESCE(environment_type, name) AS folder_name',
+ items = resource.order('folder_name ASC')
+ .group('COALESCE(environment_type, name)')
+ .select('COALESCE(environment_type, name) AS folder_name',
'COUNT(*) AS size', 'MAX(id) AS last_id')
# It makes a difference when you call `paginate` method, because
diff --git a/app/services/after_branch_delete_service.rb b/app/services/after_branch_delete_service.rb
index 95492f709bb..227e9ea9c6d 100644
--- a/app/services/after_branch_delete_service.rb
+++ b/app/services/after_branch_delete_service.rb
@@ -14,8 +14,8 @@ class AfterBranchDeleteService < BaseService
private
def stop_environments
- Ci::StopEnvironmentsService.
- new(project, current_user).
- execute(branch_name)
+ Ci::StopEnvironmentsService
+ .new(project, current_user)
+ .execute(branch_name)
end
end
diff --git a/app/services/boards/issues/list_service.rb b/app/services/boards/issues/list_service.rb
index 2d664f3f0c8..8a94c54b6ab 100644
--- a/app/services/boards/issues/list_service.rb
+++ b/app/services/boards/issues/list_service.rb
@@ -57,15 +57,15 @@ module Boards
return issues unless board_label_ids.any?
issues.where.not(
- LabelLink.where("label_links.target_type = 'Issue' AND label_links.target_id = issues.id").
- where(label_id: board_label_ids).limit(1).arel.exists
+ LabelLink.where("label_links.target_type = 'Issue' AND label_links.target_id = issues.id")
+ .where(label_id: board_label_ids).limit(1).arel.exists
)
end
def with_list_label(issues)
issues.where(
- LabelLink.where("label_links.target_type = 'Issue' AND label_links.target_id = issues.id").
- where("label_links.label_id = ?", list.label_id).limit(1).arel.exists
+ LabelLink.where("label_links.target_type = 'Issue' AND label_links.target_id = issues.id")
+ .where("label_links.label_id = ?", list.label_id).limit(1).arel.exists
)
end
end
diff --git a/app/services/boards/lists/destroy_service.rb b/app/services/boards/lists/destroy_service.rb
index 6c80dd61873..f986e05944c 100644
--- a/app/services/boards/lists/destroy_service.rb
+++ b/app/services/boards/lists/destroy_service.rb
@@ -17,8 +17,8 @@ module Boards
attr_reader :board
def decrement_higher_lists(list)
- board.lists.movable.where('position > ?', list.position).
- update_all('position = position - 1')
+ board.lists.movable.where('position > ?', list.position)
+ .update_all('position = position - 1')
end
def remove_list(list)
diff --git a/app/services/boards/lists/move_service.rb b/app/services/boards/lists/move_service.rb
index 2f109934ea9..f2a68865f7b 100644
--- a/app/services/boards/lists/move_service.rb
+++ b/app/services/boards/lists/move_service.rb
@@ -33,15 +33,15 @@ module Boards
end
def decrement_intermediate_lists
- board.lists.movable.where('position > ?', old_position).
- where('position <= ?', new_position).
- update_all('position = position - 1')
+ board.lists.movable.where('position > ?', old_position)
+ .where('position <= ?', new_position)
+ .update_all('position = position - 1')
end
def increment_intermediate_lists
- board.lists.movable.where('position >= ?', new_position).
- where('position < ?', old_position).
- update_all('position = position + 1')
+ board.lists.movable.where('position >= ?', new_position)
+ .where('position < ?', old_position)
+ .update_all('position = position + 1')
end
def update_list_position(list)
diff --git a/app/services/ci/create_pipeline_builds_service.rb b/app/services/ci/create_pipeline_builds_service.rb
index b7da3f8e7eb..c5da757c840 100644
--- a/app/services/ci/create_pipeline_builds_service.rb
+++ b/app/services/ci/create_pipeline_builds_service.rb
@@ -36,8 +36,8 @@ module Ci
end
def new_builds
- @new_builds ||= pipeline.config_builds_attributes.
- reject { |build| existing_build_names.include?(build[:name]) }
+ @new_builds ||= pipeline.config_builds_attributes
+ .reject { |build| existing_build_names.include?(build[:name]) }
end
def existing_build_names
diff --git a/app/services/ci/create_pipeline_service.rb b/app/services/ci/create_pipeline_service.rb
index b53a467655f..38a85e9fc42 100644
--- a/app/services/ci/create_pipeline_service.rb
+++ b/app/services/ci/create_pipeline_service.rb
@@ -48,9 +48,9 @@ module Ci
Ci::Pipeline.transaction do
pipeline.save
- Ci::CreatePipelineBuildsService.
- new(project, current_user).
- execute(pipeline)
+ Ci::CreatePipelineBuildsService
+ .new(project, current_user)
+ .execute(pipeline)
end
pipeline.tap(&:process!)
diff --git a/app/services/ci/create_trigger_request_service.rb b/app/services/ci/create_trigger_request_service.rb
index 6af3c1ca5b1..062e7be5be8 100644
--- a/app/services/ci/create_trigger_request_service.rb
+++ b/app/services/ci/create_trigger_request_service.rb
@@ -3,8 +3,8 @@ module Ci
def execute(project, trigger, ref, variables = nil)
trigger_request = trigger.trigger_requests.create(variables: variables)
- pipeline = Ci::CreatePipelineService.new(project, nil, ref: ref).
- execute(ignore_skip_ci: true, trigger_request: trigger_request)
+ pipeline = Ci::CreatePipelineService.new(project, nil, ref: ref)
+ .execute(ignore_skip_ci: true, trigger_request: trigger_request)
if pipeline.persisted?
trigger_request
end
diff --git a/app/services/ci/process_pipeline_service.rb b/app/services/ci/process_pipeline_service.rb
index 442230abe29..79eb97b7b55 100644
--- a/app/services/ci/process_pipeline_service.rb
+++ b/app/services/ci/process_pipeline_service.rb
@@ -78,9 +78,9 @@ module Ci
def ensure_created_builds!
return if created_builds.any?
- Ci::CreatePipelineBuildsService.
- new(project, current_user).
- execute(pipeline)
+ Ci::CreatePipelineBuildsService
+ .new(project, current_user)
+ .execute(pipeline)
end
end
end
diff --git a/app/services/ci/register_build_service.rb b/app/services/ci/register_build_service.rb
index 6f03bf2be13..9c7abf97b4c 100644
--- a/app/services/ci/register_build_service.rb
+++ b/app/services/ci/register_build_service.rb
@@ -42,15 +42,15 @@ module Ci
def builds_for_shared_runner
new_builds.
# don't run projects which have not enabled shared runners and builds
- joins(:project).where(projects: { shared_runners_enabled: true }).
- joins('LEFT JOIN project_features ON ci_builds.gl_project_id = project_features.project_id').
- where('project_features.builds_access_level IS NULL or project_features.builds_access_level > 0').
+ joins(:project).where(projects: { shared_runners_enabled: true })
+ .joins('LEFT JOIN project_features ON ci_builds.gl_project_id = project_features.project_id')
+ .where('project_features.builds_access_level IS NULL or project_features.builds_access_level > 0').
# Implement fair scheduling
# this returns builds that are ordered by number of running builds
# we prefer projects that don't use shared runners at all
- joins("LEFT JOIN (#{running_builds_for_shared_runners.to_sql}) AS project_builds ON ci_builds.gl_project_id=project_builds.gl_project_id").
- order('COALESCE(project_builds.running_builds, 0) ASC', 'ci_builds.id ASC')
+ joins("LEFT JOIN (#{running_builds_for_shared_runners.to_sql}) AS project_builds ON ci_builds.gl_project_id=project_builds.gl_project_id")
+ .order('COALESCE(project_builds.running_builds, 0) ASC', 'ci_builds.id ASC')
end
def builds_for_specific_runner
@@ -58,8 +58,8 @@ module Ci
end
def running_builds_for_shared_runners
- Ci::Build.running.where(runner: Ci::Runner.shared).
- group(:gl_project_id).select(:gl_project_id, 'count(*) AS running_builds')
+ Ci::Build.running.where(runner: Ci::Runner.shared)
+ .group(:gl_project_id).select(:gl_project_id, 'count(*) AS running_builds')
end
def new_builds
diff --git a/app/services/ci/retry_build_service.rb b/app/services/ci/retry_build_service.rb
index c1fa9278f0f..38ef323f6e5 100644
--- a/app/services/ci/retry_build_service.rb
+++ b/app/services/ci/retry_build_service.rb
@@ -2,8 +2,8 @@ module Ci
class RetryBuildService < ::BaseService
CLONE_ATTRIBUTES = %i[pipeline project ref tag options commands name
allow_failure stage stage_idx trigger_request
- yaml_variables when environment coverage_regex].
- freeze
+ yaml_variables when environment coverage_regex]
+ .freeze
REJECT_ATTRIBUTES = %i[id status user token coverage trace runner
artifacts_expire_at artifacts_file
@@ -20,9 +20,9 @@ module Ci
new_build.enqueue!
- MergeRequests::AddTodoWhenBuildFailsService.
- new(project, current_user).
- close(new_build)
+ MergeRequests::AddTodoWhenBuildFailsService
+ .new(project, current_user)
+ .close(new_build)
end
end
diff --git a/app/services/ci/retry_pipeline_service.rb b/app/services/ci/retry_pipeline_service.rb
index 6e9781ca8cf..2c5e130e5aa 100644
--- a/app/services/ci/retry_pipeline_service.rb
+++ b/app/services/ci/retry_pipeline_service.rb
@@ -8,13 +8,13 @@ module Ci
pipeline.builds.failed_or_canceled.find_each do |build|
next unless build.retryable?
- Ci::RetryBuildService.new(project, current_user).
- reprocess(build)
+ Ci::RetryBuildService.new(project, current_user)
+ .reprocess(build)
end
- MergeRequests::AddTodoWhenBuildFailsService.
- new(project, current_user).
- close_all(pipeline)
+ MergeRequests::AddTodoWhenBuildFailsService
+ .new(project, current_user)
+ .close_all(pipeline)
pipeline.process!
end
diff --git a/app/services/commits/change_service.rb b/app/services/commits/change_service.rb
index 75281837b09..25e22f14e60 100644
--- a/app/services/commits/change_service.rb
+++ b/app/services/commits/change_service.rb
@@ -70,8 +70,8 @@ module Commits
# Temporary branch exists and contains the change commit
return if repository.find_branch(new_branch)
- result = ValidateNewBranchService.new(@project, current_user).
- execute(new_branch)
+ result = ValidateNewBranchService.new(@project, current_user)
+ .execute(new_branch)
if result[:status] == :error
raise ChangeError, "There was an error creating the source branch: #{result[:message]}"
diff --git a/app/services/create_branch_service.rb b/app/services/create_branch_service.rb
index 1b5e504573a..77459d8779d 100644
--- a/app/services/create_branch_service.rb
+++ b/app/services/create_branch_service.rb
@@ -1,7 +1,7 @@
class CreateBranchService < BaseService
def execute(branch_name, ref)
- result = ValidateNewBranchService.new(project, current_user).
- execute(branch_name)
+ result = ValidateNewBranchService.new(project, current_user)
+ .execute(branch_name)
return result if result[:status] == :error
diff --git a/app/services/files/base_service.rb b/app/services/files/base_service.rb
index 0a25f56d24c..dcec604b455 100644
--- a/app/services/files/base_service.rb
+++ b/app/services/files/base_service.rb
@@ -72,8 +72,8 @@ module Files
end
def validate_target_branch
- result = ValidateNewBranchService.new(project, current_user).
- execute(@target_branch)
+ result = ValidateNewBranchService.new(project, current_user)
+ .execute(@target_branch)
if result[:status] == :error
raise_error("Something went wrong when we tried to create #{@target_branch} for you: #{result[:message]}")
diff --git a/app/services/files/update_service.rb b/app/services/files/update_service.rb
index a71fe61a4b6..b1e8d11fdcf 100644
--- a/app/services/files/update_service.rb
+++ b/app/services/files/update_service.rb
@@ -24,8 +24,8 @@ module Files
end
def last_commit
- @last_commit ||= Gitlab::Git::Commit.
- last_for_path(@start_project.repository, @start_branch, @file_path)
+ @last_commit ||= Gitlab::Git::Commit
+ .last_for_path(@start_project.repository, @start_branch, @file_path)
end
end
end
diff --git a/app/services/git_push_service.rb b/app/services/git_push_service.rb
index f681f831cbd..ee6e695c134 100644
--- a/app/services/git_push_service.rb
+++ b/app/services/git_push_service.rb
@@ -85,8 +85,8 @@ class GitPushService < BaseService
default = is_default_branch?
push_commits.last(PROCESS_COMMIT_LIMIT).each do |commit|
- ProcessCommitWorker.
- perform_async(project.id, current_user.id, commit.to_hash, default)
+ ProcessCommitWorker
+ .perform_async(project.id, current_user.id, commit.to_hash, default)
end
end
@@ -96,8 +96,8 @@ class GitPushService < BaseService
# Update merge requests that may be affected by this push. A new branch
# could cause the last commit of a merge request to change.
#
- UpdateMergeRequestsWorker.
- perform_async(@project.id, current_user.id, params[:oldrev], params[:newrev], params[:ref])
+ UpdateMergeRequestsWorker
+ .perform_async(@project.id, current_user.id, params[:oldrev], params[:newrev], params[:ref])
EventCreateService.new.push(@project, current_user, build_push_data)
@project.execute_hooks(build_push_data.dup, :push_hooks)
@@ -105,9 +105,9 @@ class GitPushService < BaseService
Ci::CreatePipelineService.new(@project, current_user, build_push_data).execute
if push_remove_branch?
- AfterBranchDeleteService.
- new(project, current_user).
- execute(branch_name)
+ AfterBranchDeleteService
+ .new(project, current_user)
+ .execute(branch_name)
end
end
diff --git a/app/services/issuable_base_service.rb b/app/services/issuable_base_service.rb
index 9500faf2862..457dcf76995 100644
--- a/app/services/issuable_base_service.rb
+++ b/app/services/issuable_base_service.rb
@@ -144,8 +144,8 @@ class IssuableBaseService < BaseService
def merge_slash_commands_into_params!(issuable)
description, command_params =
- SlashCommands::InterpretService.new(project, current_user).
- execute(params[:description], issuable)
+ SlashCommands::InterpretService.new(project, current_user)
+ .execute(params[:description], issuable)
# Avoid a description already set on an issuable to be overwritten by a nil
params[:description] = description if params.has_key?(:description)
diff --git a/app/services/issues/create_service.rb b/app/services/issues/create_service.rb
index 366b3572738..9e0c90b56f6 100644
--- a/app/services/issues/create_service.rb
+++ b/app/services/issues/create_service.rb
@@ -29,8 +29,8 @@ module Issues
def resolve_discussions_in_merge_request(issue)
Discussions::ResolveService.new(project, current_user,
merge_request: merge_request_for_resolving_discussions,
- follow_up_issue: issue).
- execute(merge_request_for_resolving_discussions.resolvable_discussions)
+ follow_up_issue: issue)
+ .execute(merge_request_for_resolving_discussions.resolvable_discussions)
end
private
diff --git a/app/services/issues/move_service.rb b/app/services/issues/move_service.rb
index 17b65947468..a2a5f57d069 100644
--- a/app/services/issues/move_service.rb
+++ b/app/services/issues/move_service.rb
@@ -61,8 +61,8 @@ module Issues
end
def cloneable_milestone_id
- @new_project.milestones.
- find_by(title: @old_issue.milestone.try(:title)).try(:id)
+ @new_project.milestones
+ .find_by(title: @old_issue.milestone.try(:title)).try(:id)
end
def rewrite_notes
diff --git a/app/services/labels/promote_service.rb b/app/services/labels/promote_service.rb
index 76d0ba67b07..43b539ded53 100644
--- a/app/services/labels/promote_service.rb
+++ b/app/services/labels/promote_service.rb
@@ -26,29 +26,29 @@ module Labels
private
def label_ids_for_merge(new_label)
- LabelsFinder.
- new(current_user, title: new_label.title, group_id: project.group.id).
- execute(skip_authorization: true).
- where.not(id: new_label).
- select(:id) # Can't use pluck() to avoid object-creation because of the batching
+ LabelsFinder
+ .new(current_user, title: new_label.title, group_id: project.group.id)
+ .execute(skip_authorization: true)
+ .where.not(id: new_label)
+ .select(:id) # Can't use pluck() to avoid object-creation because of the batching
end
def update_issuables(new_label, label_ids)
- LabelLink.
- where(label: label_ids).
- update_all(label_id: new_label)
+ LabelLink
+ .where(label: label_ids)
+ .update_all(label_id: new_label)
end
def update_issue_board_lists(new_label, label_ids)
- List.
- where(label: label_ids).
- update_all(label_id: new_label)
+ List
+ .where(label: label_ids)
+ .update_all(label_id: new_label)
end
def update_priorities(new_label, label_ids)
- LabelPriority.
- where(label: label_ids).
- update_all(label_id: new_label)
+ LabelPriority
+ .where(label: label_ids)
+ .update_all(label_id: new_label)
end
def update_project_labels(label_ids)
diff --git a/app/services/labels/transfer_service.rb b/app/services/labels/transfer_service.rb
index 514679ed29d..d2ece354efc 100644
--- a/app/services/labels/transfer_service.rb
+++ b/app/services/labels/transfer_service.rb
@@ -41,16 +41,16 @@ module Labels
end
def group_labels_applied_to_issues
- Label.joins(:issues).
- where(
+ Label.joins(:issues)
+ .where(
issues: { project_id: project.id },
labels: { type: 'GroupLabel', group_id: old_group.id }
)
end
def group_labels_applied_to_merge_requests
- Label.joins(:merge_requests).
- where(
+ Label.joins(:merge_requests)
+ .where(
merge_requests: { target_project_id: project.id },
labels: { type: 'GroupLabel', group_id: old_group.id }
)
@@ -64,15 +64,15 @@ module Labels
end
def update_label_links(labels, old_label_id:, new_label_id:)
- LabelLink.joins(:label).
- merge(labels).
- where(label_id: old_label_id).
- update_all(label_id: new_label_id)
+ LabelLink.joins(:label)
+ .merge(labels)
+ .where(label_id: old_label_id)
+ .update_all(label_id: new_label_id)
end
def update_label_priorities(old_label_id:, new_label_id:)
- LabelPriority.where(project_id: project.id, label_id: old_label_id).
- update_all(label_id: new_label_id)
+ LabelPriority.where(project_id: project.id, label_id: old_label_id)
+ .update_all(label_id: new_label_id)
end
end
end
diff --git a/app/services/merge_requests/base_service.rb b/app/services/merge_requests/base_service.rb
index fd9d7de35f4..5a53b973059 100644
--- a/app/services/merge_requests/base_service.rb
+++ b/app/services/merge_requests/base_service.rb
@@ -40,11 +40,11 @@ module MergeRequests
# Returns all origin and fork merge requests from `@project` satisfying passed arguments.
def merge_requests_for(source_branch, mr_states: [:opened])
- MergeRequest.
- with_state(mr_states).
- where(source_branch: source_branch, source_project_id: @project.id).
- preload(:source_project). # we don't need a #includes since we're just preloading for the #select
- select(&:source_project)
+ MergeRequest
+ .with_state(mr_states)
+ .where(source_branch: source_branch, source_project_id: @project.id)
+ .preload(:source_project) # we don't need a #includes since we're just preloading for the #select
+ .select(&:source_project)
end
def pipeline_merge_requests(pipeline)
diff --git a/app/services/merge_requests/merge_service.rb b/app/services/merge_requests/merge_service.rb
index 3da1b657a41..1657f8624a7 100644
--- a/app/services/merge_requests/merge_service.rb
+++ b/app/services/merge_requests/merge_service.rb
@@ -63,8 +63,8 @@ module MergeRequests
MergeRequests::PostMergeService.new(project, current_user).execute(merge_request)
if params[:should_remove_source_branch].present? || @merge_request.force_remove_source_branch?
- DeleteBranchService.new(@merge_request.source_project, branch_deletion_user).
- execute(merge_request.source_branch)
+ DeleteBranchService.new(@merge_request.source_project, branch_deletion_user)
+ .execute(merge_request.source_branch)
end
end
diff --git a/app/services/merge_requests/refresh_service.rb b/app/services/merge_requests/refresh_service.rb
index edee3032683..9277f67e5ae 100644
--- a/app/services/merge_requests/refresh_service.rb
+++ b/app/services/merge_requests/refresh_service.rb
@@ -43,9 +43,9 @@ module MergeRequests
end
filter_merge_requests(merge_requests).each do |merge_request|
- MergeRequests::PostMergeService.
- new(merge_request.target_project, @current_user).
- execute(merge_request)
+ MergeRequests::PostMergeService
+ .new(merge_request.target_project, @current_user)
+ .execute(merge_request)
end
end
@@ -56,13 +56,13 @@ module MergeRequests
# Refresh merge request diff if we push to source or target branch of merge request
# Note: we should update merge requests from forks too
def reload_merge_requests
- merge_requests = @project.merge_requests.opened.
- by_source_or_target_branch(@branch_name).to_a
+ merge_requests = @project.merge_requests.opened
+ .by_source_or_target_branch(@branch_name).to_a
# Fork merge requests
- merge_requests += MergeRequest.opened.
- where(source_branch: @branch_name, source_project: @project).
- where.not(target_project: @project).to_a
+ merge_requests += MergeRequest.opened
+ .where(source_branch: @branch_name, source_project: @project)
+ .where.not(target_project: @project).to_a
filter_merge_requests(merge_requests).each do |merge_request|
if merge_request.source_branch == @branch_name || force_push?
diff --git a/app/services/notes/slash_commands_service.rb b/app/services/notes/slash_commands_service.rb
index ad1e6f6774a..addb6a7e65b 100644
--- a/app/services/notes/slash_commands_service.rb
+++ b/app/services/notes/slash_commands_service.rb
@@ -22,8 +22,8 @@ module Notes
def extract_commands(note, options = {})
return [note.note, {}] unless supported?(note)
- SlashCommands::InterpretService.new(project, current_user, options).
- execute(note.note, note.noteable)
+ SlashCommands::InterpretService.new(project, current_user, options)
+ .execute(note.note, note.noteable)
end
def execute(command_params, note)
diff --git a/app/services/tags/create_service.rb b/app/services/tags/create_service.rb
index 1756da9e519..674792f6138 100644
--- a/app/services/tags/create_service.rb
+++ b/app/services/tags/create_service.rb
@@ -19,8 +19,8 @@ module Tags
if new_tag
if release_description
- CreateReleaseService.new(@project, @current_user).
- execute(tag_name, release_description)
+ CreateReleaseService.new(@project, @current_user)
+ .execute(tag_name, release_description)
end
success.merge(tag: new_tag)
diff --git a/app/services/users/refresh_authorized_projects_service.rb b/app/services/users/refresh_authorized_projects_service.rb
index fad741531ea..4411eda3b02 100644
--- a/app/services/users/refresh_authorized_projects_service.rb
+++ b/app/services/users/refresh_authorized_projects_service.rb
@@ -103,11 +103,11 @@ module Users
end
def fresh_authorizations
- ProjectAuthorization.
- unscoped.
- select('project_id, MAX(access_level) AS access_level').
- from("(#{project_authorizations_union.to_sql}) #{ProjectAuthorization.table_name}").
- group(:project_id)
+ ProjectAuthorization
+ .unscoped
+ .select('project_id, MAX(access_level) AS access_level')
+ .from("(#{project_authorizations_union.to_sql}) #{ProjectAuthorization.table_name}")
+ .group(:project_id)
end
private
diff --git a/app/workers/build_coverage_worker.rb b/app/workers/build_coverage_worker.rb
index 31e2dc448da..def0ab1dde1 100644
--- a/app/workers/build_coverage_worker.rb
+++ b/app/workers/build_coverage_worker.rb
@@ -3,7 +3,7 @@ class BuildCoverageWorker
include BuildQueue
def perform(build_id)
- Ci::Build.find_by(id: build_id).
- try(:update_coverage)
+ Ci::Build.find_by(id: build_id)
+ .try(:update_coverage)
end
end
diff --git a/app/workers/build_hooks_worker.rb b/app/workers/build_hooks_worker.rb
index ff22313c491..9965af935d4 100644
--- a/app/workers/build_hooks_worker.rb
+++ b/app/workers/build_hooks_worker.rb
@@ -3,7 +3,7 @@ class BuildHooksWorker
include BuildQueue
def perform(build_id)
- Ci::Build.find_by(id: build_id).
- try(:execute_hooks)
+ Ci::Build.find_by(id: build_id)
+ .try(:execute_hooks)
end
end
diff --git a/app/workers/emails_on_push_worker.rb b/app/workers/emails_on_push_worker.rb
index d4c3f14ec06..f5ccc84c160 100644
--- a/app/workers/emails_on_push_worker.rb
+++ b/app/workers/emails_on_push_worker.rb
@@ -33,15 +33,15 @@ class EmailsOnPushWorker
reverse_compare = false
if action == :push
- compare = CompareService.new(project, after_sha).
- execute(project, before_sha)
+ compare = CompareService.new(project, after_sha)
+ .execute(project, before_sha)
diff_refs = compare.diff_refs
return false if compare.same
if compare.commits.empty?
- compare = CompareService.new(project, before_sha).
- execute(project, after_sha)
+ compare = CompareService.new(project, before_sha)
+ .execute(project, after_sha)
diff_refs = compare.diff_refs
reverse_compare = true
diff --git a/app/workers/expire_build_instance_artifacts_worker.rb b/app/workers/expire_build_instance_artifacts_worker.rb
index 2c29a9a58e1..eb403c134d1 100644
--- a/app/workers/expire_build_instance_artifacts_worker.rb
+++ b/app/workers/expire_build_instance_artifacts_worker.rb
@@ -3,10 +3,10 @@ class ExpireBuildInstanceArtifactsWorker
include DedicatedSidekiqQueue
def perform(build_id)
- build = Ci::Build.
- with_expired_artifacts.
- reorder(nil).
- find_by(id: build_id)
+ build = Ci::Build
+ .with_expired_artifacts
+ .reorder(nil)
+ .find_by(id: build_id)
return unless build.try(:project)
diff --git a/app/workers/merge_worker.rb b/app/workers/merge_worker.rb
index 79efca4f2f9..48e2da338f6 100644
--- a/app/workers/merge_worker.rb
+++ b/app/workers/merge_worker.rb
@@ -7,7 +7,7 @@ class MergeWorker
current_user = User.find(current_user_id)
merge_request = MergeRequest.find(merge_request_id)
- MergeRequests::MergeService.new(merge_request.target_project, current_user, params).
- execute(merge_request)
+ MergeRequests::MergeService.new(merge_request.target_project, current_user, params)
+ .execute(merge_request)
end
end
diff --git a/app/workers/pipeline_hooks_worker.rb b/app/workers/pipeline_hooks_worker.rb
index 7480a055e6a..7e36eacebf8 100644
--- a/app/workers/pipeline_hooks_worker.rb
+++ b/app/workers/pipeline_hooks_worker.rb
@@ -3,7 +3,7 @@ class PipelineHooksWorker
include PipelineQueue
def perform(pipeline_id)
- Ci::Pipeline.find_by(id: pipeline_id).
- try(:execute_hooks)
+ Ci::Pipeline.find_by(id: pipeline_id)
+ .try(:execute_hooks)
end
end
diff --git a/app/workers/pipeline_process_worker.rb b/app/workers/pipeline_process_worker.rb
index 5dcb09f553e..357e4a9a1c3 100644
--- a/app/workers/pipeline_process_worker.rb
+++ b/app/workers/pipeline_process_worker.rb
@@ -3,7 +3,7 @@ class PipelineProcessWorker
include PipelineQueue
def perform(pipeline_id)
- Ci::Pipeline.find_by(id: pipeline_id).
- try(:process!)
+ Ci::Pipeline.find_by(id: pipeline_id)
+ .try(:process!)
end
end
diff --git a/app/workers/pipeline_success_worker.rb b/app/workers/pipeline_success_worker.rb
index ef710f374ca..cc0eb708cf9 100644
--- a/app/workers/pipeline_success_worker.rb
+++ b/app/workers/pipeline_success_worker.rb
@@ -4,9 +4,9 @@ class PipelineSuccessWorker
def perform(pipeline_id)
Ci::Pipeline.find_by(id: pipeline_id).try do |pipeline|
- MergeRequests::MergeWhenPipelineSucceedsService.
- new(pipeline.project, nil).
- trigger(pipeline)
+ MergeRequests::MergeWhenPipelineSucceedsService
+ .new(pipeline.project, nil)
+ .trigger(pipeline)
end
end
end
diff --git a/app/workers/pipeline_update_worker.rb b/app/workers/pipeline_update_worker.rb
index e6d06d0577d..96c4152c674 100644
--- a/app/workers/pipeline_update_worker.rb
+++ b/app/workers/pipeline_update_worker.rb
@@ -3,7 +3,7 @@ class PipelineUpdateWorker
include PipelineQueue
def perform(pipeline_id)
- Ci::Pipeline.find_by(id: pipeline_id).
- try(:update_status)
+ Ci::Pipeline.find_by(id: pipeline_id)
+ .try(:update_status)
end
end
diff --git a/app/workers/process_commit_worker.rb b/app/workers/process_commit_worker.rb
index e9a5bd7f24e..5d7561732f1 100644
--- a/app/workers/process_commit_worker.rb
+++ b/app/workers/process_commit_worker.rb
@@ -45,16 +45,16 @@ class ProcessCommitWorker
# therefor we use IssueCollection here and skip the authorization check in
# Issues::CloseService#execute.
IssueCollection.new(issues).updatable_by_user(user).each do |issue|
- Issues::CloseService.new(project, author).
- close_issue(issue, commit: commit)
+ Issues::CloseService.new(project, author)
+ .close_issue(issue, commit: commit)
end
end
def update_issue_metrics(commit, author)
mentioned_issues = commit.all_references(author).issues
- Issue::Metrics.where(issue_id: mentioned_issues.map(&:id), first_mentioned_in_commit_at: nil).
- update_all(first_mentioned_in_commit_at: commit.committed_date)
+ Issue::Metrics.where(issue_id: mentioned_issues.map(&:id), first_mentioned_in_commit_at: nil)
+ .update_all(first_mentioned_in_commit_at: commit.committed_date)
end
def build_commit(project, hash)
diff --git a/app/workers/project_cache_worker.rb b/app/workers/project_cache_worker.rb
index 8ff9d07860f..505ff9e086e 100644
--- a/app/workers/project_cache_worker.rb
+++ b/app/workers/project_cache_worker.rb
@@ -32,8 +32,8 @@ class ProjectCacheWorker
private
def try_obtain_lease_for(project_id, section)
- Gitlab::ExclusiveLease.
- new("project_cache_worker:#{project_id}:#{section}", timeout: LEASE_TIMEOUT).
- try_obtain
+ Gitlab::ExclusiveLease
+ .new("project_cache_worker:#{project_id}:#{section}", timeout: LEASE_TIMEOUT)
+ .try_obtain
end
end
diff --git a/app/workers/prune_old_events_worker.rb b/app/workers/prune_old_events_worker.rb
index 392abb9c21b..2b43bb19ad1 100644
--- a/app/workers/prune_old_events_worker.rb
+++ b/app/workers/prune_old_events_worker.rb
@@ -10,9 +10,9 @@ class PruneOldEventsWorker
'(id IN (SELECT id FROM (?) ids_to_remove))',
Event.unscoped.where(
'created_at < ?',
- (12.months + 1.day).ago).
- select(:id).
- limit(10_000)).
- delete_all
+ (12.months + 1.day).ago)
+ .select(:id)
+ .limit(10_000))
+ .delete_all
end
end
diff --git a/app/workers/repository_check/batch_worker.rb b/app/workers/repository_check/batch_worker.rb
index c3e7491ec4e..b94d83bd709 100644
--- a/app/workers/repository_check/batch_worker.rb
+++ b/app/workers/repository_check/batch_worker.rb
@@ -32,10 +32,10 @@ module RepositoryCheck
# has to sit and wait for this query to finish.
def project_ids
limit = 10_000
- never_checked_projects = Project.where('last_repository_check_at IS NULL AND created_at < ?', 24.hours.ago).
- limit(limit).pluck(:id)
- old_check_projects = Project.where('last_repository_check_at < ?', 1.month.ago).
- reorder('last_repository_check_at ASC').limit(limit).pluck(:id)
+ never_checked_projects = Project.where('last_repository_check_at IS NULL AND created_at < ?', 24.hours.ago)
+ .limit(limit).pluck(:id)
+ old_check_projects = Project.where('last_repository_check_at < ?', 1.month.ago)
+ .reorder('last_repository_check_at ASC').limit(limit).pluck(:id)
never_checked_projects + old_check_projects
end
diff --git a/config/initializers/metrics.rb b/config/initializers/metrics.rb
index e0702e06cc9..2dcaaa09242 100644
--- a/config/initializers/metrics.rb
+++ b/config/initializers/metrics.rb
@@ -147,8 +147,8 @@ if Gitlab::Metrics.enabled?
ActiveRecord::Querying.public_instance_methods(false).map(&:to_s)
)
- Gitlab::Metrics::Instrumentation.
- instrument_class_hierarchy(ActiveRecord::Base) do |klass, method|
+ Gitlab::Metrics::Instrumentation
+ .instrument_class_hierarchy(ActiveRecord::Base) do |klass, method|
# Instrumenting the ApplicationSetting class can lead to an infinite
# loop. Since the data is cached any way we don't really need to
# instrument it.
diff --git a/db/migrate/20161124141322_migrate_process_commit_worker_jobs.rb b/db/migrate/20161124141322_migrate_process_commit_worker_jobs.rb
index 35697aab207..3865f3e3a08 100644
--- a/db/migrate/20161124141322_migrate_process_commit_worker_jobs.rb
+++ b/db/migrate/20161124141322_migrate_process_commit_worker_jobs.rb
@@ -6,9 +6,9 @@ class MigrateProcessCommitWorkerJobs < ActiveRecord::Migration
class Project < ActiveRecord::Base
def self.find_including_path(id)
- select("projects.*, CONCAT(namespaces.path, '/', projects.path) AS path_with_namespace").
- joins('INNER JOIN namespaces ON namespaces.id = projects.namespace_id').
- find_by(id: id)
+ select("projects.*, CONCAT(namespaces.path, '/', projects.path) AS path_with_namespace")
+ .joins('INNER JOIN namespaces ON namespaces.id = projects.namespace_id')
+ .find_by(id: id)
end
def repository_storage_path
diff --git a/db/migrate/20161207231620_fixup_environment_name_uniqueness.rb b/db/migrate/20161207231620_fixup_environment_name_uniqueness.rb
index 57f28e809de..b31f9699f3d 100644
--- a/db/migrate/20161207231620_fixup_environment_name_uniqueness.rb
+++ b/db/migrate/20161207231620_fixup_environment_name_uniqueness.rb
@@ -8,11 +8,11 @@ class FixupEnvironmentNameUniqueness < ActiveRecord::Migration
environments = Arel::Table.new(:environments)
# Get all [project_id, name] pairs that occur more than once
- finder_sql = environments.
- group(environments[:project_id], environments[:name]).
- having(Arel.sql("COUNT(1)").gt(1)).
- project(environments[:project_id], environments[:name]).
- to_sql
+ finder_sql = environments
+ .group(environments[:project_id], environments[:name])
+ .having(Arel.sql("COUNT(1)").gt(1))
+ .project(environments[:project_id], environments[:name])
+ .to_sql
conflicting = connection.exec_query(finder_sql)
@@ -28,12 +28,12 @@ class FixupEnvironmentNameUniqueness < ActiveRecord::Migration
# Rename conflicting environments by appending "-#{id}" to all but the first
def fix_duplicates(project_id, name)
environments = Arel::Table.new(:environments)
- finder_sql = environments.
- where(environments[:project_id].eq(project_id)).
- where(environments[:name].eq(name)).
- order(environments[:id].asc).
- project(environments[:id], environments[:name]).
- to_sql
+ finder_sql = environments
+ .where(environments[:project_id].eq(project_id))
+ .where(environments[:name].eq(name))
+ .order(environments[:id].asc)
+ .project(environments[:id], environments[:name])
+ .to_sql
# Now we have the data for all the conflicting rows
conflicts = connection.exec_query(finder_sql).rows
@@ -41,11 +41,11 @@ class FixupEnvironmentNameUniqueness < ActiveRecord::Migration
conflicts.each do |id, name|
update_sql =
- Arel::UpdateManager.new(ActiveRecord::Base).
- table(environments).
- set(environments[:name] => name + "-" + id.to_s).
- where(environments[:id].eq(id)).
- to_sql
+ Arel::UpdateManager.new(ActiveRecord::Base)
+ .table(environments)
+ .set(environments[:name] => name + "-" + id.to_s)
+ .where(environments[:id].eq(id))
+ .to_sql
connection.exec_update(update_sql, self.class.name, [])
end
diff --git a/db/migrate/20161207231626_add_environment_slug.rb b/db/migrate/20161207231626_add_environment_slug.rb
index aec08dc79f2..1dec96a1299 100644
--- a/db/migrate/20161207231626_add_environment_slug.rb
+++ b/db/migrate/20161207231626_add_environment_slug.rb
@@ -19,10 +19,10 @@ class AddEnvironmentSlug < ActiveRecord::Migration
finder = environments.project(:id, :name)
connection.exec_query(finder.to_sql).rows.each do |id, name|
- updater = Arel::UpdateManager.new(ActiveRecord::Base).
- table(environments).
- set(environments[:slug] => generate_slug(name)).
- where(environments[:id].eq(id))
+ updater = Arel::UpdateManager.new(ActiveRecord::Base)
+ .table(environments)
+ .set(environments[:slug] => generate_slug(name))
+ .where(environments[:id].eq(id))
connection.exec_update(updater.to_sql, self.class.name, [])
end
diff --git a/db/post_migrate/20161109150329_fix_project_records_with_invalid_visibility.rb b/db/post_migrate/20161109150329_fix_project_records_with_invalid_visibility.rb
index df38591a333..823274b08c0 100644
--- a/db/post_migrate/20161109150329_fix_project_records_with_invalid_visibility.rb
+++ b/db/post_migrate/20161109150329_fix_project_records_with_invalid_visibility.rb
@@ -13,13 +13,13 @@ class FixProjectRecordsWithInvalidVisibility < ActiveRecord::Migration
namespaces = Arel::Table.new(:namespaces)
finder_sql =
- projects.
- join(namespaces, Arel::Nodes::InnerJoin).
- on(projects[:namespace_id].eq(namespaces[:id])).
- where(projects[:visibility_level].gt(namespaces[:visibility_level])).
- project(projects[:id], namespaces[:visibility_level]).
- take(BATCH_SIZE).
- to_sql
+ projects
+ .join(namespaces, Arel::Nodes::InnerJoin)
+ .on(projects[:namespace_id].eq(namespaces[:id]))
+ .where(projects[:visibility_level].gt(namespaces[:visibility_level]))
+ .project(projects[:id], namespaces[:visibility_level])
+ .take(BATCH_SIZE)
+ .to_sql
# Update matching rows in batches. Each batch can cause up to 3 UPDATE
# statements, in addition to the SELECT: one per visibility_level
@@ -33,10 +33,10 @@ class FixProjectRecordsWithInvalidVisibility < ActiveRecord::Migration
end
updates.each do |visibility_level, project_ids|
- updater = Arel::UpdateManager.new(ActiveRecord::Base).
- table(projects).
- set(projects[:visibility_level] => visibility_level).
- where(projects[:id].in(project_ids))
+ updater = Arel::UpdateManager.new(ActiveRecord::Base)
+ .table(projects)
+ .set(projects[:visibility_level] => visibility_level)
+ .where(projects[:id].in(project_ids))
ActiveRecord::Base.connection.exec_update(updater.to_sql, self.class.name, [])
end
diff --git a/db/post_migrate/20161221153951_rename_reserved_project_names.rb b/db/post_migrate/20161221153951_rename_reserved_project_names.rb
index 49a6bc884a8..d322844e2fd 100644
--- a/db/post_migrate/20161221153951_rename_reserved_project_names.rb
+++ b/db/post_migrate/20161221153951_rename_reserved_project_names.rb
@@ -79,17 +79,17 @@ class RenameReservedProjectNames < ActiveRecord::Migration
private
def reserved_projects
- Project.unscoped.
- includes(:namespace).
- where('EXISTS (SELECT 1 FROM namespaces WHERE projects.namespace_id = namespaces.id)').
- where('projects.path' => KNOWN_PATHS)
+ Project.unscoped
+ .includes(:namespace)
+ .where('EXISTS (SELECT 1 FROM namespaces WHERE projects.namespace_id = namespaces.id)')
+ .where('projects.path' => KNOWN_PATHS)
end
def route_exists?(full_path)
quoted_path = ActiveRecord::Base.connection.quote_string(full_path)
- ActiveRecord::Base.connection.
- select_all("SELECT id, path FROM routes WHERE path = '#{quoted_path}'").present?
+ ActiveRecord::Base.connection
+ .select_all("SELECT id, path FROM routes WHERE path = '#{quoted_path}'").present?
end
# Adds number to the end of the path that is not taken by other route
diff --git a/db/post_migrate/20170104150317_requeue_pending_delete_projects.rb b/db/post_migrate/20170104150317_requeue_pending_delete_projects.rb
index f399950bd5e..d7be004d47f 100644
--- a/db/post_migrate/20170104150317_requeue_pending_delete_projects.rb
+++ b/db/post_migrate/20170104150317_requeue_pending_delete_projects.rb
@@ -39,11 +39,11 @@ class RequeuePendingDeleteProjects < ActiveRecord::Migration
def find_batch
projects = Arel::Table.new(:projects)
- projects.project(projects[:id]).
- where(projects[:pending_delete].eq(true)).
- where(projects[:namespace_id].not_eq(nil)).
- skip(@offset * BATCH_SIZE).
- take(BATCH_SIZE).
- to_sql
+ projects.project(projects[:id])
+ .where(projects[:pending_delete].eq(true))
+ .where(projects[:namespace_id].not_eq(nil))
+ .skip(@offset * BATCH_SIZE)
+ .take(BATCH_SIZE)
+ .to_sql
end
end
diff --git a/db/post_migrate/20170106142508_fill_authorized_projects.rb b/db/post_migrate/20170106142508_fill_authorized_projects.rb
index 314c8440c8b..0ca20587981 100644
--- a/db/post_migrate/20170106142508_fill_authorized_projects.rb
+++ b/db/post_migrate/20170106142508_fill_authorized_projects.rb
@@ -15,8 +15,8 @@ class FillAuthorizedProjects < ActiveRecord::Migration
disable_ddl_transaction!
def up
- relation = User.select(:id).
- where('authorized_projects_populated IS NOT TRUE')
+ relation = User.select(:id)
+ .where('authorized_projects_populated IS NOT TRUE')
relation.find_in_batches(batch_size: 1_000) do |rows|
args = rows.map { |row| [row.id] }
diff --git a/lib/api/access_requests.rb b/lib/api/access_requests.rb
index 789f45489eb..4d4e442cb49 100644
--- a/lib/api/access_requests.rb
+++ b/lib/api/access_requests.rb
@@ -68,8 +68,8 @@ module API
delete ":id/access_requests/:user_id" do
source = find_source(source_type, params[:id])
- ::Members::DestroyService.new(source, current_user, params).
- execute(:requesters)
+ ::Members::DestroyService.new(source, current_user, params)
+ .execute(:requesters)
end
end
end
diff --git a/lib/api/branches.rb b/lib/api/branches.rb
index c65de90cca2..804fca9b0fb 100644
--- a/lib/api/branches.rb
+++ b/lib/api/branches.rb
@@ -102,8 +102,8 @@ module API
end
post ":id/repository/branches" do
authorize_push_project
- result = CreateBranchService.new(user_project, current_user).
- execute(params[:branch], params[:ref])
+ result = CreateBranchService.new(user_project, current_user)
+ .execute(params[:branch], params[:ref])
if result[:status] == :success
present result[:branch],
@@ -121,8 +121,8 @@ module API
delete ":id/repository/branches/:branch", requirements: { branch: /.+/ } do
authorize_push_project
- result = DeleteBranchService.new(user_project, current_user).
- execute(params[:branch])
+ result = DeleteBranchService.new(user_project, current_user)
+ .execute(params[:branch])
if result[:status] == :success
{
diff --git a/lib/api/entities.rb b/lib/api/entities.rb
index 85aa6932f81..a9429262981 100644
--- a/lib/api/entities.rb
+++ b/lib/api/entities.rb
@@ -451,9 +451,9 @@ module API
expose :tag_push_events, :note_events, :build_events, :pipeline_events
# Expose serialized properties
expose :properties do |service, options|
- field_names = service.fields.
- select { |field| options[:include_passwords] || field[:type] != 'password' }.
- map { |field| field[:name] }
+ field_names = service.fields
+ .select { |field| options[:include_passwords] || field[:type] != 'password' }
+ .map { |field| field[:name] }
service.properties.slice(*field_names)
end
end
diff --git a/lib/api/issues.rb b/lib/api/issues.rb
index 6d30c5d81b1..0515533b850 100644
--- a/lib/api/issues.rb
+++ b/lib/api/issues.rb
@@ -128,9 +128,9 @@ module API
issue_params = declared_params(include_missing: false)
if merge_request_iid = params[:merge_request_for_resolving_discussions]
- issue_params[:merge_request_for_resolving_discussions] = MergeRequestsFinder.new(current_user, project_id: user_project.id).
- execute.
- find_by(iid: merge_request_iid)
+ issue_params[:merge_request_for_resolving_discussions] = MergeRequestsFinder.new(current_user, project_id: user_project.id)
+ .execute
+ .find_by(iid: merge_request_iid)
end
issue = ::Issues::CreateService.new(user_project,
diff --git a/lib/api/merge_requests.rb b/lib/api/merge_requests.rb
index 6a2476424a7..bdd764abfeb 100644
--- a/lib/api/merge_requests.rb
+++ b/lib/api/merge_requests.rb
@@ -193,13 +193,13 @@ module API
}
if params[:merge_when_build_succeeds] && merge_request.head_pipeline && merge_request.head_pipeline.active?
- ::MergeRequests::MergeWhenPipelineSucceedsService.
- new(merge_request.target_project, current_user, merge_params).
- execute(merge_request)
+ ::MergeRequests::MergeWhenPipelineSucceedsService
+ .new(merge_request.target_project, current_user, merge_params)
+ .execute(merge_request)
else
- ::MergeRequests::MergeService.
- new(merge_request.target_project, current_user, merge_params).
- execute(merge_request)
+ ::MergeRequests::MergeService
+ .new(merge_request.target_project, current_user, merge_params)
+ .execute(merge_request)
end
present merge_request, with: Entities::MergeRequest, current_user: current_user, project: user_project
@@ -213,9 +213,9 @@ module API
unauthorized! unless merge_request.can_cancel_merge_when_build_succeeds?(current_user)
- ::MergeRequest::MergeWhenPipelineSucceedsService.
- new(merge_request.target_project, current_user).
- cancel(merge_request)
+ ::MergeRequest::MergeWhenPipelineSucceedsService
+ .new(merge_request.target_project, current_user)
+ .cancel(merge_request)
end
desc 'Get the comments of a merge request' do
diff --git a/lib/api/notes.rb b/lib/api/notes.rb
index f559a7f74a0..dc47aeafb82 100644
--- a/lib/api/notes.rb
+++ b/lib/api/notes.rb
@@ -33,8 +33,8 @@ module API
# paginate() only works with a relation. This could lead to a
# mismatch between the pagination headers info and the actual notes
# array returned, but this is really a edge-case.
- paginate(noteable.notes).
- reject { |n| n.cross_reference_not_visible_for?(current_user) }
+ paginate(noteable.notes)
+ .reject { |n| n.cross_reference_not_visible_for?(current_user) }
present notes, with: Entities::Note
else
not_found!("Notes")
diff --git a/lib/api/pipelines.rb b/lib/api/pipelines.rb
index ffa73696029..f59f7959173 100644
--- a/lib/api/pipelines.rb
+++ b/lib/api/pipelines.rb
@@ -36,8 +36,8 @@ module API
new_pipeline = Ci::CreatePipelineService.new(user_project,
current_user,
- declared_params(include_missing: false)).
- execute(ignore_skip_ci: true, save_on_errors: false)
+ declared_params(include_missing: false))
+ .execute(ignore_skip_ci: true, save_on_errors: false)
if new_pipeline.persisted?
present new_pipeline, with: Entities::Pipeline
else
diff --git a/lib/api/tags.rb b/lib/api/tags.rb
index 86759ab882f..40d37e44db1 100644
--- a/lib/api/tags.rb
+++ b/lib/api/tags.rb
@@ -44,8 +44,8 @@ module API
post ':id/repository/tags' do
authorize_push_project
- result = ::Tags::CreateService.new(user_project, current_user).
- execute(params[:tag_name], params[:ref], params[:message], params[:release_description])
+ result = ::Tags::CreateService.new(user_project, current_user)
+ .execute(params[:tag_name], params[:ref], params[:message], params[:release_description])
if result[:status] == :success
present result[:tag],
@@ -63,8 +63,8 @@ module API
delete ":id/repository/tags/:tag_name", requirements: { tag_name: /.+/ } do
authorize_push_project
- result = ::Tags::DestroyService.new(user_project, current_user).
- execute(params[:tag_name])
+ result = ::Tags::DestroyService.new(user_project, current_user)
+ .execute(params[:tag_name])
if result[:status] == :success
{
@@ -85,8 +85,8 @@ module API
post ':id/repository/tags/:tag_name/release', requirements: { tag_name: /.+/ } do
authorize_push_project
- result = CreateReleaseService.new(user_project, current_user).
- execute(params[:tag_name], params[:description])
+ result = CreateReleaseService.new(user_project, current_user)
+ .execute(params[:tag_name], params[:description])
if result[:status] == :success
present result[:release], with: Entities::Release
@@ -105,8 +105,8 @@ module API
put ':id/repository/tags/:tag_name/release', requirements: { tag_name: /.+/ } do
authorize_push_project
- result = UpdateReleaseService.new(user_project, current_user).
- execute(params[:tag_name], params[:description])
+ result = UpdateReleaseService.new(user_project, current_user)
+ .execute(params[:tag_name], params[:description])
if result[:status] == :success
present result[:release], with: Entities::Release
diff --git a/lib/api/users.rb b/lib/api/users.rb
index 94b2b6653d2..9824f8c2ce6 100644
--- a/lib/api/users.rb
+++ b/lib/api/users.rb
@@ -117,13 +117,13 @@ module API
if user.save
present user, with: Entities::UserPublic
else
- conflict!('Email has already been taken') if User.
- where(email: user.email).
- count > 0
+ conflict!('Email has already been taken') if User
+ .where(email: user.email)
+ .count > 0
- conflict!('Username has already been taken') if User.
- where(username: user.username).
- count > 0
+ conflict!('Username has already been taken') if User
+ .where(username: user.username)
+ .count > 0
render_validation_error!(user)
end
@@ -151,12 +151,12 @@ module API
not_found!('User') unless user
conflict!('Email has already been taken') if params[:email] &&
- User.where(email: params[:email]).
- where.not(id: user.id).count > 0
+ User.where(email: params[:email])
+ .where.not(id: user.id).count > 0
conflict!('Username has already been taken') if params[:username] &&
- User.where(username: params[:username]).
- where.not(id: user.id).count > 0
+ User.where(username: params[:username])
+ .where.not(id: user.id).count > 0
user_params = declared_params(include_missing: false)
identity_attrs = user_params.slice(:provider, :extern_uid)
@@ -354,11 +354,11 @@ module API
user = User.find_by(id: params[:id])
not_found!('User') unless user
- events = user.events.
- merge(ProjectsFinder.new.execute(current_user)).
- references(:project).
- with_associations.
- recent
+ events = user.events
+ .merge(ProjectsFinder.new.execute(current_user))
+ .references(:project)
+ .with_associations
+ .recent
present paginate(events), with: Entities::Event
end
diff --git a/lib/api/v3/issues.rb b/lib/api/v3/issues.rb
index d0af09f0e1e..264ad8d0da5 100644
--- a/lib/api/v3/issues.rb
+++ b/lib/api/v3/issues.rb
@@ -141,9 +141,9 @@ module API
issue_params = declared_params(include_missing: false)
if merge_request_iid = params[:merge_request_for_resolving_discussions]
- issue_params[:merge_request_for_resolving_discussions] = MergeRequestsFinder.new(current_user, project_id: user_project.id).
- execute.
- find_by(iid: merge_request_iid)
+ issue_params[:merge_request_for_resolving_discussions] = MergeRequestsFinder.new(current_user, project_id: user_project.id)
+ .execute
+ .find_by(iid: merge_request_iid)
end
issue = ::Issues::CreateService.new(user_project,
diff --git a/lib/api/v3/merge_requests.rb b/lib/api/v3/merge_requests.rb
index 5a8dacc9c44..129f9d850e9 100644
--- a/lib/api/v3/merge_requests.rb
+++ b/lib/api/v3/merge_requests.rb
@@ -200,13 +200,13 @@ module API
}
if params[:merge_when_build_succeeds] && merge_request.head_pipeline && merge_request.head_pipeline.active?
- ::MergeRequests::MergeWhenPipelineSucceedsService.
- new(merge_request.target_project, current_user, merge_params).
- execute(merge_request)
+ ::MergeRequests::MergeWhenPipelineSucceedsService
+ .new(merge_request.target_project, current_user, merge_params)
+ .execute(merge_request)
else
- ::MergeRequests::MergeService.
- new(merge_request.target_project, current_user, merge_params).
- execute(merge_request)
+ ::MergeRequests::MergeService
+ .new(merge_request.target_project, current_user, merge_params)
+ .execute(merge_request)
end
present merge_request, with: ::API::Entities::MergeRequest, current_user: current_user, project: user_project
@@ -220,9 +220,9 @@ module API
unauthorized! unless merge_request.can_cancel_merge_when_build_succeeds?(current_user)
- ::MergeRequest::MergeWhenPipelineSucceedsService.
- new(merge_request.target_project, current_user).
- cancel(merge_request)
+ ::MergeRequest::MergeWhenPipelineSucceedsService
+ .new(merge_request.target_project, current_user)
+ .cancel(merge_request)
end
desc 'Get the comments of a merge request' do
diff --git a/lib/banzai/pipeline/wiki_pipeline.rb b/lib/banzai/pipeline/wiki_pipeline.rb
index 17b460608d7..c37b8e71cb0 100644
--- a/lib/banzai/pipeline/wiki_pipeline.rb
+++ b/lib/banzai/pipeline/wiki_pipeline.rb
@@ -3,8 +3,8 @@ module Banzai
class WikiPipeline < FullPipeline
def self.filters
@filters ||= begin
- super.insert_after(Filter::TableOfContentsFilter, Filter::GollumTagsFilter).
- insert_before(Filter::TaskListFilter, Filter::WikiLinkFilter)
+ super.insert_after(Filter::TableOfContentsFilter, Filter::GollumTagsFilter)
+ .insert_before(Filter::TaskListFilter, Filter::WikiLinkFilter)
end
end
end
diff --git a/lib/banzai/reference_extractor.rb b/lib/banzai/reference_extractor.rb
index c6426210a92..7e6357f8a00 100644
--- a/lib/banzai/reference_extractor.rb
+++ b/lib/banzai/reference_extractor.rb
@@ -10,8 +10,8 @@ module Banzai
end
def references(type, project, current_user = nil)
- processor = Banzai::ReferenceParser[type].
- new(project, current_user)
+ processor = Banzai::ReferenceParser[type]
+ .new(project, current_user)
processor.process(html_documents)
end
@@ -28,8 +28,8 @@ module Banzai
# text blobs to parse.
return [] if @texts_and_contexts.empty?
- @html_documents ||= Renderer.cache_collection_render(@texts_and_contexts).
- map { |html| Nokogiri::HTML.fragment(html) }
+ @html_documents ||= Renderer.cache_collection_render(@texts_and_contexts)
+ .map { |html| Nokogiri::HTML.fragment(html) }
end
end
end
diff --git a/lib/banzai/reference_parser/issue_parser.rb b/lib/banzai/reference_parser/issue_parser.rb
index 6c20dec5734..0ffaf79d9d8 100644
--- a/lib/banzai/reference_parser/issue_parser.rb
+++ b/lib/banzai/reference_parser/issue_parser.rb
@@ -9,8 +9,8 @@ module Banzai
issues = issues_for_nodes(nodes)
- readable_issues = Ability.
- issues_readable_by_user(issues.values, user).to_set
+ readable_issues = Ability
+ .issues_readable_by_user(issues.values, user).to_set
nodes.select do |node|
readable_issues.include?(issue_for_node(issues, node))
diff --git a/lib/banzai/reference_parser/user_parser.rb b/lib/banzai/reference_parser/user_parser.rb
index 7adaffa19c1..e0125fabcec 100644
--- a/lib/banzai/reference_parser/user_parser.rb
+++ b/lib/banzai/reference_parser/user_parser.rb
@@ -99,8 +99,8 @@ module Banzai
def find_users_for_projects(ids)
return [] if ids.empty?
- collection_objects_for_ids(Project, ids).
- flat_map { |p| p.team.members.to_a }
+ collection_objects_for_ids(Project, ids)
+ .flat_map { |p| p.team.members.to_a }
end
def can_read_reference?(user, ref_project)
diff --git a/lib/ci/charts.rb b/lib/ci/charts.rb
index 3decc3b1a26..6063d6f45e8 100644
--- a/lib/ci/charts.rb
+++ b/lib/ci/charts.rb
@@ -2,10 +2,10 @@ module Ci
module Charts
module DailyInterval
def grouped_count(query)
- query.
- group("DATE(#{Ci::Build.table_name}.created_at)").
- count(:created_at).
- transform_keys { |date| date.strftime(@format) }
+ query
+ .group("DATE(#{Ci::Build.table_name}.created_at)")
+ .count(:created_at)
+ .transform_keys { |date| date.strftime(@format) }
end
def interval_step
@@ -16,14 +16,14 @@ module Ci
module MonthlyInterval
def grouped_count(query)
if Gitlab::Database.postgresql?
- query.
- group("to_char(#{Ci::Build.table_name}.created_at, '01 Month YYYY')").
- count(:created_at).
- transform_keys(&:squish)
+ query
+ .group("to_char(#{Ci::Build.table_name}.created_at, '01 Month YYYY')")
+ .count(:created_at)
+ .transform_keys(&:squish)
else
- query.
- group("DATE_FORMAT(#{Ci::Build.table_name}.created_at, '01 %M %Y')").
- count(:created_at)
+ query
+ .group("DATE_FORMAT(#{Ci::Build.table_name}.created_at, '01 %M %Y')")
+ .count(:created_at)
end
end
@@ -46,8 +46,8 @@ module Ci
end
def collect
- query = project.builds.
- where("? > #{Ci::Build.table_name}.created_at AND #{Ci::Build.table_name}.created_at > ?", @to, @from)
+ query = project.builds
+ .where("? > #{Ci::Build.table_name}.created_at AND #{Ci::Build.table_name}.created_at > ?", @to, @from)
totals_count = grouped_count(query)
success_count = grouped_count(query.success)
diff --git a/lib/ci/gitlab_ci_yaml_processor.rb b/lib/ci/gitlab_ci_yaml_processor.rb
index 04d9756657a..649ee4d018b 100644
--- a/lib/ci/gitlab_ci_yaml_processor.rb
+++ b/lib/ci/gitlab_ci_yaml_processor.rb
@@ -115,8 +115,8 @@ module Ci
end
def yaml_variables(name)
- variables = (@variables || {}).
- merge(job_variables(name))
+ variables = (@variables || {})
+ .merge(job_variables(name))
variables.map do |key, value|
{ key: key.to_s, value: value, public: true }
diff --git a/lib/gitlab/badge/build/status.rb b/lib/gitlab/badge/build/status.rb
index 3c65fd02e4c..b762d85b6e5 100644
--- a/lib/gitlab/badge/build/status.rb
+++ b/lib/gitlab/badge/build/status.rb
@@ -19,9 +19,9 @@ module Gitlab
end
def status
- @project.pipelines.
- where(sha: @sha).
- latest_status(@ref) || 'unknown'
+ @project.pipelines
+ .where(sha: @sha)
+ .latest_status(@ref) || 'unknown'
end
def metadata
diff --git a/lib/gitlab/badge/coverage/report.rb b/lib/gitlab/badge/coverage/report.rb
index 8a6564755ab..9a0482306b7 100644
--- a/lib/gitlab/badge/coverage/report.rb
+++ b/lib/gitlab/badge/coverage/report.rb
@@ -42,9 +42,9 @@ module Gitlab
if @job.blank?
@pipeline.coverage
else
- @pipeline.builds.
- find_by(name: @job).
- try(:coverage)
+ @pipeline.builds
+ .find_by(name: @job)
+ .try(:coverage)
end
end
end
diff --git a/lib/gitlab/bitbucket_import/importer.rb b/lib/gitlab/bitbucket_import/importer.rb
index 03a7981b1db..44323b47dca 100644
--- a/lib/gitlab/bitbucket_import/importer.rb
+++ b/lib/gitlab/bitbucket_import/importer.rb
@@ -48,10 +48,10 @@ module Gitlab
return users[username] if users.key?(username)
- users[username] = User.select(:id).
- joins(:identities).
- find_by("identities.extern_uid = ? AND identities.provider = 'bitbucket'", username).
- try(:id)
+ users[username] = User.select(:id)
+ .joins(:identities)
+ .find_by("identities.extern_uid = ? AND identities.provider = 'bitbucket'", username)
+ .try(:id)
end
def repo
diff --git a/lib/gitlab/checks/matching_merge_request.rb b/lib/gitlab/checks/matching_merge_request.rb
index bd295c25194..849848515da 100644
--- a/lib/gitlab/checks/matching_merge_request.rb
+++ b/lib/gitlab/checks/matching_merge_request.rb
@@ -8,10 +8,10 @@ module Gitlab
end
def match?
- @project.merge_requests.
- with_state(:locked).
- where(in_progress_merge_commit_sha: @newrev, target_branch: @branch_name).
- exists?
+ @project.merge_requests
+ .with_state(:locked)
+ .where(in_progress_merge_commit_sha: @newrev, target_branch: @branch_name)
+ .exists?
end
end
end
diff --git a/lib/gitlab/ci/config/entry/configurable.rb b/lib/gitlab/ci/config/entry/configurable.rb
index deaaf06bbd7..e05aca9881b 100644
--- a/lib/gitlab/ci/config/entry/configurable.rb
+++ b/lib/gitlab/ci/config/entry/configurable.rb
@@ -27,9 +27,9 @@ module Gitlab
return unless valid?
self.class.nodes.each do |key, factory|
- factory.
- value(@config[key]).
- with(key: key, parent: self)
+ factory
+ .value(@config[key])
+ .with(key: key, parent: self)
@entries[key] = factory.create!
end
@@ -49,8 +49,8 @@ module Gitlab
private # rubocop:disable Lint/UselessAccessModifier
def entry(key, entry, metadata)
- factory = Entry::Factory.new(entry).
- with(description: metadata[:description])
+ factory = Entry::Factory.new(entry)
+ .with(description: metadata[:description])
(@nodes ||= {}).merge!(key.to_sym => factory)
end
diff --git a/lib/gitlab/ci/config/entry/global.rb b/lib/gitlab/ci/config/entry/global.rb
index 0a404331225..ac771662b2f 100644
--- a/lib/gitlab/ci/config/entry/global.rb
+++ b/lib/gitlab/ci/config/entry/global.rb
@@ -46,9 +46,9 @@ module Gitlab
private
def compose_jobs!
- factory = Entry::Factory.new(Entry::Jobs).
- value(@config.except(*self.class.nodes.keys)).
- with(key: :jobs, parent: self,
+ factory = Entry::Factory.new(Entry::Jobs)
+ .value(@config.except(*self.class.nodes.keys))
+ .with(key: :jobs, parent: self,
description: 'Jobs definition for this pipeline')
@entries[:jobs] = factory.create!
diff --git a/lib/gitlab/ci/config/entry/jobs.rb b/lib/gitlab/ci/config/entry/jobs.rb
index 7b83f0f1b69..a487a3a06d6 100644
--- a/lib/gitlab/ci/config/entry/jobs.rb
+++ b/lib/gitlab/ci/config/entry/jobs.rb
@@ -31,10 +31,10 @@ module Gitlab
@config.each do |name, config|
node = hidden?(name) ? Entry::Hidden : Entry::Job
- factory = Entry::Factory.new(node).
- value(config || {}).
- metadata(name: name).
- with(key: name, parent: self,
+ factory = Entry::Factory.new(node)
+ .value(config || {})
+ .metadata(name: name)
+ .with(key: name, parent: self,
description: "#{name} job definition.")
@entries[name] = factory.create!
diff --git a/lib/gitlab/ci/pipeline_duration.rb b/lib/gitlab/ci/pipeline_duration.rb
index a210e76acaa..3208cc2bef6 100644
--- a/lib/gitlab/ci/pipeline_duration.rb
+++ b/lib/gitlab/ci/pipeline_duration.rb
@@ -87,8 +87,8 @@ module Gitlab
def from_pipeline(pipeline)
status = %w[success failed running canceled]
- builds = pipeline.builds.latest.
- where(status: status).where.not(started_at: nil).order(:started_at)
+ builds = pipeline.builds.latest
+ .where(status: status).where.not(started_at: nil).order(:started_at)
from_builds(builds)
end
diff --git a/lib/gitlab/ci/status/factory.rb b/lib/gitlab/ci/status/factory.rb
index efe756cc585..15836c699c7 100644
--- a/lib/gitlab/ci/status/factory.rb
+++ b/lib/gitlab/ci/status/factory.rb
@@ -17,10 +17,10 @@ module Gitlab
end
def core_status
- Gitlab::Ci::Status.
- const_get(@status.capitalize).
- new(@subject, @user).
- extend(self.class.common_helpers)
+ Gitlab::Ci::Status
+ .const_get(@status.capitalize)
+ .new(@subject, @user)
+ .extend(self.class.common_helpers)
end
def compound_extended_status
diff --git a/lib/gitlab/ci/trace_reader.rb b/lib/gitlab/ci/trace_reader.rb
index dd6a84d7d1c..1d7ddeb3e0f 100644
--- a/lib/gitlab/ci/trace_reader.rb
+++ b/lib/gitlab/ci/trace_reader.rb
@@ -41,8 +41,8 @@ module Gitlab
chunks.unshift(buf)
end
- chunks.join.lines.last(max_lines).join.
- force_encoding(Encoding.default_external)
+ chunks.join.lines.last(max_lines).join
+ .force_encoding(Encoding.default_external)
end
end
end
diff --git a/lib/gitlab/contributions_calendar.rb b/lib/gitlab/contributions_calendar.rb
index 15992b77680..5d271829f37 100644
--- a/lib/gitlab/contributions_calendar.rb
+++ b/lib/gitlab/contributions_calendar.rb
@@ -16,14 +16,14 @@ module Gitlab
# Can't use Event.contributions here because we need to check 3 different
# project_features for the (currently) 3 different contribution types
date_from = 1.year.ago
- repo_events = event_counts(date_from, :repository).
- having(action: Event::PUSHED)
- issue_events = event_counts(date_from, :issues).
- having(action: [Event::CREATED, Event::CLOSED], target_type: "Issue")
- mr_events = event_counts(date_from, :merge_requests).
- having(action: [Event::MERGED, Event::CREATED, Event::CLOSED], target_type: "MergeRequest")
- note_events = event_counts(date_from, :merge_requests).
- having(action: [Event::COMMENTED], target_type: "Note")
+ repo_events = event_counts(date_from, :repository)
+ .having(action: Event::PUSHED)
+ issue_events = event_counts(date_from, :issues)
+ .having(action: [Event::CREATED, Event::CLOSED], target_type: "Issue")
+ mr_events = event_counts(date_from, :merge_requests)
+ .having(action: [Event::MERGED, Event::CREATED, Event::CLOSED], target_type: "MergeRequest")
+ note_events = event_counts(date_from, :merge_requests)
+ .having(action: [Event::COMMENTED], target_type: "Note")
union = Gitlab::SQL::Union.new([repo_events, issue_events, mr_events, note_events])
events = Event.find_by_sql(union.to_sql).map(&:attributes)
@@ -34,9 +34,9 @@ module Gitlab
end
def events_by_date(date)
- events = Event.contributions.where(author_id: contributor.id).
- where(created_at: date.beginning_of_day..date.end_of_day).
- where(project_id: projects)
+ events = Event.contributions.where(author_id: contributor.id)
+ .where(created_at: date.beginning_of_day..date.end_of_day)
+ .where(project_id: projects)
# Use visible_to_user? instead of the complicated logic in activity_dates
# because we're only viewing the events for a single day.
@@ -60,20 +60,20 @@ module Gitlab
# use IN(project_ids...) instead. It's the intersection of two users so
# the list will be (relatively) short
@contributed_project_ids ||= projects.uniq.pluck(:id)
- authed_projects = Project.where(id: @contributed_project_ids).
- with_feature_available_for_user(feature, current_user).
- reorder(nil).
- select(:id)
+ authed_projects = Project.where(id: @contributed_project_ids)
+ .with_feature_available_for_user(feature, current_user)
+ .reorder(nil)
+ .select(:id)
- conditions = t[:created_at].gteq(date_from.beginning_of_day).
- and(t[:created_at].lteq(Date.today.end_of_day)).
- and(t[:author_id].eq(contributor.id))
+ conditions = t[:created_at].gteq(date_from.beginning_of_day)
+ .and(t[:created_at].lteq(Date.today.end_of_day))
+ .and(t[:author_id].eq(contributor.id))
- Event.reorder(nil).
- select(t[:project_id], t[:target_type], t[:action], 'date(created_at) AS date', 'count(id) as total_amount').
- group(t[:project_id], t[:target_type], t[:action], 'date(created_at)').
- where(conditions).
- having(t[:project_id].in(Arel::Nodes::SqlLiteral.new(authed_projects.to_sql)))
+ Event.reorder(nil)
+ .select(t[:project_id], t[:target_type], t[:action], 'date(created_at) AS date', 'count(id) as total_amount')
+ .group(t[:project_id], t[:target_type], t[:action], 'date(created_at)')
+ .where(conditions)
+ .having(t[:project_id].in(Arel::Nodes::SqlLiteral.new(authed_projects.to_sql)))
end
end
end
diff --git a/lib/gitlab/cycle_analytics/base_query.rb b/lib/gitlab/cycle_analytics/base_query.rb
index d560dca45c8..58729d3ced8 100644
--- a/lib/gitlab/cycle_analytics/base_query.rb
+++ b/lib/gitlab/cycle_analytics/base_query.rb
@@ -12,17 +12,17 @@ module Gitlab
end
def stage_query
- query = mr_closing_issues_table.join(issue_table).on(issue_table[:id].eq(mr_closing_issues_table[:issue_id])).
- join(issue_metrics_table).on(issue_table[:id].eq(issue_metrics_table[:issue_id])).
- where(issue_table[:project_id].eq(@project.id)).
- where(issue_table[:deleted_at].eq(nil)).
- where(issue_table[:created_at].gteq(@options[:from]))
+ query = mr_closing_issues_table.join(issue_table).on(issue_table[:id].eq(mr_closing_issues_table[:issue_id]))
+ .join(issue_metrics_table).on(issue_table[:id].eq(issue_metrics_table[:issue_id]))
+ .where(issue_table[:project_id].eq(@project.id))
+ .where(issue_table[:deleted_at].eq(nil))
+ .where(issue_table[:created_at].gteq(@options[:from]))
# Load merge_requests
- query = query.join(mr_table, Arel::Nodes::OuterJoin).
- on(mr_table[:id].eq(mr_closing_issues_table[:merge_request_id])).
- join(mr_metrics_table).
- on(mr_table[:id].eq(mr_metrics_table[:merge_request_id]))
+ query = query.join(mr_table, Arel::Nodes::OuterJoin)
+ .on(mr_table[:id].eq(mr_closing_issues_table[:merge_request_id]))
+ .join(mr_metrics_table)
+ .on(mr_table[:id].eq(mr_metrics_table[:merge_request_id]))
query
end
diff --git a/lib/gitlab/database/median.rb b/lib/gitlab/database/median.rb
index e46c551098d..4e4ddf32754 100644
--- a/lib/gitlab/database/median.rb
+++ b/lib/gitlab/database/median.rb
@@ -29,10 +29,10 @@ module Gitlab
end
def mysql_median_datetime_sql(arel_table, query_so_far, column_sym)
- query = arel_table.
- from(arel_table.project(Arel.sql('*')).order(arel_table[column_sym]).as(arel_table.table_name)).
- project(average([arel_table[column_sym]], 'median')).
- where(
+ query = arel_table
+ .from(arel_table.project(Arel.sql('*')).order(arel_table[column_sym]).as(arel_table.table_name))
+ .project(average([arel_table[column_sym]], 'median'))
+ .where(
Arel::Nodes::Between.new(
Arel.sql("(select @row_id := @row_id + 1)"),
Arel::Nodes::And.new(
@@ -67,8 +67,8 @@ module Gitlab
cte_table = Arel::Table.new("ordered_records")
cte = Arel::Nodes::As.new(
cte_table,
- arel_table.
- project(
+ arel_table
+ .project(
arel_table[column_sym].as(column_sym.to_s),
Arel::Nodes::Over.new(Arel::Nodes::NamedFunction.new("row_number", []),
Arel::Nodes::Window.new.order(arel_table[column_sym])).as('row_id'),
@@ -79,8 +79,8 @@ module Gitlab
# From the CTE, select either the middle row or the middle two rows (this is accomplished
# by 'where cte.row_id between cte.ct / 2.0 AND cte.ct / 2.0 + 1'). Find the average of the
# selected rows, and this is the median value.
- cte_table.project(average([extract_epoch(cte_table[column_sym])], "median")).
- where(
+ cte_table.project(average([extract_epoch(cte_table[column_sym])], "median"))
+ .where(
Arel::Nodes::Between.new(
cte_table[:row_id],
Arel::Nodes::And.new(
@@ -88,9 +88,9 @@ module Gitlab
(cte_table[:ct] / Arel.sql('2.0') + 1)]
)
)
- ).
- with(query_so_far, cte).
- to_sql
+ )
+ .with(query_so_far, cte)
+ .to_sql
end
private
diff --git a/lib/gitlab/database/migration_helpers.rb b/lib/gitlab/database/migration_helpers.rb
index fc445ab9483..0c7c77f52e3 100644
--- a/lib/gitlab/database/migration_helpers.rb
+++ b/lib/gitlab/database/migration_helpers.rb
@@ -140,19 +140,19 @@ module Gitlab
start_id = exec_query(start_arel.to_sql).to_hash.first['id'].to_i
loop do
- stop_arel = table.project(table[:id]).
- where(table[:id].gteq(start_id)).
- order(table[:id].asc).
- take(1).
- skip(batch_size)
+ stop_arel = table.project(table[:id])
+ .where(table[:id].gteq(start_id))
+ .order(table[:id].asc)
+ .take(1)
+ .skip(batch_size)
stop_arel = yield table, stop_arel if block_given?
stop_row = exec_query(stop_arel.to_sql).to_hash.first
- update_arel = Arel::UpdateManager.new(ActiveRecord::Base).
- table(table).
- set([[table[column], value]]).
- where(table[:id].gteq(start_id))
+ update_arel = Arel::UpdateManager.new(ActiveRecord::Base)
+ .table(table)
+ .set([[table[column], value]])
+ .where(table[:id].gteq(start_id))
if stop_row
stop_id = stop_row['id'].to_i
diff --git a/lib/gitlab/downtime_check.rb b/lib/gitlab/downtime_check.rb
index ab9537ed7d7..941244694e2 100644
--- a/lib/gitlab/downtime_check.rb
+++ b/lib/gitlab/downtime_check.rb
@@ -50,8 +50,8 @@ module Gitlab
# Returns the class for the given migration file path.
def class_for_migration_file(path)
- File.basename(path, File.extname(path)).split('_', 2).last.camelize.
- constantize
+ File.basename(path, File.extname(path)).split('_', 2).last.camelize
+ .constantize
end
# Returns true if the given migration can be performed without downtime.
diff --git a/lib/gitlab/git/encoding_helper.rb b/lib/gitlab/git/encoding_helper.rb
index 874fd8fe6e2..e57d228e688 100644
--- a/lib/gitlab/git/encoding_helper.rb
+++ b/lib/gitlab/git/encoding_helper.rb
@@ -49,9 +49,9 @@ module Gitlab
private
def clean(message)
- message.encode("UTF-16BE", undef: :replace, invalid: :replace, replace: "").
- encode("UTF-8").
- gsub("\0".encode("UTF-8"), "")
+ message.encode("UTF-16BE", undef: :replace, invalid: :replace, replace: "")
+ .encode("UTF-8")
+ .gsub("\0".encode("UTF-8"), "")
end
end
end
diff --git a/lib/gitlab/github_import/importer.rb b/lib/gitlab/github_import/importer.rb
index a160869541a..dc73cad93a5 100644
--- a/lib/gitlab/github_import/importer.rb
+++ b/lib/gitlab/github_import/importer.rb
@@ -178,9 +178,9 @@ module Gitlab
def apply_labels(issuable, raw)
return unless raw.labels.count > 0
- label_ids = raw.labels.
- map { |attrs| @labels[attrs.name] }.
- compact
+ label_ids = raw.labels
+ .map { |attrs| @labels[attrs.name] }
+ .compact
issuable.update_attribute(:label_ids, label_ids)
end
diff --git a/lib/gitlab/github_import/user_formatter.rb b/lib/gitlab/github_import/user_formatter.rb
index 7f3bf0052a7..04c2964da20 100644
--- a/lib/gitlab/github_import/user_formatter.rb
+++ b/lib/gitlab/github_import/user_formatter.rb
@@ -25,8 +25,8 @@ module Gitlab
def find_by_email
return nil unless email
- User.find_by_any_email(email).
- try(:id)
+ User.find_by_any_email(email)
+ .try(:id)
end
def find_by_external_uid
@@ -34,11 +34,11 @@ module Gitlab
identities = ::Identity.arel_table
- User.select(:id).
- joins(:identities).where(identities[:provider].eq(:github).
- and(identities[:extern_uid].eq(id))).
- first.
- try(:id)
+ User.select(:id)
+ .joins(:identities).where(identities[:provider].eq(:github)
+ .and(identities[:extern_uid].eq(id)))
+ .first
+ .try(:id)
end
end
end
diff --git a/lib/gitlab/highlight.rb b/lib/gitlab/highlight.rb
index 9360afedfcb..bfc57544485 100644
--- a/lib/gitlab/highlight.rb
+++ b/lib/gitlab/highlight.rb
@@ -1,8 +1,8 @@
module Gitlab
class Highlight
def self.highlight(blob_name, blob_content, repository: nil, plain: false)
- new(blob_name, blob_content, repository: repository).
- highlight(blob_content, continue: false, plain: plain)
+ new(blob_name, blob_content, repository: repository)
+ .highlight(blob_content, continue: false, plain: plain)
end
def self.highlight_lines(repository, ref, file_name)
diff --git a/lib/gitlab/ldap/user.rb b/lib/gitlab/ldap/user.rb
index b84c81f1a6c..8bf32f9e43f 100644
--- a/lib/gitlab/ldap/user.rb
+++ b/lib/gitlab/ldap/user.rb
@@ -12,9 +12,9 @@ module Gitlab
class << self
def find_by_uid_and_provider(uid, provider)
# LDAP distinguished name is case-insensitive
- identity = ::Identity.
- where(provider: provider).
- iwhere(extern_uid: uid).last
+ identity = ::Identity
+ .where(provider: provider)
+ .iwhere(extern_uid: uid).last
identity && identity.user
end
end
diff --git a/lib/gitlab/metrics.rb b/lib/gitlab/metrics.rb
index 857e0abf710..c5b746a83a6 100644
--- a/lib/gitlab/metrics.rb
+++ b/lib/gitlab/metrics.rb
@@ -145,8 +145,8 @@ module Gitlab
host = settings[:host]
port = settings[:port]
- InfluxDB::Client.
- new(udp: { host: host, port: port })
+ InfluxDB::Client
+ .new(udp: { host: host, port: port })
end
end
diff --git a/lib/gitlab/metrics/system.rb b/lib/gitlab/metrics/system.rb
index 3aaebb3e9c3..aba3e0df382 100644
--- a/lib/gitlab/metrics/system.rb
+++ b/lib/gitlab/metrics/system.rb
@@ -34,13 +34,13 @@ module Gitlab
# THREAD_CPUTIME is not supported on OS X
if Process.const_defined?(:CLOCK_THREAD_CPUTIME_ID)
def self.cpu_time
- Process.
- clock_gettime(Process::CLOCK_THREAD_CPUTIME_ID, :millisecond)
+ Process
+ .clock_gettime(Process::CLOCK_THREAD_CPUTIME_ID, :millisecond)
end
else
def self.cpu_time
- Process.
- clock_gettime(Process::CLOCK_PROCESS_CPUTIME_ID, :millisecond)
+ Process
+ .clock_gettime(Process::CLOCK_PROCESS_CPUTIME_ID, :millisecond)
end
end
diff --git a/lib/gitlab/other_markup.rb b/lib/gitlab/other_markup.rb
index e67acf28c94..7b0e9e4a7b4 100644
--- a/lib/gitlab/other_markup.rb
+++ b/lib/gitlab/other_markup.rb
@@ -12,8 +12,8 @@ module Gitlab
# :ref
#
def self.render(file_name, input, context)
- html = GitHub::Markup.render(file_name, input).
- force_encoding(input.encoding)
+ html = GitHub::Markup.render(file_name, input)
+ .force_encoding(input.encoding)
html = Banzai.post_process(html, context)
diff --git a/lib/gitlab/shell.rb b/lib/gitlab/shell.rb
index 7374d2bc8b8..71e798424a5 100644
--- a/lib/gitlab/shell.rb
+++ b/lib/gitlab/shell.rb
@@ -30,8 +30,8 @@ module Gitlab
end
def version_required
- @version_required ||= File.read(Rails.root.
- join('GITLAB_SHELL_VERSION')).strip
+ @version_required ||= File.read(Rails.root
+ .join('GITLAB_SHELL_VERSION')).strip
end
def strip_key(key)
diff --git a/lib/gitlab/sherlock/line_profiler.rb b/lib/gitlab/sherlock/line_profiler.rb
index aa1468bff6b..b5f9d040047 100644
--- a/lib/gitlab/sherlock/line_profiler.rb
+++ b/lib/gitlab/sherlock/line_profiler.rb
@@ -77,8 +77,8 @@ module Gitlab
line_samples << LineSample.new(duration, events)
end
- samples << FileSample.
- new(file, line_samples, total_duration, total_events)
+ samples << FileSample
+ .new(file, line_samples, total_duration, total_events)
end
samples
diff --git a/lib/gitlab/sherlock/query.rb b/lib/gitlab/sherlock/query.rb
index 99e56e923eb..948bf5e6528 100644
--- a/lib/gitlab/sherlock/query.rb
+++ b/lib/gitlab/sherlock/query.rb
@@ -105,10 +105,10 @@ module Gitlab
end
def format_sql(query)
- query.each_line.
- map { |line| line.strip }.
- join("\n").
- gsub(PREFIX_NEWLINE) { "\n#{$1} " }
+ query.each_line
+ .map { |line| line.strip }
+ .join("\n")
+ .gsub(PREFIX_NEWLINE) { "\n#{$1} " }
end
end
end
diff --git a/rubocop/cop/gem_fetcher.rb b/rubocop/cop/gem_fetcher.rb
index 6a951f5f91a..e157d8e0791 100644
--- a/rubocop/cop/gem_fetcher.rb
+++ b/rubocop/cop/gem_fetcher.rb
@@ -25,12 +25,12 @@ module RuboCop
private
def gemfile?(node)
- node.
- location.
- expression.
- source_buffer.
- name.
- end_with?("Gemfile")
+ node
+ .location
+ .expression
+ .source_buffer
+ .name
+ .end_with?("Gemfile")
end
end
end
diff --git a/rubocop/migration_helpers.rb b/rubocop/migration_helpers.rb
index 3160a784a04..35f1868fcc0 100644
--- a/rubocop/migration_helpers.rb
+++ b/rubocop/migration_helpers.rb
@@ -3,8 +3,8 @@ module RuboCop
module MigrationHelpers
# Returns true if the given node originated from the db/migrate directory.
def in_migration?(node)
- File.dirname(node.location.expression.source_buffer.name).
- end_with?('db/migrate')
+ File.dirname(node.location.expression.source_buffer.name)
+ .end_with?('db/migrate')
end
end
end
diff --git a/spec/controllers/admin/users_controller_spec.rb b/spec/controllers/admin/users_controller_spec.rb
index 2ab2ca1b667..03f46f82874 100644
--- a/spec/controllers/admin/users_controller_spec.rb
+++ b/spec/controllers/admin/users_controller_spec.rb
@@ -105,8 +105,8 @@ describe Admin::UsersController do
it 'displays an alert' do
go
- expect(flash[:notice]).
- to eq 'Two-factor Authentication has been disabled for this user'
+ expect(flash[:notice])
+ .to eq 'Two-factor Authentication has been disabled for this user'
end
def go
diff --git a/spec/controllers/blob_controller_spec.rb b/spec/controllers/blob_controller_spec.rb
index 2fcb4a6a528..45fbe09c9f7 100644
--- a/spec/controllers/blob_controller_spec.rb
+++ b/spec/controllers/blob_controller_spec.rb
@@ -59,8 +59,8 @@ describe Projects::BlobController do
context 'redirect to tree' do
let(:id) { 'markdown/doc' }
it 'redirects' do
- expect(subject).
- to redirect_to("/#{project.path_with_namespace}/tree/markdown/doc")
+ expect(subject)
+ .to redirect_to("/#{project.path_with_namespace}/tree/markdown/doc")
end
end
end
diff --git a/spec/controllers/ci/projects_controller_spec.rb b/spec/controllers/ci/projects_controller_spec.rb
index 3cd955dc9d4..86f01f437a2 100644
--- a/spec/controllers/ci/projects_controller_spec.rb
+++ b/spec/controllers/ci/projects_controller_spec.rb
@@ -33,8 +33,8 @@ describe Ci::ProjectsController do
shared_examples 'badge provider' do
it 'shows badge' do
expect(response.status).to eq 200
- expect(response.headers).
- to include('Content-Type' => 'image/svg+xml')
+ expect(response.headers)
+ .to include('Content-Type' => 'image/svg+xml')
end
end
diff --git a/spec/controllers/import/bitbucket_controller_spec.rb b/spec/controllers/import/bitbucket_controller_spec.rb
index fa4cc0ebbe0..66b45cf33c1 100644
--- a/spec/controllers/import/bitbucket_controller_spec.rb
+++ b/spec/controllers/import/bitbucket_controller_spec.rb
@@ -31,8 +31,8 @@ describe Import::BitbucketController do
expires_at: expires_at,
expires_in: expires_in,
refresh_token: refresh_token)
- allow_any_instance_of(OAuth2::Client).
- to receive(:get_token).and_return(access_token)
+ allow_any_instance_of(OAuth2::Client)
+ .to receive(:get_token).and_return(access_token)
stub_omniauth_provider('bitbucket')
get :callback
@@ -93,9 +93,9 @@ describe Import::BitbucketController do
context "when the repository owner is the Bitbucket user" do
context "when the Bitbucket user and GitLab user's usernames match" do
it "takes the current user's namespace" do
- expect(Gitlab::BitbucketImport::ProjectCreator).
- to receive(:new).with(bitbucket_repo, bitbucket_repo.name, user.namespace, user, access_params).
- and_return(double(execute: true))
+ expect(Gitlab::BitbucketImport::ProjectCreator)
+ .to receive(:new).with(bitbucket_repo, bitbucket_repo.name, user.namespace, user, access_params)
+ .and_return(double(execute: true))
post :create, format: :js
end
@@ -105,9 +105,9 @@ describe Import::BitbucketController do
let(:bitbucket_username) { "someone_else" }
it "takes the current user's namespace" do
- expect(Gitlab::BitbucketImport::ProjectCreator).
- to receive(:new).with(bitbucket_repo, bitbucket_repo.name, user.namespace, user, access_params).
- and_return(double(execute: true))
+ expect(Gitlab::BitbucketImport::ProjectCreator)
+ .to receive(:new).with(bitbucket_repo, bitbucket_repo.name, user.namespace, user, access_params)
+ .and_return(double(execute: true))
post :create, format: :js
end
@@ -126,9 +126,9 @@ describe Import::BitbucketController do
context "when the namespace is owned by the GitLab user" do
it "takes the existing namespace" do
- expect(Gitlab::BitbucketImport::ProjectCreator).
- to receive(:new).with(bitbucket_repo, bitbucket_repo.name, existing_namespace, user, access_params).
- and_return(double(execute: true))
+ expect(Gitlab::BitbucketImport::ProjectCreator)
+ .to receive(:new).with(bitbucket_repo, bitbucket_repo.name, existing_namespace, user, access_params)
+ .and_return(double(execute: true))
post :create, format: :js
end
@@ -141,8 +141,8 @@ describe Import::BitbucketController do
end
it "doesn't create a project" do
- expect(Gitlab::BitbucketImport::ProjectCreator).
- not_to receive(:new)
+ expect(Gitlab::BitbucketImport::ProjectCreator)
+ .not_to receive(:new)
post :create, format: :js
end
@@ -152,16 +152,16 @@ describe Import::BitbucketController do
context "when a namespace with the Bitbucket user's username doesn't exist" do
context "when current user can create namespaces" do
it "creates the namespace" do
- expect(Gitlab::BitbucketImport::ProjectCreator).
- to receive(:new).and_return(double(execute: true))
+ expect(Gitlab::BitbucketImport::ProjectCreator)
+ .to receive(:new).and_return(double(execute: true))
expect { post :create, format: :js }.to change(Namespace, :count).by(1)
end
it "takes the new namespace" do
- expect(Gitlab::BitbucketImport::ProjectCreator).
- to receive(:new).with(bitbucket_repo, bitbucket_repo.name, an_instance_of(Group), user, access_params).
- and_return(double(execute: true))
+ expect(Gitlab::BitbucketImport::ProjectCreator)
+ .to receive(:new).with(bitbucket_repo, bitbucket_repo.name, an_instance_of(Group), user, access_params)
+ .and_return(double(execute: true))
post :create, format: :js
end
@@ -173,16 +173,16 @@ describe Import::BitbucketController do
end
it "doesn't create the namespace" do
- expect(Gitlab::BitbucketImport::ProjectCreator).
- to receive(:new).and_return(double(execute: true))
+ expect(Gitlab::BitbucketImport::ProjectCreator)
+ .to receive(:new).and_return(double(execute: true))
expect { post :create, format: :js }.not_to change(Namespace, :count)
end
it "takes the current user's namespace" do
- expect(Gitlab::BitbucketImport::ProjectCreator).
- to receive(:new).with(bitbucket_repo, bitbucket_repo.name, user.namespace, user, access_params).
- and_return(double(execute: true))
+ expect(Gitlab::BitbucketImport::ProjectCreator)
+ .to receive(:new).with(bitbucket_repo, bitbucket_repo.name, user.namespace, user, access_params)
+ .and_return(double(execute: true))
post :create, format: :js
end
diff --git a/spec/controllers/import/github_controller_spec.rb b/spec/controllers/import/github_controller_spec.rb
index 95696e14b6c..45c3fa075ef 100644
--- a/spec/controllers/import/github_controller_spec.rb
+++ b/spec/controllers/import/github_controller_spec.rb
@@ -21,10 +21,10 @@ describe Import::GithubController do
describe "GET callback" do
it "updates access token" do
token = "asdasd12345"
- allow_any_instance_of(Gitlab::GithubImport::Client).
- to receive(:get_token).and_return(token)
- allow_any_instance_of(Gitlab::GithubImport::Client).
- to receive(:github_options).and_return({})
+ allow_any_instance_of(Gitlab::GithubImport::Client)
+ .to receive(:get_token).and_return(token)
+ allow_any_instance_of(Gitlab::GithubImport::Client)
+ .to receive(:github_options).and_return({})
stub_omniauth_provider('github')
get :callback
diff --git a/spec/controllers/import/gitlab_controller_spec.rb b/spec/controllers/import/gitlab_controller_spec.rb
index 3f73ea000ae..3ef1bbaa9b7 100644
--- a/spec/controllers/import/gitlab_controller_spec.rb
+++ b/spec/controllers/import/gitlab_controller_spec.rb
@@ -18,8 +18,8 @@ describe Import::GitlabController do
describe "GET callback" do
it "updates access token" do
- allow_any_instance_of(Gitlab::GitlabImport::Client).
- to receive(:get_token).and_return(token)
+ allow_any_instance_of(Gitlab::GitlabImport::Client)
+ .to receive(:get_token).and_return(token)
stub_omniauth_provider('gitlab')
get :callback
@@ -78,9 +78,9 @@ describe Import::GitlabController do
context "when the repository owner is the GitLab.com user" do
context "when the GitLab.com user and GitLab server user's usernames match" do
it "takes the current user's namespace" do
- expect(Gitlab::GitlabImport::ProjectCreator).
- to receive(:new).with(gitlab_repo, user.namespace, user, access_params).
- and_return(double(execute: true))
+ expect(Gitlab::GitlabImport::ProjectCreator)
+ .to receive(:new).with(gitlab_repo, user.namespace, user, access_params)
+ .and_return(double(execute: true))
post :create, format: :js
end
@@ -90,9 +90,9 @@ describe Import::GitlabController do
let(:gitlab_username) { "someone_else" }
it "takes the current user's namespace" do
- expect(Gitlab::GitlabImport::ProjectCreator).
- to receive(:new).with(gitlab_repo, user.namespace, user, access_params).
- and_return(double(execute: true))
+ expect(Gitlab::GitlabImport::ProjectCreator)
+ .to receive(:new).with(gitlab_repo, user.namespace, user, access_params)
+ .and_return(double(execute: true))
post :create, format: :js
end
@@ -112,9 +112,9 @@ describe Import::GitlabController do
context "when the namespace is owned by the GitLab server user" do
it "takes the existing namespace" do
- expect(Gitlab::GitlabImport::ProjectCreator).
- to receive(:new).with(gitlab_repo, existing_namespace, user, access_params).
- and_return(double(execute: true))
+ expect(Gitlab::GitlabImport::ProjectCreator)
+ .to receive(:new).with(gitlab_repo, existing_namespace, user, access_params)
+ .and_return(double(execute: true))
post :create, format: :js
end
@@ -127,8 +127,8 @@ describe Import::GitlabController do
end
it "doesn't create a project" do
- expect(Gitlab::GitlabImport::ProjectCreator).
- not_to receive(:new)
+ expect(Gitlab::GitlabImport::ProjectCreator)
+ .not_to receive(:new)
post :create, format: :js
end
@@ -138,16 +138,16 @@ describe Import::GitlabController do
context "when a namespace with the GitLab.com user's username doesn't exist" do
context "when current user can create namespaces" do
it "creates the namespace" do
- expect(Gitlab::GitlabImport::ProjectCreator).
- to receive(:new).and_return(double(execute: true))
+ expect(Gitlab::GitlabImport::ProjectCreator)
+ .to receive(:new).and_return(double(execute: true))
expect { post :create, format: :js }.to change(Namespace, :count).by(1)
end
it "takes the new namespace" do
- expect(Gitlab::GitlabImport::ProjectCreator).
- to receive(:new).with(gitlab_repo, an_instance_of(Group), user, access_params).
- and_return(double(execute: true))
+ expect(Gitlab::GitlabImport::ProjectCreator)
+ .to receive(:new).with(gitlab_repo, an_instance_of(Group), user, access_params)
+ .and_return(double(execute: true))
post :create, format: :js
end
@@ -159,16 +159,16 @@ describe Import::GitlabController do
end
it "doesn't create the namespace" do
- expect(Gitlab::GitlabImport::ProjectCreator).
- to receive(:new).and_return(double(execute: true))
+ expect(Gitlab::GitlabImport::ProjectCreator)
+ .to receive(:new).and_return(double(execute: true))
expect { post :create, format: :js }.not_to change(Namespace, :count)
end
it "takes the current user's namespace" do
- expect(Gitlab::GitlabImport::ProjectCreator).
- to receive(:new).with(gitlab_repo, user.namespace, user, access_params).
- and_return(double(execute: true))
+ expect(Gitlab::GitlabImport::ProjectCreator)
+ .to receive(:new).with(gitlab_repo, user.namespace, user, access_params)
+ .and_return(double(execute: true))
post :create, format: :js
end
diff --git a/spec/controllers/projects/branches_controller_spec.rb b/spec/controllers/projects/branches_controller_spec.rb
index 9de03876755..6df654087dc 100644
--- a/spec/controllers/projects/branches_controller_spec.rb
+++ b/spec/controllers/projects/branches_controller_spec.rb
@@ -32,8 +32,8 @@ describe Projects::BranchesController do
let(:branch) { "merge_branch" }
let(:ref) { "master" }
it 'redirects' do
- expect(subject).
- to redirect_to("/#{project.path_with_namespace}/tree/merge_branch")
+ expect(subject)
+ .to redirect_to("/#{project.path_with_namespace}/tree/merge_branch")
end
end
@@ -41,8 +41,8 @@ describe Projects::BranchesController do
let(:branch) { "" }
let(:ref) { "master" }
it 'redirects' do
- expect(subject).
- to redirect_to("/#{project.path_with_namespace}/tree/alert('merge');")
+ expect(subject)
+ .to redirect_to("/#{project.path_with_namespace}/tree/alert('merge');")
end
end
@@ -81,8 +81,8 @@ describe Projects::BranchesController do
branch_name: branch,
issue_iid: issue.iid
- expect(subject).
- to redirect_to("/#{project.path_with_namespace}/tree/1-feature-branch")
+ expect(subject)
+ .to redirect_to("/#{project.path_with_namespace}/tree/1-feature-branch")
end
it 'posts a system note' do
diff --git a/spec/controllers/projects/commit_controller_spec.rb b/spec/controllers/projects/commit_controller_spec.rb
index ebd2d0e092b..1b5f6c4b43a 100644
--- a/spec/controllers/projects/commit_controller_spec.rb
+++ b/spec/controllers/projects/commit_controller_spec.rb
@@ -66,8 +66,8 @@ describe Projects::CommitController do
end
it "does not escape Html" do
- allow_any_instance_of(Commit).to receive(:"to_#{format}").
- and_return('HTML entities &<>" ')
+ allow_any_instance_of(Commit).to receive(:"to_#{format}")
+ .and_return('HTML entities &<>" ')
go(id: commit.id, format: format)
diff --git a/spec/controllers/projects/environments_controller_spec.rb b/spec/controllers/projects/environments_controller_spec.rb
index 84d119f1867..72a13d77a85 100644
--- a/spec/controllers/projects/environments_controller_spec.rb
+++ b/spec/controllers/projects/environments_controller_spec.rb
@@ -150,14 +150,14 @@ describe Projects::EnvironmentsController do
context 'and valid id' do
it 'returns the first terminal for the environment' do
- expect_any_instance_of(Environment).
- to receive(:terminals).
- and_return([:fake_terminal])
+ expect_any_instance_of(Environment)
+ .to receive(:terminals)
+ .and_return([:fake_terminal])
- expect(Gitlab::Workhorse).
- to receive(:terminal_websocket).
- with(:fake_terminal).
- and_return(workhorse: :response)
+ expect(Gitlab::Workhorse)
+ .to receive(:terminal_websocket)
+ .with(:fake_terminal)
+ .and_return(workhorse: :response)
get :terminal_websocket_authorize, environment_params
diff --git a/spec/controllers/projects/issues_controller_spec.rb b/spec/controllers/projects/issues_controller_spec.rb
index 7871b6a9e10..85ad883534a 100644
--- a/spec/controllers/projects/issues_controller_spec.rb
+++ b/spec/controllers/projects/issues_controller_spec.rb
@@ -226,8 +226,8 @@ describe Projects::IssuesController do
it 'redirect to issue page' do
update_verified_issue
- expect(response).
- to redirect_to(namespace_project_issue_path(project.namespace, project, issue))
+ expect(response)
+ .to redirect_to(namespace_project_issue_path(project.namespace, project, issue))
end
it 'accepts an issue after recaptcha is verified' do
@@ -241,8 +241,8 @@ describe Projects::IssuesController do
it 'does not mark spam log as recaptcha_verified when it does not belong to current_user' do
spam_log = create(:spam_log)
- expect { update_issue(spam_log_id: spam_log.id, recaptcha_verification: true) }.
- not_to change { SpamLog.last.recaptcha_verified }
+ expect { update_issue(spam_log_id: spam_log.id, recaptcha_verification: true) }
+ .not_to change { SpamLog.last.recaptcha_verified }
end
end
end
@@ -558,8 +558,8 @@ describe Projects::IssuesController do
it 'does not mark spam log as recaptcha_verified when it does not belong to current_user' do
spam_log = create(:spam_log)
- expect { post_new_issue({}, { spam_log_id: spam_log.id, recaptcha_verification: true } ) }.
- not_to change { SpamLog.last.recaptcha_verified }
+ expect { post_new_issue({}, { spam_log_id: spam_log.id, recaptcha_verification: true } ) }
+ .not_to change { SpamLog.last.recaptcha_verified }
end
end
end
diff --git a/spec/controllers/projects/mattermosts_controller_spec.rb b/spec/controllers/projects/mattermosts_controller_spec.rb
index cae733f0cfb..a8c365a209f 100644
--- a/spec/controllers/projects/mattermosts_controller_spec.rb
+++ b/spec/controllers/projects/mattermosts_controller_spec.rb
@@ -11,8 +11,8 @@ describe Projects::MattermostsController do
describe 'GET #new' do
before do
- allow_any_instance_of(MattermostSlashCommandsService).
- to receive(:list_teams).and_return([])
+ allow_any_instance_of(MattermostSlashCommandsService)
+ .to receive(:list_teams).and_return([])
end
it 'accepts the request' do
diff --git a/spec/controllers/projects/merge_requests_controller_spec.rb b/spec/controllers/projects/merge_requests_controller_spec.rb
index 1c5dbda0de2..b990f4dae86 100644
--- a/spec/controllers/projects/merge_requests_controller_spec.rb
+++ b/spec/controllers/projects/merge_requests_controller_spec.rb
@@ -105,8 +105,8 @@ describe Projects::MergeRequestsController do
end
it "does not escape Html" do
- allow_any_instance_of(MergeRequest).to receive(:"to_#{format}").
- and_return('HTML entities &<>" ')
+ allow_any_instance_of(MergeRequest).to receive(:"to_#{format}")
+ .and_return('HTML entities &<>" ')
get(:show,
namespace_id: project.namespace.to_param,
@@ -334,9 +334,9 @@ describe Projects::MergeRequestsController do
it 'sets the MR to merge when the build succeeds' do
service = double(:merge_when_build_succeeds_service)
- expect(MergeRequests::MergeWhenPipelineSucceedsService).
- to receive(:new).with(project, anything, anything).
- and_return(service)
+ expect(MergeRequests::MergeWhenPipelineSucceedsService)
+ .to receive(:new).with(project, anything, anything)
+ .and_return(service)
expect(service).to receive(:execute).with(merge_request)
merge_when_build_succeeds
@@ -720,8 +720,8 @@ describe Projects::MergeRequestsController do
describe 'GET conflicts' do
context 'when the conflicts cannot be resolved in the UI' do
before do
- allow_any_instance_of(Gitlab::Conflict::Parser).
- to receive(:parse).and_raise(Gitlab::Conflict::Parser::UnmergeableFile)
+ allow_any_instance_of(Gitlab::Conflict::Parser)
+ .to receive(:parse).and_raise(Gitlab::Conflict::Parser::UnmergeableFile)
get :conflicts,
namespace_id: merge_request_with_conflicts.project.namespace.to_param,
@@ -826,8 +826,8 @@ describe Projects::MergeRequestsController do
context 'when the conflicts cannot be resolved in the UI' do
before do
- allow_any_instance_of(Gitlab::Conflict::Parser).
- to receive(:parse).and_raise(Gitlab::Conflict::Parser::UnmergeableFile)
+ allow_any_instance_of(Gitlab::Conflict::Parser)
+ .to receive(:parse).and_raise(Gitlab::Conflict::Parser::UnmergeableFile)
conflict_for_path('files/ruby/regex.rb')
end
@@ -1043,9 +1043,9 @@ describe Projects::MergeRequestsController do
end
it 'calls MergeRequests::AssignIssuesService' do
- expect(MergeRequests::AssignIssuesService).to receive(:new).
- with(project, user, merge_request: merge_request).
- and_return(double(execute: { count: 1 }))
+ expect(MergeRequests::AssignIssuesService).to receive(:new)
+ .with(project, user, merge_request: merge_request)
+ .and_return(double(execute: { count: 1 }))
post_assign_issues
end
diff --git a/spec/controllers/projects/raw_controller_spec.rb b/spec/controllers/projects/raw_controller_spec.rb
index b23d6e257ba..68fe29ce2d5 100644
--- a/spec/controllers/projects/raw_controller_spec.rb
+++ b/spec/controllers/projects/raw_controller_spec.rb
@@ -15,8 +15,8 @@ describe Projects::RawController do
expect(response).to have_http_status(200)
expect(response.header['Content-Type']).to eq('text/plain; charset=utf-8')
- expect(response.header['Content-Disposition']).
- to eq("inline")
+ expect(response.header['Content-Disposition'])
+ .to eq("inline")
expect(response.header[Gitlab::Workhorse::SEND_DATA_HEADER]).to start_with("git-blob:")
end
end
diff --git a/spec/controllers/projects/snippets_controller_spec.rb b/spec/controllers/projects/snippets_controller_spec.rb
index 8bab094a79e..65e554aee49 100644
--- a/spec/controllers/projects/snippets_controller_spec.rb
+++ b/spec/controllers/projects/snippets_controller_spec.rb
@@ -89,21 +89,21 @@ describe Projects::SnippetsController do
context 'when the snippet is private' do
it 'creates the snippet' do
- expect { create_snippet(project, visibility_level: Snippet::PRIVATE) }.
- to change { Snippet.count }.by(1)
+ expect { create_snippet(project, visibility_level: Snippet::PRIVATE) }
+ .to change { Snippet.count }.by(1)
end
end
context 'when the snippet is public' do
it 'rejects the shippet' do
- expect { create_snippet(project, visibility_level: Snippet::PUBLIC) }.
- not_to change { Snippet.count }
+ expect { create_snippet(project, visibility_level: Snippet::PUBLIC) }
+ .not_to change { Snippet.count }
expect(response).to render_template(:new)
end
it 'creates a spam log' do
- expect { create_snippet(project, visibility_level: Snippet::PUBLIC) }.
- to change { SpamLog.count }.by(1)
+ expect { create_snippet(project, visibility_level: Snippet::PUBLIC) }
+ .to change { SpamLog.count }.by(1)
end
it 'renders :new with recaptcha disabled' do
@@ -169,8 +169,8 @@ describe Projects::SnippetsController do
let(:visibility_level) { Snippet::PRIVATE }
it 'updates the snippet' do
- expect { update_snippet(title: 'Foo') }.
- to change { snippet.reload.title }.to('Foo')
+ expect { update_snippet(title: 'Foo') }
+ .to change { snippet.reload.title }.to('Foo')
end
end
@@ -178,13 +178,13 @@ describe Projects::SnippetsController do
let(:visibility_level) { Snippet::PUBLIC }
it 'rejects the shippet' do
- expect { update_snippet(title: 'Foo') }.
- not_to change { snippet.reload.title }
+ expect { update_snippet(title: 'Foo') }
+ .not_to change { snippet.reload.title }
end
it 'creates a spam log' do
- expect { update_snippet(title: 'Foo') }.
- to change { SpamLog.count }.by(1)
+ expect { update_snippet(title: 'Foo') }
+ .to change { SpamLog.count }.by(1)
end
it 'renders :edit with recaptcha disabled' do
@@ -223,13 +223,13 @@ describe Projects::SnippetsController do
let(:visibility_level) { Snippet::PRIVATE }
it 'rejects the shippet' do
- expect { update_snippet(title: 'Foo', visibility_level: Snippet::PUBLIC) }.
- not_to change { snippet.reload.title }
+ expect { update_snippet(title: 'Foo', visibility_level: Snippet::PUBLIC) }
+ .not_to change { snippet.reload.title }
end
it 'creates a spam log' do
- expect { update_snippet(title: 'Foo', visibility_level: Snippet::PUBLIC) }.
- to change { SpamLog.count }.by(1)
+ expect { update_snippet(title: 'Foo', visibility_level: Snippet::PUBLIC) }
+ .to change { SpamLog.count }.by(1)
end
it 'renders :edit with recaptcha disabled' do
diff --git a/spec/controllers/projects/tree_controller_spec.rb b/spec/controllers/projects/tree_controller_spec.rb
index b81645a3d2d..71193feaaaa 100644
--- a/spec/controllers/projects/tree_controller_spec.rb
+++ b/spec/controllers/projects/tree_controller_spec.rb
@@ -82,8 +82,8 @@ describe Projects::TreeController do
let(:id) { 'master/README.md' }
it 'redirects' do
redirect_url = "/#{project.path_with_namespace}/blob/master/README.md"
- expect(subject).
- to redirect_to(redirect_url)
+ expect(subject)
+ .to redirect_to(redirect_url)
end
end
end
@@ -106,8 +106,8 @@ describe Projects::TreeController do
let(:target_branch) { 'master-test'}
it 'redirects to the new directory' do
- expect(subject).
- to redirect_to("/#{project.path_with_namespace}/tree/#{target_branch}/#{path}")
+ expect(subject)
+ .to redirect_to("/#{project.path_with_namespace}/tree/#{target_branch}/#{path}")
expect(flash[:notice]).to eq('The directory has been successfully created.')
end
end
@@ -117,8 +117,8 @@ describe Projects::TreeController do
let(:target_branch) { 'master'}
it 'does not allow overwriting of existing files' do
- expect(subject).
- to redirect_to("/#{project.path_with_namespace}/tree/master")
+ expect(subject)
+ .to redirect_to("/#{project.path_with_namespace}/tree/master")
expect(flash[:alert]).to eq('Directory already exists as a file')
end
end
diff --git a/spec/controllers/sent_notifications_controller_spec.rb b/spec/controllers/sent_notifications_controller_spec.rb
index 954fc2eaf21..6a437350248 100644
--- a/spec/controllers/sent_notifications_controller_spec.rb
+++ b/spec/controllers/sent_notifications_controller_spec.rb
@@ -77,8 +77,8 @@ describe SentNotificationsController, type: :controller do
end
it 'redirects to the issue page' do
- expect(response).
- to redirect_to(namespace_project_issue_path(project.namespace, project, issue))
+ expect(response)
+ .to redirect_to(namespace_project_issue_path(project.namespace, project, issue))
end
end
@@ -100,8 +100,8 @@ describe SentNotificationsController, type: :controller do
end
it 'redirects to the merge request page' do
- expect(response).
- to redirect_to(namespace_project_merge_request_path(project.namespace, project, merge_request))
+ expect(response)
+ .to redirect_to(namespace_project_merge_request_path(project.namespace, project, merge_request))
end
end
end
diff --git a/spec/controllers/sessions_controller_spec.rb b/spec/controllers/sessions_controller_spec.rb
index d951325f765..42fd37f81d4 100644
--- a/spec/controllers/sessions_controller_spec.rb
+++ b/spec/controllers/sessions_controller_spec.rb
@@ -11,8 +11,8 @@ describe SessionsController do
it 'does not authenticate user' do
post(:create, user: { login: 'invalid', password: 'invalid' })
- expect(response).
- to set_flash.now[:alert].to /Invalid Login or password/
+ expect(response)
+ .to set_flash.now[:alert].to /Invalid Login or password/
end
end
@@ -42,8 +42,8 @@ describe SessionsController do
context 'remember_me field' do
it 'sets a remember_user_token cookie when enabled' do
allow(controller).to receive(:find_user).and_return(user)
- expect(controller).
- to receive(:remember_me).with(user).and_call_original
+ expect(controller)
+ .to receive(:remember_me).with(user).and_call_original
authenticate_2fa(remember_me: '1', otp_attempt: user.current_otp)
@@ -102,8 +102,8 @@ describe SessionsController do
end
it 'warns about invalid OTP code' do
- expect(response).to set_flash.now[:alert].
- to /Invalid two-factor code/
+ expect(response).to set_flash.now[:alert]
+ .to /Invalid two-factor code/
end
end
end
@@ -129,8 +129,8 @@ describe SessionsController do
end
it 'warns about invalid login' do
- expect(response).to set_flash.now[:alert].
- to /Invalid Login or password/
+ expect(response).to set_flash.now[:alert]
+ .to /Invalid Login or password/
end
it 'locks the user' do
@@ -140,8 +140,8 @@ describe SessionsController do
it 'keeps the user locked on future login attempts' do
post(:create, user: { login: user.username, password: user.password })
- expect(response).
- to set_flash.now[:alert].to /Invalid Login or password/
+ expect(response)
+ .to set_flash.now[:alert].to /Invalid Login or password/
end
end
end
@@ -153,8 +153,8 @@ describe SessionsController do
authenticate_2fa(login: another_user.username,
otp_attempt: 'invalid')
- expect(response).to set_flash.now[:alert].
- to /Invalid two-factor code/
+ expect(response).to set_flash.now[:alert]
+ .to /Invalid two-factor code/
end
end
end
@@ -177,8 +177,8 @@ describe SessionsController do
it 'sets a remember_user_token cookie when enabled' do
allow(U2fRegistration).to receive(:authenticate).and_return(true)
allow(controller).to receive(:find_user).and_return(user)
- expect(controller).
- to receive(:remember_me).with(user).and_call_original
+ expect(controller)
+ .to receive(:remember_me).with(user).and_call_original
authenticate_2fa_u2f(remember_me: '1', login: user.username, device_response: "{}")
diff --git a/spec/controllers/snippets_controller_spec.rb b/spec/controllers/snippets_controller_spec.rb
index 5de3b9890ef..6b52839fe2c 100644
--- a/spec/controllers/snippets_controller_spec.rb
+++ b/spec/controllers/snippets_controller_spec.rb
@@ -156,20 +156,20 @@ describe SnippetsController do
context 'when the snippet is private' do
it 'creates the snippet' do
- expect { create_snippet(visibility_level: Snippet::PRIVATE) }.
- to change { Snippet.count }.by(1)
+ expect { create_snippet(visibility_level: Snippet::PRIVATE) }
+ .to change { Snippet.count }.by(1)
end
end
context 'when the snippet is public' do
it 'rejects the shippet' do
- expect { create_snippet(visibility_level: Snippet::PUBLIC) }.
- not_to change { Snippet.count }
+ expect { create_snippet(visibility_level: Snippet::PUBLIC) }
+ .not_to change { Snippet.count }
end
it 'creates a spam log' do
- expect { create_snippet(visibility_level: Snippet::PUBLIC) }.
- to change { SpamLog.count }.by(1)
+ expect { create_snippet(visibility_level: Snippet::PUBLIC) }
+ .to change { SpamLog.count }.by(1)
end
it 'renders :new with recaptcha disabled' do
@@ -230,8 +230,8 @@ describe SnippetsController do
let(:visibility_level) { Snippet::PRIVATE }
it 'updates the snippet' do
- expect { update_snippet(title: 'Foo') }.
- to change { snippet.reload.title }.to('Foo')
+ expect { update_snippet(title: 'Foo') }
+ .to change { snippet.reload.title }.to('Foo')
end
end
@@ -239,13 +239,13 @@ describe SnippetsController do
let(:visibility_level) { Snippet::PRIVATE }
it 'rejects the snippet' do
- expect { update_snippet(title: 'Foo', visibility_level: Snippet::PUBLIC) }.
- not_to change { snippet.reload.title }
+ expect { update_snippet(title: 'Foo', visibility_level: Snippet::PUBLIC) }
+ .not_to change { snippet.reload.title }
end
it 'creates a spam log' do
- expect { update_snippet(title: 'Foo', visibility_level: Snippet::PUBLIC) }.
- to change { SpamLog.count }.by(1)
+ expect { update_snippet(title: 'Foo', visibility_level: Snippet::PUBLIC) }
+ .to change { SpamLog.count }.by(1)
end
it 'renders :edit with recaptcha disabled' do
@@ -284,13 +284,13 @@ describe SnippetsController do
let(:visibility_level) { Snippet::PUBLIC }
it 'rejects the shippet' do
- expect { update_snippet(title: 'Foo') }.
- not_to change { snippet.reload.title }
+ expect { update_snippet(title: 'Foo') }
+ .not_to change { snippet.reload.title }
end
it 'creates a spam log' do
- expect { update_snippet(title: 'Foo') }.
- to change { SpamLog.count }.by(1)
+ expect { update_snippet(title: 'Foo') }
+ .to change { SpamLog.count }.by(1)
end
it 'renders :edit with recaptcha disabled' do
diff --git a/spec/factories/projects.rb b/spec/factories/projects.rb
index c80b09e9b9d..8df86435501 100644
--- a/spec/factories/projects.rb
+++ b/spec/factories/projects.rb
@@ -90,8 +90,8 @@ FactoryGirl.define do
builds_access_level = [evaluator.builds_access_level, evaluator.repository_access_level].min
merge_requests_access_level = [evaluator.merge_requests_access_level, evaluator.repository_access_level].min
- project.project_feature.
- update_attributes!(
+ project.project_feature
+ .update_attributes!(
wiki_access_level: evaluator.wiki_access_level,
builds_access_level: builds_access_level,
snippets_access_level: evaluator.snippets_access_level,
diff --git a/spec/features/admin/admin_projects_spec.rb b/spec/features/admin/admin_projects_spec.rb
index 87a8f62687a..7b82c3ae3d1 100644
--- a/spec/features/admin/admin_projects_spec.rb
+++ b/spec/features/admin/admin_projects_spec.rb
@@ -57,8 +57,8 @@ describe "Admin::Projects", feature: true do
before do
create(:group, name: 'Web')
- allow_any_instance_of(Projects::TransferService).
- to receive(:move_uploads_to_new_namespace).and_return(true)
+ allow_any_instance_of(Projects::TransferService)
+ .to receive(:move_uploads_to_new_namespace).and_return(true)
end
it 'transfers project to group web', js: true do
diff --git a/spec/features/admin/admin_users_spec.rb b/spec/features/admin/admin_users_spec.rb
index c0807b8c507..332abb121fc 100644
--- a/spec/features/admin/admin_users_spec.rb
+++ b/spec/features/admin/admin_users_spec.rb
@@ -77,10 +77,10 @@ describe "Admin::Users", feature: true do
it "applies defaults to user" do
click_button "Create user"
user = User.find_by(username: 'bang')
- expect(user.projects_limit).
- to eq(Gitlab.config.gitlab.default_projects_limit)
- expect(user.can_create_group).
- to eq(Gitlab.config.gitlab.default_can_create_group)
+ expect(user.projects_limit)
+ .to eq(Gitlab.config.gitlab.default_projects_limit)
+ expect(user.can_create_group)
+ .to eq(Gitlab.config.gitlab.default_can_create_group)
end
it "creates user with valid data" do
diff --git a/spec/features/atom/dashboard_spec.rb b/spec/features/atom/dashboard_spec.rb
index 746df36bb25..4ed06bb3a32 100644
--- a/spec/features/atom/dashboard_spec.rb
+++ b/spec/features/atom/dashboard_spec.rb
@@ -28,8 +28,8 @@ describe "Dashboard Feed", feature: true do
end
it "has issue comment event" do
- expect(body).
- to have_content("#{user.name} commented on issue ##{issue.iid}")
+ expect(body)
+ .to have_content("#{user.name} commented on issue ##{issue.iid}")
end
end
end
diff --git a/spec/features/atom/issues_spec.rb b/spec/features/atom/issues_spec.rb
index a01a050a013..6caaa703ae0 100644
--- a/spec/features/atom/issues_spec.rb
+++ b/spec/features/atom/issues_spec.rb
@@ -17,8 +17,8 @@ describe 'Issues Feed', feature: true do
login_with user
visit namespace_project_issues_path(project.namespace, project, :atom)
- expect(response_headers['Content-Type']).
- to have_content('application/atom+xml')
+ expect(response_headers['Content-Type'])
+ .to have_content('application/atom+xml')
expect(body).to have_selector('title', text: "#{project.name} issues")
expect(body).to have_selector('author email', text: issue.author_email)
expect(body).to have_selector('entry summary', text: issue.title)
@@ -30,8 +30,8 @@ describe 'Issues Feed', feature: true do
visit namespace_project_issues_path(project.namespace, project, :atom,
private_token: user.private_token)
- expect(response_headers['Content-Type']).
- to have_content('application/atom+xml')
+ expect(response_headers['Content-Type'])
+ .to have_content('application/atom+xml')
expect(body).to have_selector('title', text: "#{project.name} issues")
expect(body).to have_selector('author email', text: issue.author_email)
expect(body).to have_selector('entry summary', text: issue.title)
diff --git a/spec/features/atom/users_spec.rb b/spec/features/atom/users_spec.rb
index f8c3ccb416b..9b569e83257 100644
--- a/spec/features/atom/users_spec.rb
+++ b/spec/features/atom/users_spec.rb
@@ -48,8 +48,8 @@ describe "User Feed", feature: true do
end
it 'has issue comment event' do
- expect(body).
- to have_content("#{safe_name} commented on issue ##{issue.iid}")
+ expect(body)
+ .to have_content("#{safe_name} commented on issue ##{issue.iid}")
end
it 'has XHTML summaries in issue descriptions' do
diff --git a/spec/features/environments_spec.rb b/spec/features/environments_spec.rb
index 513de297fdf..78be7d36f47 100644
--- a/spec/features/environments_spec.rb
+++ b/spec/features/environments_spec.rb
@@ -111,8 +111,8 @@ feature 'Environments page', :feature, :js do
find('.js-dropdown-play-icon-container').click
expect(page).to have_content(manual.name.humanize)
- expect { click_link(manual.name.humanize) }.
- not_to change { Ci::Pipeline.count }
+ expect { click_link(manual.name.humanize) }
+ .not_to change { Ci::Pipeline.count }
expect(manual.reload).to be_pending
end
diff --git a/spec/features/gitlab_flavored_markdown_spec.rb b/spec/features/gitlab_flavored_markdown_spec.rb
index 84d73d693bc..45d21817824 100644
--- a/spec/features/gitlab_flavored_markdown_spec.rb
+++ b/spec/features/gitlab_flavored_markdown_spec.rb
@@ -11,8 +11,8 @@ describe "GitLab Flavored Markdown", feature: true do
end
before do
- allow_any_instance_of(Commit).to receive(:title).
- and_return("fix #{issue.to_reference}\n\nask #{fred.to_reference} for details")
+ allow_any_instance_of(Commit).to receive(:title)
+ .and_return("fix #{issue.to_reference}\n\nask #{fred.to_reference} for details")
end
let(:commit) { project.commit }
diff --git a/spec/features/login_spec.rb b/spec/features/login_spec.rb
index ae609160e18..d545d38424c 100644
--- a/spec/features/login_spec.rb
+++ b/spec/features/login_spec.rb
@@ -110,8 +110,8 @@ feature 'Login', feature: true do
end
it 'invalidates the used code' do
- expect { enter_code(codes.sample) }.
- to change { user.reload.otp_backup_codes.size }.by(-1)
+ expect { enter_code(codes.sample) }
+ .to change { user.reload.otp_backup_codes.size }.by(-1)
end
end
diff --git a/spec/features/markdown_spec.rb b/spec/features/markdown_spec.rb
index 32159559c37..75ade80012c 100644
--- a/spec/features/markdown_spec.rb
+++ b/spec/features/markdown_spec.rb
@@ -58,8 +58,8 @@ describe 'GitLab Markdown', feature: true do
end
it 'allows Markdown in tables' do
- expect(doc.at_css('td:contains("Baz")').children.to_html).
- to eq 'Baz'
+ expect(doc.at_css('td:contains("Baz")').children.to_html)
+ .to eq 'Baz'
end
it 'parses fenced code blocks' do
@@ -150,14 +150,14 @@ describe 'GitLab Markdown', feature: true do
describe 'Edge Cases' do
it 'allows markup inside link elements' do
aggregate_failures do
- expect(doc.at_css('a[href="#link-emphasis"]').to_html).
- to eq %{text}
+ expect(doc.at_css('a[href="#link-emphasis"]').to_html)
+ .to eq %{text}
- expect(doc.at_css('a[href="#link-strong"]').to_html).
- to eq %{text}
+ expect(doc.at_css('a[href="#link-strong"]').to_html)
+ .to eq %{text}
- expect(doc.at_css('a[href="#link-code"]').to_html).
- to eq %{text
}
+ expect(doc.at_css('a[href="#link-code"]').to_html)
+ .to eq %{text
}
end
end
end
diff --git a/spec/features/merge_requests/created_from_fork_spec.rb b/spec/features/merge_requests/created_from_fork_spec.rb
index 9fc5339308c..73c5ef31edc 100644
--- a/spec/features/merge_requests/created_from_fork_spec.rb
+++ b/spec/features/merge_requests/created_from_fork_spec.rb
@@ -61,8 +61,8 @@ feature 'Merge request created from fork' do
expect(page).to have_content pipeline.id
end
- expect(page.find('a.btn-remove')[:href]).
- to include fork_project.path_with_namespace
+ expect(page.find('a.btn-remove')[:href])
+ .to include fork_project.path_with_namespace
end
end
diff --git a/spec/features/notes_on_merge_requests_spec.rb b/spec/features/notes_on_merge_requests_spec.rb
index fab2d532e06..bfb28e1de15 100644
--- a/spec/features/notes_on_merge_requests_spec.rb
+++ b/spec/features/notes_on_merge_requests_spec.rb
@@ -25,8 +25,8 @@ describe 'Comments', feature: true do
describe 'the note form' do
it 'is valid' do
is_expected.to have_css('.js-main-target-form', visible: true, count: 1)
- expect(find('.js-main-target-form input[type=submit]').value).
- to eq('Comment')
+ expect(find('.js-main-target-form input[type=submit]').value)
+ .to eq('Comment')
page.within('.js-main-target-form') do
expect(page).not_to have_link('Cancel')
end
@@ -121,8 +121,8 @@ describe 'Comments', feature: true do
page.within("#note_#{note.id}") do
is_expected.to have_css('.note_edited_ago')
- expect(find('.note_edited_ago').text).
- to match(/less than a minute ago/)
+ expect(find('.note_edited_ago').text)
+ .to match(/less than a minute ago/)
end
end
end
@@ -201,8 +201,8 @@ describe 'Comments', feature: true do
it "does not add a second form for same row" do
click_diff_line
- is_expected.
- to have_css("form[data-line-code='#{line_code}']",
+ is_expected
+ .to have_css("form[data-line-code='#{line_code}']",
count: 1)
end
diff --git a/spec/features/projects/pipelines/pipelines_spec.rb b/spec/features/projects/pipelines/pipelines_spec.rb
index 845490badd4..0e12618b629 100644
--- a/spec/features/projects/pipelines/pipelines_spec.rb
+++ b/spec/features/projects/pipelines/pipelines_spec.rb
@@ -366,8 +366,8 @@ describe 'Pipelines', :feature, :js do
before { stub_ci_pipeline_to_return_yaml_file }
it 'creates a new pipeline' do
- expect { click_on 'Create pipeline' }.
- to change { Ci::Pipeline.count }.by(1)
+ expect { click_on 'Create pipeline' }
+ .to change { Ci::Pipeline.count }.by(1)
end
end
diff --git a/spec/finders/environments_finder_spec.rb b/spec/finders/environments_finder_spec.rb
index ed60a95deba..0c063f6d5ee 100644
--- a/spec/finders/environments_finder_spec.rb
+++ b/spec/finders/environments_finder_spec.rb
@@ -16,18 +16,18 @@ describe EnvironmentsFinder do
end
it 'returns environment when with_tags is set' do
- expect(described_class.new(project, user, ref: 'master', commit: project.commit, with_tags: true).execute).
- to contain_exactly(environment)
+ expect(described_class.new(project, user, ref: 'master', commit: project.commit, with_tags: true).execute)
+ .to contain_exactly(environment)
end
it 'does not return environment when no with_tags is set' do
- expect(described_class.new(project, user, ref: 'master', commit: project.commit).execute).
- to be_empty
+ expect(described_class.new(project, user, ref: 'master', commit: project.commit).execute)
+ .to be_empty
end
it 'does not return environment when commit is not part of deployment' do
- expect(described_class.new(project, user, ref: 'master', commit: project.commit('feature')).execute).
- to be_empty
+ expect(described_class.new(project, user, ref: 'master', commit: project.commit('feature')).execute)
+ .to be_empty
end
end
@@ -37,23 +37,23 @@ describe EnvironmentsFinder do
end
it 'returns environment when ref is set' do
- expect(described_class.new(project, user, ref: 'master', commit: project.commit).execute).
- to contain_exactly(environment)
+ expect(described_class.new(project, user, ref: 'master', commit: project.commit).execute)
+ .to contain_exactly(environment)
end
it 'does not environment when ref is different' do
- expect(described_class.new(project, user, ref: 'feature', commit: project.commit).execute).
- to be_empty
+ expect(described_class.new(project, user, ref: 'feature', commit: project.commit).execute)
+ .to be_empty
end
it 'does not return environment when commit is not part of deployment' do
- expect(described_class.new(project, user, ref: 'master', commit: project.commit('feature')).execute).
- to be_empty
+ expect(described_class.new(project, user, ref: 'master', commit: project.commit('feature')).execute)
+ .to be_empty
end
it 'returns environment when commit constraint is not set' do
- expect(described_class.new(project, user, ref: 'master').execute).
- to contain_exactly(environment)
+ expect(described_class.new(project, user, ref: 'master').execute)
+ .to contain_exactly(environment)
end
end
@@ -63,8 +63,8 @@ describe EnvironmentsFinder do
end
it 'returns environment' do
- expect(described_class.new(project, user, commit: project.commit).execute).
- to contain_exactly(environment)
+ expect(described_class.new(project, user, commit: project.commit).execute)
+ .to contain_exactly(environment)
end
end
@@ -75,8 +75,8 @@ describe EnvironmentsFinder do
end
it 'finds recently updated environment' do
- expect(described_class.new(project, user, ref: 'feature', recently_updated: true).execute).
- to contain_exactly(environment)
+ expect(described_class.new(project, user, ref: 'feature', recently_updated: true).execute)
+ .to contain_exactly(environment)
end
end
@@ -87,8 +87,8 @@ describe EnvironmentsFinder do
end
it 'does not find environment' do
- expect(described_class.new(project, user, ref: 'feature', recently_updated: true).execute).
- to be_empty
+ expect(described_class.new(project, user, ref: 'feature', recently_updated: true).execute)
+ .to be_empty
end
end
@@ -101,8 +101,8 @@ describe EnvironmentsFinder do
end
it 'finds both environments' do
- expect(described_class.new(project, user, ref: 'feature', recently_updated: true).execute).
- to contain_exactly(environment, second_environment)
+ expect(described_class.new(project, user, ref: 'feature', recently_updated: true).execute)
+ .to contain_exactly(environment, second_environment)
end
end
end
diff --git a/spec/helpers/application_helper_spec.rb b/spec/helpers/application_helper_spec.rb
index fd40fe99941..e96576b5d45 100644
--- a/spec/helpers/application_helper_spec.rb
+++ b/spec/helpers/application_helper_spec.rb
@@ -58,8 +58,8 @@ describe ApplicationHelper do
project = create(:empty_project, avatar: File.open(uploaded_image_temp_path))
avatar_url = "http://#{Gitlab.config.gitlab.host}/uploads/project/avatar/#{project.id}/banana_sample.gif"
- expect(helper.project_icon("#{project.namespace.to_param}/#{project.to_param}").to_s).
- to eq ""
+ expect(helper.project_icon("#{project.namespace.to_param}/#{project.to_param}").to_s)
+ .to eq ""
end
it 'gives uploaded icon when present' do
@@ -77,8 +77,8 @@ describe ApplicationHelper do
it 'returns an url for the avatar' do
user = create(:user, avatar: File.open(uploaded_image_temp_path))
- expect(helper.avatar_icon(user.email).to_s).
- to match("/uploads/user/avatar/#{user.id}/banana_sample.gif")
+ expect(helper.avatar_icon(user.email).to_s)
+ .to match("/uploads/user/avatar/#{user.id}/banana_sample.gif")
end
it 'returns an url for the avatar with relative url' do
@@ -88,8 +88,8 @@ describe ApplicationHelper do
user = create(:user, avatar: File.open(uploaded_image_temp_path))
- expect(helper.avatar_icon(user.email).to_s).
- to match("/gitlab/uploads/user/avatar/#{user.id}/banana_sample.gif")
+ expect(helper.avatar_icon(user.email).to_s)
+ .to match("/gitlab/uploads/user/avatar/#{user.id}/banana_sample.gif")
end
it 'calls gravatar_icon when no User exists with the given email' do
@@ -102,8 +102,8 @@ describe ApplicationHelper do
it 'returns an URL for the avatar' do
user = create(:user, avatar: File.open(uploaded_image_temp_path))
- expect(helper.avatar_icon(user).to_s).
- to match("/uploads/user/avatar/#{user.id}/banana_sample.gif")
+ expect(helper.avatar_icon(user).to_s)
+ .to match("/uploads/user/avatar/#{user.id}/banana_sample.gif")
end
end
end
@@ -133,22 +133,22 @@ describe ApplicationHelper do
it 'returns a valid Gravatar URL' do
stub_config_setting(https: false)
- expect(helper.gravatar_icon(user_email)).
- to match('http://www.gravatar.com/avatar/b58c6f14d292556214bd64909bcdb118')
+ expect(helper.gravatar_icon(user_email))
+ .to match('http://www.gravatar.com/avatar/b58c6f14d292556214bd64909bcdb118')
end
it 'uses HTTPs when configured' do
stub_config_setting(https: true)
- expect(helper.gravatar_icon(user_email)).
- to match('https://secure.gravatar.com')
+ expect(helper.gravatar_icon(user_email))
+ .to match('https://secure.gravatar.com')
end
it 'returns custom gravatar path when gravatar_url is set' do
stub_gravatar_setting(plain_url: 'http://example.local/?s=%{size}&hash=%{hash}')
- expect(gravatar_icon(user_email, 20)).
- to eq('http://example.local/?s=40&hash=b58c6f14d292556214bd64909bcdb118')
+ expect(gravatar_icon(user_email, 20))
+ .to eq('http://example.local/?s=40&hash=b58c6f14d292556214bd64909bcdb118')
end
it 'accepts a custom size argument' do
@@ -220,8 +220,8 @@ describe ApplicationHelper do
end
it 'accepts a custom html_class' do
- expect(element(html_class: 'custom_class').attr('class')).
- to eq 'js-timeago custom_class'
+ expect(element(html_class: 'custom_class').attr('class'))
+ .to eq 'js-timeago custom_class'
end
it 'accepts a custom tooltip placement' do
diff --git a/spec/helpers/broadcast_messages_helper_spec.rb b/spec/helpers/broadcast_messages_helper_spec.rb
index c6e3c5c2368..9bec0f9f432 100644
--- a/spec/helpers/broadcast_messages_helper_spec.rb
+++ b/spec/helpers/broadcast_messages_helper_spec.rb
@@ -33,8 +33,8 @@ describe BroadcastMessagesHelper do
it 'allows custom style' do
broadcast_message = double(color: '#f2dede', font: '#b94a48')
- expect(helper.broadcast_message_style(broadcast_message)).
- to match('background-color: #f2dede; color: #b94a48')
+ expect(helper.broadcast_message_style(broadcast_message))
+ .to match('background-color: #f2dede; color: #b94a48')
end
end
diff --git a/spec/helpers/commits_helper_spec.rb b/spec/helpers/commits_helper_spec.rb
index a2c008790f9..c245bb439db 100644
--- a/spec/helpers/commits_helper_spec.rb
+++ b/spec/helpers/commits_helper_spec.rb
@@ -9,8 +9,8 @@ describe CommitsHelper do
author_email: 'my@email.com" onmouseover="alert(1)'
)
- expect(helper.commit_author_link(commit)).
- not_to include('onmouseover="alert(1)"')
+ expect(helper.commit_author_link(commit))
+ .not_to include('onmouseover="alert(1)"')
end
end
@@ -22,8 +22,8 @@ describe CommitsHelper do
committer_email: 'my@email.com" onmouseover="alert(1)'
)
- expect(helper.commit_committer_link(commit)).
- not_to include('onmouseover="alert(1)"')
+ expect(helper.commit_committer_link(commit))
+ .not_to include('onmouseover="alert(1)"')
end
end
diff --git a/spec/helpers/form_helper_spec.rb b/spec/helpers/form_helper_spec.rb
index b20373a96fb..18cf0031d5f 100644
--- a/spec/helpers/form_helper_spec.rb
+++ b/spec/helpers/form_helper_spec.rb
@@ -11,18 +11,18 @@ describe FormHelper do
it 'renders an alert div' do
model = double(errors: errors_stub('Error 1'))
- expect(helper.form_errors(model)).
- to include('
hello
') expect(object).to receive(:user_visible_reference_count=).with(0) @@ -37,8 +37,8 @@ describe Banzai::ObjectRenderer do renderer = described_class.new(project, user) - expect(renderer).to receive(:render_attributes).with([object], :note). - and_call_original + expect(renderer).to receive(:render_attributes).with([object], :note) + .and_call_original rendered = renderer.render_objects([object], :note) @@ -52,9 +52,9 @@ describe Banzai::ObjectRenderer do doc = Nokogiri::HTML.fragment('hello
') renderer = described_class.new(project, user) - expect_any_instance_of(Banzai::Redactor).to receive(:redact). - with([doc]). - and_call_original + expect_any_instance_of(Banzai::Redactor).to receive(:redact) + .with([doc]) + .and_call_original redacted = renderer.redact_documents([doc]) diff --git a/spec/lib/banzai/redactor_spec.rb b/spec/lib/banzai/redactor_spec.rb index 6d2c141e18b..a14a1405ca6 100644 --- a/spec/lib/banzai/redactor_spec.rb +++ b/spec/lib/banzai/redactor_spec.rb @@ -12,11 +12,11 @@ describe Banzai::Redactor do end it 'redacts an array of documents' do - doc1 = Nokogiri::HTML. - fragment('foo') + doc1 = Nokogiri::HTML + .fragment('foo') - doc2 = Nokogiri::HTML. - fragment('bar') + doc2 = Nokogiri::HTML + .fragment('bar') redacted_data = redactor.redact([doc1, doc2]) @@ -68,9 +68,9 @@ describe Banzai::Redactor do doc = Nokogiri::HTML.fragment('foo') node = doc.children[0] - expect(redactor).to receive(:nodes_visible_to_user). - with([node]). - and_return(Set.new) + expect(redactor).to receive(:nodes_visible_to_user) + .with([node]) + .and_return(Set.new) redactor.redact_document_nodes([{ document: doc, nodes: [node] }]) @@ -83,10 +83,10 @@ describe Banzai::Redactor do doc = Nokogiri::HTML.fragment('') node = doc.children[0] - expect_any_instance_of(Banzai::ReferenceParser::IssueParser). - to receive(:nodes_visible_to_user). - with(user, [node]). - and_return([node]) + expect_any_instance_of(Banzai::ReferenceParser::IssueParser) + .to receive(:nodes_visible_to_user) + .with(user, [node]) + .and_return([node]) expect(redactor.nodes_visible_to_user([node])).to eq(Set.new([node])) end diff --git a/spec/lib/banzai/reference_parser/base_parser_spec.rb b/spec/lib/banzai/reference_parser/base_parser_spec.rb index aa127f0179d..9126afb0693 100644 --- a/spec/lib/banzai/reference_parser/base_parser_spec.rb +++ b/spec/lib/banzai/reference_parser/base_parser_spec.rb @@ -54,8 +54,8 @@ describe Banzai::ReferenceParser::BaseParser, lib: true do describe '#referenced_by' do context 'when references_relation is implemented' do it 'returns a collection of objects' do - links = Nokogiri::HTML.fragment(""). - children + links = Nokogiri::HTML.fragment("") + .children expect(subject).to receive(:references_relation).and_return(User) expect(subject.referenced_by(links)).to eq([user]) @@ -66,8 +66,8 @@ describe Banzai::ReferenceParser::BaseParser, lib: true do it 'raises NotImplementedError' do links = Nokogiri::HTML.fragment('').children - expect { subject.referenced_by(links) }. - to raise_error(NotImplementedError) + expect { subject.referenced_by(links) } + .to raise_error(NotImplementedError) end end end @@ -80,8 +80,8 @@ describe Banzai::ReferenceParser::BaseParser, lib: true do describe '#gather_attributes_per_project' do it 'returns a Hash containing attribute values per project' do - link = Nokogiri::HTML.fragment(''). - children[0] + link = Nokogiri::HTML.fragment('') + .children[0] hash = subject.gather_attributes_per_project([link], 'data-foo') @@ -95,9 +95,9 @@ describe Banzai::ReferenceParser::BaseParser, lib: true do it 'returns a Hash grouping objects per ID' do nodes = [double(:node)] - expect(subject).to receive(:unique_attribute_values). - with(nodes, 'data-user'). - and_return([user.id]) + expect(subject).to receive(:unique_attribute_values) + .with(nodes, 'data-user') + .and_return([user.id]) hash = subject.grouped_objects_for_nodes(nodes, User, 'data-user') @@ -113,15 +113,15 @@ describe Banzai::ReferenceParser::BaseParser, lib: true do it 'returns an Array of unique values' do link = double(:link) - expect(link).to receive(:has_attribute?). - with('data-foo'). - twice. - and_return(true) + expect(link).to receive(:has_attribute?) + .with('data-foo') + .twice + .and_return(true) - expect(link).to receive(:attr). - with('data-foo'). - twice. - and_return('1') + expect(link).to receive(:attr) + .with('data-foo') + .twice + .and_return('1') nodes = [link, link] @@ -138,9 +138,9 @@ describe Banzai::ReferenceParser::BaseParser, lib: true do instance = dummy.new(project, user) document = Nokogiri::HTML.fragment('') - expect(instance).to receive(:gather_references). - with([document.children[1]]). - and_return([user]) + expect(instance).to receive(:gather_references) + .with([document.children[1]]) + .and_return([user]) expect(instance.process([document])).to eq([user]) end @@ -150,9 +150,9 @@ describe Banzai::ReferenceParser::BaseParser, lib: true do let(:link) { double(:link) } it 'does not process links a user can not reference' do - expect(subject).to receive(:nodes_user_can_reference). - with(user, [link]). - and_return([]) + expect(subject).to receive(:nodes_user_can_reference) + .with(user, [link]) + .and_return([]) expect(subject).to receive(:referenced_by).with([]) @@ -160,13 +160,13 @@ describe Banzai::ReferenceParser::BaseParser, lib: true do end it 'does not process links a user can not see' do - expect(subject).to receive(:nodes_user_can_reference). - with(user, [link]). - and_return([link]) + expect(subject).to receive(:nodes_user_can_reference) + .with(user, [link]) + .and_return([link]) - expect(subject).to receive(:nodes_visible_to_user). - with(user, [link]). - and_return([]) + expect(subject).to receive(:nodes_visible_to_user) + .with(user, [link]) + .and_return([]) expect(subject).to receive(:referenced_by).with([]) @@ -174,13 +174,13 @@ describe Banzai::ReferenceParser::BaseParser, lib: true do end it 'returns the references if a user can reference and see a link' do - expect(subject).to receive(:nodes_user_can_reference). - with(user, [link]). - and_return([link]) + expect(subject).to receive(:nodes_user_can_reference) + .with(user, [link]) + .and_return([link]) - expect(subject).to receive(:nodes_visible_to_user). - with(user, [link]). - and_return([link]) + expect(subject).to receive(:nodes_visible_to_user) + .with(user, [link]) + .and_return([link]) expect(subject).to receive(:referenced_by).with([link]) @@ -192,8 +192,8 @@ describe Banzai::ReferenceParser::BaseParser, lib: true do it 'delegates the permissions check to the Ability class' do user = double(:user) - expect(Ability).to receive(:allowed?). - with(user, :read_project, project) + expect(Ability).to receive(:allowed?) + .with(user, :read_project, project) subject.can?(user, :read_project, project) end @@ -201,8 +201,8 @@ describe Banzai::ReferenceParser::BaseParser, lib: true do describe '#find_projects_for_hash_keys' do it 'returns a list of Projects' do - expect(subject.find_projects_for_hash_keys(project.id => project)). - to eq([project]) + expect(subject.find_projects_for_hash_keys(project.id => project)) + .to eq([project]) end end @@ -214,8 +214,8 @@ describe Banzai::ReferenceParser::BaseParser, lib: true do expect(collection).to receive(:where).twice.and_call_original 2.times do - expect(subject.collection_objects_for_ids(collection, [user.id])). - to eq([user]) + expect(subject.collection_objects_for_ids(collection, [user.id])) + .to eq([user]) end end end @@ -229,8 +229,8 @@ describe Banzai::ReferenceParser::BaseParser, lib: true do end it 'queries the collection on the first call' do - expect(subject.collection_objects_for_ids(User, [user.id])). - to eq([user]) + expect(subject.collection_objects_for_ids(User, [user.id])) + .to eq([user]) end it 'does not query previously queried objects' do @@ -239,34 +239,34 @@ describe Banzai::ReferenceParser::BaseParser, lib: true do expect(collection).to receive(:where).once.and_call_original 2.times do - expect(subject.collection_objects_for_ids(collection, [user.id])). - to eq([user]) + expect(subject.collection_objects_for_ids(collection, [user.id])) + .to eq([user]) end end it 'casts String based IDs to Fixnums before querying objects' do 2.times do - expect(subject.collection_objects_for_ids(User, [user.id.to_s])). - to eq([user]) + expect(subject.collection_objects_for_ids(User, [user.id.to_s])) + .to eq([user]) end end it 'queries any additional objects after the first call' do other_user = create(:user) - expect(subject.collection_objects_for_ids(User, [user.id])). - to eq([user]) + expect(subject.collection_objects_for_ids(User, [user.id])) + .to eq([user]) - expect(subject.collection_objects_for_ids(User, [user.id, other_user.id])). - to eq([user, other_user]) + expect(subject.collection_objects_for_ids(User, [user.id, other_user.id])) + .to eq([user, other_user]) end it 'caches objects on a per collection class basis' do - expect(subject.collection_objects_for_ids(User, [user.id])). - to eq([user]) + expect(subject.collection_objects_for_ids(User, [user.id])) + .to eq([user]) - expect(subject.collection_objects_for_ids(Project, [project.id])). - to eq([project]) + expect(subject.collection_objects_for_ids(Project, [project.id])) + .to eq([project]) end end end diff --git a/spec/lib/banzai/reference_parser/commit_parser_spec.rb b/spec/lib/banzai/reference_parser/commit_parser_spec.rb index 412ffa77c36..9c2b2c0a1a9 100644 --- a/spec/lib/banzai/reference_parser/commit_parser_spec.rb +++ b/spec/lib/banzai/reference_parser/commit_parser_spec.rb @@ -30,30 +30,30 @@ describe Banzai::ReferenceParser::CommitParser, lib: true do it 'returns an Array of commits' do commit = double(:commit) - allow_any_instance_of(Project).to receive(:valid_repo?). - and_return(true) + allow_any_instance_of(Project).to receive(:valid_repo?) + .and_return(true) - expect(subject).to receive(:find_commits). - with(project, ['123']). - and_return([commit]) + expect(subject).to receive(:find_commits) + .with(project, ['123']) + .and_return([commit]) expect(subject.referenced_by([link])).to eq([commit]) end it 'returns an empty Array when the commit could not be found' do - allow_any_instance_of(Project).to receive(:valid_repo?). - and_return(true) + allow_any_instance_of(Project).to receive(:valid_repo?) + .and_return(true) - expect(subject).to receive(:find_commits). - with(project, ['123']). - and_return([]) + expect(subject).to receive(:find_commits) + .with(project, ['123']) + .and_return([]) expect(subject.referenced_by([link])).to eq([]) end it 'skips projects without valid repositories' do - allow_any_instance_of(Project).to receive(:valid_repo?). - and_return(false) + allow_any_instance_of(Project).to receive(:valid_repo?) + .and_return(false) expect(subject.referenced_by([link])).to eq([]) end @@ -61,8 +61,8 @@ describe Banzai::ReferenceParser::CommitParser, lib: true do context 'when the link does not have a data-commit attribute' do it 'returns an empty Array' do - allow_any_instance_of(Project).to receive(:valid_repo?). - and_return(true) + allow_any_instance_of(Project).to receive(:valid_repo?) + .and_return(true) expect(subject.referenced_by([link])).to eq([]) end @@ -71,8 +71,8 @@ describe Banzai::ReferenceParser::CommitParser, lib: true do context 'when the link does not have a data-project attribute' do it 'returns an empty Array' do - allow_any_instance_of(Project).to receive(:valid_repo?). - and_return(true) + allow_any_instance_of(Project).to receive(:valid_repo?) + .and_return(true) expect(subject.referenced_by([link])).to eq([]) end diff --git a/spec/lib/banzai/reference_parser/commit_range_parser_spec.rb b/spec/lib/banzai/reference_parser/commit_range_parser_spec.rb index 96e55b0997a..5aec04e8d5b 100644 --- a/spec/lib/banzai/reference_parser/commit_range_parser_spec.rb +++ b/spec/lib/banzai/reference_parser/commit_range_parser_spec.rb @@ -30,17 +30,17 @@ describe Banzai::ReferenceParser::CommitRangeParser, lib: true do it 'returns an Array of commit ranges' do range = double(:range) - expect(subject).to receive(:find_object). - with(project, '123..456'). - and_return(range) + expect(subject).to receive(:find_object) + .with(project, '123..456') + .and_return(range) expect(subject.referenced_by([link])).to eq([range]) end it 'returns an empty Array when the commit range could not be found' do - expect(subject).to receive(:find_object). - with(project, '123..456'). - and_return(nil) + expect(subject).to receive(:find_object) + .with(project, '123..456') + .and_return(nil) expect(subject.referenced_by([link])).to eq([]) end @@ -86,17 +86,17 @@ describe Banzai::ReferenceParser::CommitRangeParser, lib: true do it 'returns an Array of range objects' do range = double(:commit) - expect(subject).to receive(:find_object). - with(project, '123..456'). - and_return(range) + expect(subject).to receive(:find_object) + .with(project, '123..456') + .and_return(range) expect(subject.find_ranges(project, ['123..456'])).to eq([range]) end it 'skips ranges that could not be found' do - expect(subject).to receive(:find_object). - with(project, '123..456'). - and_return(nil) + expect(subject).to receive(:find_object) + .with(project, '123..456') + .and_return(nil) expect(subject.find_ranges(project, ['123..456'])).to eq([]) end diff --git a/spec/lib/banzai/reference_parser/issue_parser_spec.rb b/spec/lib/banzai/reference_parser/issue_parser_spec.rb index 6873b7b85f9..bc81d2808b5 100644 --- a/spec/lib/banzai/reference_parser/issue_parser_spec.rb +++ b/spec/lib/banzai/reference_parser/issue_parser_spec.rb @@ -18,17 +18,17 @@ describe Banzai::ReferenceParser::IssueParser, lib: true do it_behaves_like "referenced feature visibility", "issues" it 'returns the nodes when the user can read the issue' do - expect(Ability).to receive(:issues_readable_by_user). - with([issue], user). - and_return([issue]) + expect(Ability).to receive(:issues_readable_by_user) + .with([issue], user) + .and_return([issue]) expect(subject.nodes_visible_to_user(user, [link])).to eq([link]) end it 'returns an empty Array when the user can not read the issue' do - expect(Ability).to receive(:issues_readable_by_user). - with([issue], user). - and_return([]) + expect(Ability).to receive(:issues_readable_by_user) + .with([issue], user) + .and_return([]) expect(subject.nodes_visible_to_user(user, [link])).to eq([]) end diff --git a/spec/lib/banzai/reference_parser/user_parser_spec.rb b/spec/lib/banzai/reference_parser/user_parser_spec.rb index 31ca9d27b0b..f2f11cd5088 100644 --- a/spec/lib/banzai/reference_parser/user_parser_spec.rb +++ b/spec/lib/banzai/reference_parser/user_parser_spec.rb @@ -82,17 +82,17 @@ describe Banzai::ReferenceParser::UserParser, lib: true do end it 'returns the nodes if the user can read the group' do - expect(Ability).to receive(:allowed?). - with(user, :read_group, group). - and_return(true) + expect(Ability).to receive(:allowed?) + .with(user, :read_group, group) + .and_return(true) expect(subject.nodes_visible_to_user(user, [link])).to eq([link]) end it 'returns an empty Array if the user can not read the group' do - expect(Ability).to receive(:allowed?). - with(user, :read_group, group). - and_return(false) + expect(Ability).to receive(:allowed?) + .with(user, :read_group, group) + .and_return(false) expect(subject.nodes_visible_to_user(user, [link])).to eq([]) end @@ -115,9 +115,9 @@ describe Banzai::ReferenceParser::UserParser, lib: true do link['data-project'] = other_project.id.to_s - expect(Ability).to receive(:allowed?). - with(user, :read_project, other_project). - and_return(true) + expect(Ability).to receive(:allowed?) + .with(user, :read_project, other_project) + .and_return(true) expect(subject.nodes_visible_to_user(user, [link])).to eq([link]) end @@ -127,9 +127,9 @@ describe Banzai::ReferenceParser::UserParser, lib: true do link['data-project'] = other_project.id.to_s - expect(Ability).to receive(:allowed?). - with(user, :read_project, other_project). - and_return(false) + expect(Ability).to receive(:allowed?) + .with(user, :read_project, other_project) + .and_return(false) expect(subject.nodes_visible_to_user(user, [link])).to eq([]) end diff --git a/spec/lib/ci/gitlab_ci_yaml_processor_spec.rb b/spec/lib/ci/gitlab_ci_yaml_processor_spec.rb index 86eec3d6392..a1bde4a0518 100644 --- a/spec/lib/ci/gitlab_ci_yaml_processor_spec.rb +++ b/spec/lib/ci/gitlab_ci_yaml_processor_spec.rb @@ -25,8 +25,8 @@ module Ci end it 'includes coverage regexp in build attributes' do - expect(subject). - to include(coverage_regex: 'Code coverage: \d+\.\d+') + expect(subject) + .to include(coverage_regex: 'Code coverage: \d+\.\d+') end end end @@ -584,8 +584,8 @@ module Ci end it 'raises error' do - expect { subject }. - to raise_error(GitlabCiYamlProcessor::ValidationError, + expect { subject } + .to raise_error(GitlabCiYamlProcessor::ValidationError, /jobs:rspec:variables config should be a hash of key value pairs/) end end @@ -1365,8 +1365,8 @@ EOT it "returns an error about invalid configutaion" do content = YAML.dump("invalid: yaml: test") - expect(GitlabCiYamlProcessor.validation_message(content)). - to eq "Invalid configuration format" + expect(GitlabCiYamlProcessor.validation_message(content)) + .to eq "Invalid configuration format" end end @@ -1374,15 +1374,15 @@ EOT it "returns an error about invalid tags" do content = YAML.dump({ rspec: { script: "test", tags: "mysql" } }) - expect(GitlabCiYamlProcessor.validation_message(content)). - to eq "jobs:rspec tags should be an array of strings" + expect(GitlabCiYamlProcessor.validation_message(content)) + .to eq "jobs:rspec tags should be an array of strings" end end context "when YAML content is empty" do it "returns an error about missing content" do - expect(GitlabCiYamlProcessor.validation_message('')). - to eq "Please provide content of .gitlab-ci.yml" + expect(GitlabCiYamlProcessor.validation_message('')) + .to eq "Please provide content of .gitlab-ci.yml" end end diff --git a/spec/lib/container_registry/blob_spec.rb b/spec/lib/container_registry/blob_spec.rb index bbacdc67ebd..7fd2321d18a 100644 --- a/spec/lib/container_registry/blob_spec.rb +++ b/spec/lib/container_registry/blob_spec.rb @@ -51,8 +51,8 @@ describe ContainerRegistry::Blob do context '#delete' do before do - stub_request(:delete, 'http://example.com/v2/group/test/blobs/sha256:0123456789012345'). - to_return(status: 200) + stub_request(:delete, 'http://example.com/v2/group/test/blobs/sha256:0123456789012345') + .to_return(status: 200) end subject { blob.delete } @@ -67,8 +67,8 @@ describe ContainerRegistry::Blob do context 'when locally stored' do before do - stub_request(:get, 'http://example.com/v2/group/test/blobs/sha256:0123456789012345'). - to_return( + stub_request(:get, 'http://example.com/v2/group/test/blobs/sha256:0123456789012345') + .to_return( status: 200, headers: { 'Content-Type' => 'application/json' }, body: data) @@ -79,9 +79,9 @@ describe ContainerRegistry::Blob do context 'when externally stored' do before do - stub_request(:get, 'http://example.com/v2/group/test/blobs/sha256:0123456789012345'). - with(headers: { 'Authorization' => "bearer #{token}" }). - to_return( + stub_request(:get, 'http://example.com/v2/group/test/blobs/sha256:0123456789012345') + .with(headers: { 'Authorization' => "bearer #{token}" }) + .to_return( status: 307, headers: { 'Location' => location }) end @@ -90,9 +90,9 @@ describe ContainerRegistry::Blob do let(:location) { 'http://external.com/blob/file' } before do - stub_request(:get, location). - with(headers: { 'Authorization' => nil }). - to_return( + stub_request(:get, location) + .with(headers: { 'Authorization' => nil }) + .to_return( status: 200, headers: { 'Content-Type' => 'application/json' }, body: data) diff --git a/spec/lib/container_registry/repository_spec.rb b/spec/lib/container_registry/repository_spec.rb index c364e759108..eeb924ebe48 100644 --- a/spec/lib/container_registry/repository_spec.rb +++ b/spec/lib/container_registry/repository_spec.rb @@ -16,9 +16,9 @@ describe ContainerRegistry::Repository do context 'manifest processing' do before do - stub_request(:get, 'http://example.com/v2/group/test/tags/list'). - with(headers: { 'Accept' => 'application/vnd.docker.distribution.manifest.v2+json' }). - to_return( + stub_request(:get, 'http://example.com/v2/group/test/tags/list') + .with(headers: { 'Accept' => 'application/vnd.docker.distribution.manifest.v2+json' }) + .to_return( status: 200, body: JSON.dump(tags: ['test']), headers: { 'Content-Type' => 'application/json' }) diff --git a/spec/lib/container_registry/tag_spec.rb b/spec/lib/container_registry/tag_spec.rb index c5e31ae82b6..2d7e355a737 100644 --- a/spec/lib/container_registry/tag_spec.rb +++ b/spec/lib/container_registry/tag_spec.rb @@ -19,9 +19,9 @@ describe ContainerRegistry::Tag do context 'manifest processing' do context 'schema v1' do before do - stub_request(:get, 'http://example.com/v2/group/test/manifests/tag'). - with(headers: headers). - to_return( + stub_request(:get, 'http://example.com/v2/group/test/manifests/tag') + .with(headers: headers) + .to_return( status: 200, body: File.read(Rails.root + 'spec/fixtures/container_registry/tag_manifest_1.json'), headers: { 'Content-Type' => 'application/vnd.docker.distribution.manifest.v1+prettyjws' }) @@ -56,9 +56,9 @@ describe ContainerRegistry::Tag do context 'schema v2' do before do - stub_request(:get, 'http://example.com/v2/group/test/manifests/tag'). - with(headers: headers). - to_return( + stub_request(:get, 'http://example.com/v2/group/test/manifests/tag') + .with(headers: headers) + .to_return( status: 200, body: File.read(Rails.root + 'spec/fixtures/container_registry/tag_manifest.json'), headers: { 'Content-Type' => 'application/vnd.docker.distribution.manifest.v2+json' }) @@ -93,9 +93,9 @@ describe ContainerRegistry::Tag do context 'when locally stored' do before do - stub_request(:get, 'http://example.com/v2/group/test/blobs/sha256:d7a513a663c1a6dcdba9ed832ca53c02ac2af0c333322cd6ca92936d1d9917ac'). - with(headers: { 'Accept' => 'application/octet-stream' }). - to_return( + stub_request(:get, 'http://example.com/v2/group/test/blobs/sha256:d7a513a663c1a6dcdba9ed832ca53c02ac2af0c333322cd6ca92936d1d9917ac') + .with(headers: { 'Accept' => 'application/octet-stream' }) + .to_return( status: 200, body: File.read(Rails.root + 'spec/fixtures/container_registry/config_blob.json')) end @@ -105,14 +105,14 @@ describe ContainerRegistry::Tag do context 'when externally stored' do before do - stub_request(:get, 'http://example.com/v2/group/test/blobs/sha256:d7a513a663c1a6dcdba9ed832ca53c02ac2af0c333322cd6ca92936d1d9917ac'). - with(headers: { 'Accept' => 'application/octet-stream' }). - to_return( + stub_request(:get, 'http://example.com/v2/group/test/blobs/sha256:d7a513a663c1a6dcdba9ed832ca53c02ac2af0c333322cd6ca92936d1d9917ac') + .with(headers: { 'Accept' => 'application/octet-stream' }) + .to_return( status: 307, headers: { 'Location' => 'http://external.com/blob/file' }) - stub_request(:get, 'http://external.com/blob/file'). - to_return( + stub_request(:get, 'http://external.com/blob/file') + .to_return( status: 200, body: File.read(Rails.root + 'spec/fixtures/container_registry/config_blob.json')) end @@ -125,9 +125,9 @@ describe ContainerRegistry::Tag do context 'manifest digest' do before do - stub_request(:head, 'http://example.com/v2/group/test/manifests/tag'). - with(headers: headers). - to_return(status: 200, headers: { 'Docker-Content-Digest' => 'sha256:digest' }) + stub_request(:head, 'http://example.com/v2/group/test/manifests/tag') + .with(headers: headers) + .to_return(status: 200, headers: { 'Docker-Content-Digest' => 'sha256:digest' }) end context '#digest' do @@ -138,9 +138,9 @@ describe ContainerRegistry::Tag do context '#delete' do before do - stub_request(:delete, 'http://example.com/v2/group/test/manifests/sha256:digest'). - with(headers: headers). - to_return(status: 200) + stub_request(:delete, 'http://example.com/v2/group/test/manifests/sha256:digest') + .with(headers: headers) + .to_return(status: 200) end subject { tag.delete } diff --git a/spec/lib/extracts_path_spec.rb b/spec/lib/extracts_path_spec.rb index 29c07655ae8..78ac4da8dfe 100644 --- a/spec/lib/extracts_path_spec.rb +++ b/spec/lib/extracts_path_spec.rb @@ -14,8 +14,8 @@ describe ExtractsPath, lib: true do repo = double(ref_names: ['master', 'foo/bar/baz', 'v1.0.0', 'v2.0.0', 'release/app', 'release/app/v1.0.0']) allow(project).to receive(:repository).and_return(repo) - allow(project).to receive(:path_with_namespace). - and_return('gitlab/gitlab-ci') + allow(project).to receive(:path_with_namespace) + .and_return('gitlab/gitlab-ci') allow(request).to receive(:format=) end diff --git a/spec/lib/gitlab/asciidoc_spec.rb b/spec/lib/gitlab/asciidoc_spec.rb index e193a3b79a6..bca57105d1d 100644 --- a/spec/lib/gitlab/asciidoc_spec.rb +++ b/spec/lib/gitlab/asciidoc_spec.rb @@ -19,8 +19,8 @@ module Gitlab attributes: described_class::DEFAULT_ADOC_ATTRS } - expect(Asciidoctor).to receive(:convert). - with(input, expected_asciidoc_opts).and_return(html) + expect(Asciidoctor).to receive(:convert) + .with(input, expected_asciidoc_opts).and_return(html) expect( render(input, context) ).to eql html end @@ -35,8 +35,8 @@ module Gitlab attributes: described_class::DEFAULT_ADOC_ATTRS + ['foo'] } - expect(Asciidoctor).to receive(:convert). - with(input, expected_asciidoc_opts).and_return(html) + expect(Asciidoctor).to receive(:convert) + .with(input, expected_asciidoc_opts).and_return(html) render(input, context, asciidoc_opts) end diff --git a/spec/lib/gitlab/auth_spec.rb b/spec/lib/gitlab/auth_spec.rb index 57c416fb35a..b234de4c772 100644 --- a/spec/lib/gitlab/auth_spec.rb +++ b/spec/lib/gitlab/auth_spec.rb @@ -140,8 +140,8 @@ describe Gitlab::Auth, lib: true do password: 'my-secret', ) - expect(gl_auth.find_for_git_client(user.username, user.password, project: nil, ip: 'ip')). - to eq(Gitlab::Auth::Result.new(user, nil, :gitlab_or_ldap, full_authentication_abilities)) + expect(gl_auth.find_for_git_client(user.username, user.password, project: nil, ip: 'ip')) + .to eq(Gitlab::Auth::Result.new(user, nil, :gitlab_or_ldap, full_authentication_abilities)) end it 'falls through oauth authentication when the username is oauth2' do @@ -151,8 +151,8 @@ describe Gitlab::Auth, lib: true do password: 'my-secret', ) - expect(gl_auth.find_for_git_client(user.username, user.password, project: nil, ip: 'ip')). - to eq(Gitlab::Auth::Result.new(user, nil, :gitlab_or_ldap, full_authentication_abilities)) + expect(gl_auth.find_for_git_client(user.username, user.password, project: nil, ip: 'ip')) + .to eq(Gitlab::Auth::Result.new(user, nil, :gitlab_or_ldap, full_authentication_abilities)) end end diff --git a/spec/lib/gitlab/backup/manager_spec.rb b/spec/lib/gitlab/backup/manager_spec.rb index e9c69183d00..f84782ab440 100644 --- a/spec/lib/gitlab/backup/manager_spec.rb +++ b/spec/lib/gitlab/backup/manager_spec.rb @@ -141,8 +141,8 @@ describe Backup::Manager, lib: true do it 'fails the operation and prints an error' do expect { subject.unpack }.to raise_error SystemExit - expect(progress).to have_received(:puts). - with(a_string_matching('No backups found')) + expect(progress).to have_received(:puts) + .with(a_string_matching('No backups found')) end end @@ -158,8 +158,8 @@ describe Backup::Manager, lib: true do it 'fails the operation and prints an error' do expect { subject.unpack }.to raise_error SystemExit - expect(progress).to have_received(:puts). - with(a_string_matching('Found more than one backup')) + expect(progress).to have_received(:puts) + .with(a_string_matching('Found more than one backup')) end end @@ -178,8 +178,8 @@ describe Backup::Manager, lib: true do it 'fails the operation and prints an error' do expect { subject.unpack }.to raise_error SystemExit expect(File).to have_received(:exist?).with('wrong_gitlab_backup.tar') - expect(progress).to have_received(:puts). - with(a_string_matching('The backup file wrong_gitlab_backup.tar does not exist')) + expect(progress).to have_received(:puts) + .with(a_string_matching('The backup file wrong_gitlab_backup.tar does not exist')) end end @@ -200,8 +200,8 @@ describe Backup::Manager, lib: true do it 'unpacks the file' do subject.unpack - expect(Kernel).to have_received(:system). - with("tar", "-xf", "1451606400_2016_01_01_gitlab_backup.tar") + expect(Kernel).to have_received(:system) + .with("tar", "-xf", "1451606400_2016_01_01_gitlab_backup.tar") expect(progress).to have_received(:puts).with(a_string_matching('done')) end end diff --git a/spec/lib/gitlab/badge/build/status_spec.rb b/spec/lib/gitlab/badge/build/status_spec.rb index 8a4bf4dc89b..3c5414701a7 100644 --- a/spec/lib/gitlab/badge/build/status_spec.rb +++ b/spec/lib/gitlab/badge/build/status_spec.rb @@ -20,8 +20,8 @@ describe Gitlab::Badge::Build::Status do describe '#metadata' do it 'returns badge metadata' do - expect(badge.metadata.image_url). - to include 'badges/master/build.svg' + expect(badge.metadata.image_url) + .to include 'badges/master/build.svg' end end diff --git a/spec/lib/gitlab/bitbucket_import/importer_spec.rb b/spec/lib/gitlab/bitbucket_import/importer_spec.rb index 0a2fe5af2c3..9e557d06ef0 100644 --- a/spec/lib/gitlab/bitbucket_import/importer_spec.rb +++ b/spec/lib/gitlab/bitbucket_import/importer_spec.rb @@ -86,9 +86,9 @@ describe Gitlab::BitbucketImport::Importer, lib: true do headers: { "Content-Type" => "application/json" }, body: issues_statuses_sample_data.to_json) - stub_request(:get, "https://api.bitbucket.org/2.0/repositories/namespace/repo?pagelen=50&sort=created_on"). - with(headers: { 'Accept' => '*/*', 'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Authorization' => 'Bearer', 'User-Agent' => 'Faraday v0.9.2' }). - to_return(status: 200, + stub_request(:get, "https://api.bitbucket.org/2.0/repositories/namespace/repo?pagelen=50&sort=created_on") + .with(headers: { 'Accept' => '*/*', 'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Authorization' => 'Bearer', 'User-Agent' => 'Faraday v0.9.2' }) + .to_return(status: 200, body: "", headers: {}) diff --git a/spec/lib/gitlab/ci/build/artifacts/metadata_spec.rb b/spec/lib/gitlab/ci/build/artifacts/metadata_spec.rb index eea01f91879..6a52ae01b2f 100644 --- a/spec/lib/gitlab/ci/build/artifacts/metadata_spec.rb +++ b/spec/lib/gitlab/ci/build/artifacts/metadata_spec.rb @@ -33,8 +33,8 @@ describe Gitlab::Ci::Build::Artifacts::Metadata do subject { metadata('other_artifacts_0.1.2/').find_entries! } it 'matches correct paths' do - expect(subject.keys). - to contain_exactly 'other_artifacts_0.1.2/', + expect(subject.keys) + .to contain_exactly 'other_artifacts_0.1.2/', 'other_artifacts_0.1.2/doc_sample.txt', 'other_artifacts_0.1.2/another-subdirectory/' end @@ -44,8 +44,8 @@ describe Gitlab::Ci::Build::Artifacts::Metadata do subject { metadata('other_artifacts_0.1.2/another-subdirectory/').find_entries! } it 'matches correct paths' do - expect(subject.keys). - to contain_exactly 'other_artifacts_0.1.2/another-subdirectory/', + expect(subject.keys) + .to contain_exactly 'other_artifacts_0.1.2/another-subdirectory/', 'other_artifacts_0.1.2/another-subdirectory/empty_directory/', 'other_artifacts_0.1.2/another-subdirectory/banana_sample.gif' end @@ -55,8 +55,8 @@ describe Gitlab::Ci::Build::Artifacts::Metadata do subject { metadata('other_artifacts_0.1.2/', recursive: true).find_entries! } it 'matches correct paths' do - expect(subject.keys). - to contain_exactly 'other_artifacts_0.1.2/', + expect(subject.keys) + .to contain_exactly 'other_artifacts_0.1.2/', 'other_artifacts_0.1.2/doc_sample.txt', 'other_artifacts_0.1.2/another-subdirectory/', 'other_artifacts_0.1.2/another-subdirectory/empty_directory/', diff --git a/spec/lib/gitlab/ci/config/entry/artifacts_spec.rb b/spec/lib/gitlab/ci/config/entry/artifacts_spec.rb index 987a0b1f67f..5c31423fdee 100644 --- a/spec/lib/gitlab/ci/config/entry/artifacts_spec.rb +++ b/spec/lib/gitlab/ci/config/entry/artifacts_spec.rb @@ -26,8 +26,8 @@ describe Gitlab::Ci::Config::Entry::Artifacts do let(:config) { { name: 10 } } it 'reports error' do - expect(entry.errors). - to include 'artifacts name should be a string' + expect(entry.errors) + .to include 'artifacts name should be a string' end end @@ -35,8 +35,8 @@ describe Gitlab::Ci::Config::Entry::Artifacts do let(:config) { { test: 100 } } it 'reports error' do - expect(entry.errors). - to include 'artifacts config contains unknown keys: test' + expect(entry.errors) + .to include 'artifacts config contains unknown keys: test' end end end diff --git a/spec/lib/gitlab/ci/config/entry/attributable_spec.rb b/spec/lib/gitlab/ci/config/entry/attributable_spec.rb index efb8c5adab1..fde03c51e2c 100644 --- a/spec/lib/gitlab/ci/config/entry/attributable_spec.rb +++ b/spec/lib/gitlab/ci/config/entry/attributable_spec.rb @@ -14,9 +14,9 @@ describe Gitlab::Ci::Config::Entry::Attributable do context 'config is a hash' do before do - allow(instance). - to receive(:config). - and_return({ name: 'some name', test: 'some test' }) + allow(instance) + .to receive(:config) + .and_return({ name: 'some name', test: 'some test' }) end it 'returns the value of config' do @@ -31,9 +31,9 @@ describe Gitlab::Ci::Config::Entry::Attributable do context 'config is not a hash' do before do - allow(instance). - to receive(:config). - and_return('some test') + allow(instance) + .to receive(:config) + .and_return('some test') end it 'returns nil' do diff --git a/spec/lib/gitlab/ci/config/entry/boolean_spec.rb b/spec/lib/gitlab/ci/config/entry/boolean_spec.rb index 8987c0549c5..5f067cad93c 100644 --- a/spec/lib/gitlab/ci/config/entry/boolean_spec.rb +++ b/spec/lib/gitlab/ci/config/entry/boolean_spec.rb @@ -25,8 +25,8 @@ describe Gitlab::Ci::Config::Entry::Boolean do describe '#errors' do it 'saves errors' do - expect(entry.errors). - to include 'boolean config should be a boolean value' + expect(entry.errors) + .to include 'boolean config should be a boolean value' end end end diff --git a/spec/lib/gitlab/ci/config/entry/cache_spec.rb b/spec/lib/gitlab/ci/config/entry/cache_spec.rb index e91f049ee72..70a327c5183 100644 --- a/spec/lib/gitlab/ci/config/entry/cache_spec.rb +++ b/spec/lib/gitlab/ci/config/entry/cache_spec.rb @@ -32,8 +32,8 @@ describe Gitlab::Ci::Config::Entry::Cache do let(:config) { 'ls' } it 'reports errors with config value' do - expect(entry.errors). - to include 'cache config should be a hash' + expect(entry.errors) + .to include 'cache config should be a hash' end end @@ -41,8 +41,8 @@ describe Gitlab::Ci::Config::Entry::Cache do let(:config) { { key: 1 } } it 'reports error with descendants' do - expect(entry.errors). - to include 'key config should be a string or symbol' + expect(entry.errors) + .to include 'key config should be a string or symbol' end end @@ -50,8 +50,8 @@ describe Gitlab::Ci::Config::Entry::Cache do let(:config) { { invalid: true } } it 'reports error with descendants' do - expect(entry.errors). - to include 'cache config contains unknown keys: invalid' + expect(entry.errors) + .to include 'cache config contains unknown keys: invalid' end end end diff --git a/spec/lib/gitlab/ci/config/entry/commands_spec.rb b/spec/lib/gitlab/ci/config/entry/commands_spec.rb index fa3dbd9bf32..b8b0825a1c7 100644 --- a/spec/lib/gitlab/ci/config/entry/commands_spec.rb +++ b/spec/lib/gitlab/ci/config/entry/commands_spec.rb @@ -40,8 +40,8 @@ describe Gitlab::Ci::Config::Entry::Commands do describe '#errors' do it 'saves errors' do - expect(entry.errors). - to include 'commands config should be a ' \ + expect(entry.errors) + .to include 'commands config should be a ' \ 'string or an array of strings' end end diff --git a/spec/lib/gitlab/ci/config/entry/configurable_spec.rb b/spec/lib/gitlab/ci/config/entry/configurable_spec.rb index 490ba9b7df1..ae7e628b5b5 100644 --- a/spec/lib/gitlab/ci/config/entry/configurable_spec.rb +++ b/spec/lib/gitlab/ci/config/entry/configurable_spec.rb @@ -52,8 +52,8 @@ describe Gitlab::Ci::Config::Entry::Configurable do end it 'creates a node factory' do - expect(entry.nodes[:object]). - to be_an_instance_of Gitlab::Ci::Config::Entry::Factory + expect(entry.nodes[:object]) + .to be_an_instance_of Gitlab::Ci::Config::Entry::Factory end it 'returns a duplicated factory object' do diff --git a/spec/lib/gitlab/ci/config/entry/environment_spec.rb b/spec/lib/gitlab/ci/config/entry/environment_spec.rb index fab2825fbb0..2adbed2154f 100644 --- a/spec/lib/gitlab/ci/config/entry/environment_spec.rb +++ b/spec/lib/gitlab/ci/config/entry/environment_spec.rb @@ -112,8 +112,8 @@ describe Gitlab::Ci::Config::Entry::Environment do describe '#errors' do it 'contains error about invalid action' do - expect(entry.errors). - to include 'environment action should be start or stop' + expect(entry.errors) + .to include 'environment action should be start or stop' end end end @@ -143,8 +143,8 @@ describe Gitlab::Ci::Config::Entry::Environment do describe '#errors' do it 'contains error about invalid action' do - expect(entry.errors). - to include 'environment on stop should be a string' + expect(entry.errors) + .to include 'environment on stop should be a string' end end end @@ -174,8 +174,8 @@ describe Gitlab::Ci::Config::Entry::Environment do describe '#errors' do it 'contains error about invalid type' do - expect(entry.errors). - to include 'environment config should be a hash or a string' + expect(entry.errors) + .to include 'environment config should be a hash or a string' end end end @@ -191,8 +191,8 @@ describe Gitlab::Ci::Config::Entry::Environment do describe '#errors?' do it 'contains error about missing environment name' do - expect(entry.errors). - to include "environment name can't be blank" + expect(entry.errors) + .to include "environment name can't be blank" end end end diff --git a/spec/lib/gitlab/ci/config/entry/factory_spec.rb b/spec/lib/gitlab/ci/config/entry/factory_spec.rb index 281a110071a..00dad5d9591 100644 --- a/spec/lib/gitlab/ci/config/entry/factory_spec.rb +++ b/spec/lib/gitlab/ci/config/entry/factory_spec.rb @@ -7,19 +7,19 @@ describe Gitlab::Ci::Config::Entry::Factory do context 'when setting a concrete value' do it 'creates entry with valid value' do - entry = factory. - value(['ls', 'pwd']). - create! + entry = factory + .value(['ls', 'pwd']) + .create! expect(entry.value).to eq ['ls', 'pwd'] end context 'when setting description' do it 'creates entry with description' do - entry = factory. - value(['ls', 'pwd']). - with(description: 'test description'). - create! + entry = factory + .value(['ls', 'pwd']) + .with(description: 'test description') + .create! expect(entry.value).to eq ['ls', 'pwd'] expect(entry.description).to eq 'test description' @@ -28,10 +28,10 @@ describe Gitlab::Ci::Config::Entry::Factory do context 'when setting key' do it 'creates entry with custom key' do - entry = factory. - value(['ls', 'pwd']). - with(key: 'test key'). - create! + entry = factory + .value(['ls', 'pwd']) + .with(key: 'test key') + .create! expect(entry.key).to eq 'test key' end @@ -41,10 +41,10 @@ describe Gitlab::Ci::Config::Entry::Factory do let(:object) { Object.new } it 'creates entry with valid parent' do - entry = factory. - value('ls'). - with(parent: object). - create! + entry = factory + .value('ls') + .with(parent: object) + .create! expect(entry.parent).to eq object end @@ -61,12 +61,12 @@ describe Gitlab::Ci::Config::Entry::Factory do context 'when creating entry with nil value' do it 'creates an undefined entry' do - entry = factory. - value(nil). - create! + entry = factory + .value(nil) + .create! - expect(entry). - to be_an_instance_of Gitlab::Ci::Config::Entry::Unspecified + expect(entry) + .to be_an_instance_of Gitlab::Ci::Config::Entry::Unspecified end end @@ -74,13 +74,13 @@ describe Gitlab::Ci::Config::Entry::Factory do let(:entry) { spy('entry') } it 'passes metadata as a parameter' do - factory. - value('some value'). - metadata(some: 'hash'). - create! + factory + .value('some value') + .metadata(some: 'hash') + .create! - expect(entry).to have_received(:new). - with('some value', { some: 'hash' }) + expect(entry).to have_received(:new) + .with('some value', { some: 'hash' }) end end end diff --git a/spec/lib/gitlab/ci/config/entry/global_spec.rb b/spec/lib/gitlab/ci/config/entry/global_spec.rb index 3b2d043301e..8a74743eda8 100644 --- a/spec/lib/gitlab/ci/config/entry/global_spec.rb +++ b/spec/lib/gitlab/ci/config/entry/global_spec.rb @@ -10,8 +10,8 @@ describe Gitlab::Ci::Config::Entry::Global do context 'when filtering all the entry/node names' do it 'contains the expected node names' do - expect(described_class.nodes.keys). - to match_array(%i[before_script image services + expect(described_class.nodes.keys) + .to match_array(%i[before_script image services after_script variables stages types cache]) end @@ -44,17 +44,17 @@ describe Gitlab::Ci::Config::Entry::Global do end it 'creates node object using valid class' do - expect(global.descendants.first). - to be_an_instance_of Gitlab::Ci::Config::Entry::Script - expect(global.descendants.second). - to be_an_instance_of Gitlab::Ci::Config::Entry::Image + expect(global.descendants.first) + .to be_an_instance_of Gitlab::Ci::Config::Entry::Script + expect(global.descendants.second) + .to be_an_instance_of Gitlab::Ci::Config::Entry::Image end it 'sets correct description for nodes' do - expect(global.descendants.first.description). - to eq 'Script that will be executed before each job.' - expect(global.descendants.second.description). - to eq 'Docker image that will be used to execute jobs.' + expect(global.descendants.first.description) + .to eq 'Script that will be executed before each job.' + expect(global.descendants.second.description) + .to eq 'Docker image that will be used to execute jobs.' end describe '#leaf?' do @@ -138,8 +138,8 @@ describe Gitlab::Ci::Config::Entry::Global do describe '#cache_value' do it 'returns cache configuration' do - expect(global.cache_value). - to eq(key: 'k', untracked: true, paths: ['public/']) + expect(global.cache_value) + .to eq(key: 'k', untracked: true, paths: ['public/']) end end @@ -185,8 +185,8 @@ describe Gitlab::Ci::Config::Entry::Global do end it 'contains unspecified nodes' do - expect(global.descendants.first). - to be_an_instance_of Gitlab::Ci::Config::Entry::Unspecified + expect(global.descendants.first) + .to be_an_instance_of Gitlab::Ci::Config::Entry::Unspecified end end @@ -246,8 +246,8 @@ describe Gitlab::Ci::Config::Entry::Global do describe '#errors' do it 'reports errors from child nodes' do - expect(global.errors). - to include 'before_script config should be an array of strings' + expect(global.errors) + .to include 'before_script config should be an array of strings' end end @@ -265,8 +265,8 @@ describe Gitlab::Ci::Config::Entry::Global do describe '#errors' do it 'reports errors about missing script' do - expect(global.errors). - to include "jobs:rspec script can't be blank" + expect(global.errors) + .to include "jobs:rspec script can't be blank" end end end @@ -303,16 +303,16 @@ describe Gitlab::Ci::Config::Entry::Global do context 'when entry exists' do it 'returns correct entry' do - expect(global[:cache]). - to be_an_instance_of Gitlab::Ci::Config::Entry::Cache + expect(global[:cache]) + .to be_an_instance_of Gitlab::Ci::Config::Entry::Cache expect(global[:jobs][:rspec][:script].value).to eq ['ls'] end end context 'when entry does not exist' do it 'always return unspecified node' do - expect(global[:some][:unknown][:node]). - not_to be_specified + expect(global[:some][:unknown][:node]) + .not_to be_specified end end end diff --git a/spec/lib/gitlab/ci/config/entry/image_spec.rb b/spec/lib/gitlab/ci/config/entry/image_spec.rb index 062817e07fd..3c99cb0a1ee 100644 --- a/spec/lib/gitlab/ci/config/entry/image_spec.rb +++ b/spec/lib/gitlab/ci/config/entry/image_spec.rb @@ -31,8 +31,8 @@ describe Gitlab::Ci::Config::Entry::Image do describe '#errors' do it 'saves errors' do - expect(entry.errors). - to include 'image config should be a string' + expect(entry.errors) + .to include 'image config should be a string' end end diff --git a/spec/lib/gitlab/ci/config/entry/job_spec.rb b/spec/lib/gitlab/ci/config/entry/job_spec.rb index 82feff0af1c..7a733e6a4a7 100644 --- a/spec/lib/gitlab/ci/config/entry/job_spec.rb +++ b/spec/lib/gitlab/ci/config/entry/job_spec.rb @@ -44,8 +44,8 @@ describe Gitlab::Ci::Config::Entry::Job do describe '#errors' do it 'reports error about a config type' do - expect(entry.errors). - to include 'job config should be a hash' + expect(entry.errors) + .to include 'job config should be a hash' end end end @@ -138,8 +138,8 @@ describe Gitlab::Ci::Config::Entry::Job do end it 'returns correct value' do - expect(entry.value). - to eq(name: :rspec, + expect(entry.value) + .to eq(name: :rspec, before_script: %w[ls pwd], script: %w[rspec], commands: "ls\npwd\nrspec", diff --git a/spec/lib/gitlab/ci/config/entry/jobs_spec.rb b/spec/lib/gitlab/ci/config/entry/jobs_spec.rb index c332b70dc71..aaebf783962 100644 --- a/spec/lib/gitlab/ci/config/entry/jobs_spec.rb +++ b/spec/lib/gitlab/ci/config/entry/jobs_spec.rb @@ -22,8 +22,8 @@ describe Gitlab::Ci::Config::Entry::Jobs do let(:config) { ['incorrect'] } it 'returns error about incorrect type' do - expect(entry.errors). - to include 'jobs config should be a hash' + expect(entry.errors) + .to include 'jobs config should be a hash' end end @@ -39,8 +39,8 @@ describe Gitlab::Ci::Config::Entry::Jobs do let(:config) { { '.hidden'.to_sym => { script: [] } } } it 'returns error about no visible jobs defined' do - expect(entry.errors). - to include 'jobs config should contain at least one visible job' + expect(entry.errors) + .to include 'jobs config should contain at least one visible job' end end end @@ -73,10 +73,10 @@ describe Gitlab::Ci::Config::Entry::Jobs do describe '#descendants' do it 'creates valid descendant nodes' do expect(entry.descendants.count).to eq 3 - expect(entry.descendants.first(2)). - to all(be_an_instance_of(Gitlab::Ci::Config::Entry::Job)) - expect(entry.descendants.last). - to be_an_instance_of(Gitlab::Ci::Config::Entry::Hidden) + expect(entry.descendants.first(2)) + .to all(be_an_instance_of(Gitlab::Ci::Config::Entry::Job)) + expect(entry.descendants.last) + .to be_an_instance_of(Gitlab::Ci::Config::Entry::Hidden) end end diff --git a/spec/lib/gitlab/ci/config/entry/key_spec.rb b/spec/lib/gitlab/ci/config/entry/key_spec.rb index cd7b03ffb11..0dd36fe1f44 100644 --- a/spec/lib/gitlab/ci/config/entry/key_spec.rb +++ b/spec/lib/gitlab/ci/config/entry/key_spec.rb @@ -25,8 +25,8 @@ describe Gitlab::Ci::Config::Entry::Key do describe '#errors' do it 'saves errors' do - expect(entry.errors). - to include 'key config should be a string or symbol' + expect(entry.errors) + .to include 'key config should be a string or symbol' end end end diff --git a/spec/lib/gitlab/ci/config/entry/paths_spec.rb b/spec/lib/gitlab/ci/config/entry/paths_spec.rb index b0ac90f1d94..1d9c5ddee9b 100644 --- a/spec/lib/gitlab/ci/config/entry/paths_spec.rb +++ b/spec/lib/gitlab/ci/config/entry/paths_spec.rb @@ -25,8 +25,8 @@ describe Gitlab::Ci::Config::Entry::Paths do describe '#errors' do it 'saves errors' do - expect(entry.errors). - to include 'paths config should be an array of strings' + expect(entry.errors) + .to include 'paths config should be an array of strings' end end end diff --git a/spec/lib/gitlab/ci/config/entry/script_spec.rb b/spec/lib/gitlab/ci/config/entry/script_spec.rb index 8c1305f376d..aa99cee2690 100644 --- a/spec/lib/gitlab/ci/config/entry/script_spec.rb +++ b/spec/lib/gitlab/ci/config/entry/script_spec.rb @@ -31,8 +31,8 @@ describe Gitlab::Ci::Config::Entry::Script do describe '#errors' do it 'saves errors' do - expect(entry.errors). - to include 'script config should be an array of strings' + expect(entry.errors) + .to include 'script config should be an array of strings' end end diff --git a/spec/lib/gitlab/ci/config/entry/services_spec.rb b/spec/lib/gitlab/ci/config/entry/services_spec.rb index c31a7c0ec3e..66fad3b6b16 100644 --- a/spec/lib/gitlab/ci/config/entry/services_spec.rb +++ b/spec/lib/gitlab/ci/config/entry/services_spec.rb @@ -25,8 +25,8 @@ describe Gitlab::Ci::Config::Entry::Services do describe '#errors' do it 'saves errors' do - expect(entry.errors). - to include 'services config should be an array of strings' + expect(entry.errors) + .to include 'services config should be an array of strings' end end diff --git a/spec/lib/gitlab/ci/config/entry/stage_spec.rb b/spec/lib/gitlab/ci/config/entry/stage_spec.rb index cefef7a805a..70c8a0a355a 100644 --- a/spec/lib/gitlab/ci/config/entry/stage_spec.rb +++ b/spec/lib/gitlab/ci/config/entry/stage_spec.rb @@ -24,8 +24,8 @@ describe Gitlab::Ci::Config::Entry::Stage do let(:config) { { test: true } } it 'reports errors about wrong type' do - expect(stage.errors). - to include 'stage config should be a string' + expect(stage.errors) + .to include 'stage config should be a string' end end end diff --git a/spec/lib/gitlab/ci/config/entry/stages_spec.rb b/spec/lib/gitlab/ci/config/entry/stages_spec.rb index bdcd6c98a85..182c8d867c7 100644 --- a/spec/lib/gitlab/ci/config/entry/stages_spec.rb +++ b/spec/lib/gitlab/ci/config/entry/stages_spec.rb @@ -25,8 +25,8 @@ describe Gitlab::Ci::Config::Entry::Stages do describe '#errors' do it 'saves errors' do - expect(entry.errors). - to include 'stages config should be an array of strings' + expect(entry.errors) + .to include 'stages config should be an array of strings' end end diff --git a/spec/lib/gitlab/ci/config/entry/trigger_spec.rb b/spec/lib/gitlab/ci/config/entry/trigger_spec.rb index 13b00a98b6a..e4ee44f1274 100644 --- a/spec/lib/gitlab/ci/config/entry/trigger_spec.rb +++ b/spec/lib/gitlab/ci/config/entry/trigger_spec.rb @@ -47,8 +47,8 @@ describe Gitlab::Ci::Config::Entry::Trigger do describe '#errors' do it 'saves errors' do - expect(entry.errors). - to include 'trigger config should be an array of strings or regexps' + expect(entry.errors) + .to include 'trigger config should be an array of strings or regexps' end end end diff --git a/spec/lib/gitlab/ci/config/entry/validatable_spec.rb b/spec/lib/gitlab/ci/config/entry/validatable_spec.rb index e31e85538b9..d1856801827 100644 --- a/spec/lib/gitlab/ci/config/entry/validatable_spec.rb +++ b/spec/lib/gitlab/ci/config/entry/validatable_spec.rb @@ -19,8 +19,8 @@ describe Gitlab::Ci::Config::Entry::Validatable do end it 'returns validator' do - expect(entry.validator.superclass). - to be Gitlab::Ci::Config::Entry::Validator + expect(entry.validator.superclass) + .to be Gitlab::Ci::Config::Entry::Validator end it 'returns only one validator to mitigate leaks' do diff --git a/spec/lib/gitlab/ci/config/entry/validator_spec.rb b/spec/lib/gitlab/ci/config/entry/validator_spec.rb index c6e21cd67b0..ad7e6f07d3c 100644 --- a/spec/lib/gitlab/ci/config/entry/validator_spec.rb +++ b/spec/lib/gitlab/ci/config/entry/validator_spec.rb @@ -47,8 +47,8 @@ describe Gitlab::Ci::Config::Entry::Validator do it 'returns errors' do validator_instance.validate - expect(validator_instance.messages). - to include "node test attribute can't be blank" + expect(validator_instance.messages) + .to include "node test attribute can't be blank" end end end diff --git a/spec/lib/gitlab/ci/config/entry/variables_spec.rb b/spec/lib/gitlab/ci/config/entry/variables_spec.rb index c117f35c906..f15f02f403e 100644 --- a/spec/lib/gitlab/ci/config/entry/variables_spec.rb +++ b/spec/lib/gitlab/ci/config/entry/variables_spec.rb @@ -33,8 +33,8 @@ describe Gitlab::Ci::Config::Entry::Variables do describe '#errors' do it 'saves errors' do - expect(entry.errors). - to include /should be a hash of key value pairs/ + expect(entry.errors) + .to include /should be a hash of key value pairs/ end end diff --git a/spec/lib/gitlab/ci/status/build/common_spec.rb b/spec/lib/gitlab/ci/status/build/common_spec.rb index cd893a09748..40b96b1807b 100644 --- a/spec/lib/gitlab/ci/status/build/common_spec.rb +++ b/spec/lib/gitlab/ci/status/build/common_spec.rb @@ -6,9 +6,9 @@ describe Gitlab::Ci::Status::Build::Common do let(:project) { build.project } subject do - Gitlab::Ci::Status::Core. - new(build, user). - extend(described_class) + Gitlab::Ci::Status::Core + .new(build, user) + .extend(described_class) end describe '#has_action?' do diff --git a/spec/lib/gitlab/ci/status/build/factory_spec.rb b/spec/lib/gitlab/ci/status/build/factory_spec.rb index aa026a66460..16f0a7b5388 100644 --- a/spec/lib/gitlab/ci/status/build/factory_spec.rb +++ b/spec/lib/gitlab/ci/status/build/factory_spec.rb @@ -16,8 +16,8 @@ describe Gitlab::Ci::Status::Build::Factory do end it 'matches correct extended statuses' do - expect(factory.extended_statuses). - to eq [Gitlab::Ci::Status::Build::Retryable] + expect(factory.extended_statuses) + .to eq [Gitlab::Ci::Status::Build::Retryable] end it 'fabricates a retryable build status' do @@ -42,8 +42,8 @@ describe Gitlab::Ci::Status::Build::Factory do end it 'matches correct extended statuses' do - expect(factory.extended_statuses). - to eq [Gitlab::Ci::Status::Build::Retryable] + expect(factory.extended_statuses) + .to eq [Gitlab::Ci::Status::Build::Retryable] end it 'fabricates a retryable build status' do @@ -67,8 +67,8 @@ describe Gitlab::Ci::Status::Build::Factory do end it 'matches correct extended statuses' do - expect(factory.extended_statuses). - to eq [Gitlab::Ci::Status::Build::Retryable, + expect(factory.extended_statuses) + .to eq [Gitlab::Ci::Status::Build::Retryable, Gitlab::Ci::Status::Build::FailedAllowed] end @@ -96,8 +96,8 @@ describe Gitlab::Ci::Status::Build::Factory do end it 'matches correct extended statuses' do - expect(factory.extended_statuses). - to eq [Gitlab::Ci::Status::Build::Retryable] + expect(factory.extended_statuses) + .to eq [Gitlab::Ci::Status::Build::Retryable] end it 'fabricates a retryable build status' do @@ -121,8 +121,8 @@ describe Gitlab::Ci::Status::Build::Factory do end it 'matches correct extended statuses' do - expect(factory.extended_statuses). - to eq [Gitlab::Ci::Status::Build::Cancelable] + expect(factory.extended_statuses) + .to eq [Gitlab::Ci::Status::Build::Cancelable] end it 'fabricates a canceable build status' do @@ -146,8 +146,8 @@ describe Gitlab::Ci::Status::Build::Factory do end it 'matches correct extended statuses' do - expect(factory.extended_statuses). - to eq [Gitlab::Ci::Status::Build::Cancelable] + expect(factory.extended_statuses) + .to eq [Gitlab::Ci::Status::Build::Cancelable] end it 'fabricates a cancelable build status' do @@ -196,8 +196,8 @@ describe Gitlab::Ci::Status::Build::Factory do end it 'matches correct extended statuses' do - expect(factory.extended_statuses). - to eq [Gitlab::Ci::Status::Build::Play] + expect(factory.extended_statuses) + .to eq [Gitlab::Ci::Status::Build::Play] end it 'fabricates a core skipped status' do @@ -222,8 +222,8 @@ describe Gitlab::Ci::Status::Build::Factory do end it 'matches correct extended statuses' do - expect(factory.extended_statuses). - to eq [Gitlab::Ci::Status::Build::Stop] + expect(factory.extended_statuses) + .to eq [Gitlab::Ci::Status::Build::Stop] end it 'fabricates a core skipped status' do diff --git a/spec/lib/gitlab/ci/status/extended_spec.rb b/spec/lib/gitlab/ci/status/extended_spec.rb index 459044eb968..c2d74ca5cde 100644 --- a/spec/lib/gitlab/ci/status/extended_spec.rb +++ b/spec/lib/gitlab/ci/status/extended_spec.rb @@ -6,7 +6,7 @@ describe Gitlab::Ci::Status::Extended do end it 'requires subclass to implement matcher' do - expect { subject.matches?(double, double) }. - to raise_error(NotImplementedError) + expect { subject.matches?(double, double) } + .to raise_error(NotImplementedError) end end diff --git a/spec/lib/gitlab/ci/status/external/common_spec.rb b/spec/lib/gitlab/ci/status/external/common_spec.rb index 6a564eeb8b7..5a97d98b55f 100644 --- a/spec/lib/gitlab/ci/status/external/common_spec.rb +++ b/spec/lib/gitlab/ci/status/external/common_spec.rb @@ -10,9 +10,9 @@ describe Gitlab::Ci::Status::External::Common do end subject do - Gitlab::Ci::Status::Core. - new(external_status, user). - extend(described_class) + Gitlab::Ci::Status::Core + .new(external_status, user) + .extend(described_class) end describe '#has_action?' do diff --git a/spec/lib/gitlab/ci/status/factory_spec.rb b/spec/lib/gitlab/ci/status/factory_spec.rb index 45fd49b91ea..bbf9c7c83a3 100644 --- a/spec/lib/gitlab/ci/status/factory_spec.rb +++ b/spec/lib/gitlab/ci/status/factory_spec.rb @@ -84,15 +84,15 @@ describe Gitlab::Ci::Status::Factory do end it 'matches correct extended statuses' do - expect(factory.extended_statuses). - to eq [first_extended_status, second_extended_status] + expect(factory.extended_statuses) + .to eq [first_extended_status, second_extended_status] end end context 'when exclusive statuses are matches' do before do - allow(described_class).to receive(:extended_statuses). - and_return([[first_extended_status, second_extended_status]]) + allow(described_class).to receive(:extended_statuses) + .and_return([[first_extended_status, second_extended_status]]) end it 'does not fabricate compound decorator' do @@ -116,8 +116,8 @@ describe Gitlab::Ci::Status::Factory do context 'when exclusive statuses are not matched' do before do - allow(described_class).to receive(:extended_statuses). - and_return([[first_extended_status], [second_extended_status]]) + allow(described_class).to receive(:extended_statuses) + .and_return([[first_extended_status], [second_extended_status]]) end it_behaves_like 'compound decorator factory' @@ -125,8 +125,8 @@ describe Gitlab::Ci::Status::Factory do context 'when using simplified status grouping' do before do - allow(described_class).to receive(:extended_statuses). - and_return([first_extended_status, second_extended_status]) + allow(described_class).to receive(:extended_statuses) + .and_return([first_extended_status, second_extended_status]) end it_behaves_like 'compound decorator factory' diff --git a/spec/lib/gitlab/ci/status/pipeline/common_spec.rb b/spec/lib/gitlab/ci/status/pipeline/common_spec.rb index 35dad60febf..d665674bf70 100644 --- a/spec/lib/gitlab/ci/status/pipeline/common_spec.rb +++ b/spec/lib/gitlab/ci/status/pipeline/common_spec.rb @@ -6,9 +6,9 @@ describe Gitlab::Ci::Status::Pipeline::Common do let(:pipeline) { create(:ci_pipeline, project: project) } subject do - Gitlab::Ci::Status::Core. - new(pipeline, user). - extend(described_class) + Gitlab::Ci::Status::Core + .new(pipeline, user) + .extend(described_class) end describe '#has_action?' do @@ -29,8 +29,8 @@ describe Gitlab::Ci::Status::Pipeline::Common do describe '#details_path' do it 'links to the pipeline details page' do - expect(subject.details_path). - to include "pipelines/#{pipeline.id}" + expect(subject.details_path) + .to include "pipelines/#{pipeline.id}" end end end diff --git a/spec/lib/gitlab/ci/status/pipeline/factory_spec.rb b/spec/lib/gitlab/ci/status/pipeline/factory_spec.rb index 7cee4435931..b10a447c27a 100644 --- a/spec/lib/gitlab/ci/status/pipeline/factory_spec.rb +++ b/spec/lib/gitlab/ci/status/pipeline/factory_spec.rb @@ -34,8 +34,8 @@ describe Gitlab::Ci::Status::Pipeline::Factory do it 'extends core status with common pipeline methods' do expect(status).to have_details expect(status).not_to have_action - expect(status.details_path). - to include "pipelines/#{pipeline.id}" + expect(status.details_path) + .to include "pipelines/#{pipeline.id}" end end end @@ -55,8 +55,8 @@ describe Gitlab::Ci::Status::Pipeline::Factory do end it 'matches correct extended statuses' do - expect(factory.extended_statuses). - to eq [Gitlab::Ci::Status::SuccessWarning] + expect(factory.extended_statuses) + .to eq [Gitlab::Ci::Status::SuccessWarning] end it 'fabricates extended "success with warnings" status' do diff --git a/spec/lib/gitlab/ci/status/stage/common_spec.rb b/spec/lib/gitlab/ci/status/stage/common_spec.rb index 3b25893d8c7..8814a7614a0 100644 --- a/spec/lib/gitlab/ci/status/stage/common_spec.rb +++ b/spec/lib/gitlab/ci/status/stage/common_spec.rb @@ -10,8 +10,8 @@ describe Gitlab::Ci::Status::Stage::Common do end subject do - Class.new(Gitlab::Ci::Status::Core). - new(stage, user).extend(described_class) + Class.new(Gitlab::Ci::Status::Core) + .new(stage, user).extend(described_class) end it 'does not have action' do @@ -19,10 +19,10 @@ describe Gitlab::Ci::Status::Stage::Common do end it 'links to the pipeline details page' do - expect(subject.details_path). - to include "pipelines/#{pipeline.id}" - expect(subject.details_path). - to include "##{stage.name}" + expect(subject.details_path) + .to include "pipelines/#{pipeline.id}" + expect(subject.details_path) + .to include "##{stage.name}" end context 'when user has permission to read pipeline' do diff --git a/spec/lib/gitlab/ci/status/stage/factory_spec.rb b/spec/lib/gitlab/ci/status/stage/factory_spec.rb index c8503392b34..bbb40e2c1ab 100644 --- a/spec/lib/gitlab/ci/status/stage/factory_spec.rb +++ b/spec/lib/gitlab/ci/status/stage/factory_spec.rb @@ -55,8 +55,8 @@ describe Gitlab::Ci::Status::Stage::Factory do end it 'fabricates extended "success with warnings" status' do - expect(status). - to be_a Gitlab::Ci::Status::SuccessWarning + expect(status) + .to be_a Gitlab::Ci::Status::SuccessWarning end it 'extends core status with common stage method' do diff --git a/spec/lib/gitlab/closing_issue_extractor_spec.rb b/spec/lib/gitlab/closing_issue_extractor_spec.rb index 97af1c2523d..ca68010cb89 100644 --- a/spec/lib/gitlab/closing_issue_extractor_spec.rb +++ b/spec/lib/gitlab/closing_issue_extractor_spec.rb @@ -306,58 +306,58 @@ describe Gitlab::ClosingIssueExtractor, lib: true do it 'fetches issues in single line message' do message = "Closes #{reference} and fix #{reference2}" - expect(subject.closed_by_message(message)). - to match_array([issue, other_issue]) + expect(subject.closed_by_message(message)) + .to match_array([issue, other_issue]) end it 'fetches comma-separated issues references in single line message' do message = "Closes #{reference}, closes #{reference2}" - expect(subject.closed_by_message(message)). - to match_array([issue, other_issue]) + expect(subject.closed_by_message(message)) + .to match_array([issue, other_issue]) end it 'fetches comma-separated issues numbers in single line message' do message = "Closes #{reference}, #{reference2} and #{reference3}" - expect(subject.closed_by_message(message)). - to match_array([issue, other_issue, third_issue]) + expect(subject.closed_by_message(message)) + .to match_array([issue, other_issue, third_issue]) end it 'fetches issues in multi-line message' do message = "Awesome commit (closes #{reference})\nAlso fixes #{reference2}" - expect(subject.closed_by_message(message)). - to match_array([issue, other_issue]) + expect(subject.closed_by_message(message)) + .to match_array([issue, other_issue]) end it 'fetches issues in hybrid message' do message = "Awesome commit (closes #{reference})\n"\ "Also fixing issues #{reference2}, #{reference3} and #4" - expect(subject.closed_by_message(message)). - to match_array([issue, other_issue, third_issue]) + expect(subject.closed_by_message(message)) + .to match_array([issue, other_issue, third_issue]) end it "fetches cross-project references" do message = "Closes #{reference} and #{cross_reference}" - expect(subject.closed_by_message(message)). - to match_array([issue, issue2]) + expect(subject.closed_by_message(message)) + .to match_array([issue, issue2]) end it "fetches cross-project URL references" do message = "Closes #{urls.namespace_project_issue_url(issue2.project.namespace, issue2.project, issue2)} and #{reference}" - expect(subject.closed_by_message(message)). - to match_array([issue, issue2]) + expect(subject.closed_by_message(message)) + .to match_array([issue, issue2]) end it "ignores invalid cross-project URL references" do message = "Closes https://google.com#{urls.namespace_project_issue_path(issue2.project.namespace, issue2.project, issue2)} and #{reference}" - expect(subject.closed_by_message(message)). - to match_array([issue]) + expect(subject.closed_by_message(message)) + .to match_array([issue]) end end end diff --git a/spec/lib/gitlab/conflict/file_spec.rb b/spec/lib/gitlab/conflict/file_spec.rb index fbf679c5215..3a24aff7fa9 100644 --- a/spec/lib/gitlab/conflict/file_spec.rb +++ b/spec/lib/gitlab/conflict/file_spec.rb @@ -43,8 +43,8 @@ describe Gitlab::Conflict::File, lib: true do end it 'returns a file containing only the chosen parts of the resolved sections' do - expect(resolved_lines.chunk { |line| line.type || 'both' }.map(&:first)). - to eq(['both', 'new', 'both', 'old', 'both', 'new', 'both']) + expect(resolved_lines.chunk { |line| line.type || 'both' }.map(&:first)) + .to eq(['both', 'new', 'both', 'old', 'both', 'new', 'both']) end end @@ -52,14 +52,14 @@ describe Gitlab::Conflict::File, lib: true do empty_hash = section_keys.map { |key| [key, nil] }.to_h invalid_hash = section_keys.map { |key| [key, 'invalid'] }.to_h - expect { conflict_file.resolve_lines({}) }. - to raise_error(Gitlab::Conflict::File::MissingResolution) + expect { conflict_file.resolve_lines({}) } + .to raise_error(Gitlab::Conflict::File::MissingResolution) - expect { conflict_file.resolve_lines(empty_hash) }. - to raise_error(Gitlab::Conflict::File::MissingResolution) + expect { conflict_file.resolve_lines(empty_hash) } + .to raise_error(Gitlab::Conflict::File::MissingResolution) - expect { conflict_file.resolve_lines(invalid_hash) }. - to raise_error(Gitlab::Conflict::File::MissingResolution) + expect { conflict_file.resolve_lines(invalid_hash) } + .to raise_error(Gitlab::Conflict::File::MissingResolution) end end @@ -250,8 +250,8 @@ FILE describe '#as_json' do it 'includes the blob path for the file' do - expect(conflict_file.as_json[:blob_path]). - to eq("/#{project.namespace.to_param}/#{merge_request.project.to_param}/blob/#{our_commit.oid}/files/ruby/regex.rb") + expect(conflict_file.as_json[:blob_path]) + .to eq("/#{project.namespace.to_param}/#{merge_request.project.to_param}/blob/#{our_commit.oid}/files/ruby/regex.rb") end it 'includes the blob icon for the file' do @@ -264,8 +264,8 @@ FILE end it 'includes the detected language of the conflict file' do - expect(conflict_file.as_json(full_content: true)[:blob_ace_mode]). - to eq('ruby') + expect(conflict_file.as_json(full_content: true)[:blob_ace_mode]) + .to eq('ruby') end end end diff --git a/spec/lib/gitlab/conflict/parser_spec.rb b/spec/lib/gitlab/conflict/parser_spec.rb index 16eb3766356..ca4bdcc3672 100644 --- a/spec/lib/gitlab/conflict/parser_spec.rb +++ b/spec/lib/gitlab/conflict/parser_spec.rb @@ -121,72 +121,72 @@ CONFLICT context 'when the file contents include conflict delimiters' do it 'raises UnexpectedDelimiter when there is a non-start delimiter first' do - expect { parse_text('=======') }. - to raise_error(Gitlab::Conflict::Parser::UnexpectedDelimiter) + expect { parse_text('=======') } + .to raise_error(Gitlab::Conflict::Parser::UnexpectedDelimiter) - expect { parse_text('>>>>>>> README.md') }. - to raise_error(Gitlab::Conflict::Parser::UnexpectedDelimiter) + expect { parse_text('>>>>>>> README.md') } + .to raise_error(Gitlab::Conflict::Parser::UnexpectedDelimiter) - expect { parse_text('>>>>>>> some-other-path.md') }. - not_to raise_error + expect { parse_text('>>>>>>> some-other-path.md') } + .not_to raise_error end it 'raises UnexpectedDelimiter when a start delimiter is followed by a non-middle delimiter' do start_text = "<<<<<<< README.md\n" end_text = "\n=======\n>>>>>>> README.md" - expect { parse_text(start_text + '>>>>>>> README.md' + end_text) }. - to raise_error(Gitlab::Conflict::Parser::UnexpectedDelimiter) + expect { parse_text(start_text + '>>>>>>> README.md' + end_text) } + .to raise_error(Gitlab::Conflict::Parser::UnexpectedDelimiter) - expect { parse_text(start_text + start_text + end_text) }. - to raise_error(Gitlab::Conflict::Parser::UnexpectedDelimiter) + expect { parse_text(start_text + start_text + end_text) } + .to raise_error(Gitlab::Conflict::Parser::UnexpectedDelimiter) - expect { parse_text(start_text + '>>>>>>> some-other-path.md' + end_text) }. - not_to raise_error + expect { parse_text(start_text + '>>>>>>> some-other-path.md' + end_text) } + .not_to raise_error end it 'raises UnexpectedDelimiter when a middle delimiter is followed by a non-end delimiter' do start_text = "<<<<<<< README.md\n=======\n" end_text = "\n>>>>>>> README.md" - expect { parse_text(start_text + '=======' + end_text) }. - to raise_error(Gitlab::Conflict::Parser::UnexpectedDelimiter) + expect { parse_text(start_text + '=======' + end_text) } + .to raise_error(Gitlab::Conflict::Parser::UnexpectedDelimiter) - expect { parse_text(start_text + start_text + end_text) }. - to raise_error(Gitlab::Conflict::Parser::UnexpectedDelimiter) + expect { parse_text(start_text + start_text + end_text) } + .to raise_error(Gitlab::Conflict::Parser::UnexpectedDelimiter) - expect { parse_text(start_text + '>>>>>>> some-other-path.md' + end_text) }. - not_to raise_error + expect { parse_text(start_text + '>>>>>>> some-other-path.md' + end_text) } + .not_to raise_error end it 'raises MissingEndDelimiter when there is no end delimiter at the end' do start_text = "<<<<<<< README.md\n=======\n" - expect { parse_text(start_text) }. - to raise_error(Gitlab::Conflict::Parser::MissingEndDelimiter) + expect { parse_text(start_text) } + .to raise_error(Gitlab::Conflict::Parser::MissingEndDelimiter) - expect { parse_text(start_text + '>>>>>>> some-other-path.md') }. - to raise_error(Gitlab::Conflict::Parser::MissingEndDelimiter) + expect { parse_text(start_text + '>>>>>>> some-other-path.md') } + .to raise_error(Gitlab::Conflict::Parser::MissingEndDelimiter) end end context 'other file types' do it 'raises UnmergeableFile when lines is blank, indicating a binary file' do - expect { parse_text('') }. - to raise_error(Gitlab::Conflict::Parser::UnmergeableFile) + expect { parse_text('') } + .to raise_error(Gitlab::Conflict::Parser::UnmergeableFile) - expect { parse_text(nil) }. - to raise_error(Gitlab::Conflict::Parser::UnmergeableFile) + expect { parse_text(nil) } + .to raise_error(Gitlab::Conflict::Parser::UnmergeableFile) end it 'raises UnmergeableFile when the file is over 200 KB' do - expect { parse_text('a' * 204801) }. - to raise_error(Gitlab::Conflict::Parser::UnmergeableFile) + expect { parse_text('a' * 204801) } + .to raise_error(Gitlab::Conflict::Parser::UnmergeableFile) end it 'raises UnsupportedEncoding when the file contains non-UTF-8 characters' do - expect { parse_text("a\xC4\xFC".force_encoding(Encoding::ASCII_8BIT)) }. - to raise_error(Gitlab::Conflict::Parser::UnsupportedEncoding) + expect { parse_text("a\xC4\xFC".force_encoding(Encoding::ASCII_8BIT)) } + .to raise_error(Gitlab::Conflict::Parser::UnsupportedEncoding) end end end diff --git a/spec/lib/gitlab/data_builder/note_spec.rb b/spec/lib/gitlab/data_builder/note_spec.rb index 7658153df0b..04ec34492e1 100644 --- a/spec/lib/gitlab/data_builder/note_spec.rb +++ b/spec/lib/gitlab/data_builder/note_spec.rb @@ -9,8 +9,8 @@ describe Gitlab::DataBuilder::Note, lib: true do before(:each) do expect(data).to have_key(:object_attributes) expect(data[:object_attributes]).to have_key(:url) - expect(data[:object_attributes][:url]). - to eq(Gitlab::UrlBuilder.build(note)) + expect(data[:object_attributes][:url]) + .to eq(Gitlab::UrlBuilder.build(note)) expect(data[:object_kind]).to eq('note') expect(data[:user]).to eq(user.hook_attrs) end @@ -49,10 +49,10 @@ describe Gitlab::DataBuilder::Note, lib: true do it 'returns the note and issue-specific data' do expect(data).to have_key(:issue) - expect(data[:issue].except('updated_at')). - to eq(issue.reload.hook_attrs.except('updated_at')) - expect(data[:issue]['updated_at']). - to be > issue.hook_attrs['updated_at'] + expect(data[:issue].except('updated_at')) + .to eq(issue.reload.hook_attrs.except('updated_at')) + expect(data[:issue]['updated_at']) + .to be > issue.hook_attrs['updated_at'] end include_examples 'project hook data' @@ -73,10 +73,10 @@ describe Gitlab::DataBuilder::Note, lib: true do it 'returns the note and merge request data' do expect(data).to have_key(:merge_request) - expect(data[:merge_request].except('updated_at')). - to eq(merge_request.reload.hook_attrs.except('updated_at')) - expect(data[:merge_request]['updated_at']). - to be > merge_request.hook_attrs['updated_at'] + expect(data[:merge_request].except('updated_at')) + .to eq(merge_request.reload.hook_attrs.except('updated_at')) + expect(data[:merge_request]['updated_at']) + .to be > merge_request.hook_attrs['updated_at'] end include_examples 'project hook data' @@ -96,10 +96,10 @@ describe Gitlab::DataBuilder::Note, lib: true do it 'returns the note and merge request diff data' do expect(data).to have_key(:merge_request) - expect(data[:merge_request].except('updated_at')). - to eq(merge_request.reload.hook_attrs.except('updated_at')) - expect(data[:merge_request]['updated_at']). - to be > merge_request.hook_attrs['updated_at'] + expect(data[:merge_request].except('updated_at')) + .to eq(merge_request.reload.hook_attrs.except('updated_at')) + expect(data[:merge_request]['updated_at']) + .to be > merge_request.hook_attrs['updated_at'] end include_examples 'project hook data' @@ -119,10 +119,10 @@ describe Gitlab::DataBuilder::Note, lib: true do it 'returns the note and project snippet data' do expect(data).to have_key(:snippet) - expect(data[:snippet].except('updated_at')). - to eq(snippet.reload.hook_attrs.except('updated_at')) - expect(data[:snippet]['updated_at']). - to be > snippet.hook_attrs['updated_at'] + expect(data[:snippet].except('updated_at')) + .to eq(snippet.reload.hook_attrs.except('updated_at')) + expect(data[:snippet]['updated_at']) + .to be > snippet.hook_attrs['updated_at'] end include_examples 'project hook data' diff --git a/spec/lib/gitlab/data_builder/push_spec.rb b/spec/lib/gitlab/data_builder/push_spec.rb index dbcfb9b7400..019d7d75814 100644 --- a/spec/lib/gitlab/data_builder/push_spec.rb +++ b/spec/lib/gitlab/data_builder/push_spec.rb @@ -46,8 +46,8 @@ describe Gitlab::DataBuilder::Push, lib: true do include_examples 'deprecated repository hook data' it 'does not raise an error when given nil commits' do - expect { described_class.build(spy, spy, spy, spy, spy, nil) }. - not_to raise_error + expect { described_class.build(spy, spy, spy, spy, spy, nil) } + .not_to raise_error end end end diff --git a/spec/lib/gitlab/database/migration_helpers_spec.rb b/spec/lib/gitlab/database/migration_helpers_spec.rb index e007044868c..511b4a988aa 100644 --- a/spec/lib/gitlab/database/migration_helpers_spec.rb +++ b/spec/lib/gitlab/database/migration_helpers_spec.rb @@ -22,15 +22,15 @@ describe Gitlab::Database::MigrationHelpers, lib: true do end it 'creates the index concurrently' do - expect(model).to receive(:add_index). - with(:users, :foo, algorithm: :concurrently) + expect(model).to receive(:add_index) + .with(:users, :foo, algorithm: :concurrently) model.add_concurrent_index(:users, :foo) end it 'creates unique index concurrently' do - expect(model).to receive(:add_index). - with(:users, :foo, { algorithm: :concurrently, unique: true }) + expect(model).to receive(:add_index) + .with(:users, :foo, { algorithm: :concurrently, unique: true }) model.add_concurrent_index(:users, :foo, unique: true) end @@ -40,8 +40,8 @@ describe Gitlab::Database::MigrationHelpers, lib: true do it 'creates a regular index' do expect(Gitlab::Database).to receive(:postgresql?).and_return(false) - expect(model).to receive(:add_index). - with(:users, :foo, {}) + expect(model).to receive(:add_index) + .with(:users, :foo, {}) model.add_concurrent_index(:users, :foo) end @@ -52,8 +52,8 @@ describe Gitlab::Database::MigrationHelpers, lib: true do it 'raises RuntimeError' do expect(model).to receive(:transaction_open?).and_return(true) - expect { model.add_concurrent_index(:users, :foo) }. - to raise_error(RuntimeError) + expect { model.add_concurrent_index(:users, :foo) } + .to raise_error(RuntimeError) end end end @@ -78,8 +78,8 @@ describe Gitlab::Database::MigrationHelpers, lib: true do it 'creates a regular foreign key' do allow(Gitlab::Database).to receive(:mysql?).and_return(true) - expect(model).to receive(:add_foreign_key). - with(:projects, :users, column: :user_id, on_delete: :cascade) + expect(model).to receive(:add_foreign_key) + .with(:projects, :users, column: :user_id, on_delete: :cascade) model.add_concurrent_foreign_key(:projects, :users, column: :user_id) end @@ -171,16 +171,16 @@ describe Gitlab::Database::MigrationHelpers, lib: true do expect(model).to receive(:transaction).and_yield - expect(model).to receive(:add_column). - with(:projects, :foo, :integer, default: nil) + expect(model).to receive(:add_column) + .with(:projects, :foo, :integer, default: nil) - expect(model).to receive(:change_column_default). - with(:projects, :foo, 10) + expect(model).to receive(:change_column_default) + .with(:projects, :foo, 10) end it 'adds the column while allowing NULL values' do - expect(model).to receive(:update_column_in_batches). - with(:projects, :foo, 10) + expect(model).to receive(:update_column_in_batches) + .with(:projects, :foo, 10) expect(model).not_to receive(:change_column_null) @@ -190,22 +190,22 @@ describe Gitlab::Database::MigrationHelpers, lib: true do end it 'adds the column while not allowing NULL values' do - expect(model).to receive(:update_column_in_batches). - with(:projects, :foo, 10) + expect(model).to receive(:update_column_in_batches) + .with(:projects, :foo, 10) - expect(model).to receive(:change_column_null). - with(:projects, :foo, false) + expect(model).to receive(:change_column_null) + .with(:projects, :foo, false) model.add_column_with_default(:projects, :foo, :integer, default: 10) end it 'removes the added column whenever updating the rows fails' do - expect(model).to receive(:update_column_in_batches). - with(:projects, :foo, 10). - and_raise(RuntimeError) + expect(model).to receive(:update_column_in_batches) + .with(:projects, :foo, 10) + .and_raise(RuntimeError) - expect(model).to receive(:remove_column). - with(:projects, :foo) + expect(model).to receive(:remove_column) + .with(:projects, :foo) expect do model.add_column_with_default(:projects, :foo, :integer, default: 10) @@ -213,12 +213,12 @@ describe Gitlab::Database::MigrationHelpers, lib: true do end it 'removes the added column whenever changing a column NULL constraint fails' do - expect(model).to receive(:change_column_null). - with(:projects, :foo, false). - and_raise(RuntimeError) + expect(model).to receive(:change_column_null) + .with(:projects, :foo, false) + .and_raise(RuntimeError) - expect(model).to receive(:remove_column). - with(:projects, :foo) + expect(model).to receive(:remove_column) + .with(:projects, :foo) expect do model.add_column_with_default(:projects, :foo, :integer, default: 10) @@ -234,8 +234,8 @@ describe Gitlab::Database::MigrationHelpers, lib: true do allow(model).to receive(:change_column_null).with(:projects, :foo, false) allow(model).to receive(:change_column_default).with(:projects, :foo, 10) - expect(model).to receive(:add_column). - with(:projects, :foo, :integer, default: nil, limit: 8) + expect(model).to receive(:add_column) + .with(:projects, :foo, :integer, default: nil, limit: 8) model.add_column_with_default(:projects, :foo, :integer, default: 10, limit: 8) end diff --git a/spec/lib/gitlab/database_spec.rb b/spec/lib/gitlab/database_spec.rb index 5eff7e8425b..053ce1d9e68 100644 --- a/spec/lib/gitlab/database_spec.rb +++ b/spec/lib/gitlab/database_spec.rb @@ -28,8 +28,8 @@ describe Gitlab::Database, lib: true do describe '.version' do context "on mysql" do it "extracts the version number" do - allow(described_class).to receive(:database_version). - and_return("5.7.12-standard") + allow(described_class).to receive(:database_version) + .and_return("5.7.12-standard") expect(described_class.version).to eq '5.7.12-standard' end @@ -37,8 +37,8 @@ describe Gitlab::Database, lib: true do context "on postgresql" do it "extracts the version number" do - allow(described_class).to receive(:database_version). - and_return("PostgreSQL 9.4.4 on x86_64-apple-darwin14.3.0") + allow(described_class).to receive(:database_version) + .and_return("PostgreSQL 9.4.4 on x86_64-apple-darwin14.3.0") expect(described_class.version).to eq '9.4.4' end @@ -120,8 +120,8 @@ describe Gitlab::Database, lib: true do pool = described_class.create_connection_pool(5) begin - expect(pool). - to be_kind_of(ActiveRecord::ConnectionAdapters::ConnectionPool) + expect(pool) + .to be_kind_of(ActiveRecord::ConnectionAdapters::ConnectionPool) expect(pool.spec.config[:pool]).to eq(5) ensure diff --git a/spec/lib/gitlab/downtime_check_spec.rb b/spec/lib/gitlab/downtime_check_spec.rb index 42d895e548e..1f1e4e0216c 100644 --- a/spec/lib/gitlab/downtime_check_spec.rb +++ b/spec/lib/gitlab/downtime_check_spec.rb @@ -11,12 +11,12 @@ describe Gitlab::DowntimeCheck do context 'when a migration does not specify if downtime is required' do it 'raises RuntimeError' do - expect(subject).to receive(:class_for_migration_file). - with(path). - and_return(Class.new) + expect(subject).to receive(:class_for_migration_file) + .with(path) + .and_return(Class.new) - expect { subject.check([path]) }. - to raise_error(RuntimeError, /it requires downtime/) + expect { subject.check([path]) } + .to raise_error(RuntimeError, /it requires downtime/) end end @@ -25,12 +25,12 @@ describe Gitlab::DowntimeCheck do it 'raises RuntimeError' do stub_const('TestMigration::DOWNTIME', true) - expect(subject).to receive(:class_for_migration_file). - with(path). - and_return(TestMigration) + expect(subject).to receive(:class_for_migration_file) + .with(path) + .and_return(TestMigration) - expect { subject.check([path]) }. - to raise_error(RuntimeError, /no reason was given/) + expect { subject.check([path]) } + .to raise_error(RuntimeError, /no reason was given/) end end @@ -39,9 +39,9 @@ describe Gitlab::DowntimeCheck do stub_const('TestMigration::DOWNTIME', true) stub_const('TestMigration::DOWNTIME_REASON', 'foo') - expect(subject).to receive(:class_for_migration_file). - with(path). - and_return(TestMigration) + expect(subject).to receive(:class_for_migration_file) + .with(path) + .and_return(TestMigration) messages = subject.check([path]) @@ -65,9 +65,9 @@ describe Gitlab::DowntimeCheck do expect(subject).to receive(:require).with(path) - expect(subject).to receive(:class_for_migration_file). - with(path). - and_return(TestMigration) + expect(subject).to receive(:class_for_migration_file) + .with(path) + .and_return(TestMigration) expect(subject).to receive(:puts).with(an_instance_of(String)) diff --git a/spec/lib/gitlab/email/reply_parser_spec.rb b/spec/lib/gitlab/email/reply_parser_spec.rb index 28698e89c33..02ff2a46c48 100644 --- a/spec/lib/gitlab/email/reply_parser_spec.rb +++ b/spec/lib/gitlab/email/reply_parser_spec.rb @@ -20,8 +20,8 @@ describe Gitlab::Email::ReplyParser, lib: true do end it "properly renders plaintext-only email" do - expect(test_parse_body(fixture_file("emails/plaintext_only.eml"))). - to eq( + expect(test_parse_body(fixture_file("emails/plaintext_only.eml"))) + .to eq( <<-BODY.strip_heredoc.chomp ### reply from default mail client in Windows 8.1 Metro @@ -46,8 +46,8 @@ describe Gitlab::Email::ReplyParser, lib: true do end it "handles multiple paragraphs" do - expect(test_parse_body(fixture_file("emails/paragraphs.eml"))). - to eq( + expect(test_parse_body(fixture_file("emails/paragraphs.eml"))) + .to eq( <<-BODY.strip_heredoc.chomp Is there any reason the *old* candy can't be be kept in silos while the new candy is imported into *new* silos? @@ -61,8 +61,8 @@ describe Gitlab::Email::ReplyParser, lib: true do end it "handles multiple paragraphs when parsing html" do - expect(test_parse_body(fixture_file("emails/html_paragraphs.eml"))). - to eq( + expect(test_parse_body(fixture_file("emails/html_paragraphs.eml"))) + .to eq( <<-BODY.strip_heredoc.chomp Awesome! @@ -74,8 +74,8 @@ describe Gitlab::Email::ReplyParser, lib: true do end it "handles newlines" do - expect(test_parse_body(fixture_file("emails/newlines.eml"))). - to eq( + expect(test_parse_body(fixture_file("emails/newlines.eml"))) + .to eq( <<-BODY.strip_heredoc.chomp This is my reply. It is my best reply. @@ -85,8 +85,8 @@ describe Gitlab::Email::ReplyParser, lib: true do end it "handles inline reply" do - expect(test_parse_body(fixture_file("emails/inline_reply.eml"))). - to eq( + expect(test_parse_body(fixture_file("emails/inline_reply.eml"))) + .to eq( <<-BODY.strip_heredoc.chomp > techAPJ