diff options
191 files changed, 886 insertions, 884 deletions
diff --git a/.rubocop.yml b/.rubocop.yml index 2eebe73313b..b72bcf8a34a 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -163,11 +163,6 @@ Style/DefWithParentheses: Style/Documentation: Enabled: false -# This cop checks the . position in multi-line method calls. -Style/DotPosition: - Enabled: true - EnforcedStyle: trailing - # This cop checks for uses of double negation (!!) to convert something # to a boolean value. As this is both cryptic and usually redundant, it # should be avoided. diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 8bc7d568c10..c24142c0a11 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -63,7 +63,7 @@ Rails/SkipsModelValidations: # Cop supports --auto-correct. Security/YAMLLoad: Enabled: false - + # Offense count: 55 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle, SupportedStyles. @@ -71,6 +71,13 @@ Security/YAMLLoad: Style/BarePercentLiterals: Enabled: false +# Offense count: 1304 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, SupportedStyles. +# SupportedStyles: leading, trailing +Style/DotPosition: + Enabled: false + # Offense count: 6 # Cop supports --auto-correct. Style/EachWithObject: 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/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/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/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/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/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/compare_controller.rb b/app/controllers/projects/compare_controller.rb index 99204c82784..c6651254d70 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 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/merge_requests_controller.rb b/app/controllers/projects/merge_requests_controller.rb index 5ee7972e29e..d122c7fdcb2 100644 --- a/app/controllers/projects/merge_requests_controller.rb +++ b/app/controllers/projects/merge_requests_controller.rb @@ -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? @@ -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_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/users_controller.rb b/app/controllers/users_controller.rb index c92594d4097..6e29f1e8a65 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -118,8 +118,8 @@ class UsersController < ApplicationController 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/models/ci/build.rb b/app/models/ci/build.rb index 2689078c771..16d4f3b4f1b 100644 --- a/app/models/ci/build.rb +++ b/app/models/ci/build.rb @@ -65,9 +65,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 @@ -98,9 +98,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? @@ -222,9 +222,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) diff --git a/app/models/ci/pipeline.rb b/app/models/ci/pipeline.rb index 04d43ca3c5c..80e11a5b58f 100644 --- a/app/models/ci/pipeline.rb +++ b/app/models/ci/pipeline.rb @@ -91,9 +91,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)) @@ -135,16 +135,16 @@ module Ci 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)]) @@ -220,8 +220,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) @@ -353,15 +353,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..4863c34a6a6 100644 --- a/app/models/ci/runner.rb +++ b/app/models/ci/runner.rb @@ -23,8 +23,8 @@ 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 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 1349beafb76..fc750a3e5e9 100644 --- a/app/models/commit_status.rb +++ b/app/models/commit_status.rb @@ -97,8 +97,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 @@ -132,9 +132,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/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/subscribable.rb b/app/models/concerns/subscribable.rb index e4f5818d0e3..83daa9b1a64 100644 --- a/app/models/concerns/subscribable.rb +++ b/app/models/concerns/subscribable.rb @@ -42,15 +42,15 @@ module Subscribable 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 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..240a17f1dc1 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 diff --git a/app/models/label.rb b/app/models/label.rb index 27429e60e4a..f68a8c9cff2 100644 --- a/app/models/label.rb +++ b/app/models/label.rb @@ -34,9 +34,9 @@ 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) 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 abe9aee3edf..0545bd4eedf 100644 --- a/app/models/member.rb +++ b/app/models/member.rb @@ -41,9 +41,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) } diff --git a/app/models/merge_request.rb b/app/models/merge_request.rb index ea784f77015..d5eb44aeeb8 100644 --- a/app/models/merge_request.rb +++ b/app/models/merge_request.rb @@ -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/namespace.rb b/app/models/namespace.rb index e207ac3db4e..bd0336c984a 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', 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/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_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/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/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/git_push_service.rb b/app/services/git_push_service.rb index f681f831cbd..dbe2fda27b5 100644 --- a/app/services/git_push_service.rb +++ b/app/services/git_push_service.rb @@ -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/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/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/refresh_service.rb b/app/services/merge_requests/refresh_service.rb index edee3032683..581d18032e6 100644 --- a/app/services/merge_requests/refresh_service.rb +++ b/app/services/merge_requests/refresh_service.rb @@ -60,9 +60,9 @@ module MergeRequests 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/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/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/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/pipelines.rb b/lib/api/pipelines.rb index 02e397a681c..3afc1e385fe 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/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..8e3b0c4db79 100644 --- a/lib/banzai/reference_extractor.rb +++ b/lib/banzai/reference_extractor.rb @@ -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/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..a4ec8f0ff2f 100644 --- a/lib/gitlab/ci/config/entry/global.rb +++ b/lib/gitlab/ci/config/entry/global.rb @@ -46,10 +46,10 @@ module Gitlab private def compose_jobs! - factory = Entry::Factory.new(Entry::Jobs). - value(@config.except(*self.class.nodes.keys)). - with(key: :jobs, parent: self, - description: 'Jobs definition for this pipeline') + 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! end diff --git a/lib/gitlab/ci/config/entry/jobs.rb b/lib/gitlab/ci/config/entry/jobs.rb index 7b83f0f1b69..5671a09480b 100644 --- a/lib/gitlab/ci/config/entry/jobs.rb +++ b/lib/gitlab/ci/config/entry/jobs.rb @@ -31,11 +31,11 @@ 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, - description: "#{name} job definition.") + factory = Entry::Factory.new(node) + .value(config || {}) + .metadata(name: name) + .with(key: name, parent: self, + description: "#{name} job definition.") @entries[name] = factory.create! 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/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/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/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/projects/merge_requests_controller_spec.rb b/spec/controllers/projects/merge_requests_controller_spec.rb index e631e5fa5e7..af13649eec5 100644 --- a/spec/controllers/projects/merge_requests_controller_spec.rb +++ b/spec/controllers/projects/merge_requests_controller_spec.rb @@ -335,9 +335,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 diff --git a/spec/controllers/sessions_controller_spec.rb b/spec/controllers/sessions_controller_spec.rb index d951325f765..b56c7880b64 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 @@ -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 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/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/projects/pipelines/pipelines_spec.rb b/spec/features/projects/pipelines/pipelines_spec.rb index 81f5ebf6339..592dc4483d2 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/issues_helper_spec.rb b/spec/helpers/issues_helper_spec.rb index 1204d5c9888..88d853935c7 100644 --- a/spec/helpers/issues_helper_spec.rb +++ b/spec/helpers/issues_helper_spec.rb @@ -67,8 +67,8 @@ describe IssuesHelper do user = build_stubbed(:user, name: 'Joe') awards = Array.new(3, build_stubbed(:award_emoji, user: user)) - expect(award_user_list(awards, nil, limit: 3)). - to eq('Joe, Joe, and Joe') + expect(award_user_list(awards, nil, limit: 3)) + .to eq('Joe, Joe, and Joe') end it "displays the current user's name as 'You'" do @@ -83,8 +83,8 @@ describe IssuesHelper do user = build_stubbed(:user, name: 'Jane') awards = Array.new(5, build_stubbed(:award_emoji, user: user)) - expect(award_user_list(awards, nil, limit: 3)). - to eq('Jane, Jane, Jane, and 2 more.') + expect(award_user_list(awards, nil, limit: 3)) + .to eq('Jane, Jane, Jane, and 2 more.') end it "displays the current user in front of other users" do diff --git a/spec/helpers/page_layout_helper_spec.rb b/spec/helpers/page_layout_helper_spec.rb index 9d7a39d3721..2cc0b40b2d0 100644 --- a/spec/helpers/page_layout_helper_spec.rb +++ b/spec/helpers/page_layout_helper_spec.rb @@ -111,8 +111,8 @@ describe PageLayoutHelper do end it 'escapes content' do - allow(helper).to receive(:page_card_attributes). - and_return(foo: %q{foo" http-equiv="refresh}.html_safe) + allow(helper).to receive(:page_card_attributes) + .and_return(foo: %q{foo" http-equiv="refresh}.html_safe) tags = helper.page_card_meta_tags diff --git a/spec/helpers/visibility_level_helper_spec.rb b/spec/helpers/visibility_level_helper_spec.rb index 387279b2031..8942b00b128 100644 --- a/spec/helpers/visibility_level_helper_spec.rb +++ b/spec/helpers/visibility_level_helper_spec.rb @@ -9,52 +9,52 @@ describe VisibilityLevelHelper do describe 'visibility_level_description' do context 'used with a Project' do it 'delegates projects to #project_visibility_level_description' do - expect(visibility_level_description(Gitlab::VisibilityLevel::PRIVATE, project)). - to match /project/i + expect(visibility_level_description(Gitlab::VisibilityLevel::PRIVATE, project)) + .to match /project/i end end context 'used with a Group' do it 'delegates groups to #group_visibility_level_description' do - expect(visibility_level_description(Gitlab::VisibilityLevel::PRIVATE, group)). - to match /group/i + expect(visibility_level_description(Gitlab::VisibilityLevel::PRIVATE, group)) + .to match /group/i end end context 'called with a Snippet' do it 'delegates snippets to #snippet_visibility_level_description' do - expect(visibility_level_description(Gitlab::VisibilityLevel::INTERNAL, project_snippet)). - to match /snippet/i + expect(visibility_level_description(Gitlab::VisibilityLevel::INTERNAL, project_snippet)) + .to match /snippet/i end end end describe "#project_visibility_level_description" do it "describes private projects" do - expect(project_visibility_level_description(Gitlab::VisibilityLevel::PRIVATE)). - to eq "Project access must be granted explicitly to each user." + expect(project_visibility_level_description(Gitlab::VisibilityLevel::PRIVATE)) + .to eq "Project access must be granted explicitly to each user." end it "describes public projects" do - expect(project_visibility_level_description(Gitlab::VisibilityLevel::PUBLIC)). - to eq "The project can be cloned without any authentication." + expect(project_visibility_level_description(Gitlab::VisibilityLevel::PUBLIC)) + .to eq "The project can be cloned without any authentication." end end describe "#snippet_visibility_level_description" do it 'describes visibility only for me' do - expect(snippet_visibility_level_description(Gitlab::VisibilityLevel::PRIVATE, personal_snippet)). - to eq "The snippet is visible only to me." + expect(snippet_visibility_level_description(Gitlab::VisibilityLevel::PRIVATE, personal_snippet)) + .to eq "The snippet is visible only to me." end it 'describes visibility for project members' do - expect(snippet_visibility_level_description(Gitlab::VisibilityLevel::PRIVATE, project_snippet)). - to eq "The snippet is visible only to project members." + expect(snippet_visibility_level_description(Gitlab::VisibilityLevel::PRIVATE, project_snippet)) + .to eq "The snippet is visible only to project members." end it 'defaults to personal snippet' do - expect(snippet_visibility_level_description(Gitlab::VisibilityLevel::PRIVATE)). - to eq "The snippet is visible only to me." + expect(snippet_visibility_level_description(Gitlab::VisibilityLevel::PRIVATE)) + .to eq "The snippet is visible only to me." end end diff --git a/spec/lib/api/helpers/pagination_spec.rb b/spec/lib/api/helpers/pagination_spec.rb index 152c36a3ae6..267318faed4 100644 --- a/spec/lib/api/helpers/pagination_spec.rb +++ b/spec/lib/api/helpers/pagination_spec.rb @@ -37,8 +37,8 @@ describe API::Helpers::Pagination do describe 'first page' do before do - allow(subject).to receive(:params). - and_return({ page: 1, per_page: 2 }) + allow(subject).to receive(:params) + .and_return({ page: 1, per_page: 2 }) end it 'returns appropriate amount of resources' do @@ -60,8 +60,8 @@ describe API::Helpers::Pagination do describe 'second page' do before do - allow(subject).to receive(:params). - and_return({ page: 2, per_page: 2 }) + allow(subject).to receive(:params) + .and_return({ page: 2, per_page: 2 }) end it 'returns appropriate amount of resources' do @@ -87,8 +87,8 @@ describe API::Helpers::Pagination do end def expect_message(method) - expect(subject).to receive(method). - at_least(:once).and_return(value) + expect(subject).to receive(method) + .at_least(:once).and_return(value) end end end diff --git a/spec/lib/banzai/filter/external_issue_reference_filter_spec.rb b/spec/lib/banzai/filter/external_issue_reference_filter_spec.rb index efd145e9452..fbf7a461fa5 100644 --- a/spec/lib/banzai/filter/external_issue_reference_filter_spec.rb +++ b/spec/lib/banzai/filter/external_issue_reference_filter_spec.rb @@ -33,8 +33,8 @@ describe Banzai::Filter::ExternalIssueReferenceFilter, lib: true do doc = filter("Issue #{reference}") issue_id = doc.css('a').first.attr("data-external-issue") - expect(doc.css('a').first.attr('href')). - to eq helper.url_for_issue(issue_id, project) + expect(doc.css('a').first.attr('href')) + .to eq helper.url_for_issue(issue_id, project) end it 'links to the external tracker' do diff --git a/spec/lib/banzai/filter/label_reference_filter_spec.rb b/spec/lib/banzai/filter/label_reference_filter_spec.rb index 5e16fd10ebe..284641fb20a 100644 --- a/spec/lib/banzai/filter/label_reference_filter_spec.rb +++ b/spec/lib/banzai/filter/label_reference_filter_spec.rb @@ -372,8 +372,8 @@ describe Banzai::Filter::LabelReferenceFilter, lib: true do let!(:result) { reference_filter("See #{reference}") } it 'links to a valid reference' do - expect(result.css('a').first.attr('href')). - to eq urls.namespace_project_issues_url(project2.namespace, + expect(result.css('a').first.attr('href')) + .to eq urls.namespace_project_issues_url(project2.namespace, project2, label_name: label.name) end @@ -406,8 +406,8 @@ describe Banzai::Filter::LabelReferenceFilter, lib: true do let!(:result) { reference_filter("See #{reference}") } it 'links to a valid reference' do - expect(result.css('a').first.attr('href')). - to eq urls.namespace_project_issues_url(project2.namespace, + expect(result.css('a').first.attr('href')) + .to eq urls.namespace_project_issues_url(project2.namespace, project2, label_name: label.name) end @@ -440,8 +440,8 @@ describe Banzai::Filter::LabelReferenceFilter, lib: true do let!(:result) { reference_filter("See #{reference}") } it 'links to a valid reference' do - expect(result.css('a').first.attr('href')). - to eq urls.namespace_project_issues_url(project2.namespace, + expect(result.css('a').first.attr('href')) + .to eq urls.namespace_project_issues_url(project2.namespace, project2, label_name: label.name) end @@ -476,8 +476,8 @@ describe Banzai::Filter::LabelReferenceFilter, lib: true do let!(:result) { reference_filter("See #{reference}", project: project) } it 'points to referenced project issues page' do - expect(result.css('a').first.attr('href')). - to eq urls.namespace_project_issues_url(another_project.namespace, + expect(result.css('a').first.attr('href')) + .to eq urls.namespace_project_issues_url(another_project.namespace, another_project, label_name: group_label.name) end @@ -549,15 +549,15 @@ describe Banzai::Filter::LabelReferenceFilter, lib: true do let!(:result) { reference_filter("See #{reference}", project: project) } it 'points to referenced project issues page' do - expect(result.css('a').first.attr('href')). - to eq urls.namespace_project_issues_url(project.namespace, + expect(result.css('a').first.attr('href')) + .to eq urls.namespace_project_issues_url(project.namespace, project, label_name: group_label.name) end it 'has valid color' do - expect(result.css('a span').first.attr('style')). - to match /background-color: #00ff00/ + expect(result.css('a span').first.attr('style')) + .to match /background-color: #00ff00/ end it 'has valid link text' do @@ -583,8 +583,8 @@ describe Banzai::Filter::LabelReferenceFilter, lib: true do let!(:result) { reference_filter("See #{reference}", project: project) } it 'points to referenced project issues page' do - expect(result.css('a').first.attr('href')). - to eq urls.namespace_project_issues_url(project.namespace, + expect(result.css('a').first.attr('href')) + .to eq urls.namespace_project_issues_url(project.namespace, project, label_name: group_label.name) end diff --git a/spec/lib/banzai/filter/user_reference_filter_spec.rb b/spec/lib/banzai/filter/user_reference_filter_spec.rb index e9b7b566806..d5d128c1907 100644 --- a/spec/lib/banzai/filter/user_reference_filter_spec.rb +++ b/spec/lib/banzai/filter/user_reference_filter_spec.rb @@ -37,8 +37,8 @@ describe Banzai::Filter::UserReferenceFilter, lib: true do doc = reference_filter("Hey #{reference}", author: user) expect(doc.css('a').length).to eq 1 - expect(doc.css('a').first.attr('href')). - to eq urls.namespace_project_url(project.namespace, project) + expect(doc.css('a').first.attr('href')) + .to eq urls.namespace_project_url(project.namespace, project) end it 'includes a data-author attribute when there is an author' do diff --git a/spec/lib/ci/gitlab_ci_yaml_processor_spec.rb b/spec/lib/ci/gitlab_ci_yaml_processor_spec.rb index ae3253777c3..7145f0da1d3 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/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 1da145e7b68..a7ee7f53a6b 100644 --- a/spec/lib/gitlab/bitbucket_import/importer_spec.rb +++ b/spec/lib/gitlab/bitbucket_import/importer_spec.rb @@ -89,8 +89,8 @@ describe Gitlab::BitbucketImport::Importer, lib: true do 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: {}) + body: "", + headers: {}) sample_issues_statuses.each_with_index do |issue, index| stub_request( 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 8fe82bc2ebd..afa4a089418 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 5c5ce2d6f39..3395b3c645b 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(%w(ls pwd)). - create! + entry = factory + .value(%w(ls pwd)) + .create! expect(entry.value).to eq %w(ls pwd) end context 'when setting description' do it 'creates entry with description' do - entry = factory. - value(%w(ls pwd)). - with(description: 'test description'). - create! + entry = factory + .value(%w(ls pwd)) + .with(description: 'test description') + .create! expect(entry.value).to eq %w(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(%w(ls pwd)). - with(key: 'test key'). - create! + entry = factory + .value(%w(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 67a6b3cc98d..ebd80ac5e1d 100644 --- a/spec/lib/gitlab/ci/config/entry/global_spec.rb +++ b/spec/lib/gitlab/ci/config/entry/global_spec.rb @@ -10,10 +10,10 @@ 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 - after_script variables stages - types cache]) + expect(described_class.nodes.keys) + .to match_array(%i[before_script image services + after_script variables stages + types cache]) end end 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..d20f4ec207d 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,13 +138,13 @@ describe Gitlab::Ci::Config::Entry::Job do end it 'returns correct value' do - expect(entry.value). - to eq(name: :rspec, - before_script: %w[ls pwd], - script: %w[rspec], - commands: "ls\npwd\nrspec", - stage: 'test', - after_script: %w[cleanup]) + expect(entry.value) + .to eq(name: :rspec, + before_script: %w[ls pwd], + script: %w[rspec], + commands: "ls\npwd\nrspec", + stage: 'test', + after_script: %w[cleanup]) end end end 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 49cca49509c..069eaa26422 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..0c40fca0c1a 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,9 +67,9 @@ 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, - Gitlab::Ci::Status::Build::FailedAllowed] + expect(factory.extended_statuses) + .to eq [Gitlab::Ci::Status::Build::Retryable, + Gitlab::Ci::Status::Build::FailedAllowed] end it 'fabricates a failed but allowed build status' do @@ -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/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/database_spec.rb b/spec/lib/gitlab/database_spec.rb index 5eff7e8425b..edd01d032c8 100644 --- a/spec/lib/gitlab/database_spec.rb +++ b/spec/lib/gitlab/database_spec.rb @@ -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/import_export/avatar_restorer_spec.rb b/spec/lib/gitlab/import_export/avatar_restorer_spec.rb index c141762421f..08a42fd27a2 100644 --- a/spec/lib/gitlab/import_export/avatar_restorer_spec.rb +++ b/spec/lib/gitlab/import_export/avatar_restorer_spec.rb @@ -7,8 +7,8 @@ describe Gitlab::ImportExport::AvatarRestorer, lib: true do let(:project) { create(:empty_project) } before do - allow_any_instance_of(described_class).to receive(:avatar_export_file). - and_return(uploaded_image_temp_path) + allow_any_instance_of(described_class).to receive(:avatar_export_file) + .and_return(uploaded_image_temp_path) end after do diff --git a/spec/lib/gitlab/incoming_email_spec.rb b/spec/lib/gitlab/incoming_email_spec.rb index d54753ccf90..698bd72d0f8 100644 --- a/spec/lib/gitlab/incoming_email_spec.rb +++ b/spec/lib/gitlab/incoming_email_spec.rb @@ -99,10 +99,10 @@ describe Gitlab::IncomingEmail, lib: true do end it 'returns reply key' do - expect(described_class.scan_fallback_references(references)). - to eq(%w[issue_1@localhost - reply-59d8df8370b7e95c5a49fbf86aeb2c93@localhost - exchange@microsoft.com]) + expect(described_class.scan_fallback_references(references)) + .to eq(%w[issue_1@localhost + reply-59d8df8370b7e95c5a49fbf86aeb2c93@localhost + exchange@microsoft.com]) end end end diff --git a/spec/lib/gitlab/ldap/adapter_spec.rb b/spec/lib/gitlab/ldap/adapter_spec.rb index fe3709f30e1..563c074017a 100644 --- a/spec/lib/gitlab/ldap/adapter_spec.rb +++ b/spec/lib/gitlab/ldap/adapter_spec.rb @@ -34,8 +34,8 @@ describe Gitlab::LDAP::Adapter, lib: true do end it 'searches with the proper options when searching with a limit' do - expect(adapter). - to receive(:ldap_search).with(hash_including(size: 100)).and_return({}) + expect(adapter) + .to receive(:ldap_search).with(hash_including(size: 100)).and_return({}) adapter.users('uid', 'johndoe', 100) end diff --git a/spec/lib/gitlab/o_auth/user_spec.rb b/spec/lib/gitlab/o_auth/user_spec.rb index 4de5991db37..c49d2b286ff 100644 --- a/spec/lib/gitlab/o_auth/user_spec.rb +++ b/spec/lib/gitlab/o_auth/user_spec.rb @@ -188,8 +188,8 @@ describe Gitlab::OAuth::User, lib: true do oauth_user.save identities_as_hash = gl_user.identities.map { |id| { provider: id.provider, extern_uid: id.extern_uid } } - expect(identities_as_hash). - to match_array( + expect(identities_as_hash) + .to match_array( [ { provider: 'ldapmain', extern_uid: 'uid=user1,ou=People,dc=example' }, { provider: 'twitter', extern_uid: uid } diff --git a/spec/lib/gitlab/serializer/pagination_spec.rb b/spec/lib/gitlab/serializer/pagination_spec.rb index e05160da7a6..519eb1b274f 100644 --- a/spec/lib/gitlab/serializer/pagination_spec.rb +++ b/spec/lib/gitlab/serializer/pagination_spec.rb @@ -6,11 +6,11 @@ describe Gitlab::Serializer::Pagination do let(:headers) { spy('headers') } before do - allow(request).to receive(:query_parameters). - and_return(params) + allow(request).to receive(:query_parameters) + .and_return(params) - allow(response).to receive(:headers). - and_return(headers) + allow(response).to receive(:headers) + .and_return(headers) end let(:pagination) { described_class.new(request, response) } diff --git a/spec/models/application_setting_spec.rb b/spec/models/application_setting_spec.rb index 8688639168b..4086e00e363 100644 --- a/spec/models/application_setting_spec.rb +++ b/spec/models/application_setting_spec.rb @@ -32,9 +32,9 @@ describe ApplicationSetting, models: true do it { is_expected.to validate_presence_of(:max_attachment_size) } it do - is_expected.to validate_numericality_of(:max_attachment_size). - only_integer. - is_greater_than(0) + is_expected.to validate_numericality_of(:max_attachment_size) + .only_integer + .is_greater_than(0) end it_behaves_like 'an object with email-formated attributes', :admin_notification_email do diff --git a/spec/models/ci/build_spec.rb b/spec/models/ci/build_spec.rb index a173e3aeff6..63b6c3c65a6 100644 --- a/spec/models/ci/build_spec.rb +++ b/spec/models/ci/build_spec.rb @@ -212,15 +212,15 @@ describe Ci::Build, :models do retried_rspec = Ci::Build.retry(rspec_test, user) - expect(staging.depends_on_builds.map(&:id)). - to contain_exactly(build.id, retried_rspec.id, rubocop_test.id) + expect(staging.depends_on_builds.map(&:id)) + .to contain_exactly(build.id, retried_rspec.id, rubocop_test.id) end end describe '#detailed_status' do it 'returns a detailed status' do - expect(build.detailed_status(user)). - to be_a Gitlab::Ci::Status::Build::Cancelable + expect(build.detailed_status(user)) + .to be_a Gitlab::Ci::Status::Build::Cancelable end end @@ -1151,8 +1151,8 @@ describe Ci::Build, :models do let!(:build) { create(:ci_build, artifacts_size: 23) } it 'updates project statistics when the artifact size changes' do - expect(ProjectCacheWorker).to receive(:perform_async). - with(build.project_id, [], [:build_artifacts_size]) + expect(ProjectCacheWorker).to receive(:perform_async) + .with(build.project_id, [], [:build_artifacts_size]) build.artifacts_size = 42 build.save! @@ -1166,8 +1166,8 @@ describe Ci::Build, :models do end it 'updates project statistics when the build is destroyed' do - expect(ProjectCacheWorker).to receive(:perform_async). - with(build.project_id, [], [:build_artifacts_size]) + expect(ProjectCacheWorker).to receive(:perform_async) + .with(build.project_id, [], [:build_artifacts_size]) build.destroy end diff --git a/spec/models/commit_status_spec.rb b/spec/models/commit_status_spec.rb index f770e6a9e34..36533bdd11e 100644 --- a/spec/models/commit_status_spec.rb +++ b/spec/models/commit_status_spec.rb @@ -253,8 +253,8 @@ describe CommitStatus, :models do let(:user) { create(:user) } it 'returns a detailed status' do - expect(commit_status.detailed_status(user)). - to be_a Gitlab::Ci::Status::Success + expect(commit_status.detailed_status(user)) + .to be_a Gitlab::Ci::Status::Success end end diff --git a/spec/models/email_spec.rb b/spec/models/email_spec.rb index 4652af1cb97..fe4de1b2afb 100644 --- a/spec/models/email_spec.rb +++ b/spec/models/email_spec.rb @@ -8,7 +8,7 @@ describe Email, models: true do end it 'normalize email value' do - expect(described_class.new(email: ' inFO@exAMPLe.com ').email). - to eq 'info@example.com' + expect(described_class.new(email: ' inFO@exAMPLe.com ').email) + .to eq 'info@example.com' end end diff --git a/spec/models/group_label_spec.rb b/spec/models/group_label_spec.rb index c8d88022ec7..555a876daeb 100644 --- a/spec/models/group_label_spec.rb +++ b/spec/models/group_label_spec.rb @@ -49,8 +49,8 @@ describe GroupLabel, models: true do context 'using invalid format' do it 'raises error' do - expect { label.to_reference(format: :invalid) }. - to raise_error StandardError, /Unknown format/ + expect { label.to_reference(format: :invalid) } + .to raise_error StandardError, /Unknown format/ end end end diff --git a/spec/models/lfs_objects_project_spec.rb b/spec/models/lfs_objects_project_spec.rb index a2031beeab2..7bc278e350f 100644 --- a/spec/models/lfs_objects_project_spec.rb +++ b/spec/models/lfs_objects_project_spec.rb @@ -18,8 +18,8 @@ describe LfsObjectsProject, models: true do describe '#update_project_statistics' do it 'updates project statistics when the object is added' do - expect(ProjectCacheWorker).to receive(:perform_async). - with(project.id, [], [:lfs_objects_size]) + expect(ProjectCacheWorker).to receive(:perform_async) + .with(project.id, [], [:lfs_objects_size]) subject.save! end @@ -27,8 +27,8 @@ describe LfsObjectsProject, models: true do it 'updates project statistics when the object is removed' do subject.save! - expect(ProjectCacheWorker).to receive(:perform_async). - with(project.id, [], [:lfs_objects_size]) + expect(ProjectCacheWorker).to receive(:perform_async) + .with(project.id, [], [:lfs_objects_size]) subject.destroy end diff --git a/spec/models/merge_request_diff_spec.rb b/spec/models/merge_request_diff_spec.rb index e74e4ae0e96..0a10ee01506 100644 --- a/spec/models/merge_request_diff_spec.rb +++ b/spec/models/merge_request_diff_spec.rb @@ -84,8 +84,8 @@ describe MergeRequestDiff, models: true do end it 'saves overflow state' do - allow(Commit).to receive(:max_diff_options). - and_return(max_lines: 0, max_files: 0) + allow(Commit).to receive(:max_diff_options) + .and_return(max_lines: 0, max_files: 0) mr_diff = create(:merge_request).merge_request_diff @@ -93,8 +93,8 @@ describe MergeRequestDiff, models: true do end it 'saves empty state' do - allow_any_instance_of(MergeRequestDiff).to receive(:commits). - and_return([]) + allow_any_instance_of(MergeRequestDiff).to receive(:commits) + .and_return([]) mr_diff = create(:merge_request).merge_request_diff diff --git a/spec/models/merge_request_spec.rb b/spec/models/merge_request_spec.rb index 810c08256dc..a01741a9971 100644 --- a/spec/models/merge_request_spec.rb +++ b/spec/models/merge_request_spec.rb @@ -412,15 +412,15 @@ describe MergeRequest, models: true do it 'includes merge information as the title' do request = build(:merge_request, source_branch: 'source', target_branch: 'target') - expect(request.merge_commit_message). - to match("Merge branch 'source' into 'target'\n\n") + expect(request.merge_commit_message) + .to match("Merge branch 'source' into 'target'\n\n") end it 'includes its title in the body' do request = build(:merge_request, title: 'Remove all technical debt') - expect(request.merge_commit_message). - to match("Remove all technical debt\n\n") + expect(request.merge_commit_message) + .to match("Remove all technical debt\n\n") end it 'includes its closed issues in the body' do @@ -432,15 +432,15 @@ describe MergeRequest, models: true do allow(subject.project).to receive(:default_branch). and_return(subject.target_branch) - expect(subject.merge_commit_message). - to match("Closes #{issue.to_reference}") + expect(subject.merge_commit_message) + .to match("Closes #{issue.to_reference}") end it 'includes its reference in the body' do request = build_stubbed(:merge_request) - expect(request.merge_commit_message). - to match("See merge request #{request.to_reference}") + expect(request.merge_commit_message) + .to match("See merge request #{request.to_reference}") end it 'excludes multiple linebreak runs when description is blank' do @@ -452,15 +452,15 @@ describe MergeRequest, models: true do it 'includes its description in the body' do request = build(:merge_request, description: 'By removing all code') - expect(request.merge_commit_message(include_description: true)). - to match("By removing all code\n\n") + expect(request.merge_commit_message(include_description: true)) + .to match("By removing all code\n\n") end it 'does not includes its description in the body' do request = build(:merge_request, description: 'By removing all code') - expect(request.merge_commit_message). - not_to match("By removing all code\n\n") + expect(request.merge_commit_message) + .not_to match("By removing all code\n\n") end end diff --git a/spec/models/project_label_spec.rb b/spec/models/project_label_spec.rb index 3e9dd3758ed..9cdbfa44e5b 100644 --- a/spec/models/project_label_spec.rb +++ b/spec/models/project_label_spec.rb @@ -94,8 +94,8 @@ describe ProjectLabel, models: true do context 'using invalid format' do it 'raises error' do - expect { label.to_reference(format: :invalid) }. - to raise_error StandardError, /Unknown format/ + expect { label.to_reference(format: :invalid) } + .to raise_error StandardError, /Unknown format/ end end @@ -104,15 +104,15 @@ describe ProjectLabel, models: true do context 'using name' do it 'returns cross reference with label name' do - expect(label.to_reference(project, format: :name)). - to eq %Q(#{label.project.path_with_namespace}~"#{label.name}") + expect(label.to_reference(project, format: :name)) + .to eq %Q(#{label.project.path_with_namespace}~"#{label.name}") end end context 'using id' do it 'returns cross reference with label id' do - expect(label.to_reference(project, format: :id)). - to eq %Q(#{label.project.path_with_namespace}~#{label.id}) + expect(label.to_reference(project, format: :id)) + .to eq %Q(#{label.project.path_with_namespace}~#{label.id}) end end end diff --git a/spec/models/repository_spec.rb b/spec/models/repository_spec.rb index a3fe412b229..43aac31d8b7 100644 --- a/spec/models/repository_spec.rb +++ b/spec/models/repository_spec.rb @@ -265,8 +265,8 @@ describe Repository, models: true do describe '#commit' do context 'when ref exists' do it 'returns commit object' do - expect(repository.commit('master')). - to be_an_instance_of Commit + expect(repository.commit('master')) + .to be_an_instance_of Commit end end diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index d7aa7754834..b69fd24c586 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -1146,8 +1146,8 @@ describe User, models: true do user = create(:user) project = create(:empty_project, :private, namespace: user.namespace) - expect(user.authorized_projects(Gitlab::Access::REPORTER)). - to contain_exactly(project) + expect(user.authorized_projects(Gitlab::Access::REPORTER)) + .to contain_exactly(project) end it 'includes projects for which the user is a master' do @@ -1156,8 +1156,8 @@ describe User, models: true do project.team << [user, Gitlab::Access::MASTER] - expect(user.authorized_projects(Gitlab::Access::REPORTER)). - to contain_exactly(project) + expect(user.authorized_projects(Gitlab::Access::REPORTER)) + .to contain_exactly(project) end end diff --git a/spec/requests/api/broadcast_messages_spec.rb b/spec/requests/api/broadcast_messages_spec.rb index 576eb80605b..921d8714173 100644 --- a/spec/requests/api/broadcast_messages_spec.rb +++ b/spec/requests/api/broadcast_messages_spec.rb @@ -27,8 +27,8 @@ describe API::BroadcastMessages, api: true do expect(response).to have_http_status(200) expect(response).to include_pagination_headers expect(json_response).to be_kind_of(Array) - expect(json_response.first.keys). - to match_array(%w(id message starts_at ends_at color font active)) + expect(json_response.first.keys) + .to match_array(%w(id message starts_at ends_at color font active)) end end @@ -52,8 +52,8 @@ describe API::BroadcastMessages, api: true do expect(response).to have_http_status(200) expect(json_response['id']).to eq message.id - expect(json_response.keys). - to match_array(%w(id message starts_at ends_at color font active)) + expect(json_response.keys) + .to match_array(%w(id message starts_at ends_at color font active)) end end @@ -174,8 +174,8 @@ describe API::BroadcastMessages, api: true do end it 'deletes the broadcast message for admins' do - expect { delete api("/broadcast_messages/#{message.id}", admin) }. - to change { BroadcastMessage.count }.by(-1) + expect { delete api("/broadcast_messages/#{message.id}", admin) } + .to change { BroadcastMessage.count }.by(-1) end end end diff --git a/spec/requests/api/commit_statuses_spec.rb b/spec/requests/api/commit_statuses_spec.rb index eface28976e..81a8856b8f1 100644 --- a/spec/requests/api/commit_statuses_spec.rb +++ b/spec/requests/api/commit_statuses_spec.rb @@ -207,8 +207,8 @@ describe API::CommitStatuses, api: true do it 'responds with bad request status and validation errors' do expect(response).to have_http_status(400) - expect(json_response['message']['target_url']). - to include 'must be a valid URL' + expect(json_response['message']['target_url']) + .to include 'must be a valid URL' end end end diff --git a/spec/requests/api/groups_spec.rb b/spec/requests/api/groups_spec.rb index b82372b1b60..9c3a92bedbd 100644 --- a/spec/requests/api/groups_spec.rb +++ b/spec/requests/api/groups_spec.rb @@ -36,8 +36,8 @@ describe API::Groups, api: true do expect(response).to include_pagination_headers expect(json_response).to be_an Array expect(json_response.length).to eq(1) - expect(json_response). - to satisfy_one { |group| group['name'] == group1.name } + expect(json_response) + .to satisfy_one { |group| group['name'] == group1.name } end it "does not include statistics" do @@ -84,8 +84,8 @@ describe API::Groups, api: true do expect(response).to have_http_status(200) expect(response).to include_pagination_headers expect(json_response).to be_an Array - expect(json_response). - to satisfy_one { |group| group['statistics'] == attributes } + expect(json_response) + .to satisfy_one { |group| group['statistics'] == attributes } end end diff --git a/spec/requests/api/internal_spec.rb b/spec/requests/api/internal_spec.rb index d1e765d1fdd..ffeacb15f17 100644 --- a/spec/requests/api/internal_spec.rb +++ b/spec/requests/api/internal_spec.rb @@ -74,8 +74,8 @@ describe API::Internal, api: true do context 'when two-factor is enabled' do it 'returns new recovery codes when the user exists' do allow_any_instance_of(User).to receive(:two_factor_enabled?).and_return(true) - allow_any_instance_of(User). - to receive(:generate_otp_backup_codes!).and_return(%w(119135e5a3ebce8e 34bd7b74adbc8861)) + allow_any_instance_of(User) + .to receive(:generate_otp_backup_codes!).and_return(%w(119135e5a3ebce8e 34bd7b74adbc8861)) post api('/internal/two_factor_recovery_codes'), secret_token: secret_token, diff --git a/spec/requests/api/runners_spec.rb b/spec/requests/api/runners_spec.rb index 2e596f4197e..103d6755888 100644 --- a/spec/requests/api/runners_spec.rb +++ b/spec/requests/api/runners_spec.rb @@ -202,8 +202,8 @@ describe API::Runners, api: true do expect(shared_runner.tag_list).to include('ruby2.1', 'pgsql', 'mysql') expect(shared_runner.run_untagged?).to be(false) expect(shared_runner.locked?).to be(true) - expect(shared_runner.ensure_runner_queue_value). - not_to eq(runner_queue_value) + expect(shared_runner.ensure_runner_queue_value) + .not_to eq(runner_queue_value) end end @@ -218,8 +218,8 @@ describe API::Runners, api: true do expect(response).to have_http_status(200) expect(specific_runner.description).to eq('test') expect(specific_runner.description).not_to eq(description) - expect(specific_runner.ensure_runner_queue_value). - not_to eq(runner_queue_value) + expect(specific_runner.ensure_runner_queue_value) + .not_to eq(runner_queue_value) end end diff --git a/spec/requests/ci/api/builds_spec.rb b/spec/requests/ci/api/builds_spec.rb index 6d79f2e7b41..444258e312d 100644 --- a/spec/requests/ci/api/builds_spec.rb +++ b/spec/requests/ci/api/builds_spec.rb @@ -38,8 +38,8 @@ describe Ci::API::Builds do it 'gives 204 and set the same X-GitLab-Last-Update' do expect(response).to have_http_status(204) - expect(response.header['X-GitLab-Last-Update']). - to eq(last_update) + expect(response.header['X-GitLab-Last-Update']) + .to eq(last_update) end end @@ -49,8 +49,8 @@ describe Ci::API::Builds do it 'gives 204 and set a new X-GitLab-Last-Update' do expect(response).to have_http_status(204) - expect(response.header['X-GitLab-Last-Update']). - to eq(new_update) + expect(response.header['X-GitLab-Last-Update']) + .to eq(new_update) end end @@ -260,8 +260,8 @@ describe Ci::API::Builds do end it 'does not update runner info' do - expect { register_builds }. - not_to change { runner.reload.contacted_at } + expect { register_builds } + .not_to change { runner.reload.contacted_at } end end diff --git a/spec/serializers/analytics_build_serializer_spec.rb b/spec/serializers/analytics_build_serializer_spec.rb index c8bad5ef105..e3b1dd93dc2 100644 --- a/spec/serializers/analytics_build_serializer_spec.rb +++ b/spec/serializers/analytics_build_serializer_spec.rb @@ -7,8 +7,8 @@ describe AnalyticsBuildSerializer do context 'when there is a single object provided' do it 'contains important elements of analyticsBuild' do - expect(subject). - to include(:name, :branch, :short_sha, :date, :total_time, :url, :author) + expect(subject) + .to include(:name, :branch, :short_sha, :date, :total_time, :url, :author) end end end diff --git a/spec/serializers/analytics_issue_serializer_spec.rb b/spec/serializers/analytics_issue_serializer_spec.rb index fe26b001740..2f08958a783 100644 --- a/spec/serializers/analytics_issue_serializer_spec.rb +++ b/spec/serializers/analytics_issue_serializer_spec.rb @@ -2,9 +2,9 @@ require 'spec_helper' describe AnalyticsIssueSerializer do subject do - described_class. - new(project: project, entity: :merge_request). - represent(resource) + described_class + .new(project: project, entity: :merge_request) + .represent(resource) end let(:user) { create(:user) } diff --git a/spec/serializers/analytics_merge_request_serializer_spec.rb b/spec/serializers/analytics_merge_request_serializer_spec.rb index ee08762d237..62067cc0ef2 100644 --- a/spec/serializers/analytics_merge_request_serializer_spec.rb +++ b/spec/serializers/analytics_merge_request_serializer_spec.rb @@ -2,9 +2,9 @@ require 'spec_helper' describe AnalyticsMergeRequestSerializer do subject do - described_class. - new(project: project, entity: :merge_request). - represent(resource) + described_class + .new(project: project, entity: :merge_request) + .represent(resource) end let(:user) { create(:user) } diff --git a/spec/serializers/analytics_summary_serializer_spec.rb b/spec/serializers/analytics_summary_serializer_spec.rb index 3106af0ded7..5d7a94c2d02 100644 --- a/spec/serializers/analytics_summary_serializer_spec.rb +++ b/spec/serializers/analytics_summary_serializer_spec.rb @@ -9,13 +9,13 @@ describe AnalyticsSummarySerializer do let(:user) { create(:user) } let(:resource) do - Gitlab::CycleAnalytics::Summary::Issue. - new(project: double, from: 1.day.ago, current_user: user) + Gitlab::CycleAnalytics::Summary::Issue + .new(project: double, from: 1.day.ago, current_user: user) end before do - allow_any_instance_of(Gitlab::CycleAnalytics::Summary::Issue). - to receive(:value).and_return(1.12) + allow_any_instance_of(Gitlab::CycleAnalytics::Summary::Issue) + .to receive(:value).and_return(1.12) end it 'it generates payload for single object' do diff --git a/spec/serializers/build_artifact_entity_spec.rb b/spec/serializers/build_artifact_entity_spec.rb index 6ccea199376..2fc60aa9de6 100644 --- a/spec/serializers/build_artifact_entity_spec.rb +++ b/spec/serializers/build_artifact_entity_spec.rb @@ -15,8 +15,8 @@ describe BuildArtifactEntity do end it 'contains path to the artifacts' do - expect(subject[:path]). - to include "builds/#{build.id}/artifacts/download" + expect(subject[:path]) + .to include "builds/#{build.id}/artifacts/download" end end end diff --git a/spec/serializers/commit_entity_spec.rb b/spec/serializers/commit_entity_spec.rb index 895aeb30035..0333d73b5b5 100644 --- a/spec/serializers/commit_entity_spec.rb +++ b/spec/serializers/commit_entity_spec.rb @@ -42,8 +42,8 @@ describe CommitEntity do end it 'needs to receive project in the request' do - expect(request).to receive(:project). - and_return(project) + expect(request).to receive(:project) + .and_return(project) subject end diff --git a/spec/serializers/environment_serializer_spec.rb b/spec/serializers/environment_serializer_spec.rb index 61b2fce8e8a..6a6df377b35 100644 --- a/spec/serializers/environment_serializer_spec.rb +++ b/spec/serializers/environment_serializer_spec.rb @@ -5,9 +5,9 @@ describe EnvironmentSerializer do let(:project) { create(:project) } let(:json) do - described_class. - new(user: user, project: project). - represent(resource) + described_class + .new(user: user, project: project) + .represent(resource) end context 'when there is a single object provided' do @@ -27,15 +27,15 @@ describe EnvironmentSerializer do let(:resource) { deployment.environment } it 'contains important elements of environment' do - expect(json). - to include(:name, :external_url, :environment_path, :last_deployment) + expect(json) + .to include(:name, :external_url, :environment_path, :last_deployment) end it 'contains relevant information about last deployment' do last_deployment = json.fetch(:last_deployment) - expect(last_deployment). - to include(:ref, :user, :commit, :deployable, :manual_actions) + expect(last_deployment) + .to include(:ref, :user, :commit, :deployable, :manual_actions) end end @@ -44,8 +44,8 @@ describe EnvironmentSerializer do let(:resource) { create_list(:environment, 2) } it 'contains important elements of environment' do - expect(json.first). - to include(:last_deployment, :name, :external_url) + expect(json.first) + .to include(:last_deployment, :name, :external_url) end it 'generates payload for collection' do @@ -122,13 +122,13 @@ describe EnvironmentSerializer do let(:pagination) { { page: 1, per_page: 2 } } let(:serializer) do - described_class.new(project: project). - with_pagination(request, response) + described_class.new(project: project) + .with_pagination(request, response) end before do - allow(request).to receive(:query_parameters). - and_return(pagination) + allow(request).to receive(:query_parameters) + .and_return(pagination) end subject { serializer.represent(resource) } @@ -164,9 +164,9 @@ describe EnvironmentSerializer do context 'when grouping environments within folders' do let(:serializer) do - described_class.new(project: project). - with_pagination(request, response). - within_folders + described_class.new(project: project) + .with_pagination(request, response) + .within_folders end before do diff --git a/spec/serializers/pipeline_entity_spec.rb b/spec/serializers/pipeline_entity_spec.rb index 96ef1d3c071..ccb72973f9c 100644 --- a/spec/serializers/pipeline_entity_spec.rb +++ b/spec/serializers/pipeline_entity_spec.rb @@ -26,17 +26,17 @@ describe PipelineEntity do it 'contains details' do expect(subject).to include :details - expect(subject[:details]). - to include :duration, :finished_at - expect(subject[:details]). - to include :stages, :artifacts, :manual_actions + expect(subject[:details]) + .to include :duration, :finished_at + expect(subject[:details]) + .to include :stages, :artifacts, :manual_actions expect(subject[:details][:status]).to include :icon, :text, :label end it 'contains flags' do expect(subject).to include :flags - expect(subject[:flags]). - to include :latest, :triggered, :stuck, + expect(subject[:flags]) + .to include :latest, :triggered, :stuck, :yaml_errors, :retryable, :cancelable end end diff --git a/spec/serializers/pipeline_serializer_spec.rb b/spec/serializers/pipeline_serializer_spec.rb index 5f84a98f06d..2aaef03cb93 100644 --- a/spec/serializers/pipeline_serializer_spec.rb +++ b/spec/serializers/pipeline_serializer_spec.rb @@ -38,14 +38,14 @@ describe PipelineSerializer do let(:pagination) { {} } before do - allow(request). - to receive(:query_parameters). - and_return(pagination) + allow(request) + .to receive(:query_parameters) + .and_return(pagination) end let(:serializer) do - described_class.new(user: user). - with_pagination(request, response) + described_class.new(user: user) + .with_pagination(request, response) end it 'created a paginated serializer' do diff --git a/spec/serializers/request_aware_entity_spec.rb b/spec/serializers/request_aware_entity_spec.rb index 94dbf02aee8..aa666b961dc 100644 --- a/spec/serializers/request_aware_entity_spec.rb +++ b/spec/serializers/request_aware_entity_spec.rb @@ -14,8 +14,8 @@ describe RequestAwareEntity do end it 'fetches request from options' do - expect(subject).to receive(:options). - and_return({ request: 'some value' }) + expect(subject).to receive(:options) + .and_return({ request: 'some value' }) expect(subject.request).to eq 'some value' end diff --git a/spec/serializers/stage_entity_spec.rb b/spec/serializers/stage_entity_spec.rb index 42f19935453..4ab40d08432 100644 --- a/spec/serializers/stage_entity_spec.rb +++ b/spec/serializers/stage_entity_spec.rb @@ -35,13 +35,13 @@ describe StageEntity do end it 'contains path to the stage' do - expect(subject[:path]). - to include "pipelines/#{pipeline.id}##{stage.name}" + expect(subject[:path]) + .to include "pipelines/#{pipeline.id}##{stage.name}" end it 'contains path to the stage dropdown' do - expect(subject[:dropdown_path]). - to include "pipelines/#{pipeline.id}/stage.json?stage=test" + expect(subject[:dropdown_path]) + .to include "pipelines/#{pipeline.id}/stage.json?stage=test" end it 'contains stage title' do diff --git a/spec/services/ci/process_pipeline_service_spec.rb b/spec/services/ci/process_pipeline_service_spec.rb index 65544c57431..b818dfdd50c 100644 --- a/spec/services/ci/process_pipeline_service_spec.rb +++ b/spec/services/ci/process_pipeline_service_spec.rb @@ -284,14 +284,14 @@ describe Ci::ProcessPipelineService, :services do pipeline.builds.running_or_pending.each(&:success) - expect(builds.pluck(:name)). - to contain_exactly('build:1', 'build:2', 'test:1', 'test:2') + expect(builds.pluck(:name)) + .to contain_exactly('build:1', 'build:2', 'test:1', 'test:2') pipeline.builds.find_by(name: 'test:1').success pipeline.builds.find_by(name: 'test:2').drop - expect(builds.pluck(:name)). - to contain_exactly('build:1', 'build:2', 'test:1', 'test:2') + expect(builds.pluck(:name)) + .to contain_exactly('build:1', 'build:2', 'test:1', 'test:2') Ci::Build.retry(pipeline.builds.find_by(name: 'test:2'), user).success diff --git a/spec/services/ci/retry_build_service_spec.rb b/spec/services/ci/retry_build_service_spec.rb index 6499c7ad63e..d03f7505eac 100644 --- a/spec/services/ci/retry_build_service_spec.rb +++ b/spec/services/ci/retry_build_service_spec.rb @@ -61,8 +61,8 @@ describe Ci::RetryBuildService, :services do end it 'resolves todos for old build that failed' do - expect(MergeRequests::AddTodoWhenBuildFailsService). - to receive_message_chain(:new, :close) + expect(MergeRequests::AddTodoWhenBuildFailsService) + .to receive_message_chain(:new, :close) service.execute(build) end @@ -82,8 +82,8 @@ describe Ci::RetryBuildService, :services do context 'when user does not have ability to execute build' do it 'raises an error' do - expect { service.execute(build) }. - to raise_error Gitlab::Access::AccessDeniedError + expect { service.execute(build) } + .to raise_error Gitlab::Access::AccessDeniedError end end end @@ -109,8 +109,8 @@ describe Ci::RetryBuildService, :services do context 'when user does not have ability to execute build' do it 'raises an error' do - expect { service.reprocess(build) }. - to raise_error Gitlab::Access::AccessDeniedError + expect { service.reprocess(build) } + .to raise_error Gitlab::Access::AccessDeniedError end end end diff --git a/spec/services/ci/retry_pipeline_service_spec.rb b/spec/services/ci/retry_pipeline_service_spec.rb index 84915b5f1aa..c0af8b8450a 100644 --- a/spec/services/ci/retry_pipeline_service_spec.rb +++ b/spec/services/ci/retry_pipeline_service_spec.rb @@ -134,8 +134,8 @@ describe Ci::RetryPipelineService, '#execute', :services do end it 'closes all todos about failed jobs for pipeline' do - expect(MergeRequests::AddTodoWhenBuildFailsService). - to receive_message_chain(:new, :close_all) + expect(MergeRequests::AddTodoWhenBuildFailsService) + .to receive_message_chain(:new, :close_all) service.execute(pipeline) end @@ -149,8 +149,8 @@ describe Ci::RetryPipelineService, '#execute', :services do context 'when user is not allowed to retry pipeline' do it 'raises an error' do - expect { service.execute(pipeline) }. - to raise_error Gitlab::Access::AccessDeniedError + expect { service.execute(pipeline) } + .to raise_error Gitlab::Access::AccessDeniedError end end diff --git a/spec/services/ci/stop_environments_service_spec.rb b/spec/services/ci/stop_environments_service_spec.rb index 23e0856fecd..560f83d94f7 100644 --- a/spec/services/ci/stop_environments_service_spec.rb +++ b/spec/services/ci/stop_environments_service_spec.rb @@ -44,8 +44,8 @@ describe Ci::StopEnvironmentsService, services: true do context 'when environment is not stopped' do before do - allow_any_instance_of(Environment). - to receive(:state).and_return(:stopped) + allow_any_instance_of(Environment) + .to receive(:state).and_return(:stopped) end it 'does not stop environment' do @@ -83,22 +83,22 @@ describe Ci::StopEnvironmentsService, services: true do context 'when environment does not exist' do it 'does not raise error' do - expect { service.execute('master') }. - not_to raise_error + expect { service.execute('master') } + .not_to raise_error end end end def expect_environment_stopped_on(branch) - expect_any_instance_of(Environment). - to receive(:stop!) + expect_any_instance_of(Environment) + .to receive(:stop!) service.execute(branch) end def expect_environment_not_stopped_on(branch) - expect_any_instance_of(Environment). - not_to receive(:stop!) + expect_any_instance_of(Environment) + .not_to receive(:stop!) service.execute(branch) end diff --git a/spec/services/ci/update_build_queue_service_spec.rb b/spec/services/ci/update_build_queue_service_spec.rb index 14092d9dcca..f01a388b895 100644 --- a/spec/services/ci/update_build_queue_service_spec.rb +++ b/spec/services/ci/update_build_queue_service_spec.rb @@ -12,15 +12,15 @@ describe Ci::UpdateBuildQueueService, :services do before { build.project.runners << runner } it 'ticks runner queue value' do - expect { subject.execute(build) }. - to change { runner.ensure_runner_queue_value } + expect { subject.execute(build) } + .to change { runner.ensure_runner_queue_value } end end context 'when there are no runners that can pick build' do it 'does not tick runner queue value' do - expect { subject.execute(build) }. - not_to change { runner.ensure_runner_queue_value } + expect { subject.execute(build) } + .not_to change { runner.ensure_runner_queue_value } end end end @@ -30,8 +30,8 @@ describe Ci::UpdateBuildQueueService, :services do context 'when there are runner that can pick build' do it 'ticks runner queue value' do - expect { subject.execute(build) }. - to change { runner.ensure_runner_queue_value } + expect { subject.execute(build) } + .to change { runner.ensure_runner_queue_value } end end @@ -39,8 +39,8 @@ describe Ci::UpdateBuildQueueService, :services do before { build.tag_list = [:docker] } it 'does not tick runner queue value' do - expect { subject.execute(build) }. - not_to change { runner.ensure_runner_queue_value } + expect { subject.execute(build) } + .not_to change { runner.ensure_runner_queue_value } end end end diff --git a/spec/services/issuable/bulk_update_service_spec.rb b/spec/services/issuable/bulk_update_service_spec.rb index 87da8581e68..0475f38fe5e 100644 --- a/spec/services/issuable/bulk_update_service_spec.rb +++ b/spec/services/issuable/bulk_update_service_spec.rb @@ -5,8 +5,8 @@ describe Issuable::BulkUpdateService, services: true do let(:project) { create(:empty_project, namespace: user.namespace) } def bulk_update(issues, extra_params = {}) - bulk_update_params = extra_params. - reverse_merge(issuable_ids: Array(issues).map(&:id).join(',')) + bulk_update_params = extra_params + .reverse_merge(issuable_ids: Array(issues).map(&:id).join(',')) Issuable::BulkUpdateService.new(project, user, bulk_update_params).execute('issue') end @@ -65,22 +65,22 @@ describe Issuable::BulkUpdateService, services: true do assignee = create(:user) project.team << [assignee, :developer] - expect { bulk_update(issue, assignee_id: assignee.id) }. - to change { issue.reload.assignee }.from(user).to(assignee) + expect { bulk_update(issue, assignee_id: assignee.id) } + .to change { issue.reload.assignee }.from(user).to(assignee) end end context "when the new assignee ID is #{IssuableFinder::NONE}" do it "unassigns the issues" do - expect { bulk_update(issue, assignee_id: IssuableFinder::NONE) }. - to change { issue.reload.assignee }.to(nil) + expect { bulk_update(issue, assignee_id: IssuableFinder::NONE) } + .to change { issue.reload.assignee }.to(nil) end end context 'when the new assignee ID is not present' do it 'does not unassign' do - expect { bulk_update(issue, assignee_id: nil) }. - not_to change { issue.reload.assignee } + expect { bulk_update(issue, assignee_id: nil) } + .not_to change { issue.reload.assignee } end end end @@ -97,8 +97,8 @@ describe Issuable::BulkUpdateService, services: true do end it 'updates the issue milestone' do - expect { bulk_update(issue, milestone_id: milestone.id) }. - to change { issue.reload.milestone }.from(nil).to(milestone) + expect { bulk_update(issue, milestone_id: milestone.id) } + .to change { issue.reload.milestone }.from(nil).to(milestone) end end diff --git a/spec/services/issues/move_service_spec.rb b/spec/services/issues/move_service_spec.rb index 59c0fa50994..db196ed5751 100644 --- a/spec/services/issues/move_service_spec.rb +++ b/spec/services/issues/move_service_spec.rb @@ -188,8 +188,8 @@ describe Issues::MoveService, services: true do let(:new_note) { new_issue.notes.first } it 'rewrites references using a cross reference to old project' do - expect(new_note.note). - to eq "Note with reference to merge request #{old_project.to_reference(new_project)}!1" + expect(new_note.note) + .to eq "Note with reference to merge request #{old_project.to_reference(new_project)}!1" end end @@ -201,8 +201,8 @@ describe Issues::MoveService, services: true do it 'rewrites uploads in description' do expect(new_issue.description).not_to eq description - expect(new_issue.description). - to match(/Text and #{FileUploader::MARKDOWN_PATTERN}/) + expect(new_issue.description) + .to match(/Text and #{FileUploader::MARKDOWN_PATTERN}/) expect(new_issue.description).not_to include uploader.secret end end @@ -216,8 +216,8 @@ describe Issues::MoveService, services: true do let(:description) { "Some description #{another_issue.to_reference}" } it 'rewrites referenced issues creating cross project reference' do - expect(new_issue.description). - to eq "Some description #{another_issue.to_reference(new_project)}" + expect(new_issue.description) + .to eq "Some description #{another_issue.to_reference(new_project)}" end end @@ -226,8 +226,8 @@ describe Issues::MoveService, services: true do let(:description) { "Some description #{user.to_reference}" } it "doesn't throw any errors for issues containing user references" do - expect(new_issue.description). - to eq "Some description #{user.to_reference}" + expect(new_issue.description) + .to eq "Some description #{user.to_reference}" end end end @@ -236,8 +236,8 @@ describe Issues::MoveService, services: true do let(:new_project) { old_project } it 'raises error' do - expect { move_service.execute(old_issue, new_project) }. - to raise_error(StandardError, /Cannot move issue/) + expect { move_service.execute(old_issue, new_project) } + .to raise_error(StandardError, /Cannot move issue/) end end end diff --git a/spec/services/merge_requests/add_todo_when_build_fails_service_spec.rb b/spec/services/merge_requests/add_todo_when_build_fails_service_spec.rb index 881458c190f..d80fb8a1af1 100644 --- a/spec/services/merge_requests/add_todo_when_build_fails_service_spec.rb +++ b/spec/services/merge_requests/add_todo_when_build_fails_service_spec.rb @@ -29,9 +29,9 @@ describe MergeRequests::AddTodoWhenBuildFailsService do end before do - allow_any_instance_of(MergeRequest). - to receive(:head_pipeline). - and_return(pipeline) + allow_any_instance_of(MergeRequest) + .to receive(:head_pipeline) + .and_return(pipeline) allow(service).to receive(:todo_service).and_return(todo_service) end @@ -113,9 +113,9 @@ describe MergeRequests::AddTodoWhenBuildFailsService do it 'resolves todos about failed builds for pipeline' do service.close_all(pipeline) - expect(todo_service). - to have_received(:merge_request_build_retried). - with(merge_request) + expect(todo_service) + .to have_received(:merge_request_build_retried) + .with(merge_request) end end @@ -125,8 +125,8 @@ describe MergeRequests::AddTodoWhenBuildFailsService do it 'does not resolve any todos about failed builds' do service.close_all(pipeline) - expect(todo_service). - not_to have_received(:merge_request_build_retried) + expect(todo_service) + .not_to have_received(:merge_request_build_retried) end end end diff --git a/spec/services/merge_requests/merge_when_pipeline_succeeds_service_spec.rb b/spec/services/merge_requests/merge_when_pipeline_succeeds_service_spec.rb index 65c08ce15f7..f92978a33a3 100644 --- a/spec/services/merge_requests/merge_when_pipeline_succeeds_service_spec.rb +++ b/spec/services/merge_requests/merge_when_pipeline_succeeds_service_spec.rb @@ -27,9 +27,9 @@ describe MergeRequests::MergeWhenPipelineSucceedsService do context 'first time enabling' do before do - allow(merge_request). - to receive(:head_pipeline). - and_return(pipeline) + allow(merge_request) + .to receive(:head_pipeline) + .and_return(pipeline) service.execute(merge_request) end @@ -52,11 +52,11 @@ describe MergeRequests::MergeWhenPipelineSucceedsService do let(:build) { create(:ci_build, ref: mr_merge_if_green_enabled.source_branch) } before do - allow(mr_merge_if_green_enabled).to receive(:head_pipeline). - and_return(pipeline) + allow(mr_merge_if_green_enabled).to receive(:head_pipeline) + .and_return(pipeline) - allow(mr_merge_if_green_enabled).to receive(:mergeable?). - and_return(true) + allow(mr_merge_if_green_enabled).to receive(:mergeable?) + .and_return(true) allow(pipeline).to receive(:success?).and_return(true) end @@ -152,9 +152,9 @@ describe MergeRequests::MergeWhenPipelineSucceedsService do before do # This behavior of MergeRequest: we instantiate a new object # - allow_any_instance_of(MergeRequest). - to receive(:head_pipeline). - and_wrap_original do + allow_any_instance_of(MergeRequest) + .to receive(:head_pipeline) + .and_wrap_original do Ci::Pipeline.find(pipeline.id) end end diff --git a/spec/services/merge_requests/resolve_service_spec.rb b/spec/services/merge_requests/resolve_service_spec.rb index 57b1c088ce4..c3b468ac47f 100644 --- a/spec/services/merge_requests/resolve_service_spec.rb +++ b/spec/services/merge_requests/resolve_service_spec.rb @@ -60,7 +60,7 @@ describe MergeRequests::ResolveService do it 'creates a commit with the correct parents' do expect(merge_request.source_branch_head.parents.map(&:id)). to eq(%w(1450cd639e0bc6721eb02800169e464f212cde06 - 824be604a34828eb682305f0d963056cfac87b2d)) + 824be604a34828eb682305f0d963056cfac87b2d)) end end @@ -86,7 +86,7 @@ describe MergeRequests::ResolveService do it 'creates a commit with the correct parents' do expect(merge_request_from_fork.source_branch_head.parents.map(&:id)). to eq(['404fa3fc7c2c9b5dacff102f353bdf55b1be2813', - target_head]) + target_head]) end end end @@ -126,7 +126,7 @@ describe MergeRequests::ResolveService do it 'creates a commit with the correct parents' do expect(merge_request.source_branch_head.parents.map(&:id)). to eq(%w(1450cd639e0bc6721eb02800169e464f212cde06 - 824be604a34828eb682305f0d963056cfac87b2d)) + 824be604a34828eb682305f0d963056cfac87b2d)) end it 'sets the content to the content given' do diff --git a/spec/services/todo_service_spec.rb b/spec/services/todo_service_spec.rb index 6dfcb702510..9f24cc0f3f2 100644 --- a/spec/services/todo_service_spec.rb +++ b/spec/services/todo_service_spec.rb @@ -768,15 +768,15 @@ describe TodoService, services: true do create(:todo, :mentioned, user: john_doe, target: issue, project: project) todos = TodosFinder.new(john_doe, {}).execute - expect { TodoService.new.mark_todos_as_done(todos, john_doe) }. - to change { john_doe.todos.done.count }.from(0).to(1) + expect { TodoService.new.mark_todos_as_done(todos, john_doe) } + .to change { john_doe.todos.done.count }.from(0).to(1) end it 'marks an array of todos as done' do todo = create(:todo, :mentioned, user: john_doe, target: issue, project: project) - expect { TodoService.new.mark_todos_as_done([todo], john_doe) }. - to change { todo.reload.state }.from('pending').to('done') + expect { TodoService.new.mark_todos_as_done([todo], john_doe) } + .to change { todo.reload.state }.from('pending').to('done') end it 'returns the number of updated todos' do # Needed on API diff --git a/spec/support/ldap_helpers.rb b/spec/support/ldap_helpers.rb index ab635711cf7..079f244475c 100644 --- a/spec/support/ldap_helpers.rb +++ b/spec/support/ldap_helpers.rb @@ -16,8 +16,8 @@ module LdapHelpers # ) def stub_ldap_config(messages) messages.each do |config, value| - allow_any_instance_of(::Gitlab::LDAP::Config). - to receive(config.to_sym).and_return(value) + allow_any_instance_of(::Gitlab::LDAP::Config) + .to receive(config.to_sym).and_return(value) end end @@ -32,8 +32,8 @@ module LdapHelpers def stub_ldap_person_find_by_uid(uid, entry, provider = 'ldapmain') return_value = ::Gitlab::LDAP::Person.new(entry, provider) if entry.present? - allow(::Gitlab::LDAP::Person). - to receive(:find_by_uid).with(uid, any_args).and_return(return_value) + allow(::Gitlab::LDAP::Person) + .to receive(:find_by_uid).with(uid, any_args).and_return(return_value) end # Create a simple LDAP user entry. diff --git a/spec/support/stub_gitlab_calls.rb b/spec/support/stub_gitlab_calls.rb index 07602c0cb40..a01ef576234 100644 --- a/spec/support/stub_gitlab_calls.rb +++ b/spec/support/stub_gitlab_calls.rb @@ -53,7 +53,7 @@ module StubGitlabCalls stub_request(:post, "#{gitlab_url}api/v3/session.json"). with(body: "{\"email\":\"test@test.com\",\"password\":\"123456\"}", - headers: { 'Content-Type' => 'application/json' }). + headers: { 'Content-Type' => 'application/json' }). to_return(status: 201, body: f, headers: { 'Content-Type' => 'application/json' }) end diff --git a/spec/tasks/gitlab/check_rake_spec.rb b/spec/tasks/gitlab/check_rake_spec.rb index a808ef7dcc0..538ff952bf4 100644 --- a/spec/tasks/gitlab/check_rake_spec.rb +++ b/spec/tasks/gitlab/check_rake_spec.rb @@ -23,8 +23,8 @@ describe 'gitlab:ldap:check rake task' do let(:adapter) { ldap_adapter('ldapmain', ldap) } before do - allow(Gitlab::LDAP::Config). - to receive_messages( + allow(Gitlab::LDAP::Config) + .to receive_messages( enabled?: true, providers: ['ldapmain'] ) diff --git a/spec/tasks/gitlab/shell_rake_spec.rb b/spec/tasks/gitlab/shell_rake_spec.rb index 0787894ad2c..226d34fe2c9 100644 --- a/spec/tasks/gitlab/shell_rake_spec.rb +++ b/spec/tasks/gitlab/shell_rake_spec.rb @@ -17,8 +17,8 @@ describe 'gitlab:shell rake tasks' do describe 'create_hooks task' do it 'calls gitlab-shell bin/create_hooks' do - expect_any_instance_of(Object).to receive(:system). - with("#{Gitlab.config.gitlab_shell.path}/bin/create-hooks", *repository_storage_paths_args) + expect_any_instance_of(Object).to receive(:system) + .with("#{Gitlab.config.gitlab_shell.path}/bin/create-hooks", *repository_storage_paths_args) run_rake_task('gitlab:shell:create_hooks') end diff --git a/spec/views/layouts/_head.html.haml_spec.rb b/spec/views/layouts/_head.html.haml_spec.rb index 254672a5612..8020faa1f9c 100644 --- a/spec/views/layouts/_head.html.haml_spec.rb +++ b/spec/views/layouts/_head.html.haml_spec.rb @@ -26,7 +26,7 @@ describe 'layouts/_head' do end def stub_helper_with_safe_string(method) - allow_any_instance_of(PageLayoutHelper).to receive(method). - and_return(%q{foo" http-equiv="refresh}.html_safe) + allow_any_instance_of(PageLayoutHelper).to receive(method) + .and_return(%q{foo" http-equiv="refresh}.html_safe) end end diff --git a/spec/views/projects/merge_requests/edit.html.haml_spec.rb b/spec/views/projects/merge_requests/edit.html.haml_spec.rb index 2e4390d6797..3650b22c389 100644 --- a/spec/views/projects/merge_requests/edit.html.haml_spec.rb +++ b/spec/views/projects/merge_requests/edit.html.haml_spec.rb @@ -23,8 +23,8 @@ describe 'projects/merge_requests/edit.html.haml' do assign(:merge_request, closed_merge_request) allow(view).to receive(:can?).and_return(true) - allow(view).to receive(:current_user). - and_return(User.find(closed_merge_request.author_id)) + allow(view).to receive(:current_user) + .and_return(User.find(closed_merge_request.author_id)) end context 'when a merge request without fork' do diff --git a/spec/workers/build_coverage_worker_spec.rb b/spec/workers/build_coverage_worker_spec.rb index 8ebf00374a1..ba20488f663 100644 --- a/spec/workers/build_coverage_worker_spec.rb +++ b/spec/workers/build_coverage_worker_spec.rb @@ -6,8 +6,8 @@ describe BuildCoverageWorker do let!(:build) { create(:ci_build) } it 'updates code coverage' do - expect_any_instance_of(Ci::Build). - to receive(:update_coverage) + expect_any_instance_of(Ci::Build) + .to receive(:update_coverage) described_class.new.perform(build.id) end @@ -15,8 +15,8 @@ describe BuildCoverageWorker do context 'when build does not exist' do it 'does not raise exception' do - expect { described_class.new.perform(123) }. - not_to raise_error + expect { described_class.new.perform(123) } + .not_to raise_error end end end diff --git a/spec/workers/build_finished_worker_spec.rb b/spec/workers/build_finished_worker_spec.rb index f8119913116..2868167c7d4 100644 --- a/spec/workers/build_finished_worker_spec.rb +++ b/spec/workers/build_finished_worker_spec.rb @@ -6,15 +6,15 @@ describe BuildFinishedWorker do let(:build) { create(:ci_build) } it 'calculates coverage and calls hooks' do - expect(BuildCoverageWorker). - to receive(:new).ordered.and_call_original - expect(BuildHooksWorker). - to receive(:new).ordered.and_call_original + expect(BuildCoverageWorker) + .to receive(:new).ordered.and_call_original + expect(BuildHooksWorker) + .to receive(:new).ordered.and_call_original - expect_any_instance_of(BuildCoverageWorker). - to receive(:perform) - expect_any_instance_of(BuildHooksWorker). - to receive(:perform) + expect_any_instance_of(BuildCoverageWorker) + .to receive(:perform) + expect_any_instance_of(BuildHooksWorker) + .to receive(:perform) described_class.new.perform(build.id) end @@ -22,8 +22,8 @@ describe BuildFinishedWorker do context 'when build does not exist' do it 'does not raise exception' do - expect { described_class.new.perform(123) }. - not_to raise_error + expect { described_class.new.perform(123) } + .not_to raise_error end end end diff --git a/spec/workers/build_hooks_worker_spec.rb b/spec/workers/build_hooks_worker_spec.rb index 51abc1d89a1..97654a93f5c 100644 --- a/spec/workers/build_hooks_worker_spec.rb +++ b/spec/workers/build_hooks_worker_spec.rb @@ -6,8 +6,8 @@ describe BuildHooksWorker do let!(:build) { create(:ci_build) } it 'calls build hooks' do - expect_any_instance_of(Ci::Build). - to receive(:execute_hooks) + expect_any_instance_of(Ci::Build) + .to receive(:execute_hooks) described_class.new.perform(build.id) end @@ -15,8 +15,8 @@ describe BuildHooksWorker do context 'when build does not exist' do it 'does not raise exception' do - expect { described_class.new.perform(123) }. - not_to raise_error + expect { described_class.new.perform(123) } + .not_to raise_error end end end diff --git a/spec/workers/build_success_worker_spec.rb b/spec/workers/build_success_worker_spec.rb index d016ecbb738..dba70883130 100644 --- a/spec/workers/build_success_worker_spec.rb +++ b/spec/workers/build_success_worker_spec.rb @@ -7,8 +7,8 @@ describe BuildSuccessWorker do let!(:build) { create(:ci_build, environment: 'production') } it 'executes deployment service' do - expect_any_instance_of(CreateDeploymentService). - to receive(:execute) + expect_any_instance_of(CreateDeploymentService) + .to receive(:execute) described_class.new.perform(build.id) end @@ -18,8 +18,8 @@ describe BuildSuccessWorker do let!(:build) { create(:ci_build, project: nil) } it 'does not create deployment' do - expect_any_instance_of(CreateDeploymentService). - not_to receive(:execute) + expect_any_instance_of(CreateDeploymentService) + .not_to receive(:execute) described_class.new.perform(build.id) end @@ -28,8 +28,8 @@ describe BuildSuccessWorker do context 'when build does not exist' do it 'does not raise exception' do - expect { described_class.new.perform(123) }. - not_to raise_error + expect { described_class.new.perform(123) } + .not_to raise_error end end end diff --git a/spec/workers/pipeline_hooks_worker_spec.rb b/spec/workers/pipeline_hooks_worker_spec.rb index 061f4bda36c..035e329839f 100644 --- a/spec/workers/pipeline_hooks_worker_spec.rb +++ b/spec/workers/pipeline_hooks_worker_spec.rb @@ -6,8 +6,8 @@ describe PipelineHooksWorker do let(:pipeline) { create(:ci_pipeline) } it 'executes hooks for the pipeline' do - expect_any_instance_of(Ci::Pipeline). - to receive(:execute_hooks) + expect_any_instance_of(Ci::Pipeline) + .to receive(:execute_hooks) described_class.new.perform(pipeline.id) end @@ -15,8 +15,8 @@ describe PipelineHooksWorker do context 'when pipeline does not exist' do it 'does not raise exception' do - expect { described_class.new.perform(123) }. - not_to raise_error + expect { described_class.new.perform(123) } + .not_to raise_error end end end diff --git a/spec/workers/pipeline_proccess_worker_spec.rb b/spec/workers/pipeline_proccess_worker_spec.rb index fd6ee0714ea..86e9d7f6684 100644 --- a/spec/workers/pipeline_proccess_worker_spec.rb +++ b/spec/workers/pipeline_proccess_worker_spec.rb @@ -14,8 +14,8 @@ describe PipelineProcessWorker do context 'when pipeline does not exist' do it 'does not raise exception' do - expect { described_class.new.perform(123) }. - not_to raise_error + expect { described_class.new.perform(123) } + .not_to raise_error end end end diff --git a/spec/workers/pipeline_success_worker_spec.rb b/spec/workers/pipeline_success_worker_spec.rb index f6c56465feb..d1c84adda6f 100644 --- a/spec/workers/pipeline_success_worker_spec.rb +++ b/spec/workers/pipeline_success_worker_spec.rb @@ -16,8 +16,8 @@ describe PipelineSuccessWorker do context 'when pipeline does not exist' do it 'does not raise exception' do - expect { described_class.new.perform(123) }. - not_to raise_error + expect { described_class.new.perform(123) } + .not_to raise_error end end end diff --git a/spec/workers/pipeline_update_worker_spec.rb b/spec/workers/pipeline_update_worker_spec.rb index 24d78aae112..0b456cfd0da 100644 --- a/spec/workers/pipeline_update_worker_spec.rb +++ b/spec/workers/pipeline_update_worker_spec.rb @@ -14,8 +14,8 @@ describe PipelineUpdateWorker do context 'when pipeline does not exist' do it 'does not raise exception' do - expect { described_class.new.perform(123) }. - not_to raise_error + expect { described_class.new.perform(123) } + .not_to raise_error end end end diff --git a/spec/workers/project_cache_worker_spec.rb b/spec/workers/project_cache_worker_spec.rb index 0fc274f1a01..f4f63b57a5f 100644 --- a/spec/workers/project_cache_worker_spec.rb +++ b/spec/workers/project_cache_worker_spec.rb @@ -31,9 +31,9 @@ describe ProjectCacheWorker do context 'with an existing project' do it 'updates the project statistics' do - expect(worker).to receive(:update_statistics). - with(kind_of(Project), %i(repository_size)). - and_call_original + expect(worker).to receive(:update_statistics) + .with(kind_of(Project), %i(repository_size)) + .and_call_original worker.perform(project.id, [], %w(repository_size)) end @@ -67,9 +67,9 @@ describe ProjectCacheWorker do with(project.id, :update_statistics). and_return(true) - expect(statistics).to receive(:refresh!). - with(only: %i(repository_size)). - and_call_original + expect(statistics).to receive(:refresh!) + .with(only: %i(repository_size)) + .and_call_original worker.update_statistics(project, %i(repository_size)) end diff --git a/spec/workers/use_key_worker_spec.rb b/spec/workers/use_key_worker_spec.rb index f8752c42a49..e50c788b82a 100644 --- a/spec/workers/use_key_worker_spec.rb +++ b/spec/workers/use_key_worker_spec.rb @@ -8,8 +8,8 @@ describe UseKeyWorker do current_time = Time.zone.now Timecop.freeze(current_time) do - expect { worker.perform(key.id) }. - to change { key.reload.last_used_at }.from(nil).to be_like_time(current_time) + expect { worker.perform(key.id) } + .to change { key.reload.last_used_at }.from(nil).to be_like_time(current_time) end end |