diff --git a/.rubocop.yml b/.rubocop.yml index a7d4222b9b22d15a0115fdfcbb655c5e90b75971..2eebe73313b34cdcbb77cc82ebcc85ac4519541e 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -166,7 +166,7 @@ Style/Documentation: # This cop checks the . position in multi-line method calls. Style/DotPosition: Enabled: true - EnforcedStyle: leading + 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 diff --git a/app/controllers/admin/application_settings_controller.rb b/app/controllers/admin/application_settings_controller.rb index b0f5d4a9933aa33002d4cd656a46a01798d4d071..f801fac18399330578cd4d4d2ac74fdffea07605 100644 --- a/app/controllers/admin/application_settings_controller.rb +++ b/app/controllers/admin/application_settings_controller.rb @@ -5,9 +5,9 @@ class Admin::ApplicationSettingsController < Admin::ApplicationController end def update - successful = ApplicationSettings::UpdateService - .new(@application_setting, current_user, application_setting_params) - .execute + successful = ApplicationSettings::UpdateService. + new(@application_setting, current_user, application_setting_params). + execute if successful redirect_to admin_application_settings_path, diff --git a/app/controllers/concerns/creates_commit.rb b/app/controllers/concerns/creates_commit.rb index 41c660be37821a9a2371bd6ac0949f0df583bca5..2fe03020d2d29056d30206c5337934bcceda5690 100644 --- a/app/controllers/concerns/creates_commit.rb +++ b/app/controllers/concerns/creates_commit.rb @@ -83,8 +83,8 @@ module CreatesCommit def merge_request_exists? return @merge_request if defined?(@merge_request) - @merge_request = MergeRequestsFinder.new(current_user, project_id: @mr_target_project.id).execute.opened - .find_by(source_branch: @mr_source_branch, target_branch: @mr_target_branch, source_project_id: @mr_source_project) + @merge_request = MergeRequestsFinder.new(current_user, project_id: @mr_target_project.id).execute.opened. + find_by(source_branch: @mr_source_branch, target_branch: @mr_target_branch, source_project_id: @mr_source_project) end def different_project? diff --git a/app/controllers/concerns/issues_action.rb b/app/controllers/concerns/issues_action.rb index b17c138d5c74d4c154df6111108f902ce44cb89e..8b985b6d003c3a28073c5dda69cf9f642216f3ad 100644 --- a/app/controllers/concerns/issues_action.rb +++ b/app/controllers/concerns/issues_action.rb @@ -5,9 +5,9 @@ module IssuesAction def issues @label = issues_finder.labels.first - @issues = issues_collection - .non_archived - .page(params[:page]) + @issues = issues_collection. + non_archived. + page(params[:page]) @collection_type = "Issue" @issuable_meta_data = issuable_meta_data(@issues, @collection_type) diff --git a/app/controllers/concerns/membership_actions.rb b/app/controllers/concerns/membership_actions.rb index 43ca4b6ac026b9d0113f5f53722b943c4f3ee84e..c13333641d33e4da0a82de791828d40cd01b0b8d 100644 --- a/app/controllers/concerns/membership_actions.rb +++ b/app/controllers/concerns/membership_actions.rb @@ -15,8 +15,8 @@ module MembershipActions end def leave - member = Members::DestroyService.new(membershipable, current_user, user_id: current_user.id) - .execute(:all) + member = Members::DestroyService.new(membershipable, current_user, user_id: current_user.id). + execute(:all) source_type = membershipable.class.to_s.humanize(capitalize: false) notice = diff --git a/app/controllers/concerns/merge_requests_action.rb b/app/controllers/concerns/merge_requests_action.rb index d3c8e4888bca3bcbc87bf7b08b6cf2981e7229a5..28e34cffc24b142dfc98c0a98a85d08ea03874aa 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 8e42cdf415f55c0453c4e37c0af4e11e079c3566..cd5cef2c20f350c96b7bed57b9e5fb2257085c12 100644 --- a/app/controllers/import/bitbucket_controller.rb +++ b/app/controllers/import/bitbucket_controller.rb @@ -29,9 +29,9 @@ class Import::BitbucketController < Import::BaseController end def jobs - render json: current_user.created_projects - .where(import_type: 'bitbucket') - .to_json(only: [:id, :import_status]) + render json: current_user.created_projects. + where(import_type: 'bitbucket'). + to_json(only: [:id, :import_status]) end def create diff --git a/app/controllers/jwt_controller.rb b/app/controllers/jwt_controller.rb index 1b40645f2c99b910f16b3d828bef60e1cdce7137..3109439b2ff4853e84ea9733100fdbd154d41933 100644 --- a/app/controllers/jwt_controller.rb +++ b/app/controllers/jwt_controller.rb @@ -11,8 +11,8 @@ class JwtController < ApplicationController service = SERVICES[params[:service]] return head :not_found unless service - result = service.new(@authentication_result.project, @authentication_result.actor, auth_params) - .execute(authentication_abilities: @authentication_result.authentication_abilities) + result = service.new(@authentication_result.project, @authentication_result.actor, auth_params). + execute(authentication_abilities: @authentication_result.authentication_abilities) render json: result, status: result[:http_status] end diff --git a/app/controllers/omniauth_callbacks_controller.rb b/app/controllers/omniauth_callbacks_controller.rb index 0faa446aff949e7fb1029cb15fa189c9f3d24208..58d50ad647bf1d858046122fe573998135cd8e19 100644 --- a/app/controllers/omniauth_callbacks_controller.rb +++ b/app/controllers/omniauth_callbacks_controller.rb @@ -144,7 +144,7 @@ class OmniauthCallbacksController < Devise::OmniauthCallbacksController end def log_audit_event(user, options = {}) - AuditEventService.new(user, user, options) - .for_authentication.security_event + AuditEventService.new(user, user, options). + for_authentication.security_event end end diff --git a/app/controllers/profiles_controller.rb b/app/controllers/profiles_controller.rb index cc500af81dbb76cc0761b2e6bef1dce6590c6a76..f0c71725ea8c851a66c38bc209472f9657f8fa39 100644 --- a/app/controllers/profiles_controller.rb +++ b/app/controllers/profiles_controller.rb @@ -41,9 +41,9 @@ class ProfilesController < Profiles::ApplicationController end def audit_log - @events = AuditEvent.where(entity_type: "User", entity_id: current_user.id) - .order("created_at DESC") - .page(params[:page]) + @events = AuditEvent.where(entity_type: "User", entity_id: current_user.id). + order("created_at DESC"). + page(params[:page]) end def update_username diff --git a/app/controllers/projects/badges_controller.rb b/app/controllers/projects/badges_controller.rb index 6c25cd83a24353c6c5321248e997691136c721f9..c1727d9fa28454cc056cac62d5858ea3fc6059db 100644 --- a/app/controllers/projects/badges_controller.rb +++ b/app/controllers/projects/badges_controller.rb @@ -4,15 +4,15 @@ class Projects::BadgesController < Projects::ApplicationController before_action :no_cache_headers, except: [:index] def build - build_status = Gitlab::Badge::Build::Status - .new(project, params[:ref]) + build_status = Gitlab::Badge::Build::Status. + new(project, params[:ref]) render_badge build_status end def coverage - coverage_report = Gitlab::Badge::Coverage::Report - .new(project, params[:ref], params[:job]) + coverage_report = Gitlab::Badge::Coverage::Report. + new(project, params[:ref], params[:job]) render_badge coverage_report end diff --git a/app/controllers/projects/blob_controller.rb b/app/controllers/projects/blob_controller.rb index 647faca40a0d90abfd73435a2d730a02279279fe..39ba815cfcaf17c0bf87ba33d0bc7cb471ed50ee 100644 --- a/app/controllers/projects/blob_controller.rb +++ b/app/controllers/projects/blob_controller.rb @@ -164,7 +164,7 @@ class Projects::BlobController < Projects::ApplicationController end def set_last_commit_sha - @last_commit_sha = Gitlab::Git::Commit - .last_for_path(@repository, @ref, @path).sha + @last_commit_sha = Gitlab::Git::Commit. + last_for_path(@repository, @ref, @path).sha end end diff --git a/app/controllers/projects/boards/issues_controller.rb b/app/controllers/projects/boards/issues_controller.rb index 61fef4dc133d183c61d84e8dce55f813c675922b..8bcf18642cf36fed4bb9a0b46f4468739ccf5276 100644 --- a/app/controllers/projects/boards/issues_controller.rb +++ b/app/controllers/projects/boards/issues_controller.rb @@ -40,10 +40,10 @@ module Projects def issue @issue ||= - IssuesFinder.new(current_user, project_id: project.id) - .execute - .where(iid: params[:id]) - .first! + IssuesFinder.new(current_user, project_id: project.id). + execute. + where(iid: params[:id]). + first! end def authorize_read_issue! diff --git a/app/controllers/projects/branches_controller.rb b/app/controllers/projects/branches_controller.rb index c37a0653ff95499f3de00f3911e3d3041886f318..89d84809e3abf5dd5e85a6d35c1180b5407026e6 100644 --- a/app/controllers/projects/branches_controller.rb +++ b/app/controllers/projects/branches_controller.rb @@ -32,8 +32,8 @@ class Projects::BranchesController < Projects::ApplicationController branch_name = sanitize(strip_tags(params[:branch_name])) branch_name = Addressable::URI.unescape(branch_name) - result = CreateBranchService.new(project, current_user) - .execute(branch_name, ref) + result = CreateBranchService.new(project, current_user). + execute(branch_name, ref) if params[:issue_iid] issue = IssuesFinder.new(current_user, project_id: @project.id).find_by(iid: params[:issue_iid]) diff --git a/app/controllers/projects/builds_controller.rb b/app/controllers/projects/builds_controller.rb index 0db18d444f709fdea81a0a04c8c97861882316c8..886934a3f677e884ade8a5bf903d79f4a4ae4110 100644 --- a/app/controllers/projects/builds_controller.rb +++ b/app/controllers/projects/builds_controller.rb @@ -48,8 +48,8 @@ class Projects::BuildsController < Projects::ApplicationController respond_to do |format| format.json do state = params[:state].presence - render json: @build.trace_with_state(state: state) - .merge!(id: @build.id, status: @build.status) + render json: @build.trace_with_state(state: state). + merge!(id: @build.id, status: @build.status) end end end diff --git a/app/controllers/projects/commit_controller.rb b/app/controllers/projects/commit_controller.rb index e10d7992db754bea7122daa3045055c22859b5cf..23466dda9815d5b633cdd854f80f5bf343df72c9 100644 --- a/app/controllers/projects/commit_controller.rb +++ b/app/controllers/projects/commit_controller.rb @@ -35,9 +35,9 @@ class Projects::CommitController < Projects::ApplicationController respond_to do |format| format.html format.json do - render json: PipelineSerializer - .new(project: @project, user: @current_user) - .represent(@pipelines) + render json: PipelineSerializer. + new(project: @project, user: @current_user). + represent(@pipelines) end end end diff --git a/app/controllers/projects/commits_controller.rb b/app/controllers/projects/commits_controller.rb index 855147c89841472be77b2aff1494c18cc446c75d..ad92f05a42dbe8cc951e74c353f1604c3cadd6a4 100644 --- a/app/controllers/projects/commits_controller.rb +++ b/app/controllers/projects/commits_controller.rb @@ -18,11 +18,11 @@ class Projects::CommitsController < Projects::ApplicationController @repository.commits(@ref, path: @path, limit: @limit, offset: @offset) end - @note_counts = project.notes.where(commit_id: @commits.map(&:id)) - .group(:commit_id).count + @note_counts = project.notes.where(commit_id: @commits.map(&:id)). + group(:commit_id).count - @merge_request = MergeRequestsFinder.new(current_user, project_id: @project.id).execute.opened - .find_by(source_project: @project, source_branch: @ref, target_branch: @repository.root_ref) + @merge_request = MergeRequestsFinder.new(current_user, project_id: @project.id).execute.opened. + find_by(source_project: @project, source_branch: @ref, target_branch: @repository.root_ref) respond_to do |format| format.html diff --git a/app/controllers/projects/compare_controller.rb b/app/controllers/projects/compare_controller.rb index 7ef2f90ef0180063736a6c31631196b6ad6db7e7..99204c82784ac9ff3956540909a8ddf153eb93ce 100644 --- a/app/controllers/projects/compare_controller.rb +++ b/app/controllers/projects/compare_controller.rb @@ -46,8 +46,8 @@ class Projects::CompareController < Projects::ApplicationController end def define_diff_vars - @compare = CompareService.new(@project, @head_ref) - .execute(@project, @start_ref) + @compare = CompareService.new(@project, @head_ref). + execute(@project, @start_ref) if @compare @commits = @compare.commits @@ -66,7 +66,7 @@ class Projects::CompareController < Projects::ApplicationController end def merge_request - @merge_request ||= MergeRequestsFinder.new(current_user, project_id: @project.id).execute.opened - .find_by(source_project: @project, source_branch: @head_ref, target_branch: @start_ref) + @merge_request ||= MergeRequestsFinder.new(current_user, project_id: @project.id).execute.opened. + find_by(source_project: @project, source_branch: @head_ref, target_branch: @start_ref) end end diff --git a/app/controllers/projects/environments_controller.rb b/app/controllers/projects/environments_controller.rb index fed75396d6e072088744718b7170bc8a0ad58f79..2bbd8c6d04672a76ec9288de3dc128990f3d9bba 100644 --- a/app/controllers/projects/environments_controller.rb +++ b/app/controllers/projects/environments_controller.rb @@ -9,18 +9,18 @@ class Projects::EnvironmentsController < Projects::ApplicationController before_action :verify_api_request!, only: :terminal_websocket_authorize def index - @environments = project.environments - .with_state(params[:scope] || :available) + @environments = project.environments. + with_state(params[:scope] || :available) respond_to do |format| format.html format.json do render json: { - environments: EnvironmentSerializer - .new(project: @project, user: @current_user) - .with_pagination(request, response) - .within_folders - .represent(@environments), + environments: EnvironmentSerializer. + new(project: @project, user: @current_user). + with_pagination(request, response). + within_folders. + represent(@environments), available_count: project.environments.available.count, stopped_count: project.environments.stopped.count } @@ -36,10 +36,10 @@ class Projects::EnvironmentsController < Projects::ApplicationController format.html format.json do render json: { - environments: EnvironmentSerializer - .new(project: @project, user: @current_user) - .with_pagination(request, response) - .represent(@environments), + environments: EnvironmentSerializer. + new(project: @project, user: @current_user). + with_pagination(request, response). + represent(@environments), available_count: folder_environments.available.count, stopped_count: folder_environments.stopped.count } diff --git a/app/controllers/projects/issues_controller.rb b/app/controllers/projects/issues_controller.rb index 4c009dd238c68406117eaff329e66f1f075733a0..ca5e81100daf905e9beb9c01edf3f036822c0e07 100644 --- a/app/controllers/projects/issues_controller.rb +++ b/app/controllers/projects/issues_controller.rb @@ -77,8 +77,8 @@ class Projects::IssuesController < Projects::ApplicationController def show raw_notes = @issue.notes.inc_relations_for_view.fresh - @notes = Banzai::NoteRenderer - .render(raw_notes, @project, current_user, @path, @project_wiki, @ref) + @notes = Banzai::NoteRenderer. + render(raw_notes, @project, current_user, @path, @project_wiki, @ref) @note = @project.notes.new(noteable: @issue) @noteable = @issue @@ -189,9 +189,9 @@ class Projects::IssuesController < Projects::ApplicationController def merge_request_for_resolving_discussions return unless merge_request_iid = params[:merge_request_for_resolving_discussions] - @merge_request_for_resolving_discussions ||= MergeRequestsFinder.new(current_user, project_id: project.id) - .execute - .find_by(iid: merge_request_iid) + @merge_request_for_resolving_discussions ||= MergeRequestsFinder.new(current_user, project_id: project.id). + execute. + find_by(iid: merge_request_iid) end def authorize_read_issue! diff --git a/app/controllers/projects/merge_requests_controller.rb b/app/controllers/projects/merge_requests_controller.rb index 1f228d28f804cdb8b063c7733ff33a888a51d414..5ee7972e29e9fcc8cf1b66fb828f21b0e55a9d07 100644 --- a/app/controllers/projects/merge_requests_controller.rb +++ b/app/controllers/projects/merge_requests_controller.rb @@ -162,8 +162,8 @@ class Projects::MergeRequestsController < Projects::ApplicationController # Get commits from repository # or from cache if already merged @commits = @merge_request.commits - @note_counts = Note.where(commit_id: @commits.map(&:id)) - .group(:commit_id).count + @note_counts = Note.where(commit_id: @commits.map(&:id)). + group(:commit_id).count render json: { html: view_to_html_string('projects/merge_requests/show/_commits') } end @@ -232,9 +232,9 @@ class Projects::MergeRequestsController < Projects::ApplicationController end format.json do - render json: PipelineSerializer - .new(project: @project, user: @current_user) - .represent(@pipelines) + render json: PipelineSerializer. + new(project: @project, user: @current_user). + represent(@pipelines) end end end @@ -245,9 +245,9 @@ class Projects::MergeRequestsController < Projects::ApplicationController format.json do define_pipelines_vars - render json: PipelineSerializer - .new(project: @project, user: @current_user) - .represent(@pipelines) + render json: PipelineSerializer. + new(project: @project, user: @current_user). + represent(@pipelines) end end end @@ -332,9 +332,9 @@ class Projects::MergeRequestsController < Projects::ApplicationController return access_denied! end - MergeRequests::MergeWhenPipelineSucceedsService - .new(@project, current_user) - .cancel(@merge_request) + MergeRequests::MergeWhenPipelineSucceedsService. + new(@project, current_user). + cancel(@merge_request) end def merge @@ -361,9 +361,9 @@ class Projects::MergeRequestsController < Projects::ApplicationController end if @merge_request.head_pipeline.active? - MergeRequests::MergeWhenPipelineSucceedsService - .new(@project, current_user, merge_params) - .execute(@merge_request) + MergeRequests::MergeWhenPipelineSucceedsService. + new(@project, current_user, merge_params). + execute(@merge_request) @status = :merge_when_build_succeeds elsif @merge_request.head_pipeline.success? @@ -624,8 +624,8 @@ class Projects::MergeRequestsController < Projects::ApplicationController @commit = @merge_request.diff_head_commit @base_commit = @merge_request.diff_base_commit - @note_counts = Note.where(commit_id: @commits.map(&:id)) - .group(:commit_id).count + @note_counts = Note.where(commit_id: @commits.map(&:id)). + group(:commit_id).count @labels = LabelsFinder.new(current_user, project_id: @project.id).execute @@ -640,8 +640,8 @@ class Projects::MergeRequestsController < Projects::ApplicationController end def merge_request_params - params.require(:merge_request) - .permit(merge_request_params_ce) + params.require(:merge_request). + permit(merge_request_params_ce) end def merge_request_params_ce diff --git a/app/controllers/projects/pipelines_controller.rb b/app/controllers/projects/pipelines_controller.rb index e436c6666c31f9e565ffc77fd2826cbaaa85af8d..0f2b7b2a4c889d2415520cb33ac6061605344358 100644 --- a/app/controllers/projects/pipelines_controller.rb +++ b/app/controllers/projects/pipelines_controller.rb @@ -7,11 +7,11 @@ class Projects::PipelinesController < Projects::ApplicationController def index @scope = params[:scope] - @pipelines = PipelinesFinder - .new(project) - .execute(scope: @scope) - .page(params[:page]) - .per(30) + @pipelines = PipelinesFinder. + new(project). + execute(scope: @scope). + page(params[:page]). + per(30) @running_count = PipelinesFinder. .new(project).execute(scope: 'running').count @@ -29,10 +29,10 @@ class Projects::PipelinesController < Projects::ApplicationController format.html format.json do render json: { - pipelines: PipelineSerializer - .new(project: @project, user: @current_user) - .with_pagination(request, response) - .represent(@pipelines), + pipelines: PipelineSerializer. + new(project: @project, user: @current_user). + with_pagination(request, response). + represent(@pipelines), count: { all: @pipelines_count, running: @running_count, @@ -49,9 +49,9 @@ class Projects::PipelinesController < Projects::ApplicationController end def create - @pipeline = Ci::CreatePipelineService - .new(project, current_user, create_params) - .execute(ignore_skip_ci: true, save_on_errors: false) + @pipeline = Ci::CreatePipelineService. + new(project, current_user, create_params). + execute(ignore_skip_ci: true, save_on_errors: false) unless @pipeline.persisted? render 'new' return diff --git a/app/controllers/projects/project_members_controller.rb b/app/controllers/projects/project_members_controller.rb index 3c582d15a4c6e97d2b6412cc5015396720efd733..6e158e685e99470e5d6b1203266732f5c0b4c819 100644 --- a/app/controllers/projects/project_members_controller.rb +++ b/app/controllers/projects/project_members_controller.rb @@ -31,8 +31,8 @@ class Projects::ProjectMembersController < Projects::ApplicationController end def destroy - Members::DestroyService.new(@project, current_user, params) - .execute(:all) + Members::DestroyService.new(@project, current_user, params). + execute(:all) respond_to do |format| format.html do diff --git a/app/controllers/projects/settings/ci_cd_controller.rb b/app/controllers/projects/settings/ci_cd_controller.rb index 24fe78bc1bd0d62bd062c35fed90a3e8b8d32a82..6f009d6195062cba1af675340f2354b6d9dd113e 100644 --- a/app/controllers/projects/settings/ci_cd_controller.rb +++ b/app/controllers/projects/settings/ci_cd_controller.rb @@ -14,8 +14,8 @@ module Projects def define_runners_variables @project_runners = @project.runners.ordered - @assignable_runners = current_user.ci_authorized_runners - .assignable_for(project).ordered.page(params[:page]).per(20) + @assignable_runners = current_user.ci_authorized_runners. + assignable_for(project).ordered.page(params[:page]).per(20) @shared_runners = Ci::Runner.shared.active @shared_runners_count = @shared_runners.count(:all) end diff --git a/app/controllers/projects/settings/members_controller.rb b/app/controllers/projects/settings/members_controller.rb index f4c79b796fdd69b4acca7fe902391d26a110ef61..5735e281f66e772b5b31600ef71e777a233d94d6 100644 --- a/app/controllers/projects/settings/members_controller.rb +++ b/app/controllers/projects/settings/members_controller.rb @@ -41,10 +41,10 @@ module Projects wheres = ["members.id IN (#{@project_members.select(:id).to_sql})"] wheres << "members.id IN (#{group_members.select(:id).to_sql})" if group_members - @project_members = Member - .where(wheres.join(' OR ')) - .sort(@sort) - .page(params[:page]) + @project_members = Member. + where(wheres.join(' OR ')). + sort(@sort). + page(params[:page]) @requesters = AccessRequestsFinder.new(@project).execute(current_user) diff --git a/app/controllers/projects/tags_controller.rb b/app/controllers/projects/tags_controller.rb index 5aaec97a08285bde4bcb247a1408d241e30fcc84..33379659d739280ecd48de145b11d12a05f452be 100644 --- a/app/controllers/projects/tags_controller.rb +++ b/app/controllers/projects/tags_controller.rb @@ -27,8 +27,8 @@ class Projects::TagsController < Projects::ApplicationController end def create - result = Tags::CreateService.new(@project, current_user) - .execute(params[:tag_name], params[:ref], params[:message], params[:release_description]) + result = Tags::CreateService.new(@project, current_user). + execute(params[:tag_name], params[:ref], params[:message], params[:release_description]) if result[:status] == :success @tag = result[:tag] diff --git a/app/controllers/projects/uploads_controller.rb b/app/controllers/projects/uploads_controller.rb index 1e7d72f5faa1d3fc5a0405a5ad42b3755a38c087..61686499bd3d38c16c512a0280a3129b5606f0af 100644 --- a/app/controllers/projects/uploads_controller.rb +++ b/app/controllers/projects/uploads_controller.rb @@ -5,8 +5,8 @@ class Projects::UploadsController < Projects::ApplicationController before_action :authorize_upload_file!, only: [:create] def create - link_to_file = ::Projects::UploadService.new(project, params[:file]) - .execute + link_to_file = ::Projects::UploadService.new(project, params[:file]). + execute respond_to do |format| if link_to_file diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index acca821782c7d17205fbc7f957158972a668aebb..9ffb8152e32d00b6b7a2e8895497c1577e9eede6 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -293,8 +293,8 @@ class ProjectsController < Projects::ApplicationController end def project_params - params.require(:project) - .permit(project_params_ce) + params.require(:project). + permit(project_params_ce) end def project_params_ce diff --git a/app/controllers/sessions_controller.rb b/app/controllers/sessions_controller.rb index b632bbaaf78b0a1d76120c860d8c80894c6598fc..7d81c96262f89a29d4d768e47c2e00b73615ed3a 100644 --- a/app/controllers/sessions_controller.rb +++ b/app/controllers/sessions_controller.rb @@ -119,8 +119,8 @@ class SessionsController < Devise::SessionsController end def log_audit_event(user, options = {}) - AuditEventService.new(user, user, options) - .for_authentication.security_event + AuditEventService.new(user, user, options). + for_authentication.security_event end def load_recaptcha diff --git a/app/controllers/sherlock/application_controller.rb b/app/controllers/sherlock/application_controller.rb index 6bdd3568a7899d2bd2497363807dc32565a095bc..682ca5e382155f51ccc84432c29b9ecb13ea296a 100644 --- a/app/controllers/sherlock/application_controller.rb +++ b/app/controllers/sherlock/application_controller.rb @@ -4,8 +4,8 @@ module Sherlock def find_transaction if params[:transaction_id] - @transaction = Gitlab::Sherlock.collection - .find_transaction(params[:transaction_id]) + @transaction = Gitlab::Sherlock.collection. + find_transaction(params[:transaction_id]) end end end diff --git a/app/controllers/snippets_controller.rb b/app/controllers/snippets_controller.rb index 2e0f26ade91bd9e454cd99c7bd6f9198b2d5d57f..f3fd3da8b2033b5629f380a644190e45b1ea55b3 100644 --- a/app/controllers/snippets_controller.rb +++ b/app/controllers/snippets_controller.rb @@ -83,8 +83,8 @@ class SnippetsController < ApplicationController @snippet ||= if current_user PersonalSnippet.where("author_id = ? OR visibility_level IN (?)", current_user.id, - [Snippet::PUBLIC, Snippet::INTERNAL]) - .find(params[:id]) + [Snippet::PUBLIC, Snippet::INTERNAL]). + find(params[:id]) else PersonalSnippet.find(params[:id]) end diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 73056df5bef5515ecda771b3adcd1d0a3974135a..c92594d4097d486965af5a5a1edd05a0cb1611de 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -109,17 +109,17 @@ class UsersController < ApplicationController def load_events # Get user activity feed for projects common for both users - @events = user.recent_events - .merge(projects_for_current_user) - .references(:project) - .with_associations - .limit_recent(20, params[:offset]) + @events = user.recent_events. + merge(projects_for_current_user). + references(:project). + with_associations. + limit_recent(20, params[:offset]) end def load_projects @projects = - PersonalProjectsFinder.new(user).execute(current_user) - .page(params[:page]) + PersonalProjectsFinder.new(user).execute(current_user). + page(params[:page]) end def load_contributed_projects diff --git a/app/finders/environments_finder.rb b/app/finders/environments_finder.rb index a59f8c1efa355566c2028b8692c866403b81a93c..52c73abc31d777131ce2a210745363adf352caba 100644 --- a/app/finders/environments_finder.rb +++ b/app/finders/environments_finder.rb @@ -17,12 +17,12 @@ class EnvironmentsFinder deployments.none end - environment_ids = deployments - .group(:environment_id) - .select(:environment_id) + environment_ids = deployments. + group(:environment_id). + select(:environment_id) - environments = project.environments.available - .where(id: environment_ids).order_by_last_deployed_at.to_a + environments = project.environments.available. + where(id: environment_ids).order_by_last_deployed_at.to_a environments.select! do |environment| Ability.allowed?(current_user, :read_environment, environment) diff --git a/app/finders/group_members_finder.rb b/app/finders/group_members_finder.rb index 873a253e2b5939668482a3c89c6157cd69c3c2df..9f2206346ce065711df474c073b2746eb4b9e07d 100644 --- a/app/finders/group_members_finder.rb +++ b/app/finders/group_members_finder.rb @@ -8,9 +8,9 @@ class GroupMembersFinder < Projects::ApplicationController return group_members unless @group.parent - parents_members = GroupMember.non_request - .where(source_id: @group.ancestors.select(:id)) - .where.not(user_id: @group.users.select(:id)) + parents_members = GroupMember.non_request. + where(source_id: @group.ancestors.select(:id)). + where.not(user_id: @group.users.select(:id)) wheres = ["members.id IN (#{group_members.select(:id).to_sql})"] wheres << "members.id IN (#{parents_members.select(:id).to_sql})" diff --git a/app/helpers/form_helper.rb b/app/helpers/form_helper.rb index 913db3a3e26e9143492528329ac15e3480455520..1182939f656958db73c42a4673a0b1a4304e5ba8 100644 --- a/app/helpers/form_helper.rb +++ b/app/helpers/form_helper.rb @@ -8,10 +8,10 @@ module FormHelper content_tag(:div, class: 'alert alert-danger', id: 'error_explanation') do content_tag(:h4, headline) << content_tag(:ul) do - model.errors.full_messages - .map { |msg| content_tag(:li, msg) } - .join - .html_safe + model.errors.full_messages. + map { |msg| content_tag(:li, msg) }. + join. + html_safe end end end diff --git a/app/helpers/search_helper.rb b/app/helpers/search_helper.rb index 7a164cfd26d4db08b7f96326ac12c036daf3e895..8ff8db165149a30a9bf51efd358047af25dfc421 100644 --- a/app/helpers/search_helper.rb +++ b/app/helpers/search_helper.rb @@ -97,8 +97,8 @@ module SearchHelper # Autocomplete results for the current user's projects def projects_autocomplete(term, limit = 5) - current_user.authorized_projects.search_by_title(term) - .sorted_by_stars.non_archived.limit(limit).map do |p| + current_user.authorized_projects.search_by_title(term). + sorted_by_stars.non_archived.limit(limit).map do |p| { category: "Projects", id: p.id, diff --git a/app/helpers/wiki_helper.rb b/app/helpers/wiki_helper.rb index 99212a3438f7f5415a4239bfc2924c763e187fe8..3e3f6246fc5ef033f939ffd18afc6463bfbbbfea 100644 --- a/app/helpers/wiki_helper.rb +++ b/app/helpers/wiki_helper.rb @@ -6,8 +6,8 @@ module WikiHelper # Returns a String composed of the capitalized name of each directory and the # capitalized name of the page itself. def breadcrumb(page_slug) - page_slug.split('/') - .map { |dir_or_page| WikiPage.unhyphenize(dir_or_page).capitalize } - .join(' / ') + page_slug.split('/'). + map { |dir_or_page| WikiPage.unhyphenize(dir_or_page).capitalize }. + join(' / ') end end diff --git a/app/models/award_emoji.rb b/app/models/award_emoji.rb index 2eedbf3ffde0795d9bfe4d46f093c99e5ecf56de..6937ad3bdd98e559ca008df6267abdfff2f563fe 100644 --- a/app/models/award_emoji.rb +++ b/app/models/award_emoji.rb @@ -18,9 +18,9 @@ class AwardEmoji < ActiveRecord::Base class << self def votes_for_collection(ids, type) - select('name', 'awardable_id', 'COUNT(*) as count') - .where('name IN (?) AND awardable_type = ? AND awardable_id IN (?)', [DOWNVOTE_NAME, UPVOTE_NAME], type, ids) - .group('name', 'awardable_id') + select('name', 'awardable_id', 'COUNT(*) as count'). + where('name IN (?) AND awardable_type = ? AND awardable_id IN (?)', [DOWNVOTE_NAME, UPVOTE_NAME], type, ids). + group('name', 'awardable_id') end end diff --git a/app/models/ci/build.rb b/app/models/ci/build.rb index 3a17d5c8dbe4baa20b93f390c7b5358a14aa1788..2689078c771afbf4c21d4096e9c37fb8e0adfac3 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) @@ -276,8 +276,8 @@ module Ci def raw_trace(last_lines: nil) if File.exist?(trace_file_path) - Gitlab::Ci::TraceReader.new(trace_file_path) - .read(last_lines: last_lines) + Gitlab::Ci::TraceReader.new(trace_file_path). + read(last_lines: last_lines) else # backward compatibility read_attribute :trace diff --git a/app/models/ci/pipeline.rb b/app/models/ci/pipeline.rb index 632178de8870a848870c67b41e853616a0137ffb..04d43ca3c5c8289cb8b84d2bf38303d9be4b88e0 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)) @@ -128,23 +128,23 @@ module Ci end def stages_name - statuses.order(:stage_idx).distinct - .pluck(:stage, :stage_idx).map(&:first) + statuses.order(:stage_idx).distinct. + pluck(:stage, :stage_idx).map(&:first) end def stages # TODO, this needs refactoring, see gitlab-ce#26481. - stages_query = statuses - .group('stage').select(:stage).order('max(stage_idx)') + stages_query = statuses. + group('stage').select(:stage).order('max(stage_idx)') status_sql = statuses.latest.where('stage=sg.stage').status_sql - warnings_sql = statuses.latest.select('COUNT(*) > 0') - .where('stage=sg.stage').failed_but_allowed.to_sql + warnings_sql = statuses.latest.select('COUNT(*) > 0'). + where('stage=sg.stage').failed_but_allowed.to_sql - stages_with_statuses = CommitStatus.from(stages_query, :sg) - .pluck('sg.stage', status_sql, "(#{warnings_sql})") + stages_with_statuses = CommitStatus.from(stages_query, :sg). + pluck('sg.stage', status_sql, "(#{warnings_sql})") stages_with_statuses.map do |stage| Ci::Stage.new(self, Hash[%i[name status warnings].zip(stage)]) @@ -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) @@ -253,9 +253,9 @@ module Ci def config_builds_attributes return [] unless config_processor - config_processor - .builds_for_ref(ref, tag?, trigger_requests.first) - .sort_by { |build| build[:stage_idx] } + config_processor. + builds_for_ref(ref, tag?, trigger_requests.first). + sort_by { |build| build[:stage_idx] } end def has_warnings? @@ -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 9cf6164e8ddcabc8ed36eb9fed996e3e9dbc519e..a120112e882568771d9af24655bb402e390a3301 100644 --- a/app/models/ci/runner.rb +++ b/app/models/ci/runner.rb @@ -23,15 +23,15 @@ module Ci scope :ordered, ->() { order(id: :desc) } scope :owned_or_shared, ->(project_id) do - joins('LEFT JOIN ci_runner_projects ON ci_runner_projects.runner_id = ci_runners.id') - .where("ci_runner_projects.gl_project_id = :project_id OR ci_runners.is_shared = true", project_id: project_id) + joins('LEFT JOIN ci_runner_projects ON ci_runner_projects.runner_id = ci_runners.id'). + where("ci_runner_projects.gl_project_id = :project_id OR ci_runners.is_shared = true", project_id: project_id) end scope :assignable_for, ->(project) do # FIXME: That `to_sql` is needed to workaround a weird Rails bug. # Without that, placeholders would miss one and couldn't match. - where(locked: false) - .where.not("id IN (#{project.runners.select(:id).to_sql})").specific + where(locked: false). + where.not("id IN (#{project.runners.select(:id).to_sql})").specific end validate :tag_constraints diff --git a/app/models/ci/stage.rb b/app/models/ci/stage.rb index ca74c91b0627b5861e8052b0c94c31a081c22ee1..0751ab1b7d85ef1f0cc7f456ebf90908b547f3d2 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 fc750a3e5e9150ebb94708b8b4cd5d5a1ccfbfa6..1349beafb76f5822ea1a3f12248a9bfb11831373 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/issuable.rb b/app/models/concerns/issuable.rb index fcb335e48d1a22d6163428ecf2d91aabc8f7c7bd..37c727b5d9f09323879d5c99b9c7d744f4d1d057 100644 --- a/app/models/concerns/issuable.rb +++ b/app/models/concerns/issuable.rb @@ -162,9 +162,9 @@ module Issuable highest_priority = highest_label_priority(params).to_sql - select("#{table_name}.*, (#{highest_priority}) AS highest_priority") - .group(arel_table[:id]) - .reorder(Gitlab::Database.nulls_last_order('highest_priority', 'ASC')) + select("#{table_name}.*, (#{highest_priority}) AS highest_priority"). + group(arel_table[:id]). + reorder(Gitlab::Database.nulls_last_order('highest_priority', 'ASC')) end def with_label(title, sort = nil) diff --git a/app/models/concerns/mentionable.rb b/app/models/concerns/mentionable.rb index a8ce36e51fc06194b800d5aadf72c1d9cd3e4144..7e56e371b27bd046e4a1eaca1944b8a265779b8b 100644 --- a/app/models/concerns/mentionable.rb +++ b/app/models/concerns/mentionable.rb @@ -48,8 +48,8 @@ module Mentionable if extractor @extractor = extractor else - @extractor ||= Gitlab::ReferenceExtractor - .new(project, current_user) + @extractor ||= Gitlab::ReferenceExtractor. + new(project, current_user) @extractor.reset_memoized_values end diff --git a/app/models/concerns/milestoneish.rb b/app/models/concerns/milestoneish.rb index f449229864d44debc9fb5b3e5ff0a177a2141eeb..870a6fbaa90daf57083ae70f1dfdb8ad99d02d26 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 7b33b8370043cd9e7b66c72bd31fa672966b93bc..d0f84831d710b47dda6ac3415ac7b82c55589a00 100644 --- a/app/models/concerns/presentable.rb +++ b/app/models/concerns/presentable.rb @@ -1,7 +1,7 @@ module Presentable def present(**attributes) - Gitlab::View::Presenter::Factory - .new(self, attributes) - .fabricate! + Gitlab::View::Presenter::Factory. + new(self, attributes). + fabricate! end end diff --git a/app/models/concerns/routable.rb b/app/models/concerns/routable.rb index c2373de32c50585588636c7f461de5e9c006bb12..9f6d215ceb3a3c4b3d7d7f37b9c19d9ed5cfd494 100644 --- a/app/models/concerns/routable.rb +++ b/app/models/concerns/routable.rb @@ -75,11 +75,11 @@ module Routable # # Returns an ActiveRecord::Relation. def member_descendants(user_id) - joins(:route) - .joins("INNER JOIN routes r2 ON routes.path LIKE CONCAT(r2.path, '/%') + joins(:route). + joins("INNER JOIN routes r2 ON routes.path LIKE CONCAT(r2.path, '/%') INNER JOIN members ON members.source_id = r2.source_id - AND members.source_type = r2.source_type") - .where('members.user_id = ?', user_id) + AND members.source_type = r2.source_type"). + where('members.user_id = ?', user_id) end end diff --git a/app/models/concerns/sortable.rb b/app/models/concerns/sortable.rb index a155a0640321f033b666b55b92a9f0ed84a9f05a..b9a2d812edd429e9d3b3d4af0d2eacc2c0812921 100644 --- a/app/models/concerns/sortable.rb +++ b/app/models/concerns/sortable.rb @@ -39,12 +39,12 @@ module Sortable private def highest_label_priority(target_type_column: nil, target_type: nil, target_column:, project_column:, excluded_labels: []) - query = Label.select(LabelPriority.arel_table[:priority].minimum) - .left_join_priorities - .joins(:label_links) - .where("label_priorities.project_id = #{project_column}") - .where("label_links.target_id = #{target_column}") - .reorder(nil) + query = Label.select(LabelPriority.arel_table[:priority].minimum). + left_join_priorities. + joins(:label_links). + where("label_priorities.project_id = #{project_column}"). + where("label_links.target_id = #{target_column}"). + reorder(nil) query = if target_type_column diff --git a/app/models/concerns/subscribable.rb b/app/models/concerns/subscribable.rb index f60a0f8f438eacd3e3b9b53173bc809d5cdfd324..e4f5818d0e34ed7f82bcee25eb3266177d779361 100644 --- a/app/models/concerns/subscribable.rb +++ b/app/models/concerns/subscribable.rb @@ -27,30 +27,30 @@ module Subscribable end def subscribers(project) - subscriptions_available(project) - .where(subscribed: true) - .map(&:user) + subscriptions_available(project). + where(subscribed: true). + map(&:user) end def toggle_subscription(user, project = nil) unsubscribe_from_other_levels(user, project) - find_or_initialize_subscription(user, project) - .update(subscribed: !subscribed?(user, project)) + find_or_initialize_subscription(user, project). + update(subscribed: !subscribed?(user, project)) end def subscribe(user, project = nil) unsubscribe_from_other_levels(user, project) - find_or_initialize_subscription(user, project) - .update(subscribed: true) + find_or_initialize_subscription(user, project). + update(subscribed: true) end def unsubscribe(user, project = nil) unsubscribe_from_other_levels(user, project) - find_or_initialize_subscription(user, project) - .update(subscribed: false) + find_or_initialize_subscription(user, project). + update(subscribed: false) end private @@ -69,14 +69,14 @@ module Subscribable end def find_or_initialize_subscription(user, project) - subscriptions - .find_or_initialize_by(user_id: user.id, project_id: project.try(:id)) + subscriptions. + find_or_initialize_by(user_id: user.id, project_id: project.try(:id)) end def subscriptions_available(project) t = Subscription.arel_table - subscriptions - .where(t[:project_id].eq(nil).or(t[:project_id].eq(project.try(:id)))) + subscriptions. + where(t[:project_id].eq(nil).or(t[:project_id].eq(project.try(:id)))) end end diff --git a/app/models/deployment.rb b/app/models/deployment.rb index 43f7460bd5d1d065945b07033295a5e77bd17c64..afad001d50f915a4e369de7803556c6d2f659751 100644 --- a/app/models/deployment.rb +++ b/app/models/deployment.rb @@ -53,10 +53,10 @@ class Deployment < ActiveRecord::Base def update_merge_request_metrics! return unless environment.update_merge_request_metrics? - merge_requests = project.merge_requests - .joins(:metrics) - .where(target_branch: self.ref, merge_request_metrics: { first_deployed_to_production_at: nil }) - .where("merge_request_metrics.merged_at <= ?", self.created_at) + merge_requests = project.merge_requests. + joins(:metrics). + where(target_branch: self.ref, merge_request_metrics: { first_deployed_to_production_at: nil }). + where("merge_request_metrics.merged_at <= ?", self.created_at) if previous_deployment merge_requests = merge_requests.where("merge_request_metrics.merged_at >= ?", previous_deployment.created_at) @@ -71,17 +71,17 @@ class Deployment < ActiveRecord::Base merge_requests.map(&:id) end - MergeRequest::Metrics - .where(merge_request_id: merge_request_ids, first_deployed_to_production_at: nil) - .update_all(first_deployed_to_production_at: self.created_at) + MergeRequest::Metrics. + where(merge_request_id: merge_request_ids, first_deployed_to_production_at: nil). + update_all(first_deployed_to_production_at: self.created_at) end def previous_deployment @previous_deployment ||= - project.deployments.joins(:environment) - .where(environments: { name: self.environment.name }, ref: self.ref) - .where.not(id: self.id) - .take + project.deployments.joins(:environment). + where(environments: { name: self.environment.name }, ref: self.ref). + where.not(id: self.id). + take end def stop_action diff --git a/app/models/environment.rb b/app/models/environment.rb index f917f52f8323f60e29fa714133ad23fc57d478a7..1a21b5e52b5435c826027eb022aa9e8992510d50 100644 --- a/app/models/environment.rb +++ b/app/models/environment.rb @@ -40,9 +40,9 @@ class Environment < ActiveRecord::Base scope :stopped, -> { with_state(:stopped) } scope :order_by_last_deployed_at, -> do max_deployment_id_sql = - Deployment.select(Deployment.arel_table[:id].maximum) - .where(Deployment.arel_table[:environment_id].eq(arel_table[:id])) - .to_sql + Deployment.select(Deployment.arel_table[:id].maximum). + where(Deployment.arel_table[:environment_id].eq(arel_table[:id])). + to_sql order(Gitlab::Database.nulls_first_order("(#{max_deployment_id_sql})", 'ASC')) end diff --git a/app/models/event.rb b/app/models/event.rb index b8918fcda211e6fa0d4dc1f13e83b2947bcc95c9..4b8eac9accf3b924242e522ca3df059481d802ce 100644 --- a/app/models/event.rb +++ b/app/models/event.rb @@ -343,9 +343,9 @@ class Event < ActiveRecord::Base # At this point it's possible for multiple threads/processes to try to # update the project. Only one query should actually perform the update, # hence we add the extra WHERE clause for last_activity_at. - Project.unscoped.where(id: project_id) - .where('last_activity_at <= ?', RESET_PROJECT_ACTIVITY_INTERVAL.ago) - .update_all(last_activity_at: created_at) + Project.unscoped.where(id: project_id). + where('last_activity_at <= ?', RESET_PROJECT_ACTIVITY_INTERVAL.ago). + update_all(last_activity_at: created_at) end def authored_by?(user) diff --git a/app/models/generic_commit_status.rb b/app/models/generic_commit_status.rb index 8867ba0d2ff5db2300f66b37558108974cac423f..36b8568871b2e8a37f66cf4fb5d44d8d2299f7c9 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 b991d78e27fc22bbd503300c83c52e39b4ed02f1..84deb67ba9bb62cadc7f2d0919df8defe359bdb2 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 5ef3f9513fcaebc138139a38769060821f23faab..1835ce118a1d06591504fcd15c6c1be99b89d97b 100644 --- a/app/models/group.rb +++ b/app/models/group.rb @@ -71,9 +71,9 @@ class Group < Namespace def select_for_project_authorization if current_scope.joins_values.include?(:shared_projects) - joins('INNER JOIN namespaces project_namespace ON project_namespace.id = projects.namespace_id') - .where('project_namespace.share_with_group_lock = ?', false) - .select("members.user_id, projects.id AS project_id, LEAST(project_group_links.group_access, members.access_level) AS access_level") + joins('INNER JOIN namespaces project_namespace ON project_namespace.id = projects.namespace_id'). + where('project_namespace.share_with_group_lock = ?', false). + select("members.user_id, projects.id AS project_id, LEAST(project_group_links.group_access, members.access_level) AS access_level") else super end @@ -197,8 +197,8 @@ class Group < Namespace end def refresh_members_authorized_projects - UserProjectAccessChangedService.new(user_ids_for_project_authorizations) - .execute + UserProjectAccessChangedService.new(user_ids_for_project_authorizations). + execute end def user_ids_for_project_authorizations diff --git a/app/models/issue_collection.rb b/app/models/issue_collection.rb index 49f011c113f58d96adcf5f3fd41104b5ae599e6f..f0b7d9914c80167f9c5aa94cbcaa3dd9e9b019d7 100644 --- a/app/models/issue_collection.rb +++ b/app/models/issue_collection.rb @@ -17,9 +17,9 @@ class IssueCollection # Given all the issue projects we get a list of projects that the current # user has at least reporter access to. - projects_with_reporter_access = user - .projects_with_reporter_access_limited_to(project_ids) - .pluck(:id) + projects_with_reporter_access = user. + projects_with_reporter_access_limited_to(project_ids). + pluck(:id) collection.select do |issue| if projects_with_reporter_access.include?(issue.project_id) diff --git a/app/models/label.rb b/app/models/label.rb index e97e53301ccced773d2a381a237bf9b2dcf56505..27429e60e4a8152a5e30953e67bbb471b12bdee8 100644 --- a/app/models/label.rb +++ b/app/models/label.rb @@ -34,18 +34,18 @@ class Label < ActiveRecord::Base scope :with_title, ->(title) { where(title: title) } def self.prioritized(project) - joins(:priorities) - .where(label_priorities: { project_id: project }) - .reorder('label_priorities.priority ASC, labels.title ASC') + joins(:priorities). + where(label_priorities: { project_id: project }). + reorder('label_priorities.priority ASC, labels.title ASC') end def self.unprioritized(project) labels = Label.arel_table priorities = LabelPriority.arel_table - label_priorities = labels.join(priorities, Arel::Nodes::OuterJoin) - .on(labels[:id].eq(priorities[:label_id]).and(priorities[:project_id].eq(project.id))) - .join_sources + label_priorities = labels.join(priorities, Arel::Nodes::OuterJoin). + on(labels[:id].eq(priorities[:label_id]).and(priorities[:project_id].eq(project.id))). + join_sources joins(label_priorities).where(priorities[:priority].eq(nil)) end @@ -54,9 +54,9 @@ class Label < ActiveRecord::Base labels = Label.arel_table priorities = LabelPriority.arel_table - label_priorities = labels.join(priorities, Arel::Nodes::OuterJoin) - .on(labels[:id].eq(priorities[:label_id])) - .join_sources + label_priorities = labels.join(priorities, Arel::Nodes::OuterJoin). + on(labels[:id].eq(priorities[:label_id])). + join_sources joins(label_priorities) end diff --git a/app/models/lfs_object.rb b/app/models/lfs_object.rb index 7712d5783e049d0d2121b6559603669a2b9c9da9..ee9ac282e39148b27d4395b566cd356d6d3b3645 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 f198fbe9056560abd5acbd9c466caeba92082a07..abe9aee3edf0a38d572daeb32963e47d001e70c1 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) } @@ -99,9 +99,9 @@ class Member < ActiveRecord::Base users = User.arel_table members = Member.arel_table - member_users = members.join(users, Arel::Nodes::OuterJoin) - .on(members[:user_id].eq(users[:id])) - .join_sources + member_users = members.join(users, Arel::Nodes::OuterJoin). + on(members[:user_id].eq(users[:id])). + join_sources joins(member_users) end diff --git a/app/models/merge_request.rb b/app/models/merge_request.rb index c4520c16a438f921b43de961be5678b3e3200a96..ea784f77015ae3468d96cd7ada039b324ac2bdfc 100644 --- a/app/models/merge_request.rb +++ b/app/models/merge_request.rb @@ -475,10 +475,10 @@ class MergeRequest < ActiveRecord::Base end def discussions - @discussions ||= self.related_notes - .inc_relations_for_view - .fresh - .discussions + @discussions ||= self.related_notes. + inc_relations_for_view. + fresh. + discussions end def diff_discussions @@ -564,8 +564,8 @@ class MergeRequest < ActiveRecord::Base messages = [title, description] messages.concat(commits.map(&:safe_message)) if merge_request_diff - Gitlab::ClosingIssueExtractor.new(project, current_user) - .closed_by_message(messages.join("\n")) + Gitlab::ClosingIssueExtractor.new(project, current_user). + closed_by_message(messages.join("\n")) else [] end @@ -813,9 +813,9 @@ class MergeRequest < ActiveRecord::Base def all_pipelines return Ci::Pipeline.none unless source_project - @all_pipelines ||= source_project.pipelines - .where(sha: all_commits_sha, ref: source_branch) - .order(id: :desc) + @all_pipelines ||= source_project.pipelines. + where(sha: all_commits_sha, ref: source_branch). + order(id: :desc) end # Note that this could also return SHA from now dangling commits diff --git a/app/models/merge_request_diff.rb b/app/models/merge_request_diff.rb index baee00b8fcde5a286ddaaabfa0ce246faaaf8604..53d08488788585daf6c64cb8b672b748529a4a5a 100644 --- a/app/models/merge_request_diff.rb +++ b/app/models/merge_request_diff.rb @@ -169,8 +169,8 @@ class MergeRequestDiff < ActiveRecord::Base # When compare merge request versions we want diff A..B instead of A...B # so we handle cases when user does squash and rebase of the commits between versions. # For this reason we set straight to true by default. - CompareService.new(project, head_commit_sha) - .execute(project, sha, straight: straight) + CompareService.new(project, head_commit_sha). + execute(project, sha, straight: straight) end def commits_count diff --git a/app/models/merge_requests_closing_issues.rb b/app/models/merge_requests_closing_issues.rb index 7f7c114803dd55154a33ba209a406b504702a4be..daafb137be4c2be3bb7eb360abad55d025ac10df 100644 --- a/app/models/merge_requests_closing_issues.rb +++ b/app/models/merge_requests_closing_issues.rb @@ -7,9 +7,9 @@ class MergeRequestsClosingIssues < ActiveRecord::Base class << self def count_for_collection(ids) - group(:issue_id) - .where(issue_id: ids) - .pluck('issue_id', 'COUNT(*) as count') + group(:issue_id). + where(issue_id: ids). + pluck('issue_id', 'COUNT(*) as count') end end end diff --git a/app/models/milestone.rb b/app/models/milestone.rb index 30e5dfd096e6d6bd011006ef9aea980cd0fb26d8..7331000a9f2de4bd43ebc6f2dd2cf573eb54c40d 100644 --- a/app/models/milestone.rb +++ b/app/models/milestone.rb @@ -98,11 +98,11 @@ class Milestone < ActiveRecord::Base if Gitlab::Database.postgresql? rel.order(:project_id, :due_date).select('DISTINCT ON (project_id) id') else - rel - .group(:project_id) - .having('due_date = MIN(due_date)') - .pluck(:id, :project_id, :due_date) - .map(&:first) + rel. + group(:project_id). + having('due_date = MIN(due_date)'). + pluck(:id, :project_id, :due_date). + map(&:first) end end @@ -177,8 +177,8 @@ class Milestone < ActiveRecord::Base conditions = 'WHEN id = ? THEN ? ' * ids.length - issues.where(id: ids) - .update_all(["position = CASE #{conditions} ELSE position END", *pairs]) + issues.where(id: ids). + update_all(["position = CASE #{conditions} ELSE position END", *pairs]) end private diff --git a/app/models/namespace.rb b/app/models/namespace.rb index 9334b7d9e61c637867ff156d490bf96c67f3788c..e207ac3db4ea142b9ef3e80dd8d6d2fffed151cc 100644 --- a/app/models/namespace.rb +++ b/app/models/namespace.rb @@ -48,9 +48,9 @@ class Namespace < ActiveRecord::Base scope :root, -> { where('type IS NULL') } scope :with_statistics, -> do - joins('LEFT JOIN project_statistics ps ON ps.namespace_id = namespaces.id') - .group('namespaces.id') - .select( + joins('LEFT JOIN project_statistics ps ON ps.namespace_id = namespaces.id'). + group('namespaces.id'). + select( 'namespaces.*', 'COALESCE(SUM(ps.storage_size), 0) AS storage_size', 'COALESCE(SUM(ps.repository_size), 0) AS repository_size', @@ -251,10 +251,10 @@ class Namespace < ActiveRecord::Base end def refresh_access_of_projects_invited_groups - Group - .joins(project_group_links: :project) - .where(projects: { namespace_id: id }) - .find_each(&:refresh_members_authorized_projects) + Group. + joins(project_group_links: :project). + where(projects: { namespace_id: id }). + find_each(&:refresh_members_authorized_projects) end def remove_exports! diff --git a/app/models/network/commit.rb b/app/models/network/commit.rb index 8417f200e366bd61f94374e6644d81e8f5afaa07..a48e872ad8407e01742b5a5d035ebe88b7adf064 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 0bbc9451ffdb466d24dbf10fc58a39b3c24dcdf5..2a7fa7d06075c63f82fc1b1b9f1fcfe1fdfc575d 100644 --- a/app/models/network/graph.rb +++ b/app/models/network/graph.rb @@ -23,12 +23,12 @@ module Network def collect_notes h = Hash.new(0) - @project - .notes - .where('noteable_type = ?', 'Commit') - .group('notes.commit_id') - .select('notes.commit_id, count(notes.id) as note_count') - .each do |item| + @project. + notes. + where('noteable_type = ?', 'Commit'). + group('notes.commit_id'). + select('notes.commit_id, count(notes.id) as note_count'). + each do |item| h[item.commit_id] = item.note_count.to_i end diff --git a/app/models/note.rb b/app/models/note.rb index c6406f644e0641a63c9db4da194db5d9d4ea9756..d6d5396afa5e1f21c32cf2b5d7c6a94a8508a1e0 100644 --- a/app/models/note.rb +++ b/app/models/note.rb @@ -105,14 +105,14 @@ class Note < ActiveRecord::Base def grouped_diff_discussions active_notes = diff_notes.fresh.select(&:active?) - Discussion.for_diff_notes(active_notes) - .map { |d| [d.line_code, d] }.to_h + Discussion.for_diff_notes(active_notes). + map { |d| [d.line_code, d] }.to_h end def count_for_collection(ids, type) - user.select('noteable_id', 'COUNT(*) as count') - .group(:noteable_id) - .where(noteable_type: type, noteable_id: ids) + user.select('noteable_id', 'COUNT(*) as count'). + group(:noteable_id). + where(noteable_type: type, noteable_id: ids) end end diff --git a/app/models/project.rb b/app/models/project.rb index 698e742de48086c8515683a6c40f9e9caa3c1021..301ff71cc01e0d853692d8d2dd9effccb1b720c6 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -235,8 +235,8 @@ class Project < ActiveRecord::Base scope :inside_path, ->(path) do # We need routes alias rs for JOIN so it does not conflict with # includes(:route) which we use in ProjectsFinder. - joins("INNER JOIN routes rs ON rs.source_id = projects.id AND rs.source_type = 'Project'") - .where('rs.path LIKE ?', "#{path}/%") + joins("INNER JOIN routes rs ON rs.source_id = projects.id AND rs.source_type = 'Project'"). + where('rs.path LIKE ?', "#{path}/%") end # "enabled" here means "not disabled". It includes private features! @@ -313,9 +313,9 @@ class Project < ActiveRecord::Base pattern = "%#{query}%" projects = select(:id).where( - ptable[:path].matches(pattern) - .or(ptable[:name].matches(pattern)) - .or(ptable[:description].matches(pattern)) + ptable[:path].matches(pattern). + or(ptable[:name].matches(pattern)). + or(ptable[:description].matches(pattern)) ) # We explicitly remove any eager loading clauses as they're: @@ -324,10 +324,10 @@ class Project < ActiveRecord::Base # 2. Combined with .joins(:namespace) lead to all columns from the # projects & namespaces tables being selected, leading to a SQL error # due to the columns of all UNION'd queries no longer being the same. - namespaces = select(:id) - .except(:includes) - .joins(:namespace) - .where(ntable[:name].matches(pattern)) + namespaces = select(:id). + except(:includes). + joins(:namespace). + where(ntable[:name].matches(pattern)) union = Gitlab::SQL::Union.new([projects, namespaces]) @@ -369,8 +369,8 @@ class Project < ActiveRecord::Base end def trending - joins('INNER JOIN trending_projects ON projects.id = trending_projects.project_id') - .reorder('trending_projects.id ASC') + joins('INNER JOIN trending_projects ON projects.id = trending_projects.project_id'). + reorder('trending_projects.id ASC') end def cached_count diff --git a/app/models/project_services/kubernetes_service.rb b/app/models/project_services/kubernetes_service.rb index 02e802bad6d1b68653da04e2b5b3f8c90780458c..9819e723fe858a0806adad3ae4a0c6e72a550a94 100644 --- a/app/models/project_services/kubernetes_service.rb +++ b/app/models/project_services/kubernetes_service.rb @@ -105,9 +105,9 @@ class KubernetesService < DeploymentService def terminals(environment) with_reactive_cache do |data| pods = data.fetch(:pods, nil) - filter_pods(pods, app: environment.slug) - .flat_map { |pod| terminals_for_pod(api_url, namespace, pod) } - .each { |terminal| add_terminal_auth(terminal, terminal_auth) } + filter_pods(pods, app: environment.slug). + flat_map { |pod| terminals_for_pod(api_url, namespace, pod) }. + each { |terminal| add_terminal_auth(terminal, terminal_auth) } end end diff --git a/app/models/project_services/mattermost_slash_commands_service.rb b/app/models/project_services/mattermost_slash_commands_service.rb index 26376fd87ff51de9e0526a5986cc7f0cc272e478..56f42d63b2d0c765c388d747406b4eaf7605f230 100644 --- a/app/models/project_services/mattermost_slash_commands_service.rb +++ b/app/models/project_services/mattermost_slash_commands_service.rb @@ -20,8 +20,8 @@ class MattermostSlashCommandsService < ChatSlashCommandsService end def configure(user, params) - token = Mattermost::Command.new(user) - .create(command(params)) + token = Mattermost::Command.new(user). + create(command(params)) update(active: true, token: token) if token rescue Mattermost::Error => e diff --git a/app/models/project_team.rb b/app/models/project_team.rb index 67cc06642f170b9de50e5e7159083e070f4dfe37..8a53e974b6f6e725909370a5a83c336282102920 100644 --- a/app/models/project_team.rb +++ b/app/models/project_team.rb @@ -169,10 +169,10 @@ class ProjectTeam # Lookup only the IDs we need user_ids = user_ids - access.keys - users_access = project.project_authorizations - .where(user: user_ids) - .group(:user_id) - .maximum(:access_level) + users_access = project.project_authorizations. + where(user: user_ids). + group(:user_id). + maximum(:access_level) access.merge!(users_access) access diff --git a/app/models/repository.rb b/app/models/repository.rb index d1dd900d5970cef9b0240aafea0e2c39d8b65a61..cd2568ad44532fbd209e5438b83512e2456f97c8 100644 --- a/app/models/repository.rb +++ b/app/models/repository.rb @@ -249,11 +249,11 @@ class Repository cache.fetch(:"diverging_commit_counts_#{branch.name}") do # Rugged seems to throw a `ReferenceError` when given branch_names rather # than SHA-1 hashes - number_commits_behind = raw_repository - .count_commits_between(branch.dereferenced_target.sha, root_ref_hash) + number_commits_behind = raw_repository. + count_commits_between(branch.dereferenced_target.sha, root_ref_hash) - number_commits_ahead = raw_repository - .count_commits_between(root_ref_hash, branch.dereferenced_target.sha) + number_commits_ahead = raw_repository. + count_commits_between(root_ref_hash, branch.dereferenced_target.sha) { behind: number_commits_behind, ahead: number_commits_ahead } end @@ -755,8 +755,8 @@ class Repository check_tree_entry_for_dir(branch_name, path) if start_branch_name - start_project.repository - .check_tree_entry_for_dir(start_branch_name, path) + start_project.repository. + check_tree_entry_for_dir(start_branch_name, path) end commit_file( diff --git a/app/models/todo.rb b/app/models/todo.rb index 32bb9bf2045f97a062f01145a27c00428651823e..47789a211339843ea4aafeba8074f9c9a40973dc 100644 --- a/app/models/todo.rb +++ b/app/models/todo.rb @@ -64,9 +64,9 @@ class Todo < ActiveRecord::Base highest_priority = highest_label_priority(params).to_sql - select("#{table_name}.*, (#{highest_priority}) AS highest_priority") - .order(Gitlab::Database.nulls_last_order('highest_priority', 'ASC')) - .order('todos.created_at') + select("#{table_name}.*, (#{highest_priority}) AS highest_priority"). + order(Gitlab::Database.nulls_last_order('highest_priority', 'ASC')). + order('todos.created_at') end end diff --git a/app/models/user.rb b/app/models/user.rb index 801c84dc0114b69252e546c0b5590fc99a11acee..fada0e567f0ad1cce05a3b21a65e6733f3137490 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -197,13 +197,13 @@ class User < ActiveRecord::Base scope :order_oldest_sign_in, -> { reorder(Gitlab::Database.nulls_last_order('last_sign_in_at', 'ASC')) } def self.with_two_factor - joins("LEFT OUTER JOIN u2f_registrations AS u2f ON u2f.user_id = users.id") - .where("u2f.id IS NOT NULL OR otp_required_for_login = ?", true).distinct(arel_table[:id]) + joins("LEFT OUTER JOIN u2f_registrations AS u2f ON u2f.user_id = users.id"). + where("u2f.id IS NOT NULL OR otp_required_for_login = ?", true).distinct(arel_table[:id]) end def self.without_two_factor - joins("LEFT OUTER JOIN u2f_registrations AS u2f ON u2f.user_id = users.id") - .where("u2f.id IS NULL AND otp_required_for_login = ?", false) + joins("LEFT OUTER JOIN u2f_registrations AS u2f ON u2f.user_id = users.id"). + where("u2f.id IS NULL AND otp_required_for_login = ?", false) end # @@ -274,9 +274,9 @@ class User < ActiveRecord::Base pattern = "%#{query}%" where( - table[:name].matches(pattern) - .or(table[:email].matches(pattern)) - .or(table[:username].matches(pattern)) + table[:name].matches(pattern). + or(table[:email].matches(pattern)). + or(table[:username].matches(pattern)) ) end @@ -291,10 +291,10 @@ class User < ActiveRecord::Base matched_by_emails_user_ids = email_table.project(email_table[:user_id]).where(email_table[:email].matches(pattern)) where( - table[:name].matches(pattern) - .or(table[:email].matches(pattern)) - .or(table[:username].matches(pattern)) - .or(table[:id].in(matched_by_emails_user_ids)) + table[:name].matches(pattern). + or(table[:email].matches(pattern)). + or(table[:username].matches(pattern)). + or(table[:id].in(matched_by_emails_user_ids)) ) end @@ -447,8 +447,8 @@ class User < ActiveRecord::Base # Returns the groups a user has access to def authorized_groups - union = Gitlab::SQL::Union - .new([groups.select(:id), authorized_projects.select(:namespace_id)]) + union = Gitlab::SQL::Union. + new([groups.select(:id), authorized_projects.select(:namespace_id)]) Group.where("namespaces.id IN (#{union.to_sql})") end @@ -458,8 +458,8 @@ class User < ActiveRecord::Base end def nested_projects - Project.joins(:namespace).where('namespaces.parent_id IS NOT NULL') - .member_descendants(id) + Project.joins(:namespace).where('namespaces.parent_id IS NOT NULL'). + member_descendants(id) end def refresh_authorized_projects @@ -579,9 +579,9 @@ class User < ActiveRecord::Base next unless project if project.repository.branch_exists?(event.branch_name) - merge_requests = MergeRequest.where("created_at >= ?", event.created_at) - .where(source_project_id: project.id, - source_branch: event.branch_name) + merge_requests = MergeRequest.where("created_at >= ?", event.created_at). + where(source_project_id: project.id, + source_branch: event.branch_name) merge_requests.empty? end end @@ -793,8 +793,8 @@ class User < ActiveRecord::Base def toggle_star(project) UsersStarProject.transaction do - user_star_project = users_star_projects - .where(project: project, user: self).lock(true).first + user_star_project = users_star_projects. + where(project: project, user: self).lock(true).first if user_star_project user_star_project.destroy @@ -830,11 +830,11 @@ class User < ActiveRecord::Base # ms on a database with a similar size to GitLab.com's database. On the other # hand, using a subquery means we can get the exact same data in about 40 ms. def contributed_projects - events = Event.select(:project_id) - .contributions.where(author_id: self) - .where("created_at > ?", Time.now - 1.year) - .uniq - .reorder(nil) + events = Event.select(:project_id). + contributions.where(author_id: self). + where("created_at > ?", Time.now - 1.year). + uniq. + reorder(nil) Project.where(id: events) end @@ -845,9 +845,9 @@ class User < ActiveRecord::Base def ci_authorized_runners @ci_authorized_runners ||= begin - runner_ids = Ci::RunnerProject - .where("ci_runner_projects.gl_project_id IN (#{ci_projects_union.to_sql})") - .select(:runner_id) + runner_ids = Ci::RunnerProject. + where("ci_runner_projects.gl_project_id IN (#{ci_projects_union.to_sql})"). + select(:runner_id) Ci::Runner.specific.where(id: runner_ids) end end diff --git a/app/models/wiki_page.rb b/app/models/wiki_page.rb index 0fa9d77a7719b49a48bf52045d10324f501d0737..2caebb496db2d8934fa11bb27237ee7c11966442 100644 --- a/app/models/wiki_page.rb +++ b/app/models/wiki_page.rb @@ -22,16 +22,16 @@ class WikiPage def self.group_by_directory(pages) return [] if pages.blank? - pages.sort_by { |page| [page.directory, page.slug] } - .group_by(&:directory) - .map do |dir, pages| + pages.sort_by { |page| [page.directory, page.slug] }. + group_by(&:directory). + map do |dir, pages| if dir.present? WikiDirectory.new(dir, pages) else pages end - end - .flatten + end. + flatten end def self.unhyphenize(name) diff --git a/app/serializers/base_serializer.rb b/app/serializers/base_serializer.rb index 311ee9c96be401994d4305bd3eb04ccf19ff5842..032c44274ef3a6e9843266909334d95a69bb3260 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 d0a60f134da45f017aee7e2de66b9fc164494fbc..ffc4fd34c75e50d237ba7eaf5ef1f73ff849cbe2 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 227e9ea9c6dc3a83c2ee487505333e7db0cc5900..95492f709bbcaa4e8d3557f61b31f70e02128a72 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 8a94c54b6ab8460dd6f295b9403b6ca38b6565a6..2d664f3f0c86f8d85f3e273a56c7dbeeabe561f6 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 f986e05944c336281cd301f1938062fbee3c9a79..6c80dd61873df7bca0856d437196867191d81d59 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 f2a68865f7b82fe5b88d085a554b33b53abc6177..2f109934ea9efc9b54252ba7e83119da558fad60 100644 --- a/app/services/boards/lists/move_service.rb +++ b/app/services/boards/lists/move_service.rb @@ -33,15 +33,15 @@ module Boards end def decrement_intermediate_lists - board.lists.movable.where('position > ?', old_position) - .where('position <= ?', new_position) - .update_all('position = position - 1') + board.lists.movable.where('position > ?', old_position). + where('position <= ?', new_position). + update_all('position = position - 1') end def increment_intermediate_lists - board.lists.movable.where('position >= ?', new_position) - .where('position < ?', old_position) - .update_all('position = position + 1') + board.lists.movable.where('position >= ?', new_position). + where('position < ?', old_position). + update_all('position = position + 1') end def update_list_position(list) diff --git a/app/services/ci/create_pipeline_builds_service.rb b/app/services/ci/create_pipeline_builds_service.rb index 4cbbd366cc4c0161fec081fdf058b13bcf90c96d..70fb2c5e38f740b6968a5c4e3535cbe71cad14f5 100644 --- a/app/services/ci/create_pipeline_builds_service.rb +++ b/app/services/ci/create_pipeline_builds_service.rb @@ -34,8 +34,8 @@ module Ci end def new_builds - @new_builds ||= pipeline.config_builds_attributes - .reject { |build| existing_build_names.include?(build[:name]) } + @new_builds ||= pipeline.config_builds_attributes. + reject { |build| existing_build_names.include?(build[:name]) } end def existing_build_names diff --git a/app/services/ci/create_pipeline_service.rb b/app/services/ci/create_pipeline_service.rb index 38a85e9fc420178e6979e018bae7264d5a4de179..b53a467655f5b1a10513a3f5eed2607f975f7e62 100644 --- a/app/services/ci/create_pipeline_service.rb +++ b/app/services/ci/create_pipeline_service.rb @@ -48,9 +48,9 @@ module Ci Ci::Pipeline.transaction do pipeline.save - Ci::CreatePipelineBuildsService - .new(project, current_user) - .execute(pipeline) + Ci::CreatePipelineBuildsService. + new(project, current_user). + execute(pipeline) end pipeline.tap(&:process!) diff --git a/app/services/ci/create_trigger_request_service.rb b/app/services/ci/create_trigger_request_service.rb index 062e7be5be83df12900bcd951ea198f330e56483..6af3c1ca5b130d304bbb7b06f44f3877d931034a 100644 --- a/app/services/ci/create_trigger_request_service.rb +++ b/app/services/ci/create_trigger_request_service.rb @@ -3,8 +3,8 @@ module Ci def execute(project, trigger, ref, variables = nil) trigger_request = trigger.trigger_requests.create(variables: variables) - pipeline = Ci::CreatePipelineService.new(project, nil, ref: ref) - .execute(ignore_skip_ci: true, trigger_request: trigger_request) + pipeline = Ci::CreatePipelineService.new(project, nil, ref: ref). + execute(ignore_skip_ci: true, trigger_request: trigger_request) if pipeline.persisted? trigger_request end diff --git a/app/services/ci/process_pipeline_service.rb b/app/services/ci/process_pipeline_service.rb index 79eb97b7b551f7b6dd6557dc0b55e77e2e8f702d..442230abe294b85f377e8ea8d329000725a29b58 100644 --- a/app/services/ci/process_pipeline_service.rb +++ b/app/services/ci/process_pipeline_service.rb @@ -78,9 +78,9 @@ module Ci def ensure_created_builds! return if created_builds.any? - Ci::CreatePipelineBuildsService - .new(project, current_user) - .execute(pipeline) + Ci::CreatePipelineBuildsService. + new(project, current_user). + execute(pipeline) end end end diff --git a/app/services/ci/register_build_service.rb b/app/services/ci/register_build_service.rb index 9c7abf97b4cd08cb8d4e4aabd435e477b4da0821..6f03bf2be13cf5e5250f12fc1cd9871203906472 100644 --- a/app/services/ci/register_build_service.rb +++ b/app/services/ci/register_build_service.rb @@ -42,15 +42,15 @@ module Ci def builds_for_shared_runner new_builds. # don't run projects which have not enabled shared runners and builds - joins(:project).where(projects: { shared_runners_enabled: true }) - .joins('LEFT JOIN project_features ON ci_builds.gl_project_id = project_features.project_id') - .where('project_features.builds_access_level IS NULL or project_features.builds_access_level > 0'). + joins(:project).where(projects: { shared_runners_enabled: true }). + joins('LEFT JOIN project_features ON ci_builds.gl_project_id = project_features.project_id'). + where('project_features.builds_access_level IS NULL or project_features.builds_access_level > 0'). # Implement fair scheduling # this returns builds that are ordered by number of running builds # we prefer projects that don't use shared runners at all - joins("LEFT JOIN (#{running_builds_for_shared_runners.to_sql}) AS project_builds ON ci_builds.gl_project_id=project_builds.gl_project_id") - .order('COALESCE(project_builds.running_builds, 0) ASC', 'ci_builds.id ASC') + joins("LEFT JOIN (#{running_builds_for_shared_runners.to_sql}) AS project_builds ON ci_builds.gl_project_id=project_builds.gl_project_id"). + order('COALESCE(project_builds.running_builds, 0) ASC', 'ci_builds.id ASC') end def builds_for_specific_runner @@ -58,8 +58,8 @@ module Ci end def running_builds_for_shared_runners - Ci::Build.running.where(runner: Ci::Runner.shared) - .group(:gl_project_id).select(:gl_project_id, 'count(*) AS running_builds') + Ci::Build.running.where(runner: Ci::Runner.shared). + group(:gl_project_id).select(:gl_project_id, 'count(*) AS running_builds') end def new_builds diff --git a/app/services/ci/retry_build_service.rb b/app/services/ci/retry_build_service.rb index 38ef323f6e5b2a8eafb5b51208aa007e29ae8093..c1fa9278f0fb68ceb698b2e1e79371dadb621a30 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 2c5e130e5aaa7b61482424e3a24eecca1079c864..6e9781ca8cfa6dfac270b4e5b86c7df040e820e4 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 25e22f14e60b0c3d9cb3c0827cf76a6607578d33..75281837b09e358044845c26219284d575649315 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 77459d8779ddf9ad3188e35de30bee21b830deaa..1b5e504573a231e9dbac754dc5dd93db5a98d05e 100644 --- a/app/services/create_branch_service.rb +++ b/app/services/create_branch_service.rb @@ -1,7 +1,7 @@ class CreateBranchService < BaseService def execute(branch_name, ref) - result = ValidateNewBranchService.new(project, current_user) - .execute(branch_name) + result = ValidateNewBranchService.new(project, current_user). + execute(branch_name) return result if result[:status] == :error diff --git a/app/services/files/base_service.rb b/app/services/files/base_service.rb index dcec604b455699b339171fde6fb7c3a9317585a0..0a25f56d24cb1bd7eb1a0188667e80a7c5dd3ab9 100644 --- a/app/services/files/base_service.rb +++ b/app/services/files/base_service.rb @@ -72,8 +72,8 @@ module Files end def validate_target_branch - result = ValidateNewBranchService.new(project, current_user) - .execute(@target_branch) + result = ValidateNewBranchService.new(project, current_user). + execute(@target_branch) if result[:status] == :error raise_error("Something went wrong when we tried to create #{@target_branch} for you: #{result[:message]}") diff --git a/app/services/files/update_service.rb b/app/services/files/update_service.rb index b1e8d11fdcfffd063871539e0532fea07e07add2..a71fe61a4b6a8c20e13fce5576399acf9dbdab01 100644 --- a/app/services/files/update_service.rb +++ b/app/services/files/update_service.rb @@ -24,8 +24,8 @@ module Files end def last_commit - @last_commit ||= Gitlab::Git::Commit - .last_for_path(@start_project.repository, @start_branch, @file_path) + @last_commit ||= Gitlab::Git::Commit. + last_for_path(@start_project.repository, @start_branch, @file_path) end end end diff --git a/app/services/git_push_service.rb b/app/services/git_push_service.rb index ee6e695c134d6cf682a579aaaf7691ca91072cc2..f681f831cbd46f29a0f226924637beaccd49b990 100644 --- a/app/services/git_push_service.rb +++ b/app/services/git_push_service.rb @@ -85,8 +85,8 @@ class GitPushService < BaseService default = is_default_branch? push_commits.last(PROCESS_COMMIT_LIMIT).each do |commit| - ProcessCommitWorker - .perform_async(project.id, current_user.id, commit.to_hash, default) + ProcessCommitWorker. + perform_async(project.id, current_user.id, commit.to_hash, default) end end @@ -96,8 +96,8 @@ class GitPushService < BaseService # Update merge requests that may be affected by this push. A new branch # could cause the last commit of a merge request to change. # - UpdateMergeRequestsWorker - .perform_async(@project.id, current_user.id, params[:oldrev], params[:newrev], params[:ref]) + UpdateMergeRequestsWorker. + perform_async(@project.id, current_user.id, params[:oldrev], params[:newrev], params[:ref]) EventCreateService.new.push(@project, current_user, build_push_data) @project.execute_hooks(build_push_data.dup, :push_hooks) @@ -105,9 +105,9 @@ class GitPushService < BaseService Ci::CreatePipelineService.new(@project, current_user, build_push_data).execute if push_remove_branch? - AfterBranchDeleteService - .new(project, current_user) - .execute(branch_name) + AfterBranchDeleteService. + new(project, current_user). + execute(branch_name) end end diff --git a/app/services/issuable_base_service.rb b/app/services/issuable_base_service.rb index 457dcf76995ce76fa2674957c3f8bce1849ca459..9500faf2862e8e7379dd024e9203076d2f59f2aa 100644 --- a/app/services/issuable_base_service.rb +++ b/app/services/issuable_base_service.rb @@ -144,8 +144,8 @@ class IssuableBaseService < BaseService def merge_slash_commands_into_params!(issuable) description, command_params = - SlashCommands::InterpretService.new(project, current_user) - .execute(params[:description], issuable) + SlashCommands::InterpretService.new(project, current_user). + execute(params[:description], issuable) # Avoid a description already set on an issuable to be overwritten by a nil params[:description] = description if params.has_key?(:description) diff --git a/app/services/issues/create_service.rb b/app/services/issues/create_service.rb index 9e0c90b56f68e085e9d3c4e09143736051242c9e..366b3572738c4a0ffbeb82633f9a9fafe3b92464 100644 --- a/app/services/issues/create_service.rb +++ b/app/services/issues/create_service.rb @@ -29,8 +29,8 @@ module Issues def resolve_discussions_in_merge_request(issue) Discussions::ResolveService.new(project, current_user, merge_request: merge_request_for_resolving_discussions, - follow_up_issue: issue) - .execute(merge_request_for_resolving_discussions.resolvable_discussions) + follow_up_issue: issue). + execute(merge_request_for_resolving_discussions.resolvable_discussions) end private diff --git a/app/services/issues/move_service.rb b/app/services/issues/move_service.rb index a2a5f57d069db4907b1d34fb41b3f61b5106363a..17b65947468d90364aa409b12b78fac56de5cf46 100644 --- a/app/services/issues/move_service.rb +++ b/app/services/issues/move_service.rb @@ -61,8 +61,8 @@ module Issues end def cloneable_milestone_id - @new_project.milestones - .find_by(title: @old_issue.milestone.try(:title)).try(:id) + @new_project.milestones. + find_by(title: @old_issue.milestone.try(:title)).try(:id) end def rewrite_notes diff --git a/app/services/labels/promote_service.rb b/app/services/labels/promote_service.rb index 43b539ded53745302012fde1aefeccad2cde57f7..76d0ba67b07af6616831f8e64f9369ed210c565f 100644 --- a/app/services/labels/promote_service.rb +++ b/app/services/labels/promote_service.rb @@ -26,29 +26,29 @@ module Labels private def label_ids_for_merge(new_label) - LabelsFinder - .new(current_user, title: new_label.title, group_id: project.group.id) - .execute(skip_authorization: true) - .where.not(id: new_label) - .select(:id) # Can't use pluck() to avoid object-creation because of the batching + LabelsFinder. + new(current_user, title: new_label.title, group_id: project.group.id). + execute(skip_authorization: true). + where.not(id: new_label). + select(:id) # Can't use pluck() to avoid object-creation because of the batching end def update_issuables(new_label, label_ids) - LabelLink - .where(label: label_ids) - .update_all(label_id: new_label) + LabelLink. + where(label: label_ids). + update_all(label_id: new_label) end def update_issue_board_lists(new_label, label_ids) - List - .where(label: label_ids) - .update_all(label_id: new_label) + List. + where(label: label_ids). + update_all(label_id: new_label) end def update_priorities(new_label, label_ids) - LabelPriority - .where(label: label_ids) - .update_all(label_id: new_label) + LabelPriority. + where(label: label_ids). + update_all(label_id: new_label) end def update_project_labels(label_ids) diff --git a/app/services/labels/transfer_service.rb b/app/services/labels/transfer_service.rb index d2ece354efc71bd62c88661e87b3bac6ebde47c6..514679ed29d02d6450a60a1194901e9ddab2cf88 100644 --- a/app/services/labels/transfer_service.rb +++ b/app/services/labels/transfer_service.rb @@ -41,16 +41,16 @@ module Labels end def group_labels_applied_to_issues - Label.joins(:issues) - .where( + Label.joins(:issues). + where( issues: { project_id: project.id }, labels: { type: 'GroupLabel', group_id: old_group.id } ) end def group_labels_applied_to_merge_requests - Label.joins(:merge_requests) - .where( + Label.joins(:merge_requests). + where( merge_requests: { target_project_id: project.id }, labels: { type: 'GroupLabel', group_id: old_group.id } ) @@ -64,15 +64,15 @@ module Labels end def update_label_links(labels, old_label_id:, new_label_id:) - LabelLink.joins(:label) - .merge(labels) - .where(label_id: old_label_id) - .update_all(label_id: new_label_id) + LabelLink.joins(:label). + merge(labels). + where(label_id: old_label_id). + update_all(label_id: new_label_id) end def update_label_priorities(old_label_id:, new_label_id:) - LabelPriority.where(project_id: project.id, label_id: old_label_id) - .update_all(label_id: new_label_id) + LabelPriority.where(project_id: project.id, label_id: old_label_id). + update_all(label_id: new_label_id) end end end diff --git a/app/services/merge_requests/base_service.rb b/app/services/merge_requests/base_service.rb index 5a53b9730592ffe4c64331fc11a2c60ef7d74da3..fd9d7de35f41bb1030de87c77237a672fea453e1 100644 --- a/app/services/merge_requests/base_service.rb +++ b/app/services/merge_requests/base_service.rb @@ -40,11 +40,11 @@ module MergeRequests # Returns all origin and fork merge requests from `@project` satisfying passed arguments. def merge_requests_for(source_branch, mr_states: [:opened]) - MergeRequest - .with_state(mr_states) - .where(source_branch: source_branch, source_project_id: @project.id) - .preload(:source_project) # we don't need a #includes since we're just preloading for the #select - .select(&:source_project) + MergeRequest. + with_state(mr_states). + where(source_branch: source_branch, source_project_id: @project.id). + preload(:source_project). # we don't need a #includes since we're just preloading for the #select + select(&:source_project) end def pipeline_merge_requests(pipeline) diff --git a/app/services/merge_requests/merge_service.rb b/app/services/merge_requests/merge_service.rb index 1657f8624a78fca6dfd40a61620aa16491d90cef..3da1b657a41723fd04c513fa6204db5f2123fc6a 100644 --- a/app/services/merge_requests/merge_service.rb +++ b/app/services/merge_requests/merge_service.rb @@ -63,8 +63,8 @@ module MergeRequests MergeRequests::PostMergeService.new(project, current_user).execute(merge_request) if params[:should_remove_source_branch].present? || @merge_request.force_remove_source_branch? - DeleteBranchService.new(@merge_request.source_project, branch_deletion_user) - .execute(merge_request.source_branch) + DeleteBranchService.new(@merge_request.source_project, branch_deletion_user). + execute(merge_request.source_branch) end end diff --git a/app/services/merge_requests/refresh_service.rb b/app/services/merge_requests/refresh_service.rb index 9277f67e5ae3118083c6d997c368aefde8325f48..edee3032683c1eda344d85f2369044e0c6d20ab5 100644 --- a/app/services/merge_requests/refresh_service.rb +++ b/app/services/merge_requests/refresh_service.rb @@ -43,9 +43,9 @@ module MergeRequests end filter_merge_requests(merge_requests).each do |merge_request| - MergeRequests::PostMergeService - .new(merge_request.target_project, @current_user) - .execute(merge_request) + MergeRequests::PostMergeService. + new(merge_request.target_project, @current_user). + execute(merge_request) end end @@ -56,13 +56,13 @@ module MergeRequests # Refresh merge request diff if we push to source or target branch of merge request # Note: we should update merge requests from forks too def reload_merge_requests - merge_requests = @project.merge_requests.opened - .by_source_or_target_branch(@branch_name).to_a + merge_requests = @project.merge_requests.opened. + by_source_or_target_branch(@branch_name).to_a # Fork merge requests - merge_requests += MergeRequest.opened - .where(source_branch: @branch_name, source_project: @project) - .where.not(target_project: @project).to_a + merge_requests += MergeRequest.opened. + where(source_branch: @branch_name, source_project: @project). + where.not(target_project: @project).to_a filter_merge_requests(merge_requests).each do |merge_request| if merge_request.source_branch == @branch_name || force_push? diff --git a/app/services/notes/slash_commands_service.rb b/app/services/notes/slash_commands_service.rb index addb6a7e65be1874f1048df160b4e2c4be06b28f..ad1e6f6774a174c6b84d28488747d801094ccc67 100644 --- a/app/services/notes/slash_commands_service.rb +++ b/app/services/notes/slash_commands_service.rb @@ -22,8 +22,8 @@ module Notes def extract_commands(note, options = {}) return [note.note, {}] unless supported?(note) - SlashCommands::InterpretService.new(project, current_user, options) - .execute(note.note, note.noteable) + SlashCommands::InterpretService.new(project, current_user, options). + execute(note.note, note.noteable) end def execute(command_params, note) diff --git a/app/services/tags/create_service.rb b/app/services/tags/create_service.rb index 674792f61389b85f63186cafe5f5164958d83834..1756da9e519a993b6d9b5bf95a11f0c425b84be3 100644 --- a/app/services/tags/create_service.rb +++ b/app/services/tags/create_service.rb @@ -19,8 +19,8 @@ module Tags if new_tag if release_description - CreateReleaseService.new(@project, @current_user) - .execute(tag_name, release_description) + CreateReleaseService.new(@project, @current_user). + execute(tag_name, release_description) end success.merge(tag: new_tag) diff --git a/app/services/users/refresh_authorized_projects_service.rb b/app/services/users/refresh_authorized_projects_service.rb index 4411eda3b02ac57422c9d00c068d1ddcbb37638c..fad741531eab983e2cebac8915c5a40ccb725708 100644 --- a/app/services/users/refresh_authorized_projects_service.rb +++ b/app/services/users/refresh_authorized_projects_service.rb @@ -103,11 +103,11 @@ module Users end def fresh_authorizations - ProjectAuthorization - .unscoped - .select('project_id, MAX(access_level) AS access_level') - .from("(#{project_authorizations_union.to_sql}) #{ProjectAuthorization.table_name}") - .group(:project_id) + ProjectAuthorization. + unscoped. + select('project_id, MAX(access_level) AS access_level'). + from("(#{project_authorizations_union.to_sql}) #{ProjectAuthorization.table_name}"). + group(:project_id) end private diff --git a/app/workers/build_coverage_worker.rb b/app/workers/build_coverage_worker.rb index def0ab1dde12a9be9b95be014bbabb27558880c3..31e2dc448dad4191df7060a2c0b90348f1ab61d0 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 9965af935d4b2a63fe12ff2ef815b0544a445890..ff22313c4912dffe6139daaef7a58b715b150886 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 f5ccc84c160c8585158fbce902c279ed2c1472c9..d4c3f14ec06ae96b375227a9b2c4e5df43e4eda1 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 eb403c134d138d36d63bd3aaaadf6d6860efdd13..2c29a9a58e1e865829e821779d7d7d78900e0e69 100644 --- a/app/workers/expire_build_instance_artifacts_worker.rb +++ b/app/workers/expire_build_instance_artifacts_worker.rb @@ -3,10 +3,10 @@ class ExpireBuildInstanceArtifactsWorker include DedicatedSidekiqQueue def perform(build_id) - build = Ci::Build - .with_expired_artifacts - .reorder(nil) - .find_by(id: build_id) + build = Ci::Build. + with_expired_artifacts. + reorder(nil). + find_by(id: build_id) return unless build.try(:project) diff --git a/app/workers/merge_worker.rb b/app/workers/merge_worker.rb index 48e2da338f637a95b8ee04d9c72e5acca6c58b7d..79efca4f2f9443f18e4eb45aa0236f1143bc9358 100644 --- a/app/workers/merge_worker.rb +++ b/app/workers/merge_worker.rb @@ -7,7 +7,7 @@ class MergeWorker current_user = User.find(current_user_id) merge_request = MergeRequest.find(merge_request_id) - MergeRequests::MergeService.new(merge_request.target_project, current_user, params) - .execute(merge_request) + MergeRequests::MergeService.new(merge_request.target_project, current_user, params). + execute(merge_request) end end diff --git a/app/workers/pipeline_hooks_worker.rb b/app/workers/pipeline_hooks_worker.rb index 7e36eacebf88cd5d231b13311ed1991e3e695e3c..7480a055e6a6d9adbfc96c0abcb2939c4c197a97 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 357e4a9a1c3aedada45058581af723f0bf5b7e9c..5dcb09f553e6a2ba9711730daa7efba2dcfa73ec 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 cc0eb708cf9c1e79aba0bbd72c94de96bb5b23f3..ef710f374ca9c3d274295062b14577259de3ee91 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 96c4152c674c50395240cbd55ea34cce9ce6c31c..e6d06d0577d4fd52f4e5719602951fc1317b83ae 100644 --- a/app/workers/pipeline_update_worker.rb +++ b/app/workers/pipeline_update_worker.rb @@ -3,7 +3,7 @@ class PipelineUpdateWorker include PipelineQueue def perform(pipeline_id) - Ci::Pipeline.find_by(id: pipeline_id) - .try(:update_status) + Ci::Pipeline.find_by(id: pipeline_id). + try(:update_status) end end diff --git a/app/workers/process_commit_worker.rb b/app/workers/process_commit_worker.rb index 5d7561732f1a796206815c06d14efdf400200499..e9a5bd7f24eb9be17e3c6059950859b4d550341a 100644 --- a/app/workers/process_commit_worker.rb +++ b/app/workers/process_commit_worker.rb @@ -45,16 +45,16 @@ class ProcessCommitWorker # therefor we use IssueCollection here and skip the authorization check in # Issues::CloseService#execute. IssueCollection.new(issues).updatable_by_user(user).each do |issue| - Issues::CloseService.new(project, author) - .close_issue(issue, commit: commit) + Issues::CloseService.new(project, author). + close_issue(issue, commit: commit) end end def update_issue_metrics(commit, author) mentioned_issues = commit.all_references(author).issues - Issue::Metrics.where(issue_id: mentioned_issues.map(&:id), first_mentioned_in_commit_at: nil) - .update_all(first_mentioned_in_commit_at: commit.committed_date) + Issue::Metrics.where(issue_id: mentioned_issues.map(&:id), first_mentioned_in_commit_at: nil). + update_all(first_mentioned_in_commit_at: commit.committed_date) end def build_commit(project, hash) diff --git a/app/workers/project_cache_worker.rb b/app/workers/project_cache_worker.rb index 505ff9e086e7d9eee8105022d5bdec0ec66a8077..8ff9d07860fdf0ab9eaf7ca85cdca43a0e9b6749 100644 --- a/app/workers/project_cache_worker.rb +++ b/app/workers/project_cache_worker.rb @@ -32,8 +32,8 @@ class ProjectCacheWorker private def try_obtain_lease_for(project_id, section) - Gitlab::ExclusiveLease - .new("project_cache_worker:#{project_id}:#{section}", timeout: LEASE_TIMEOUT) - .try_obtain + Gitlab::ExclusiveLease. + new("project_cache_worker:#{project_id}:#{section}", timeout: LEASE_TIMEOUT). + try_obtain end end diff --git a/app/workers/prune_old_events_worker.rb b/app/workers/prune_old_events_worker.rb index cee05b42dd72a83af292be47e196bb6569e10be3..392abb9c21b43e2476ee37362b3ae7ebc5a09659 100644 --- a/app/workers/prune_old_events_worker.rb +++ b/app/workers/prune_old_events_worker.rb @@ -10,9 +10,9 @@ class PruneOldEventsWorker '(id IN (SELECT id FROM (?) ids_to_remove))', Event.unscoped.where( 'created_at < ?', - (12.months + 1.day).ago) - .select(:id) - .limit(10_000) - ).delete_all + (12.months + 1.day).ago). + select(:id). + limit(10_000)). + delete_all end end diff --git a/app/workers/repository_check/batch_worker.rb b/app/workers/repository_check/batch_worker.rb index b94d83bd7098313d4fea32df3f39b661114e20c2..c3e7491ec4ec9f1f937c9c7c9ee1dc97d16f9bf5 100644 --- a/app/workers/repository_check/batch_worker.rb +++ b/app/workers/repository_check/batch_worker.rb @@ -32,10 +32,10 @@ module RepositoryCheck # has to sit and wait for this query to finish. def project_ids limit = 10_000 - never_checked_projects = Project.where('last_repository_check_at IS NULL AND created_at < ?', 24.hours.ago) - .limit(limit).pluck(:id) - old_check_projects = Project.where('last_repository_check_at < ?', 1.month.ago) - .reorder('last_repository_check_at ASC').limit(limit).pluck(:id) + never_checked_projects = Project.where('last_repository_check_at IS NULL AND created_at < ?', 24.hours.ago). + limit(limit).pluck(:id) + old_check_projects = Project.where('last_repository_check_at < ?', 1.month.ago). + reorder('last_repository_check_at ASC').limit(limit).pluck(:id) never_checked_projects + old_check_projects end diff --git a/config/initializers/metrics.rb b/config/initializers/metrics.rb index f082495cd7d6203880e48bb59bba247c15d46f47..a1517e6afc878fd6b7eae446669191ef8adf11a2 100644 --- a/config/initializers/metrics.rb +++ b/config/initializers/metrics.rb @@ -147,8 +147,8 @@ if Gitlab::Metrics.enabled? ActiveRecord::Querying.public_instance_methods(false).map(&:to_s) ) - Gitlab::Metrics::Instrumentation - .instrument_class_hierarchy(ActiveRecord::Base) do |klass, method| + Gitlab::Metrics::Instrumentation. + instrument_class_hierarchy(ActiveRecord::Base) do |klass, method| # Instrumenting the ApplicationSetting class can lead to an infinite # loop. Since the data is cached any way we don't really need to # instrument it. diff --git a/db/migrate/20161124141322_migrate_process_commit_worker_jobs.rb b/db/migrate/20161124141322_migrate_process_commit_worker_jobs.rb index f4fe8103218ff0ccc310b38cc03711d3dc3d68aa..3e1f6b1627d91f05e69c49827bc9c028009ad6d2 100644 --- a/db/migrate/20161124141322_migrate_process_commit_worker_jobs.rb +++ b/db/migrate/20161124141322_migrate_process_commit_worker_jobs.rb @@ -6,9 +6,9 @@ class MigrateProcessCommitWorkerJobs < ActiveRecord::Migration class Project < ActiveRecord::Base def self.find_including_path(id) - select("projects.*, CONCAT(namespaces.path, '/', projects.path) AS path_with_namespace") - .joins('INNER JOIN namespaces ON namespaces.id = projects.namespace_id') - .find_by(id: id) + select("projects.*, CONCAT(namespaces.path, '/', projects.path) AS path_with_namespace"). + joins('INNER JOIN namespaces ON namespaces.id = projects.namespace_id'). + find_by(id: id) end def repository_storage_path diff --git a/db/migrate/20161207231620_fixup_environment_name_uniqueness.rb b/db/migrate/20161207231620_fixup_environment_name_uniqueness.rb index f73e4f6c99b19762a024fa410f77fabe0432d5e9..a20a903a7522cd83a1beba7c2e415308cd3141d1 100644 --- a/db/migrate/20161207231620_fixup_environment_name_uniqueness.rb +++ b/db/migrate/20161207231620_fixup_environment_name_uniqueness.rb @@ -8,11 +8,11 @@ class FixupEnvironmentNameUniqueness < ActiveRecord::Migration environments = Arel::Table.new(:environments) # Get all [project_id, name] pairs that occur more than once - finder_sql = environments - .group(environments[:project_id], environments[:name]) - .having(Arel.sql("COUNT(1)").gt(1)) - .project(environments[:project_id], environments[:name]) - .to_sql + finder_sql = environments. + group(environments[:project_id], environments[:name]). + having(Arel.sql("COUNT(1)").gt(1)). + project(environments[:project_id], environments[:name]). + to_sql conflicting = connection.exec_query(finder_sql) @@ -28,12 +28,12 @@ class FixupEnvironmentNameUniqueness < ActiveRecord::Migration # Rename conflicting environments by appending "-#{id}" to all but the first def fix_duplicates(project_id, name) environments = Arel::Table.new(:environments) - finder_sql = environments - .where(environments[:project_id].eq(project_id)) - .where(environments[:name].eq(name)) - .order(environments[:id].asc) - .project(environments[:id], environments[:name]) - .to_sql + finder_sql = environments. + where(environments[:project_id].eq(project_id)). + where(environments[:name].eq(name)). + order(environments[:id].asc). + project(environments[:id], environments[:name]). + to_sql # Now we have the data for all the conflicting rows conflicts = connection.exec_query(finder_sql).rows @@ -41,11 +41,11 @@ class FixupEnvironmentNameUniqueness < ActiveRecord::Migration conflicts.each do |id, name| update_sql = - Arel::UpdateManager.new(ActiveRecord::Base) - .table(environments) - .set(environments[:name] => name + "-" + id.to_s) - .where(environments[:id].eq(id)) - .to_sql + Arel::UpdateManager.new(ActiveRecord::Base). + table(environments). + set(environments[:name] => name + "-" + id.to_s). + where(environments[:id].eq(id)). + to_sql connection.exec_update(update_sql, self.class.name, []) end diff --git a/db/migrate/20161207231626_add_environment_slug.rb b/db/migrate/20161207231626_add_environment_slug.rb index 83cdd484c4cd0b97e19af2bdfadb22587cc96133..8e98ee5b9ba18fd3488fe2bf4e1d256637e971b2 100644 --- a/db/migrate/20161207231626_add_environment_slug.rb +++ b/db/migrate/20161207231626_add_environment_slug.rb @@ -19,10 +19,10 @@ class AddEnvironmentSlug < ActiveRecord::Migration finder = environments.project(:id, :name) connection.exec_query(finder.to_sql).rows.each do |id, name| - updater = Arel::UpdateManager.new(ActiveRecord::Base) - .table(environments) - .set(environments[:slug] => generate_slug(name)) - .where(environments[:id].eq(id)) + updater = Arel::UpdateManager.new(ActiveRecord::Base). + table(environments). + set(environments[:slug] => generate_slug(name)). + where(environments[:id].eq(id)) connection.exec_update(updater.to_sql, self.class.name, []) end diff --git a/db/post_migrate/20161109150329_fix_project_records_with_invalid_visibility.rb b/db/post_migrate/20161109150329_fix_project_records_with_invalid_visibility.rb index 69007b8e8ed29e460192408f870cf17cea9b41ce..14b5ef476f0cbbf8a5d73ed09b09081073e6341d 100644 --- a/db/post_migrate/20161109150329_fix_project_records_with_invalid_visibility.rb +++ b/db/post_migrate/20161109150329_fix_project_records_with_invalid_visibility.rb @@ -13,13 +13,13 @@ class FixProjectRecordsWithInvalidVisibility < ActiveRecord::Migration namespaces = Arel::Table.new(:namespaces) finder_sql = - projects - .join(namespaces, Arel::Nodes::InnerJoin) - .on(projects[:namespace_id].eq(namespaces[:id])) - .where(projects[:visibility_level].gt(namespaces[:visibility_level])) - .project(projects[:id], namespaces[:visibility_level]) - .take(BATCH_SIZE) - .to_sql + projects. + join(namespaces, Arel::Nodes::InnerJoin). + on(projects[:namespace_id].eq(namespaces[:id])). + where(projects[:visibility_level].gt(namespaces[:visibility_level])). + project(projects[:id], namespaces[:visibility_level]). + take(BATCH_SIZE). + to_sql # Update matching rows in batches. Each batch can cause up to 3 UPDATE # statements, in addition to the SELECT: one per visibility_level @@ -33,10 +33,10 @@ class FixProjectRecordsWithInvalidVisibility < ActiveRecord::Migration end updates.each do |visibility_level, project_ids| - updater = Arel::UpdateManager.new(ActiveRecord::Base) - .table(projects) - .set(projects[:visibility_level] => visibility_level) - .where(projects[:id].in(project_ids)) + updater = Arel::UpdateManager.new(ActiveRecord::Base). + table(projects). + set(projects[:visibility_level] => visibility_level). + where(projects[:id].in(project_ids)) ActiveRecord::Base.connection.exec_update(updater.to_sql, self.class.name, []) end diff --git a/db/post_migrate/20161221153951_rename_reserved_project_names.rb b/db/post_migrate/20161221153951_rename_reserved_project_names.rb index d322844e2fd99ba157150a446eeedab6c080d8c7..49a6bc884a8320f1fc4e9c335c91ec9161e80952 100644 --- a/db/post_migrate/20161221153951_rename_reserved_project_names.rb +++ b/db/post_migrate/20161221153951_rename_reserved_project_names.rb @@ -79,17 +79,17 @@ class RenameReservedProjectNames < ActiveRecord::Migration private def reserved_projects - Project.unscoped - .includes(:namespace) - .where('EXISTS (SELECT 1 FROM namespaces WHERE projects.namespace_id = namespaces.id)') - .where('projects.path' => KNOWN_PATHS) + Project.unscoped. + includes(:namespace). + where('EXISTS (SELECT 1 FROM namespaces WHERE projects.namespace_id = namespaces.id)'). + where('projects.path' => KNOWN_PATHS) end def route_exists?(full_path) quoted_path = ActiveRecord::Base.connection.quote_string(full_path) - ActiveRecord::Base.connection - .select_all("SELECT id, path FROM routes WHERE path = '#{quoted_path}'").present? + ActiveRecord::Base.connection. + select_all("SELECT id, path FROM routes WHERE path = '#{quoted_path}'").present? end # Adds number to the end of the path that is not taken by other route diff --git a/db/post_migrate/20170104150317_requeue_pending_delete_projects.rb b/db/post_migrate/20170104150317_requeue_pending_delete_projects.rb index d7be004d47f9032c8f62c3aea140c79a7f4f2eab..f399950bd5e4981e214b31bc0068b922dccc6d82 100644 --- a/db/post_migrate/20170104150317_requeue_pending_delete_projects.rb +++ b/db/post_migrate/20170104150317_requeue_pending_delete_projects.rb @@ -39,11 +39,11 @@ class RequeuePendingDeleteProjects < ActiveRecord::Migration def find_batch projects = Arel::Table.new(:projects) - projects.project(projects[:id]) - .where(projects[:pending_delete].eq(true)) - .where(projects[:namespace_id].not_eq(nil)) - .skip(@offset * BATCH_SIZE) - .take(BATCH_SIZE) - .to_sql + projects.project(projects[:id]). + where(projects[:pending_delete].eq(true)). + where(projects[:namespace_id].not_eq(nil)). + skip(@offset * BATCH_SIZE). + take(BATCH_SIZE). + to_sql end end diff --git a/db/post_migrate/20170106142508_fill_authorized_projects.rb b/db/post_migrate/20170106142508_fill_authorized_projects.rb index 0ca20587981c10924635d0f0fc759d93298480b9..314c8440c8b229135add22caef73f989874cabf2 100644 --- a/db/post_migrate/20170106142508_fill_authorized_projects.rb +++ b/db/post_migrate/20170106142508_fill_authorized_projects.rb @@ -15,8 +15,8 @@ class FillAuthorizedProjects < ActiveRecord::Migration disable_ddl_transaction! def up - relation = User.select(:id) - .where('authorized_projects_populated IS NOT TRUE') + relation = User.select(:id). + where('authorized_projects_populated IS NOT TRUE') relation.find_in_batches(batch_size: 1_000) do |rows| args = rows.map { |row| [row.id] } diff --git a/lib/api/access_requests.rb b/lib/api/access_requests.rb index 4d4e442cb497a9486fb15a2f1f6beb40213cad20..789f45489eba5b4ac0e592cac7775706303da9e4 100644 --- a/lib/api/access_requests.rb +++ b/lib/api/access_requests.rb @@ -68,8 +68,8 @@ module API delete ":id/access_requests/:user_id" do source = find_source(source_type, params[:id]) - ::Members::DestroyService.new(source, current_user, params) - .execute(:requesters) + ::Members::DestroyService.new(source, current_user, params). + execute(:requesters) end end end diff --git a/lib/api/branches.rb b/lib/api/branches.rb index 804fca9b0fbe98322a7ab6bcfcdc344d50c8fd5c..c65de90cca29c23064d40faf362094cddf04fd92 100644 --- a/lib/api/branches.rb +++ b/lib/api/branches.rb @@ -102,8 +102,8 @@ module API end post ":id/repository/branches" do authorize_push_project - result = CreateBranchService.new(user_project, current_user) - .execute(params[:branch], params[:ref]) + result = CreateBranchService.new(user_project, current_user). + execute(params[:branch], params[:ref]) if result[:status] == :success present result[:branch], @@ -121,8 +121,8 @@ module API delete ":id/repository/branches/:branch", requirements: { branch: /.+/ } do authorize_push_project - result = DeleteBranchService.new(user_project, current_user) - .execute(params[:branch]) + result = DeleteBranchService.new(user_project, current_user). + execute(params[:branch]) if result[:status] == :success { diff --git a/lib/api/entities.rb b/lib/api/entities.rb index a94292629812cde58db6e2c2684dc94256ecc94a..85aa6932f81d7b6ce56452c23252dca25797ca46 100644 --- a/lib/api/entities.rb +++ b/lib/api/entities.rb @@ -451,9 +451,9 @@ module API expose :tag_push_events, :note_events, :build_events, :pipeline_events # Expose serialized properties expose :properties do |service, options| - field_names = service.fields - .select { |field| options[:include_passwords] || field[:type] != 'password' } - .map { |field| field[:name] } + field_names = service.fields. + select { |field| options[:include_passwords] || field[:type] != 'password' }. + map { |field| field[:name] } service.properties.slice(*field_names) end end diff --git a/lib/api/issues.rb b/lib/api/issues.rb index 0515533b8502bdbb5489503986394f7a4c507d72..6d30c5d81b12df8d183dbdb4d6a73c734b36e917 100644 --- a/lib/api/issues.rb +++ b/lib/api/issues.rb @@ -128,9 +128,9 @@ module API issue_params = declared_params(include_missing: false) if merge_request_iid = params[:merge_request_for_resolving_discussions] - issue_params[:merge_request_for_resolving_discussions] = MergeRequestsFinder.new(current_user, project_id: user_project.id) - .execute - .find_by(iid: merge_request_iid) + issue_params[:merge_request_for_resolving_discussions] = MergeRequestsFinder.new(current_user, project_id: user_project.id). + execute. + find_by(iid: merge_request_iid) end issue = ::Issues::CreateService.new(user_project, diff --git a/lib/api/merge_requests.rb b/lib/api/merge_requests.rb index bdd764abfebe50898dfd7fd73af02c6249a88ebc..6a2476424a7ff292fa22d4a06e55e2929fe3d440 100644 --- a/lib/api/merge_requests.rb +++ b/lib/api/merge_requests.rb @@ -193,13 +193,13 @@ module API } if params[:merge_when_build_succeeds] && merge_request.head_pipeline && merge_request.head_pipeline.active? - ::MergeRequests::MergeWhenPipelineSucceedsService - .new(merge_request.target_project, current_user, merge_params) - .execute(merge_request) + ::MergeRequests::MergeWhenPipelineSucceedsService. + new(merge_request.target_project, current_user, merge_params). + execute(merge_request) else - ::MergeRequests::MergeService - .new(merge_request.target_project, current_user, merge_params) - .execute(merge_request) + ::MergeRequests::MergeService. + new(merge_request.target_project, current_user, merge_params). + execute(merge_request) end present merge_request, with: Entities::MergeRequest, current_user: current_user, project: user_project @@ -213,9 +213,9 @@ module API unauthorized! unless merge_request.can_cancel_merge_when_build_succeeds?(current_user) - ::MergeRequest::MergeWhenPipelineSucceedsService - .new(merge_request.target_project, current_user) - .cancel(merge_request) + ::MergeRequest::MergeWhenPipelineSucceedsService. + new(merge_request.target_project, current_user). + cancel(merge_request) end desc 'Get the comments of a merge request' do diff --git a/lib/api/notes.rb b/lib/api/notes.rb index dc47aeafb8263a6b9d5bf549dea877b657202d84..f559a7f74a04635ccf152f73640ca57cb58472c6 100644 --- a/lib/api/notes.rb +++ b/lib/api/notes.rb @@ -33,8 +33,8 @@ module API # paginate() only works with a relation. This could lead to a # mismatch between the pagination headers info and the actual notes # array returned, but this is really a edge-case. - paginate(noteable.notes) - .reject { |n| n.cross_reference_not_visible_for?(current_user) } + paginate(noteable.notes). + reject { |n| n.cross_reference_not_visible_for?(current_user) } present notes, with: Entities::Note else not_found!("Notes") diff --git a/lib/api/pipelines.rb b/lib/api/pipelines.rb index 3afc1e385fe5afa16f3a363e96076e4339119514..02e397a681cc1667f652c0b6c78dcd7e2111cc67 100644 --- a/lib/api/pipelines.rb +++ b/lib/api/pipelines.rb @@ -36,8 +36,8 @@ module API new_pipeline = Ci::CreatePipelineService.new(user_project, current_user, - declared_params(include_missing: false)) - .execute(ignore_skip_ci: true, save_on_errors: false) + declared_params(include_missing: false)). + execute(ignore_skip_ci: true, save_on_errors: false) if new_pipeline.persisted? present new_pipeline, with: Entities::Pipeline else diff --git a/lib/api/tags.rb b/lib/api/tags.rb index 40d37e44db1cda1c5f80bd179e86e9321d2d94fc..86759ab882f72f730333d0a7029d4fe5968c60c4 100644 --- a/lib/api/tags.rb +++ b/lib/api/tags.rb @@ -44,8 +44,8 @@ module API post ':id/repository/tags' do authorize_push_project - result = ::Tags::CreateService.new(user_project, current_user) - .execute(params[:tag_name], params[:ref], params[:message], params[:release_description]) + result = ::Tags::CreateService.new(user_project, current_user). + execute(params[:tag_name], params[:ref], params[:message], params[:release_description]) if result[:status] == :success present result[:tag], @@ -63,8 +63,8 @@ module API delete ":id/repository/tags/:tag_name", requirements: { tag_name: /.+/ } do authorize_push_project - result = ::Tags::DestroyService.new(user_project, current_user) - .execute(params[:tag_name]) + result = ::Tags::DestroyService.new(user_project, current_user). + execute(params[:tag_name]) if result[:status] == :success { @@ -85,8 +85,8 @@ module API post ':id/repository/tags/:tag_name/release', requirements: { tag_name: /.+/ } do authorize_push_project - result = CreateReleaseService.new(user_project, current_user) - .execute(params[:tag_name], params[:description]) + result = CreateReleaseService.new(user_project, current_user). + execute(params[:tag_name], params[:description]) if result[:status] == :success present result[:release], with: Entities::Release @@ -105,8 +105,8 @@ module API put ':id/repository/tags/:tag_name/release', requirements: { tag_name: /.+/ } do authorize_push_project - result = UpdateReleaseService.new(user_project, current_user) - .execute(params[:tag_name], params[:description]) + result = UpdateReleaseService.new(user_project, current_user). + execute(params[:tag_name], params[:description]) if result[:status] == :success present result[:release], with: Entities::Release diff --git a/lib/api/users.rb b/lib/api/users.rb index 9824f8c2ce6da446cc19a458e3296aa3a301adfd..94b2b6653d20f500a4d4e43eb554348360cd4cf5 100644 --- a/lib/api/users.rb +++ b/lib/api/users.rb @@ -117,13 +117,13 @@ module API if user.save present user, with: Entities::UserPublic else - conflict!('Email has already been taken') if User - .where(email: user.email) - .count > 0 + conflict!('Email has already been taken') if User. + where(email: user.email). + count > 0 - conflict!('Username has already been taken') if User - .where(username: user.username) - .count > 0 + conflict!('Username has already been taken') if User. + where(username: user.username). + count > 0 render_validation_error!(user) end @@ -151,12 +151,12 @@ module API not_found!('User') unless user conflict!('Email has already been taken') if params[:email] && - User.where(email: params[:email]) - .where.not(id: user.id).count > 0 + User.where(email: params[:email]). + where.not(id: user.id).count > 0 conflict!('Username has already been taken') if params[:username] && - User.where(username: params[:username]) - .where.not(id: user.id).count > 0 + User.where(username: params[:username]). + where.not(id: user.id).count > 0 user_params = declared_params(include_missing: false) identity_attrs = user_params.slice(:provider, :extern_uid) @@ -354,11 +354,11 @@ module API user = User.find_by(id: params[:id]) not_found!('User') unless user - events = user.events - .merge(ProjectsFinder.new.execute(current_user)) - .references(:project) - .with_associations - .recent + events = user.events. + merge(ProjectsFinder.new.execute(current_user)). + references(:project). + with_associations. + recent present paginate(events), with: Entities::Event end diff --git a/lib/api/v3/issues.rb b/lib/api/v3/issues.rb index 264ad8d0da580e01f7509407df919117fc90fb31..d0af09f0e1ec7482ac0d3c21b46628119cd777f6 100644 --- a/lib/api/v3/issues.rb +++ b/lib/api/v3/issues.rb @@ -141,9 +141,9 @@ module API issue_params = declared_params(include_missing: false) if merge_request_iid = params[:merge_request_for_resolving_discussions] - issue_params[:merge_request_for_resolving_discussions] = MergeRequestsFinder.new(current_user, project_id: user_project.id) - .execute - .find_by(iid: merge_request_iid) + issue_params[:merge_request_for_resolving_discussions] = MergeRequestsFinder.new(current_user, project_id: user_project.id). + execute. + find_by(iid: merge_request_iid) end issue = ::Issues::CreateService.new(user_project, diff --git a/lib/api/v3/merge_requests.rb b/lib/api/v3/merge_requests.rb index 129f9d850e9693f25a83c65cb8c769974aea5ce8..5a8dacc9c44fd0f779fb2e24c62e185377fa3550 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 c37b8e71cb0185dcf6b47709723cfd69eebebb80..17b460608d767e032996ff8dcba6eebdf35bb905 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 7e6357f8a008923224d11973b1ee05fd46085d9e..c6426210a92645dbee08f0ab8a703821d2583372 100644 --- a/lib/banzai/reference_extractor.rb +++ b/lib/banzai/reference_extractor.rb @@ -10,8 +10,8 @@ module Banzai end def references(type, project, current_user = nil) - processor = Banzai::ReferenceParser[type] - .new(project, current_user) + processor = Banzai::ReferenceParser[type]. + new(project, current_user) processor.process(html_documents) end @@ -28,8 +28,8 @@ module Banzai # text blobs to parse. return [] if @texts_and_contexts.empty? - @html_documents ||= Renderer.cache_collection_render(@texts_and_contexts) - .map { |html| Nokogiri::HTML.fragment(html) } + @html_documents ||= Renderer.cache_collection_render(@texts_and_contexts). + map { |html| Nokogiri::HTML.fragment(html) } end end end diff --git a/lib/banzai/reference_parser/issue_parser.rb b/lib/banzai/reference_parser/issue_parser.rb index 0ffaf79d9d8e7291154e38266e60e88b611030ba..6c20dec5734d1fbab69654c199ad377cde90ecff 100644 --- a/lib/banzai/reference_parser/issue_parser.rb +++ b/lib/banzai/reference_parser/issue_parser.rb @@ -9,8 +9,8 @@ module Banzai issues = issues_for_nodes(nodes) - readable_issues = Ability - .issues_readable_by_user(issues.values, user).to_set + readable_issues = Ability. + issues_readable_by_user(issues.values, user).to_set nodes.select do |node| readable_issues.include?(issue_for_node(issues, node)) diff --git a/lib/banzai/reference_parser/user_parser.rb b/lib/banzai/reference_parser/user_parser.rb index e0125fabceceb44c790164a240f0e2b67b5d4997..7adaffa19c19ad7546b4b05cd21fd914768be26a 100644 --- a/lib/banzai/reference_parser/user_parser.rb +++ b/lib/banzai/reference_parser/user_parser.rb @@ -99,8 +99,8 @@ module Banzai def find_users_for_projects(ids) return [] if ids.empty? - collection_objects_for_ids(Project, ids) - .flat_map { |p| p.team.members.to_a } + collection_objects_for_ids(Project, ids). + flat_map { |p| p.team.members.to_a } end def can_read_reference?(user, ref_project) diff --git a/lib/ci/charts.rb b/lib/ci/charts.rb index 6063d6f45e8f46151e0cc23070ecf7226cd773e4..3decc3b1a269e609064157e46adec6c1281a4fcf 100644 --- a/lib/ci/charts.rb +++ b/lib/ci/charts.rb @@ -2,10 +2,10 @@ module Ci module Charts module DailyInterval def grouped_count(query) - query - .group("DATE(#{Ci::Build.table_name}.created_at)") - .count(:created_at) - .transform_keys { |date| date.strftime(@format) } + query. + group("DATE(#{Ci::Build.table_name}.created_at)"). + count(:created_at). + transform_keys { |date| date.strftime(@format) } end def interval_step @@ -16,14 +16,14 @@ module Ci module MonthlyInterval def grouped_count(query) if Gitlab::Database.postgresql? - query - .group("to_char(#{Ci::Build.table_name}.created_at, '01 Month YYYY')") - .count(:created_at) - .transform_keys(&:squish) + query. + group("to_char(#{Ci::Build.table_name}.created_at, '01 Month YYYY')"). + count(:created_at). + transform_keys(&:squish) else - query - .group("DATE_FORMAT(#{Ci::Build.table_name}.created_at, '01 %M %Y')") - .count(:created_at) + query. + group("DATE_FORMAT(#{Ci::Build.table_name}.created_at, '01 %M %Y')"). + count(:created_at) end end @@ -46,8 +46,8 @@ module Ci end def collect - query = project.builds - .where("? > #{Ci::Build.table_name}.created_at AND #{Ci::Build.table_name}.created_at > ?", @to, @from) + query = project.builds. + where("? > #{Ci::Build.table_name}.created_at AND #{Ci::Build.table_name}.created_at > ?", @to, @from) totals_count = grouped_count(query) success_count = grouped_count(query.success) diff --git a/lib/ci/gitlab_ci_yaml_processor.rb b/lib/ci/gitlab_ci_yaml_processor.rb index 649ee4d018b4db4e5e793151678274fba79c22e5..04d9756657a7c2e5a645416828301eb4db4e3129 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 b762d85b6e5378b56a1693bc03c0f229f2ec7b7e..3c65fd02e4cbad4a613b8b38bfa7505012fee572 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 9a0482306b7ebda075cda06589ddc1699ab55673..8a6564755ab5770ba3152e69062a8f5e5efe6b93 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 44323b47dca856e65a06e7fa1ea690bc45f6ffaf..03a7981b1db0304b66eaaede3a94c3636cea0fc4 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 849848515da66a210ff00a0f2c9de3ce6f306f7f..bd295c25194d6cd29f3a60b77618a3018ae683dd 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 e05aca9881b75a291e8247ebd5c89d93f8f02f83..deaaf06bbd71caea8274edafabbaa54d204128d5 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 a4ec8f0ff2ffb493502f0989e180a9184b67c41e..0a404331225af2b5260676d08e603e53c6324985 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 5671a09480bb1376e676bd666005d270c3ccf25e..7b83f0f1b698d47fcf351d8a0ab2550c5600aeb0 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/pipeline_duration.rb b/lib/gitlab/ci/pipeline_duration.rb index 3208cc2bef64aaac1fd75bb832e073f6f880a590..a210e76acaa41baa7658853232b208149b14b311 100644 --- a/lib/gitlab/ci/pipeline_duration.rb +++ b/lib/gitlab/ci/pipeline_duration.rb @@ -87,8 +87,8 @@ module Gitlab def from_pipeline(pipeline) status = %w[success failed running canceled] - builds = pipeline.builds.latest - .where(status: status).where.not(started_at: nil).order(:started_at) + builds = pipeline.builds.latest. + where(status: status).where.not(started_at: nil).order(:started_at) from_builds(builds) end diff --git a/lib/gitlab/ci/status/factory.rb b/lib/gitlab/ci/status/factory.rb index 15836c699c7ce68e598d16a2046cefa68add68c0..efe756cc5859de4b9facbaae7ba64ee6c219ac4e 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 1d7ddeb3e0f02277e6ef9c2ffa20e0373e4c42dd..dd6a84d7d1c0b704a2942b4b6ed6f8cc60803564 100644 --- a/lib/gitlab/ci/trace_reader.rb +++ b/lib/gitlab/ci/trace_reader.rb @@ -41,8 +41,8 @@ module Gitlab chunks.unshift(buf) end - chunks.join.lines.last(max_lines).join - .force_encoding(Encoding.default_external) + chunks.join.lines.last(max_lines).join. + force_encoding(Encoding.default_external) end end end diff --git a/lib/gitlab/contributions_calendar.rb b/lib/gitlab/contributions_calendar.rb index 5d271829f37a65301912b5c5360699a956e5fecd..15992b77680733cae1a7530d48e1168f9203510e 100644 --- a/lib/gitlab/contributions_calendar.rb +++ b/lib/gitlab/contributions_calendar.rb @@ -16,14 +16,14 @@ module Gitlab # Can't use Event.contributions here because we need to check 3 different # project_features for the (currently) 3 different contribution types date_from = 1.year.ago - repo_events = event_counts(date_from, :repository) - .having(action: Event::PUSHED) - issue_events = event_counts(date_from, :issues) - .having(action: [Event::CREATED, Event::CLOSED], target_type: "Issue") - mr_events = event_counts(date_from, :merge_requests) - .having(action: [Event::MERGED, Event::CREATED, Event::CLOSED], target_type: "MergeRequest") - note_events = event_counts(date_from, :merge_requests) - .having(action: [Event::COMMENTED], target_type: "Note") + repo_events = event_counts(date_from, :repository). + having(action: Event::PUSHED) + issue_events = event_counts(date_from, :issues). + having(action: [Event::CREATED, Event::CLOSED], target_type: "Issue") + mr_events = event_counts(date_from, :merge_requests). + having(action: [Event::MERGED, Event::CREATED, Event::CLOSED], target_type: "MergeRequest") + note_events = event_counts(date_from, :merge_requests). + having(action: [Event::COMMENTED], target_type: "Note") union = Gitlab::SQL::Union.new([repo_events, issue_events, mr_events, note_events]) events = Event.find_by_sql(union.to_sql).map(&:attributes) @@ -34,9 +34,9 @@ module Gitlab end def events_by_date(date) - events = Event.contributions.where(author_id: contributor.id) - .where(created_at: date.beginning_of_day..date.end_of_day) - .where(project_id: projects) + events = Event.contributions.where(author_id: contributor.id). + where(created_at: date.beginning_of_day..date.end_of_day). + where(project_id: projects) # Use visible_to_user? instead of the complicated logic in activity_dates # because we're only viewing the events for a single day. @@ -60,20 +60,20 @@ module Gitlab # use IN(project_ids...) instead. It's the intersection of two users so # the list will be (relatively) short @contributed_project_ids ||= projects.uniq.pluck(:id) - authed_projects = Project.where(id: @contributed_project_ids) - .with_feature_available_for_user(feature, current_user) - .reorder(nil) - .select(:id) + authed_projects = Project.where(id: @contributed_project_ids). + with_feature_available_for_user(feature, current_user). + reorder(nil). + select(:id) - conditions = t[:created_at].gteq(date_from.beginning_of_day) - .and(t[:created_at].lteq(Date.today.end_of_day)) - .and(t[:author_id].eq(contributor.id)) + conditions = t[:created_at].gteq(date_from.beginning_of_day). + and(t[:created_at].lteq(Date.today.end_of_day)). + and(t[:author_id].eq(contributor.id)) - Event.reorder(nil) - .select(t[:project_id], t[:target_type], t[:action], 'date(created_at) AS date', 'count(id) as total_amount') - .group(t[:project_id], t[:target_type], t[:action], 'date(created_at)') - .where(conditions) - .having(t[:project_id].in(Arel::Nodes::SqlLiteral.new(authed_projects.to_sql))) + Event.reorder(nil). + select(t[:project_id], t[:target_type], t[:action], 'date(created_at) AS date', 'count(id) as total_amount'). + group(t[:project_id], t[:target_type], t[:action], 'date(created_at)'). + where(conditions). + having(t[:project_id].in(Arel::Nodes::SqlLiteral.new(authed_projects.to_sql))) end end end diff --git a/lib/gitlab/cycle_analytics/base_query.rb b/lib/gitlab/cycle_analytics/base_query.rb index 58729d3ced841ec5d956b5ef98609a8540b71b1f..d560dca45c8abbec50ecf5790b9fa0d9715e01e8 100644 --- a/lib/gitlab/cycle_analytics/base_query.rb +++ b/lib/gitlab/cycle_analytics/base_query.rb @@ -12,17 +12,17 @@ module Gitlab end def stage_query - query = mr_closing_issues_table.join(issue_table).on(issue_table[:id].eq(mr_closing_issues_table[:issue_id])) - .join(issue_metrics_table).on(issue_table[:id].eq(issue_metrics_table[:issue_id])) - .where(issue_table[:project_id].eq(@project.id)) - .where(issue_table[:deleted_at].eq(nil)) - .where(issue_table[:created_at].gteq(@options[:from])) + query = mr_closing_issues_table.join(issue_table).on(issue_table[:id].eq(mr_closing_issues_table[:issue_id])). + join(issue_metrics_table).on(issue_table[:id].eq(issue_metrics_table[:issue_id])). + where(issue_table[:project_id].eq(@project.id)). + where(issue_table[:deleted_at].eq(nil)). + where(issue_table[:created_at].gteq(@options[:from])) # Load merge_requests - query = query.join(mr_table, Arel::Nodes::OuterJoin) - .on(mr_table[:id].eq(mr_closing_issues_table[:merge_request_id])) - .join(mr_metrics_table) - .on(mr_table[:id].eq(mr_metrics_table[:merge_request_id])) + query = query.join(mr_table, Arel::Nodes::OuterJoin). + on(mr_table[:id].eq(mr_closing_issues_table[:merge_request_id])). + join(mr_metrics_table). + on(mr_table[:id].eq(mr_metrics_table[:merge_request_id])) query end diff --git a/lib/gitlab/database/median.rb b/lib/gitlab/database/median.rb index 059054ac9ffda2ccca8b9c2a5daa32844f19f43c..23890e5f4935dc94b55562d76278a86ad3bf7c89 100644 --- a/lib/gitlab/database/median.rb +++ b/lib/gitlab/database/median.rb @@ -29,10 +29,10 @@ module Gitlab end def mysql_median_datetime_sql(arel_table, query_so_far, column_sym) - query = arel_table - .from(arel_table.project(Arel.sql('*')).order(arel_table[column_sym]).as(arel_table.table_name)) - .project(average([arel_table[column_sym]], 'median')) - .where( + query = arel_table. + from(arel_table.project(Arel.sql('*')).order(arel_table[column_sym]).as(arel_table.table_name)). + project(average([arel_table[column_sym]], 'median')). + where( Arel::Nodes::Between.new( Arel.sql("(select @row_id := @row_id + 1)"), Arel::Nodes::And.new( @@ -67,8 +67,8 @@ module Gitlab cte_table = Arel::Table.new("ordered_records") cte = Arel::Nodes::As.new( cte_table, - arel_table - .project( + arel_table. + project( arel_table[column_sym].as(column_sym.to_s), Arel::Nodes::Over.new(Arel::Nodes::NamedFunction.new("row_number", []), Arel::Nodes::Window.new.order(arel_table[column_sym])).as('row_id'), @@ -79,8 +79,8 @@ module Gitlab # From the CTE, select either the middle row or the middle two rows (this is accomplished # by 'where cte.row_id between cte.ct / 2.0 AND cte.ct / 2.0 + 1'). Find the average of the # selected rows, and this is the median value. - cte_table.project(average([extract_epoch(cte_table[column_sym])], "median")) - .where( + cte_table.project(average([extract_epoch(cte_table[column_sym])], "median")). + where( Arel::Nodes::Between.new( cte_table[:row_id], Arel::Nodes::And.new( @@ -88,9 +88,9 @@ module Gitlab (cte_table[:ct] / Arel.sql('2.0') + 1)] ) ) - ) - .with(query_so_far, cte) - .to_sql + ). + with(query_so_far, cte). + to_sql end private diff --git a/lib/gitlab/database/migration_helpers.rb b/lib/gitlab/database/migration_helpers.rb index 0c7c77f52e355c4ae75d9a2c43feca5773cf5eca..fc445ab94831264f67f40ac2e8554d8adb47b672 100644 --- a/lib/gitlab/database/migration_helpers.rb +++ b/lib/gitlab/database/migration_helpers.rb @@ -140,19 +140,19 @@ module Gitlab start_id = exec_query(start_arel.to_sql).to_hash.first['id'].to_i loop do - stop_arel = table.project(table[:id]) - .where(table[:id].gteq(start_id)) - .order(table[:id].asc) - .take(1) - .skip(batch_size) + stop_arel = table.project(table[:id]). + where(table[:id].gteq(start_id)). + order(table[:id].asc). + take(1). + skip(batch_size) stop_arel = yield table, stop_arel if block_given? stop_row = exec_query(stop_arel.to_sql).to_hash.first - update_arel = Arel::UpdateManager.new(ActiveRecord::Base) - .table(table) - .set([[table[column], value]]) - .where(table[:id].gteq(start_id)) + update_arel = Arel::UpdateManager.new(ActiveRecord::Base). + table(table). + set([[table[column], value]]). + where(table[:id].gteq(start_id)) if stop_row stop_id = stop_row['id'].to_i diff --git a/lib/gitlab/downtime_check.rb b/lib/gitlab/downtime_check.rb index 941244694e2c028d6fb993417be9f68e215231ef..ab9537ed7d701752ff9c020da8a45448c016a65a 100644 --- a/lib/gitlab/downtime_check.rb +++ b/lib/gitlab/downtime_check.rb @@ -50,8 +50,8 @@ module Gitlab # Returns the class for the given migration file path. def class_for_migration_file(path) - File.basename(path, File.extname(path)).split('_', 2).last.camelize - .constantize + File.basename(path, File.extname(path)).split('_', 2).last.camelize. + constantize end # Returns true if the given migration can be performed without downtime. diff --git a/lib/gitlab/git/encoding_helper.rb b/lib/gitlab/git/encoding_helper.rb index e57d228e688a652a0334d09398d647e352f9be4b..874fd8fe6e28a789a52d60faa45d3ad01e24da7e 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 dc73cad93a5dccf902163275e301a6890443a7f5..a160869541a51248bb8e24fee7f6cb659a16913b 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 04c2964da204b8248e87da6ff7ea7b5279f52cfa..7f3bf0052a73151b41a1ad368385817cf0aec69e 100644 --- a/lib/gitlab/github_import/user_formatter.rb +++ b/lib/gitlab/github_import/user_formatter.rb @@ -25,8 +25,8 @@ module Gitlab def find_by_email return nil unless email - User.find_by_any_email(email) - .try(:id) + User.find_by_any_email(email). + try(:id) end def find_by_external_uid @@ -34,11 +34,11 @@ module Gitlab identities = ::Identity.arel_table - User.select(:id) - .joins(:identities).where(identities[:provider].eq(:github) - .and(identities[:extern_uid].eq(id))) - .first - .try(:id) + User.select(:id). + joins(:identities).where(identities[:provider].eq(:github). + and(identities[:extern_uid].eq(id))). + first. + try(:id) end end end diff --git a/lib/gitlab/highlight.rb b/lib/gitlab/highlight.rb index bfc57544485c8e8aa0b72910a646fce66f5263eb..9360afedfcb4b1df697f97482d8aede813a4dac5 100644 --- a/lib/gitlab/highlight.rb +++ b/lib/gitlab/highlight.rb @@ -1,8 +1,8 @@ module Gitlab class Highlight def self.highlight(blob_name, blob_content, repository: nil, plain: false) - new(blob_name, blob_content, repository: repository) - .highlight(blob_content, continue: false, plain: plain) + new(blob_name, blob_content, repository: repository). + highlight(blob_content, continue: false, plain: plain) end def self.highlight_lines(repository, ref, file_name) diff --git a/lib/gitlab/ldap/user.rb b/lib/gitlab/ldap/user.rb index 8bf32f9e43ff92b31684740fe2861e852ba34843..b84c81f1a6cd098954e2f7fc126b1f34b317191f 100644 --- a/lib/gitlab/ldap/user.rb +++ b/lib/gitlab/ldap/user.rb @@ -12,9 +12,9 @@ module Gitlab class << self def find_by_uid_and_provider(uid, provider) # LDAP distinguished name is case-insensitive - identity = ::Identity - .where(provider: provider) - .iwhere(extern_uid: uid).last + identity = ::Identity. + where(provider: provider). + iwhere(extern_uid: uid).last identity && identity.user end end diff --git a/lib/gitlab/metrics.rb b/lib/gitlab/metrics.rb index c5b746a83a6923ee63f151486eac0c55f4959d5d..857e0abf7109a55d86338af301888b0a2153a2a4 100644 --- a/lib/gitlab/metrics.rb +++ b/lib/gitlab/metrics.rb @@ -145,8 +145,8 @@ module Gitlab host = settings[:host] port = settings[:port] - InfluxDB::Client - .new(udp: { host: host, port: port }) + InfluxDB::Client. + new(udp: { host: host, port: port }) end end diff --git a/lib/gitlab/metrics/system.rb b/lib/gitlab/metrics/system.rb index aba3e0df382e7ad58dfc6332fd77c40ae6b40c79..3aaebb3e9c3e64eda8c52eedc54f12292db64ae5 100644 --- a/lib/gitlab/metrics/system.rb +++ b/lib/gitlab/metrics/system.rb @@ -34,13 +34,13 @@ module Gitlab # THREAD_CPUTIME is not supported on OS X if Process.const_defined?(:CLOCK_THREAD_CPUTIME_ID) def self.cpu_time - Process - .clock_gettime(Process::CLOCK_THREAD_CPUTIME_ID, :millisecond) + Process. + clock_gettime(Process::CLOCK_THREAD_CPUTIME_ID, :millisecond) end else def self.cpu_time - Process - .clock_gettime(Process::CLOCK_PROCESS_CPUTIME_ID, :millisecond) + Process. + clock_gettime(Process::CLOCK_PROCESS_CPUTIME_ID, :millisecond) end end diff --git a/lib/gitlab/other_markup.rb b/lib/gitlab/other_markup.rb index 7b0e9e4a7b419e9054a939cf9396d0c7b524f3a6..e67acf28c94b396bcaa2655f0256cf8e98458925 100644 --- a/lib/gitlab/other_markup.rb +++ b/lib/gitlab/other_markup.rb @@ -12,8 +12,8 @@ module Gitlab # :ref # def self.render(file_name, input, context) - html = GitHub::Markup.render(file_name, input) - .force_encoding(input.encoding) + html = GitHub::Markup.render(file_name, input). + force_encoding(input.encoding) html = Banzai.post_process(html, context) diff --git a/lib/gitlab/shell.rb b/lib/gitlab/shell.rb index 71e798424a5e203f84aa17508c163608d51fdd4e..7374d2bc8b8e11dc27d960851e102dc737d61066 100644 --- a/lib/gitlab/shell.rb +++ b/lib/gitlab/shell.rb @@ -30,8 +30,8 @@ module Gitlab end def version_required - @version_required ||= File.read(Rails.root - .join('GITLAB_SHELL_VERSION')).strip + @version_required ||= File.read(Rails.root. + join('GITLAB_SHELL_VERSION')).strip end def strip_key(key) diff --git a/lib/gitlab/sherlock/line_profiler.rb b/lib/gitlab/sherlock/line_profiler.rb index b5f9d04004725e3e75c5f309a9d0d1ed3b0e4e43..aa1468bff6bc66de1af5f493bd2fd887630c6578 100644 --- a/lib/gitlab/sherlock/line_profiler.rb +++ b/lib/gitlab/sherlock/line_profiler.rb @@ -77,8 +77,8 @@ module Gitlab line_samples << LineSample.new(duration, events) end - samples << FileSample - .new(file, line_samples, total_duration, total_events) + samples << FileSample. + new(file, line_samples, total_duration, total_events) end samples diff --git a/lib/gitlab/sherlock/query.rb b/lib/gitlab/sherlock/query.rb index 948bf5e6528730b2dca8f649c1ce972b1cc2a7e6..99e56e923eb08a191d3583e2baf5ab815e6d2d58 100644 --- a/lib/gitlab/sherlock/query.rb +++ b/lib/gitlab/sherlock/query.rb @@ -105,10 +105,10 @@ module Gitlab end def format_sql(query) - query.each_line - .map { |line| line.strip } - .join("\n") - .gsub(PREFIX_NEWLINE) { "\n#{$1} " } + query.each_line. + map { |line| line.strip }. + join("\n"). + gsub(PREFIX_NEWLINE) { "\n#{$1} " } end end end diff --git a/rubocop/cop/gem_fetcher.rb b/rubocop/cop/gem_fetcher.rb index e157d8e0791cc424cf534e1f1b52dcf6bbeec125..6a951f5f91afb082a9f57efef2c310fb09f27584 100644 --- a/rubocop/cop/gem_fetcher.rb +++ b/rubocop/cop/gem_fetcher.rb @@ -25,12 +25,12 @@ module RuboCop private def gemfile?(node) - node - .location - .expression - .source_buffer - .name - .end_with?("Gemfile") + node. + location. + expression. + source_buffer. + name. + end_with?("Gemfile") end end end diff --git a/rubocop/migration_helpers.rb b/rubocop/migration_helpers.rb index 35f1868fcc0198025fad35e7f044bfa93248beaa..3160a784a042299eb5cc450ca09cd859eef96a36 100644 --- a/rubocop/migration_helpers.rb +++ b/rubocop/migration_helpers.rb @@ -3,8 +3,8 @@ module RuboCop module MigrationHelpers # Returns true if the given node originated from the db/migrate directory. def in_migration?(node) - File.dirname(node.location.expression.source_buffer.name) - .end_with?('db/migrate') + File.dirname(node.location.expression.source_buffer.name). + end_with?('db/migrate') end end end diff --git a/spec/controllers/admin/users_controller_spec.rb b/spec/controllers/admin/users_controller_spec.rb index 03f46f82874d7038d70a3dcf45ccfc455cf357a9..2ab2ca1b66768e2f1dd716fed76e889e0099c818 100644 --- a/spec/controllers/admin/users_controller_spec.rb +++ b/spec/controllers/admin/users_controller_spec.rb @@ -105,8 +105,8 @@ describe Admin::UsersController do it 'displays an alert' do go - expect(flash[:notice]) - .to eq 'Two-factor Authentication has been disabled for this user' + expect(flash[:notice]). + to eq 'Two-factor Authentication has been disabled for this user' end def go diff --git a/spec/controllers/blob_controller_spec.rb b/spec/controllers/blob_controller_spec.rb index 45fbe09c9f7276c5cc3eb003e39d9586f890d587..2fcb4a6a528db118be19a0f3c35ae62aa2a66eeb 100644 --- a/spec/controllers/blob_controller_spec.rb +++ b/spec/controllers/blob_controller_spec.rb @@ -59,8 +59,8 @@ describe Projects::BlobController do context 'redirect to tree' do let(:id) { 'markdown/doc' } it 'redirects' do - expect(subject) - .to redirect_to("/#{project.path_with_namespace}/tree/markdown/doc") + expect(subject). + to redirect_to("/#{project.path_with_namespace}/tree/markdown/doc") end end end diff --git a/spec/controllers/ci/projects_controller_spec.rb b/spec/controllers/ci/projects_controller_spec.rb index 86f01f437a2b071adcc0036239fbb0ebdc214e63..3cd955dc9d4a2975d0d9fe54f9baf51e035486e6 100644 --- a/spec/controllers/ci/projects_controller_spec.rb +++ b/spec/controllers/ci/projects_controller_spec.rb @@ -33,8 +33,8 @@ describe Ci::ProjectsController do shared_examples 'badge provider' do it 'shows badge' do expect(response.status).to eq 200 - expect(response.headers) - .to include('Content-Type' => 'image/svg+xml') + expect(response.headers). + to include('Content-Type' => 'image/svg+xml') end end diff --git a/spec/controllers/import/bitbucket_controller_spec.rb b/spec/controllers/import/bitbucket_controller_spec.rb index 66b45cf33c133077e112f3e0692d9661470d8a45..fa4cc0ebbe0ca9ff7af1f3265740e9c4ef4eaf95 100644 --- a/spec/controllers/import/bitbucket_controller_spec.rb +++ b/spec/controllers/import/bitbucket_controller_spec.rb @@ -31,8 +31,8 @@ describe Import::BitbucketController do expires_at: expires_at, expires_in: expires_in, refresh_token: refresh_token) - allow_any_instance_of(OAuth2::Client) - .to receive(:get_token).and_return(access_token) + allow_any_instance_of(OAuth2::Client). + to receive(:get_token).and_return(access_token) stub_omniauth_provider('bitbucket') get :callback @@ -93,9 +93,9 @@ describe Import::BitbucketController do context "when the repository owner is the Bitbucket user" do context "when the Bitbucket user and GitLab user's usernames match" do it "takes the current user's namespace" do - expect(Gitlab::BitbucketImport::ProjectCreator) - .to receive(:new).with(bitbucket_repo, bitbucket_repo.name, user.namespace, user, access_params) - .and_return(double(execute: true)) + expect(Gitlab::BitbucketImport::ProjectCreator). + to receive(:new).with(bitbucket_repo, bitbucket_repo.name, user.namespace, user, access_params). + and_return(double(execute: true)) post :create, format: :js end @@ -105,9 +105,9 @@ describe Import::BitbucketController do let(:bitbucket_username) { "someone_else" } it "takes the current user's namespace" do - expect(Gitlab::BitbucketImport::ProjectCreator) - .to receive(:new).with(bitbucket_repo, bitbucket_repo.name, user.namespace, user, access_params) - .and_return(double(execute: true)) + expect(Gitlab::BitbucketImport::ProjectCreator). + to receive(:new).with(bitbucket_repo, bitbucket_repo.name, user.namespace, user, access_params). + and_return(double(execute: true)) post :create, format: :js end @@ -126,9 +126,9 @@ describe Import::BitbucketController do context "when the namespace is owned by the GitLab user" do it "takes the existing namespace" do - expect(Gitlab::BitbucketImport::ProjectCreator) - .to receive(:new).with(bitbucket_repo, bitbucket_repo.name, existing_namespace, user, access_params) - .and_return(double(execute: true)) + expect(Gitlab::BitbucketImport::ProjectCreator). + to receive(:new).with(bitbucket_repo, bitbucket_repo.name, existing_namespace, user, access_params). + and_return(double(execute: true)) post :create, format: :js end @@ -141,8 +141,8 @@ describe Import::BitbucketController do end it "doesn't create a project" do - expect(Gitlab::BitbucketImport::ProjectCreator) - .not_to receive(:new) + expect(Gitlab::BitbucketImport::ProjectCreator). + not_to receive(:new) post :create, format: :js end @@ -152,16 +152,16 @@ describe Import::BitbucketController do context "when a namespace with the Bitbucket user's username doesn't exist" do context "when current user can create namespaces" do it "creates the namespace" do - expect(Gitlab::BitbucketImport::ProjectCreator) - .to receive(:new).and_return(double(execute: true)) + expect(Gitlab::BitbucketImport::ProjectCreator). + to receive(:new).and_return(double(execute: true)) expect { post :create, format: :js }.to change(Namespace, :count).by(1) end it "takes the new namespace" do - expect(Gitlab::BitbucketImport::ProjectCreator) - .to receive(:new).with(bitbucket_repo, bitbucket_repo.name, an_instance_of(Group), user, access_params) - .and_return(double(execute: true)) + expect(Gitlab::BitbucketImport::ProjectCreator). + to receive(:new).with(bitbucket_repo, bitbucket_repo.name, an_instance_of(Group), user, access_params). + and_return(double(execute: true)) post :create, format: :js end @@ -173,16 +173,16 @@ describe Import::BitbucketController do end it "doesn't create the namespace" do - expect(Gitlab::BitbucketImport::ProjectCreator) - .to receive(:new).and_return(double(execute: true)) + expect(Gitlab::BitbucketImport::ProjectCreator). + to receive(:new).and_return(double(execute: true)) expect { post :create, format: :js }.not_to change(Namespace, :count) end it "takes the current user's namespace" do - expect(Gitlab::BitbucketImport::ProjectCreator) - .to receive(:new).with(bitbucket_repo, bitbucket_repo.name, user.namespace, user, access_params) - .and_return(double(execute: true)) + expect(Gitlab::BitbucketImport::ProjectCreator). + to receive(:new).with(bitbucket_repo, bitbucket_repo.name, user.namespace, user, access_params). + and_return(double(execute: true)) post :create, format: :js end diff --git a/spec/controllers/import/github_controller_spec.rb b/spec/controllers/import/github_controller_spec.rb index 45c3fa075ef039688ad37c6ef07ce1a25121a595..95696e14b6c5db12cb77e77fe84e05edcfa16c93 100644 --- a/spec/controllers/import/github_controller_spec.rb +++ b/spec/controllers/import/github_controller_spec.rb @@ -21,10 +21,10 @@ describe Import::GithubController do describe "GET callback" do it "updates access token" do token = "asdasd12345" - allow_any_instance_of(Gitlab::GithubImport::Client) - .to receive(:get_token).and_return(token) - allow_any_instance_of(Gitlab::GithubImport::Client) - .to receive(:github_options).and_return({}) + allow_any_instance_of(Gitlab::GithubImport::Client). + to receive(:get_token).and_return(token) + allow_any_instance_of(Gitlab::GithubImport::Client). + to receive(:github_options).and_return({}) stub_omniauth_provider('github') get :callback diff --git a/spec/controllers/import/gitlab_controller_spec.rb b/spec/controllers/import/gitlab_controller_spec.rb index 3ef1bbaa9b77f8343193b0776650a711ae819e50..3f73ea000ae6618d5984f1b20a972de7b9e22d0a 100644 --- a/spec/controllers/import/gitlab_controller_spec.rb +++ b/spec/controllers/import/gitlab_controller_spec.rb @@ -18,8 +18,8 @@ describe Import::GitlabController do describe "GET callback" do it "updates access token" do - allow_any_instance_of(Gitlab::GitlabImport::Client) - .to receive(:get_token).and_return(token) + allow_any_instance_of(Gitlab::GitlabImport::Client). + to receive(:get_token).and_return(token) stub_omniauth_provider('gitlab') get :callback @@ -78,9 +78,9 @@ describe Import::GitlabController do context "when the repository owner is the GitLab.com user" do context "when the GitLab.com user and GitLab server user's usernames match" do it "takes the current user's namespace" do - expect(Gitlab::GitlabImport::ProjectCreator) - .to receive(:new).with(gitlab_repo, user.namespace, user, access_params) - .and_return(double(execute: true)) + expect(Gitlab::GitlabImport::ProjectCreator). + to receive(:new).with(gitlab_repo, user.namespace, user, access_params). + and_return(double(execute: true)) post :create, format: :js end @@ -90,9 +90,9 @@ describe Import::GitlabController do let(:gitlab_username) { "someone_else" } it "takes the current user's namespace" do - expect(Gitlab::GitlabImport::ProjectCreator) - .to receive(:new).with(gitlab_repo, user.namespace, user, access_params) - .and_return(double(execute: true)) + expect(Gitlab::GitlabImport::ProjectCreator). + to receive(:new).with(gitlab_repo, user.namespace, user, access_params). + and_return(double(execute: true)) post :create, format: :js end @@ -112,9 +112,9 @@ describe Import::GitlabController do context "when the namespace is owned by the GitLab server user" do it "takes the existing namespace" do - expect(Gitlab::GitlabImport::ProjectCreator) - .to receive(:new).with(gitlab_repo, existing_namespace, user, access_params) - .and_return(double(execute: true)) + expect(Gitlab::GitlabImport::ProjectCreator). + to receive(:new).with(gitlab_repo, existing_namespace, user, access_params). + and_return(double(execute: true)) post :create, format: :js end @@ -127,8 +127,8 @@ describe Import::GitlabController do end it "doesn't create a project" do - expect(Gitlab::GitlabImport::ProjectCreator) - .not_to receive(:new) + expect(Gitlab::GitlabImport::ProjectCreator). + not_to receive(:new) post :create, format: :js end @@ -138,16 +138,16 @@ describe Import::GitlabController do context "when a namespace with the GitLab.com user's username doesn't exist" do context "when current user can create namespaces" do it "creates the namespace" do - expect(Gitlab::GitlabImport::ProjectCreator) - .to receive(:new).and_return(double(execute: true)) + expect(Gitlab::GitlabImport::ProjectCreator). + to receive(:new).and_return(double(execute: true)) expect { post :create, format: :js }.to change(Namespace, :count).by(1) end it "takes the new namespace" do - expect(Gitlab::GitlabImport::ProjectCreator) - .to receive(:new).with(gitlab_repo, an_instance_of(Group), user, access_params) - .and_return(double(execute: true)) + expect(Gitlab::GitlabImport::ProjectCreator). + to receive(:new).with(gitlab_repo, an_instance_of(Group), user, access_params). + and_return(double(execute: true)) post :create, format: :js end @@ -159,16 +159,16 @@ describe Import::GitlabController do end it "doesn't create the namespace" do - expect(Gitlab::GitlabImport::ProjectCreator) - .to receive(:new).and_return(double(execute: true)) + expect(Gitlab::GitlabImport::ProjectCreator). + to receive(:new).and_return(double(execute: true)) expect { post :create, format: :js }.not_to change(Namespace, :count) end it "takes the current user's namespace" do - expect(Gitlab::GitlabImport::ProjectCreator) - .to receive(:new).with(gitlab_repo, user.namespace, user, access_params) - .and_return(double(execute: true)) + expect(Gitlab::GitlabImport::ProjectCreator). + to receive(:new).with(gitlab_repo, user.namespace, user, access_params). + and_return(double(execute: true)) post :create, format: :js end diff --git a/spec/controllers/projects/branches_controller_spec.rb b/spec/controllers/projects/branches_controller_spec.rb index 6df654087dcf4d18c51edcdbbc6339e3c87a719f..9de038767553aa035f92a2b2a27e33613aa4ecde 100644 --- a/spec/controllers/projects/branches_controller_spec.rb +++ b/spec/controllers/projects/branches_controller_spec.rb @@ -32,8 +32,8 @@ describe Projects::BranchesController do let(:branch) { "merge_branch" } let(:ref) { "master" } it 'redirects' do - expect(subject) - .to redirect_to("/#{project.path_with_namespace}/tree/merge_branch") + expect(subject). + to redirect_to("/#{project.path_with_namespace}/tree/merge_branch") end end @@ -41,8 +41,8 @@ describe Projects::BranchesController do let(:branch) { "<script>alert('merge');</script>" } let(:ref) { "master" } it 'redirects' do - expect(subject) - .to redirect_to("/#{project.path_with_namespace}/tree/alert('merge');") + expect(subject). + to redirect_to("/#{project.path_with_namespace}/tree/alert('merge');") end end @@ -81,8 +81,8 @@ describe Projects::BranchesController do branch_name: branch, issue_iid: issue.iid - expect(subject) - .to redirect_to("/#{project.path_with_namespace}/tree/1-feature-branch") + expect(subject). + to redirect_to("/#{project.path_with_namespace}/tree/1-feature-branch") end it 'posts a system note' do diff --git a/spec/controllers/projects/commit_controller_spec.rb b/spec/controllers/projects/commit_controller_spec.rb index 1b5f6c4b43a633dd322a4e534c3c80cc4eaa0575..ebd2d0e092b9df5ffbbe04c6d3ee697adfc05739 100644 --- a/spec/controllers/projects/commit_controller_spec.rb +++ b/spec/controllers/projects/commit_controller_spec.rb @@ -66,8 +66,8 @@ describe Projects::CommitController do end it "does not escape Html" do - allow_any_instance_of(Commit).to receive(:"to_#{format}") - .and_return('HTML entities &<>" ') + allow_any_instance_of(Commit).to receive(:"to_#{format}"). + and_return('HTML entities &<>" ') go(id: commit.id, format: format) diff --git a/spec/controllers/projects/environments_controller_spec.rb b/spec/controllers/projects/environments_controller_spec.rb index 72a13d77a850500ad15c88c15dc5a211bfc90ec6..84d119f1867d2ab76861f5208a146500f81af067 100644 --- a/spec/controllers/projects/environments_controller_spec.rb +++ b/spec/controllers/projects/environments_controller_spec.rb @@ -150,14 +150,14 @@ describe Projects::EnvironmentsController do context 'and valid id' do it 'returns the first terminal for the environment' do - expect_any_instance_of(Environment) - .to receive(:terminals) - .and_return([:fake_terminal]) - - expect(Gitlab::Workhorse) - .to receive(:terminal_websocket) - .with(:fake_terminal) - .and_return(workhorse: :response) + expect_any_instance_of(Environment). + to receive(:terminals). + and_return([:fake_terminal]) + + expect(Gitlab::Workhorse). + to receive(:terminal_websocket). + with(:fake_terminal). + and_return(workhorse: :response) get :terminal_websocket_authorize, environment_params diff --git a/spec/controllers/projects/issues_controller_spec.rb b/spec/controllers/projects/issues_controller_spec.rb index 85ad883534a0113cc94d964482ff18ed8dbf9136..7871b6a9e106ece4769a9adbd19f6b8d43578c53 100644 --- a/spec/controllers/projects/issues_controller_spec.rb +++ b/spec/controllers/projects/issues_controller_spec.rb @@ -226,8 +226,8 @@ describe Projects::IssuesController do it 'redirect to issue page' do update_verified_issue - expect(response) - .to redirect_to(namespace_project_issue_path(project.namespace, project, issue)) + expect(response). + to redirect_to(namespace_project_issue_path(project.namespace, project, issue)) end it 'accepts an issue after recaptcha is verified' do @@ -241,8 +241,8 @@ describe Projects::IssuesController do it 'does not mark spam log as recaptcha_verified when it does not belong to current_user' do spam_log = create(:spam_log) - expect { update_issue(spam_log_id: spam_log.id, recaptcha_verification: true) } - .not_to change { SpamLog.last.recaptcha_verified } + expect { update_issue(spam_log_id: spam_log.id, recaptcha_verification: true) }. + not_to change { SpamLog.last.recaptcha_verified } end end end @@ -558,8 +558,8 @@ describe Projects::IssuesController do it 'does not mark spam log as recaptcha_verified when it does not belong to current_user' do spam_log = create(:spam_log) - expect { post_new_issue({}, { spam_log_id: spam_log.id, recaptcha_verification: true } ) } - .not_to change { SpamLog.last.recaptcha_verified } + expect { post_new_issue({}, { spam_log_id: spam_log.id, recaptcha_verification: true } ) }. + not_to change { SpamLog.last.recaptcha_verified } end end end diff --git a/spec/controllers/projects/mattermosts_controller_spec.rb b/spec/controllers/projects/mattermosts_controller_spec.rb index a8c365a209fd6b5ea8248a05d9e5d6fb7da34d8b..cae733f0cfb8ea9591f4bab168ae72041c8ead6d 100644 --- a/spec/controllers/projects/mattermosts_controller_spec.rb +++ b/spec/controllers/projects/mattermosts_controller_spec.rb @@ -11,8 +11,8 @@ describe Projects::MattermostsController do describe 'GET #new' do before do - allow_any_instance_of(MattermostSlashCommandsService) - .to receive(:list_teams).and_return([]) + allow_any_instance_of(MattermostSlashCommandsService). + to receive(:list_teams).and_return([]) end it 'accepts the request' do diff --git a/spec/controllers/projects/merge_requests_controller_spec.rb b/spec/controllers/projects/merge_requests_controller_spec.rb index e6a8b9f66182d8f6c4cd0abba2772aafaae56d7b..e631e5fa5e7c4b2d5957a987221afe4579ec5297 100644 --- a/spec/controllers/projects/merge_requests_controller_spec.rb +++ b/spec/controllers/projects/merge_requests_controller_spec.rb @@ -106,8 +106,8 @@ describe Projects::MergeRequestsController do end it "does not escape Html" do - allow_any_instance_of(MergeRequest).to receive(:"to_#{format}") - .and_return('HTML entities &<>" ') + allow_any_instance_of(MergeRequest).to receive(:"to_#{format}"). + and_return('HTML entities &<>" ') get(:show, namespace_id: project.namespace.to_param, @@ -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 @@ -721,8 +721,8 @@ describe Projects::MergeRequestsController do describe 'GET conflicts' do context 'when the conflicts cannot be resolved in the UI' do before do - allow_any_instance_of(Gitlab::Conflict::Parser) - .to receive(:parse).and_raise(Gitlab::Conflict::Parser::UnmergeableFile) + allow_any_instance_of(Gitlab::Conflict::Parser). + to receive(:parse).and_raise(Gitlab::Conflict::Parser::UnmergeableFile) get :conflicts, namespace_id: merge_request_with_conflicts.project.namespace.to_param, @@ -827,8 +827,8 @@ describe Projects::MergeRequestsController do context 'when the conflicts cannot be resolved in the UI' do before do - allow_any_instance_of(Gitlab::Conflict::Parser) - .to receive(:parse).and_raise(Gitlab::Conflict::Parser::UnmergeableFile) + allow_any_instance_of(Gitlab::Conflict::Parser). + to receive(:parse).and_raise(Gitlab::Conflict::Parser::UnmergeableFile) conflict_for_path('files/ruby/regex.rb') end @@ -1044,9 +1044,9 @@ describe Projects::MergeRequestsController do end it 'calls MergeRequests::AssignIssuesService' do - expect(MergeRequests::AssignIssuesService).to receive(:new) - .with(project, user, merge_request: merge_request) - .and_return(double(execute: { count: 1 })) + expect(MergeRequests::AssignIssuesService).to receive(:new). + with(project, user, merge_request: merge_request). + and_return(double(execute: { count: 1 })) post_assign_issues end diff --git a/spec/controllers/projects/raw_controller_spec.rb b/spec/controllers/projects/raw_controller_spec.rb index 68fe29ce2d5dbfada1f62ca0f3463299539d7c14..b23d6e257babee8d13f052d1aa0a7e54967af242 100644 --- a/spec/controllers/projects/raw_controller_spec.rb +++ b/spec/controllers/projects/raw_controller_spec.rb @@ -15,8 +15,8 @@ describe Projects::RawController do expect(response).to have_http_status(200) expect(response.header['Content-Type']).to eq('text/plain; charset=utf-8') - expect(response.header['Content-Disposition']) - .to eq("inline") + expect(response.header['Content-Disposition']). + to eq("inline") expect(response.header[Gitlab::Workhorse::SEND_DATA_HEADER]).to start_with("git-blob:") end end diff --git a/spec/controllers/projects/snippets_controller_spec.rb b/spec/controllers/projects/snippets_controller_spec.rb index 65e554aee49ed10cdb5dc94159765975c35c13bc..8bab094a79efe8c82fe91ac15401eb2c8675c654 100644 --- a/spec/controllers/projects/snippets_controller_spec.rb +++ b/spec/controllers/projects/snippets_controller_spec.rb @@ -89,21 +89,21 @@ describe Projects::SnippetsController do context 'when the snippet is private' do it 'creates the snippet' do - expect { create_snippet(project, visibility_level: Snippet::PRIVATE) } - .to change { Snippet.count }.by(1) + expect { create_snippet(project, visibility_level: Snippet::PRIVATE) }. + to change { Snippet.count }.by(1) end end context 'when the snippet is public' do it 'rejects the shippet' do - expect { create_snippet(project, visibility_level: Snippet::PUBLIC) } - .not_to change { Snippet.count } + expect { create_snippet(project, visibility_level: Snippet::PUBLIC) }. + not_to change { Snippet.count } expect(response).to render_template(:new) end it 'creates a spam log' do - expect { create_snippet(project, visibility_level: Snippet::PUBLIC) } - .to change { SpamLog.count }.by(1) + expect { create_snippet(project, visibility_level: Snippet::PUBLIC) }. + to change { SpamLog.count }.by(1) end it 'renders :new with recaptcha disabled' do @@ -169,8 +169,8 @@ describe Projects::SnippetsController do let(:visibility_level) { Snippet::PRIVATE } it 'updates the snippet' do - expect { update_snippet(title: 'Foo') } - .to change { snippet.reload.title }.to('Foo') + expect { update_snippet(title: 'Foo') }. + to change { snippet.reload.title }.to('Foo') end end @@ -178,13 +178,13 @@ describe Projects::SnippetsController do let(:visibility_level) { Snippet::PUBLIC } it 'rejects the shippet' do - expect { update_snippet(title: 'Foo') } - .not_to change { snippet.reload.title } + expect { update_snippet(title: 'Foo') }. + not_to change { snippet.reload.title } end it 'creates a spam log' do - expect { update_snippet(title: 'Foo') } - .to change { SpamLog.count }.by(1) + expect { update_snippet(title: 'Foo') }. + to change { SpamLog.count }.by(1) end it 'renders :edit with recaptcha disabled' do @@ -223,13 +223,13 @@ describe Projects::SnippetsController do let(:visibility_level) { Snippet::PRIVATE } it 'rejects the shippet' do - expect { update_snippet(title: 'Foo', visibility_level: Snippet::PUBLIC) } - .not_to change { snippet.reload.title } + expect { update_snippet(title: 'Foo', visibility_level: Snippet::PUBLIC) }. + not_to change { snippet.reload.title } end it 'creates a spam log' do - expect { update_snippet(title: 'Foo', visibility_level: Snippet::PUBLIC) } - .to change { SpamLog.count }.by(1) + expect { update_snippet(title: 'Foo', visibility_level: Snippet::PUBLIC) }. + to change { SpamLog.count }.by(1) end it 'renders :edit with recaptcha disabled' do diff --git a/spec/controllers/projects/tree_controller_spec.rb b/spec/controllers/projects/tree_controller_spec.rb index 71193feaaaad76e3f9e720c246e55fb7e333620c..b81645a3d2d069e114122a2f7dd8e1dd83fd2696 100644 --- a/spec/controllers/projects/tree_controller_spec.rb +++ b/spec/controllers/projects/tree_controller_spec.rb @@ -82,8 +82,8 @@ describe Projects::TreeController do let(:id) { 'master/README.md' } it 'redirects' do redirect_url = "/#{project.path_with_namespace}/blob/master/README.md" - expect(subject) - .to redirect_to(redirect_url) + expect(subject). + to redirect_to(redirect_url) end end end @@ -106,8 +106,8 @@ describe Projects::TreeController do let(:target_branch) { 'master-test'} it 'redirects to the new directory' do - expect(subject) - .to redirect_to("/#{project.path_with_namespace}/tree/#{target_branch}/#{path}") + expect(subject). + to redirect_to("/#{project.path_with_namespace}/tree/#{target_branch}/#{path}") expect(flash[:notice]).to eq('The directory has been successfully created.') end end @@ -117,8 +117,8 @@ describe Projects::TreeController do let(:target_branch) { 'master'} it 'does not allow overwriting of existing files' do - expect(subject) - .to redirect_to("/#{project.path_with_namespace}/tree/master") + expect(subject). + to redirect_to("/#{project.path_with_namespace}/tree/master") expect(flash[:alert]).to eq('Directory already exists as a file') end end diff --git a/spec/controllers/sent_notifications_controller_spec.rb b/spec/controllers/sent_notifications_controller_spec.rb index 6a4373502489b5df3e73755818d1b5acbff6a9e4..954fc2eaf210f76de1f7fd011896259c5fe0fdb0 100644 --- a/spec/controllers/sent_notifications_controller_spec.rb +++ b/spec/controllers/sent_notifications_controller_spec.rb @@ -77,8 +77,8 @@ describe SentNotificationsController, type: :controller do end it 'redirects to the issue page' do - expect(response) - .to redirect_to(namespace_project_issue_path(project.namespace, project, issue)) + expect(response). + to redirect_to(namespace_project_issue_path(project.namespace, project, issue)) end end @@ -100,8 +100,8 @@ describe SentNotificationsController, type: :controller do end it 'redirects to the merge request page' do - expect(response) - .to redirect_to(namespace_project_merge_request_path(project.namespace, project, merge_request)) + expect(response). + to redirect_to(namespace_project_merge_request_path(project.namespace, project, merge_request)) end end end diff --git a/spec/controllers/sessions_controller_spec.rb b/spec/controllers/sessions_controller_spec.rb index 42fd37f81d4ba0aad111e69cc3a1a1881cd1c2df..d951325f765e4edeb7205304dcef97d9f4e00946 100644 --- a/spec/controllers/sessions_controller_spec.rb +++ b/spec/controllers/sessions_controller_spec.rb @@ -11,8 +11,8 @@ describe SessionsController do it 'does not authenticate user' do post(:create, user: { login: 'invalid', password: 'invalid' }) - expect(response) - .to set_flash.now[:alert].to /Invalid Login or password/ + expect(response). + to set_flash.now[:alert].to /Invalid Login or password/ end end @@ -42,8 +42,8 @@ describe SessionsController do context 'remember_me field' do it 'sets a remember_user_token cookie when enabled' do allow(controller).to receive(:find_user).and_return(user) - expect(controller) - .to receive(:remember_me).with(user).and_call_original + expect(controller). + to receive(:remember_me).with(user).and_call_original authenticate_2fa(remember_me: '1', otp_attempt: user.current_otp) @@ -102,8 +102,8 @@ describe SessionsController do end it 'warns about invalid OTP code' do - expect(response).to set_flash.now[:alert] - .to /Invalid two-factor code/ + expect(response).to set_flash.now[:alert]. + to /Invalid two-factor code/ end end end @@ -129,8 +129,8 @@ describe SessionsController do end it 'warns about invalid login' do - expect(response).to set_flash.now[:alert] - .to /Invalid Login or password/ + expect(response).to set_flash.now[:alert]. + to /Invalid Login or password/ end it 'locks the user' do @@ -140,8 +140,8 @@ describe SessionsController do it 'keeps the user locked on future login attempts' do post(:create, user: { login: user.username, password: user.password }) - expect(response) - .to set_flash.now[:alert].to /Invalid Login or password/ + expect(response). + to set_flash.now[:alert].to /Invalid Login or password/ end end end @@ -153,8 +153,8 @@ describe SessionsController do authenticate_2fa(login: another_user.username, otp_attempt: 'invalid') - expect(response).to set_flash.now[:alert] - .to /Invalid two-factor code/ + expect(response).to set_flash.now[:alert]. + to /Invalid two-factor code/ end end end @@ -177,8 +177,8 @@ describe SessionsController do it 'sets a remember_user_token cookie when enabled' do allow(U2fRegistration).to receive(:authenticate).and_return(true) allow(controller).to receive(:find_user).and_return(user) - expect(controller) - .to receive(:remember_me).with(user).and_call_original + expect(controller). + to receive(:remember_me).with(user).and_call_original authenticate_2fa_u2f(remember_me: '1', login: user.username, device_response: "{}") diff --git a/spec/controllers/snippets_controller_spec.rb b/spec/controllers/snippets_controller_spec.rb index 6b52839fe2c0b513d6959f80327f201dcd432af5..5de3b9890ef3def4bde1d3035f3b7ea337c5b985 100644 --- a/spec/controllers/snippets_controller_spec.rb +++ b/spec/controllers/snippets_controller_spec.rb @@ -156,20 +156,20 @@ describe SnippetsController do context 'when the snippet is private' do it 'creates the snippet' do - expect { create_snippet(visibility_level: Snippet::PRIVATE) } - .to change { Snippet.count }.by(1) + expect { create_snippet(visibility_level: Snippet::PRIVATE) }. + to change { Snippet.count }.by(1) end end context 'when the snippet is public' do it 'rejects the shippet' do - expect { create_snippet(visibility_level: Snippet::PUBLIC) } - .not_to change { Snippet.count } + expect { create_snippet(visibility_level: Snippet::PUBLIC) }. + not_to change { Snippet.count } end it 'creates a spam log' do - expect { create_snippet(visibility_level: Snippet::PUBLIC) } - .to change { SpamLog.count }.by(1) + expect { create_snippet(visibility_level: Snippet::PUBLIC) }. + to change { SpamLog.count }.by(1) end it 'renders :new with recaptcha disabled' do @@ -230,8 +230,8 @@ describe SnippetsController do let(:visibility_level) { Snippet::PRIVATE } it 'updates the snippet' do - expect { update_snippet(title: 'Foo') } - .to change { snippet.reload.title }.to('Foo') + expect { update_snippet(title: 'Foo') }. + to change { snippet.reload.title }.to('Foo') end end @@ -239,13 +239,13 @@ describe SnippetsController do let(:visibility_level) { Snippet::PRIVATE } it 'rejects the snippet' do - expect { update_snippet(title: 'Foo', visibility_level: Snippet::PUBLIC) } - .not_to change { snippet.reload.title } + expect { update_snippet(title: 'Foo', visibility_level: Snippet::PUBLIC) }. + not_to change { snippet.reload.title } end it 'creates a spam log' do - expect { update_snippet(title: 'Foo', visibility_level: Snippet::PUBLIC) } - .to change { SpamLog.count }.by(1) + expect { update_snippet(title: 'Foo', visibility_level: Snippet::PUBLIC) }. + to change { SpamLog.count }.by(1) end it 'renders :edit with recaptcha disabled' do @@ -284,13 +284,13 @@ describe SnippetsController do let(:visibility_level) { Snippet::PUBLIC } it 'rejects the shippet' do - expect { update_snippet(title: 'Foo') } - .not_to change { snippet.reload.title } + expect { update_snippet(title: 'Foo') }. + not_to change { snippet.reload.title } end it 'creates a spam log' do - expect { update_snippet(title: 'Foo') } - .to change { SpamLog.count }.by(1) + expect { update_snippet(title: 'Foo') }. + to change { SpamLog.count }.by(1) end it 'renders :edit with recaptcha disabled' do diff --git a/spec/factories/projects.rb b/spec/factories/projects.rb index 8df86435501994fbe4fd98358f7327891acae9f4..c80b09e9b9d574b0430eff1903c0458c5691945e 100644 --- a/spec/factories/projects.rb +++ b/spec/factories/projects.rb @@ -90,8 +90,8 @@ FactoryGirl.define do builds_access_level = [evaluator.builds_access_level, evaluator.repository_access_level].min merge_requests_access_level = [evaluator.merge_requests_access_level, evaluator.repository_access_level].min - project.project_feature - .update_attributes!( + project.project_feature. + update_attributes!( wiki_access_level: evaluator.wiki_access_level, builds_access_level: builds_access_level, snippets_access_level: evaluator.snippets_access_level, diff --git a/spec/features/admin/admin_projects_spec.rb b/spec/features/admin/admin_projects_spec.rb index 7b82c3ae3d171b7febcea66a0cd79e48072283e5..87a8f62687aa918051731b8321e7b7862038228e 100644 --- a/spec/features/admin/admin_projects_spec.rb +++ b/spec/features/admin/admin_projects_spec.rb @@ -57,8 +57,8 @@ describe "Admin::Projects", feature: true do before do create(:group, name: 'Web') - allow_any_instance_of(Projects::TransferService) - .to receive(:move_uploads_to_new_namespace).and_return(true) + allow_any_instance_of(Projects::TransferService). + to receive(:move_uploads_to_new_namespace).and_return(true) end it 'transfers project to group web', js: true do diff --git a/spec/features/admin/admin_users_spec.rb b/spec/features/admin/admin_users_spec.rb index 332abb121fcced546012febca284d364d9191de1..c0807b8c507fdf8d39855fec786e9f30409ac916 100644 --- a/spec/features/admin/admin_users_spec.rb +++ b/spec/features/admin/admin_users_spec.rb @@ -77,10 +77,10 @@ describe "Admin::Users", feature: true do it "applies defaults to user" do click_button "Create user" user = User.find_by(username: 'bang') - expect(user.projects_limit) - .to eq(Gitlab.config.gitlab.default_projects_limit) - expect(user.can_create_group) - .to eq(Gitlab.config.gitlab.default_can_create_group) + expect(user.projects_limit). + to eq(Gitlab.config.gitlab.default_projects_limit) + expect(user.can_create_group). + to eq(Gitlab.config.gitlab.default_can_create_group) end it "creates user with valid data" do diff --git a/spec/features/atom/dashboard_spec.rb b/spec/features/atom/dashboard_spec.rb index 4ed06bb3a322a7d9dc029c65201a94f34cae42ca..746df36bb258992171f480987aaaf76970707bf5 100644 --- a/spec/features/atom/dashboard_spec.rb +++ b/spec/features/atom/dashboard_spec.rb @@ -28,8 +28,8 @@ describe "Dashboard Feed", feature: true do end it "has issue comment event" do - expect(body) - .to have_content("#{user.name} commented on issue ##{issue.iid}") + expect(body). + to have_content("#{user.name} commented on issue ##{issue.iid}") end end end diff --git a/spec/features/atom/issues_spec.rb b/spec/features/atom/issues_spec.rb index 6caaa703ae0e67331b6e2d375fc19dfb5f199cc0..a01a050a0130f372fd99ed9e282c20d17a7c87d1 100644 --- a/spec/features/atom/issues_spec.rb +++ b/spec/features/atom/issues_spec.rb @@ -17,8 +17,8 @@ describe 'Issues Feed', feature: true do login_with user visit namespace_project_issues_path(project.namespace, project, :atom) - expect(response_headers['Content-Type']) - .to have_content('application/atom+xml') + expect(response_headers['Content-Type']). + to have_content('application/atom+xml') expect(body).to have_selector('title', text: "#{project.name} issues") expect(body).to have_selector('author email', text: issue.author_email) expect(body).to have_selector('entry summary', text: issue.title) @@ -30,8 +30,8 @@ describe 'Issues Feed', feature: true do visit namespace_project_issues_path(project.namespace, project, :atom, private_token: user.private_token) - expect(response_headers['Content-Type']) - .to have_content('application/atom+xml') + expect(response_headers['Content-Type']). + to have_content('application/atom+xml') expect(body).to have_selector('title', text: "#{project.name} issues") expect(body).to have_selector('author email', text: issue.author_email) expect(body).to have_selector('entry summary', text: issue.title) diff --git a/spec/features/atom/users_spec.rb b/spec/features/atom/users_spec.rb index 9b569e83257c3e0936b6655c4e4b3e4862c918c6..f8c3ccb416b022a802d7438e728233f6877f96a1 100644 --- a/spec/features/atom/users_spec.rb +++ b/spec/features/atom/users_spec.rb @@ -48,8 +48,8 @@ describe "User Feed", feature: true do end it 'has issue comment event' do - expect(body) - .to have_content("#{safe_name} commented on issue ##{issue.iid}") + expect(body). + to have_content("#{safe_name} commented on issue ##{issue.iid}") end it 'has XHTML summaries in issue descriptions' do diff --git a/spec/features/environments_spec.rb b/spec/features/environments_spec.rb index 78be7d36f473a7c0a46e3ebbef5f55ab92510032..513de297fdfb83311bcd9021cfd3fb6048057b38 100644 --- a/spec/features/environments_spec.rb +++ b/spec/features/environments_spec.rb @@ -111,8 +111,8 @@ feature 'Environments page', :feature, :js do find('.js-dropdown-play-icon-container').click expect(page).to have_content(manual.name.humanize) - expect { click_link(manual.name.humanize) } - .not_to change { Ci::Pipeline.count } + expect { click_link(manual.name.humanize) }. + not_to change { Ci::Pipeline.count } expect(manual.reload).to be_pending end diff --git a/spec/features/gitlab_flavored_markdown_spec.rb b/spec/features/gitlab_flavored_markdown_spec.rb index 45d21817824b533b4bd37a33800c7f734fd3cb02..84d73d693bcfea5611df4683d955896e537d9b1f 100644 --- a/spec/features/gitlab_flavored_markdown_spec.rb +++ b/spec/features/gitlab_flavored_markdown_spec.rb @@ -11,8 +11,8 @@ describe "GitLab Flavored Markdown", feature: true do end before do - allow_any_instance_of(Commit).to receive(:title) - .and_return("fix #{issue.to_reference}\n\nask #{fred.to_reference} for details") + allow_any_instance_of(Commit).to receive(:title). + and_return("fix #{issue.to_reference}\n\nask #{fred.to_reference} for details") end let(:commit) { project.commit } diff --git a/spec/features/login_spec.rb b/spec/features/login_spec.rb index d545d38424c8424c80832bb0a97520d3f81af9a2..ae609160e18ca8b0bad7cf3b4a838b13f29e600e 100644 --- a/spec/features/login_spec.rb +++ b/spec/features/login_spec.rb @@ -110,8 +110,8 @@ feature 'Login', feature: true do end it 'invalidates the used code' do - expect { enter_code(codes.sample) } - .to change { user.reload.otp_backup_codes.size }.by(-1) + expect { enter_code(codes.sample) }. + to change { user.reload.otp_backup_codes.size }.by(-1) end end diff --git a/spec/features/markdown_spec.rb b/spec/features/markdown_spec.rb index 75ade80012cd139ce49124ea9c1cf9583f81e706..32159559c379bcd530929728d6082f007b5d53de 100644 --- a/spec/features/markdown_spec.rb +++ b/spec/features/markdown_spec.rb @@ -58,8 +58,8 @@ describe 'GitLab Markdown', feature: true do end it 'allows Markdown in tables' do - expect(doc.at_css('td:contains("Baz")').children.to_html) - .to eq '<strong>Baz</strong>' + expect(doc.at_css('td:contains("Baz")').children.to_html). + to eq '<strong>Baz</strong>' end it 'parses fenced code blocks' do @@ -150,14 +150,14 @@ describe 'GitLab Markdown', feature: true do describe 'Edge Cases' do it 'allows markup inside link elements' do aggregate_failures do - expect(doc.at_css('a[href="#link-emphasis"]').to_html) - .to eq %{<a href="#link-emphasis"><em>text</em></a>} + expect(doc.at_css('a[href="#link-emphasis"]').to_html). + to eq %{<a href="#link-emphasis"><em>text</em></a>} - expect(doc.at_css('a[href="#link-strong"]').to_html) - .to eq %{<a href="#link-strong"><strong>text</strong></a>} + expect(doc.at_css('a[href="#link-strong"]').to_html). + to eq %{<a href="#link-strong"><strong>text</strong></a>} - expect(doc.at_css('a[href="#link-code"]').to_html) - .to eq %{<a href="#link-code"><code>text</code></a>} + expect(doc.at_css('a[href="#link-code"]').to_html). + to eq %{<a href="#link-code"><code>text</code></a>} end end end diff --git a/spec/features/merge_requests/created_from_fork_spec.rb b/spec/features/merge_requests/created_from_fork_spec.rb index 73c5ef31edc5513d65d40522459efcc258259918..9fc5339308c06789fc8d0161827a7fc4aaafb17e 100644 --- a/spec/features/merge_requests/created_from_fork_spec.rb +++ b/spec/features/merge_requests/created_from_fork_spec.rb @@ -61,8 +61,8 @@ feature 'Merge request created from fork' do expect(page).to have_content pipeline.id end - expect(page.find('a.btn-remove')[:href]) - .to include fork_project.path_with_namespace + expect(page.find('a.btn-remove')[:href]). + to include fork_project.path_with_namespace end end diff --git a/spec/features/notes_on_merge_requests_spec.rb b/spec/features/notes_on_merge_requests_spec.rb index bfb28e1de15f7ed9281965825f21060aff9a637f..fab2d532e06be1bc9c2404682df8bc056a58b12f 100644 --- a/spec/features/notes_on_merge_requests_spec.rb +++ b/spec/features/notes_on_merge_requests_spec.rb @@ -25,8 +25,8 @@ describe 'Comments', feature: true do describe 'the note form' do it 'is valid' do is_expected.to have_css('.js-main-target-form', visible: true, count: 1) - expect(find('.js-main-target-form input[type=submit]').value) - .to eq('Comment') + expect(find('.js-main-target-form input[type=submit]').value). + to eq('Comment') page.within('.js-main-target-form') do expect(page).not_to have_link('Cancel') end @@ -121,8 +121,8 @@ describe 'Comments', feature: true do page.within("#note_#{note.id}") do is_expected.to have_css('.note_edited_ago') - expect(find('.note_edited_ago').text) - .to match(/less than a minute ago/) + expect(find('.note_edited_ago').text). + to match(/less than a minute ago/) end end end @@ -201,8 +201,8 @@ describe 'Comments', feature: true do it "does not add a second form for same row" do click_diff_line - is_expected - .to have_css("form[data-line-code='#{line_code}']", + is_expected. + to have_css("form[data-line-code='#{line_code}']", count: 1) end diff --git a/spec/features/projects/pipelines/pipelines_spec.rb b/spec/features/projects/pipelines/pipelines_spec.rb index 592dc4483d2a844174044d7d05eed7c4519f69c8..81f5ebf633983fe6e4ff059f5e4042c829ccb660 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 0c063f6d5ee99b5d4d494cc416db9606d08af136..ed60a95deba2b2214bd2cb5871c2129a7a6229d4 100644 --- a/spec/finders/environments_finder_spec.rb +++ b/spec/finders/environments_finder_spec.rb @@ -16,18 +16,18 @@ describe EnvironmentsFinder do end it 'returns environment when with_tags is set' do - expect(described_class.new(project, user, ref: 'master', commit: project.commit, with_tags: true).execute) - .to contain_exactly(environment) + expect(described_class.new(project, user, ref: 'master', commit: project.commit, with_tags: true).execute). + to contain_exactly(environment) end it 'does not return environment when no with_tags is set' do - expect(described_class.new(project, user, ref: 'master', commit: project.commit).execute) - .to be_empty + expect(described_class.new(project, user, ref: 'master', commit: project.commit).execute). + to be_empty end it 'does not return environment when commit is not part of deployment' do - expect(described_class.new(project, user, ref: 'master', commit: project.commit('feature')).execute) - .to be_empty + expect(described_class.new(project, user, ref: 'master', commit: project.commit('feature')).execute). + to be_empty end end @@ -37,23 +37,23 @@ describe EnvironmentsFinder do end it 'returns environment when ref is set' do - expect(described_class.new(project, user, ref: 'master', commit: project.commit).execute) - .to contain_exactly(environment) + expect(described_class.new(project, user, ref: 'master', commit: project.commit).execute). + to contain_exactly(environment) end it 'does not environment when ref is different' do - expect(described_class.new(project, user, ref: 'feature', commit: project.commit).execute) - .to be_empty + expect(described_class.new(project, user, ref: 'feature', commit: project.commit).execute). + to be_empty end it 'does not return environment when commit is not part of deployment' do - expect(described_class.new(project, user, ref: 'master', commit: project.commit('feature')).execute) - .to be_empty + expect(described_class.new(project, user, ref: 'master', commit: project.commit('feature')).execute). + to be_empty end it 'returns environment when commit constraint is not set' do - expect(described_class.new(project, user, ref: 'master').execute) - .to contain_exactly(environment) + expect(described_class.new(project, user, ref: 'master').execute). + to contain_exactly(environment) end end @@ -63,8 +63,8 @@ describe EnvironmentsFinder do end it 'returns environment' do - expect(described_class.new(project, user, commit: project.commit).execute) - .to contain_exactly(environment) + expect(described_class.new(project, user, commit: project.commit).execute). + to contain_exactly(environment) end end @@ -75,8 +75,8 @@ describe EnvironmentsFinder do end it 'finds recently updated environment' do - expect(described_class.new(project, user, ref: 'feature', recently_updated: true).execute) - .to contain_exactly(environment) + expect(described_class.new(project, user, ref: 'feature', recently_updated: true).execute). + to contain_exactly(environment) end end @@ -87,8 +87,8 @@ describe EnvironmentsFinder do end it 'does not find environment' do - expect(described_class.new(project, user, ref: 'feature', recently_updated: true).execute) - .to be_empty + expect(described_class.new(project, user, ref: 'feature', recently_updated: true).execute). + to be_empty end end @@ -101,8 +101,8 @@ describe EnvironmentsFinder do end it 'finds both environments' do - expect(described_class.new(project, user, ref: 'feature', recently_updated: true).execute) - .to contain_exactly(environment, second_environment) + expect(described_class.new(project, user, ref: 'feature', recently_updated: true).execute). + to contain_exactly(environment, second_environment) end end end diff --git a/spec/helpers/application_helper_spec.rb b/spec/helpers/application_helper_spec.rb index e96576b5d4594695956e2cc551f5323dfb7de7bd..fd40fe999411f3e4a862f20e673f0f5d3cf58a9a 100644 --- a/spec/helpers/application_helper_spec.rb +++ b/spec/helpers/application_helper_spec.rb @@ -58,8 +58,8 @@ describe ApplicationHelper do project = create(:empty_project, avatar: File.open(uploaded_image_temp_path)) avatar_url = "http://#{Gitlab.config.gitlab.host}/uploads/project/avatar/#{project.id}/banana_sample.gif" - expect(helper.project_icon("#{project.namespace.to_param}/#{project.to_param}").to_s) - .to eq "<img src=\"#{avatar_url}\" alt=\"Banana sample\" />" + expect(helper.project_icon("#{project.namespace.to_param}/#{project.to_param}").to_s). + to eq "<img src=\"#{avatar_url}\" alt=\"Banana sample\" />" end it 'gives uploaded icon when present' do @@ -77,8 +77,8 @@ describe ApplicationHelper do it 'returns an url for the avatar' do user = create(:user, avatar: File.open(uploaded_image_temp_path)) - expect(helper.avatar_icon(user.email).to_s) - .to match("/uploads/user/avatar/#{user.id}/banana_sample.gif") + expect(helper.avatar_icon(user.email).to_s). + to match("/uploads/user/avatar/#{user.id}/banana_sample.gif") end it 'returns an url for the avatar with relative url' do @@ -88,8 +88,8 @@ describe ApplicationHelper do user = create(:user, avatar: File.open(uploaded_image_temp_path)) - expect(helper.avatar_icon(user.email).to_s) - .to match("/gitlab/uploads/user/avatar/#{user.id}/banana_sample.gif") + expect(helper.avatar_icon(user.email).to_s). + to match("/gitlab/uploads/user/avatar/#{user.id}/banana_sample.gif") end it 'calls gravatar_icon when no User exists with the given email' do @@ -102,8 +102,8 @@ describe ApplicationHelper do it 'returns an URL for the avatar' do user = create(:user, avatar: File.open(uploaded_image_temp_path)) - expect(helper.avatar_icon(user).to_s) - .to match("/uploads/user/avatar/#{user.id}/banana_sample.gif") + expect(helper.avatar_icon(user).to_s). + to match("/uploads/user/avatar/#{user.id}/banana_sample.gif") end end end @@ -133,22 +133,22 @@ describe ApplicationHelper do it 'returns a valid Gravatar URL' do stub_config_setting(https: false) - expect(helper.gravatar_icon(user_email)) - .to match('http://www.gravatar.com/avatar/b58c6f14d292556214bd64909bcdb118') + expect(helper.gravatar_icon(user_email)). + to match('http://www.gravatar.com/avatar/b58c6f14d292556214bd64909bcdb118') end it 'uses HTTPs when configured' do stub_config_setting(https: true) - expect(helper.gravatar_icon(user_email)) - .to match('https://secure.gravatar.com') + expect(helper.gravatar_icon(user_email)). + to match('https://secure.gravatar.com') end it 'returns custom gravatar path when gravatar_url is set' do stub_gravatar_setting(plain_url: 'http://example.local/?s=%{size}&hash=%{hash}') - expect(gravatar_icon(user_email, 20)) - .to eq('http://example.local/?s=40&hash=b58c6f14d292556214bd64909bcdb118') + expect(gravatar_icon(user_email, 20)). + to eq('http://example.local/?s=40&hash=b58c6f14d292556214bd64909bcdb118') end it 'accepts a custom size argument' do @@ -220,8 +220,8 @@ describe ApplicationHelper do end it 'accepts a custom html_class' do - expect(element(html_class: 'custom_class').attr('class')) - .to eq 'js-timeago custom_class' + expect(element(html_class: 'custom_class').attr('class')). + to eq 'js-timeago custom_class' end it 'accepts a custom tooltip placement' do diff --git a/spec/helpers/broadcast_messages_helper_spec.rb b/spec/helpers/broadcast_messages_helper_spec.rb index 9bec0f9f432f5bd3ec67690b0e6d69f00881f3cf..c6e3c5c2368caddc87d3bd14811a989c03dedcb7 100644 --- a/spec/helpers/broadcast_messages_helper_spec.rb +++ b/spec/helpers/broadcast_messages_helper_spec.rb @@ -33,8 +33,8 @@ describe BroadcastMessagesHelper do it 'allows custom style' do broadcast_message = double(color: '#f2dede', font: '#b94a48') - expect(helper.broadcast_message_style(broadcast_message)) - .to match('background-color: #f2dede; color: #b94a48') + expect(helper.broadcast_message_style(broadcast_message)). + to match('background-color: #f2dede; color: #b94a48') end end diff --git a/spec/helpers/commits_helper_spec.rb b/spec/helpers/commits_helper_spec.rb index c245bb439db0b11c25783f32b70f34cb50f61296..a2c008790f9bf1c396d4e0116523bde237941ee0 100644 --- a/spec/helpers/commits_helper_spec.rb +++ b/spec/helpers/commits_helper_spec.rb @@ -9,8 +9,8 @@ describe CommitsHelper do author_email: 'my@email.com" onmouseover="alert(1)' ) - expect(helper.commit_author_link(commit)) - .not_to include('onmouseover="alert(1)"') + expect(helper.commit_author_link(commit)). + not_to include('onmouseover="alert(1)"') end end @@ -22,8 +22,8 @@ describe CommitsHelper do committer_email: 'my@email.com" onmouseover="alert(1)' ) - expect(helper.commit_committer_link(commit)) - .not_to include('onmouseover="alert(1)"') + expect(helper.commit_committer_link(commit)). + not_to include('onmouseover="alert(1)"') end end diff --git a/spec/helpers/form_helper_spec.rb b/spec/helpers/form_helper_spec.rb index 18cf0031d5fd89a2b9f96193dc1e1d01809aaee3..b20373a96fb4bef8a218882d4b84ab0d6916a2e3 100644 --- a/spec/helpers/form_helper_spec.rb +++ b/spec/helpers/form_helper_spec.rb @@ -11,18 +11,18 @@ describe FormHelper do it 'renders an alert div' do model = double(errors: errors_stub('Error 1')) - expect(helper.form_errors(model)) - .to include('<div class="alert alert-danger" id="error_explanation">') + expect(helper.form_errors(model)). + to include('<div class="alert alert-danger" id="error_explanation">') end it 'contains a summary message' do single_error = double(errors: errors_stub('A')) multi_errors = double(errors: errors_stub('A', 'B', 'C')) - expect(helper.form_errors(single_error)) - .to include('<h4>The form contains the following error:') - expect(helper.form_errors(multi_errors)) - .to include('<h4>The form contains the following errors:') + expect(helper.form_errors(single_error)). + to include('<h4>The form contains the following error:') + expect(helper.form_errors(multi_errors)). + to include('<h4>The form contains the following errors:') end it 'renders each message' do diff --git a/spec/helpers/gitlab_markdown_helper_spec.rb b/spec/helpers/gitlab_markdown_helper_spec.rb index 7daf03bcc54830f022f257263aba4f889b845da5..b8ec3521edb9892e9f0a56baa0c4a0ff9ac3402f 100644 --- a/spec/helpers/gitlab_markdown_helper_spec.rb +++ b/spec/helpers/gitlab_markdown_helper_spec.rb @@ -70,8 +70,8 @@ describe GitlabMarkdownHelper do expect(doc.css('a')[0].text).to eq 'This should finally fix ' # First issue link - expect(doc.css('a')[1].attr('href')) - .to eq namespace_project_issue_path(project.namespace, project, issues[0]) + expect(doc.css('a')[1].attr('href')). + to eq namespace_project_issue_path(project.namespace, project, issues[0]) expect(doc.css('a')[1].text).to eq issues[0].to_reference # Internal commit link @@ -79,8 +79,8 @@ describe GitlabMarkdownHelper do expect(doc.css('a')[2].text).to eq ' and ' # Second issue link - expect(doc.css('a')[3].attr('href')) - .to eq namespace_project_issue_path(project.namespace, project, issues[1]) + expect(doc.css('a')[3].attr('href')). + to eq namespace_project_issue_path(project.namespace, project, issues[1]) expect(doc.css('a')[3].text).to eq issues[1].to_reference # Trailing commit link @@ -100,8 +100,8 @@ describe GitlabMarkdownHelper do it "escapes HTML passed in as the body" do actual = "This is a <h1>test</h1> - see #{issues[0].to_reference}" - expect(helper.link_to_gfm(actual, link)) - .to match('<h1>test</h1>') + expect(helper.link_to_gfm(actual, link)). + to match('<h1>test</h1>') end it 'ignores reference links when they are the entire body' do @@ -112,8 +112,8 @@ describe GitlabMarkdownHelper do it 'replaces commit message with emoji to link' do actual = link_to_gfm(':book:Book', '/foo') - expect(actual) - .to eq %Q(<img class="emoji" title=":book:" alt=":book:" src="http://#{Gitlab.config.gitlab.host}/assets/1F4D6.png" height="20" width="20" align="absmiddle"><a href="/foo">Book</a>) + expect(actual). + to eq %Q(<img class="emoji" title=":book:" alt=":book:" src="http://#{Gitlab.config.gitlab.host}/assets/1F4D6.png" height="20" width="20" align="absmiddle"><a href="/foo">Book</a>) end end diff --git a/spec/helpers/groups_helper_spec.rb b/spec/helpers/groups_helper_spec.rb index 531a54a9b8d6aad2017a0702493b0e8730b3c21c..c8b0d86425fa706731191fc9a05e72f1d06ff502 100644 --- a/spec/helpers/groups_helper_spec.rb +++ b/spec/helpers/groups_helper_spec.rb @@ -8,8 +8,8 @@ describe GroupsHelper do group = create(:group) group.avatar = fixture_file_upload(avatar_file_path) group.save! - expect(group_icon(group.path).to_s) - .to match("/uploads/group/avatar/#{group.id}/banana_sample.gif") + expect(group_icon(group.path).to_s). + to match("/uploads/group/avatar/#{group.id}/banana_sample.gif") end it 'gives default avatar_icon when no avatar is present' do diff --git a/spec/helpers/import_helper_spec.rb b/spec/helpers/import_helper_spec.rb index 9afff47f4e9e1ec3de2b4cf58a2eae4dfd074db8..10f293cddf599cf6fe5d2faf122e52cc776617ef 100644 --- a/spec/helpers/import_helper_spec.rb +++ b/spec/helpers/import_helper_spec.rb @@ -29,21 +29,21 @@ describe ImportHelper do context 'when provider is "github"' do context 'when provider does not specify a custom URL' do it 'uses default GitHub URL' do - allow(Gitlab.config.omniauth).to receive(:providers) - .and_return([Settingslogic.new('name' => 'github')]) + allow(Gitlab.config.omniauth).to receive(:providers). + and_return([Settingslogic.new('name' => 'github')]) - expect(helper.provider_project_link('github', 'octocat/Hello-World')) - .to include('href="https://github.com/octocat/Hello-World"') + expect(helper.provider_project_link('github', 'octocat/Hello-World')). + to include('href="https://github.com/octocat/Hello-World"') end end context 'when provider specify a custom URL' do it 'uses custom URL' do - allow(Gitlab.config.omniauth).to receive(:providers) - .and_return([Settingslogic.new('name' => 'github', 'url' => 'https://github.company.com')]) + allow(Gitlab.config.omniauth).to receive(:providers). + and_return([Settingslogic.new('name' => 'github', 'url' => 'https://github.company.com')]) - expect(helper.provider_project_link('github', 'octocat/Hello-World')) - .to include('href="https://github.company.com/octocat/Hello-World"') + expect(helper.provider_project_link('github', 'octocat/Hello-World')). + to include('href="https://github.company.com/octocat/Hello-World"') end end end @@ -54,8 +54,8 @@ describe ImportHelper do end it 'uses given host' do - expect(helper.provider_project_link('gitea', 'octocat/Hello-World')) - .to include('href="https://try.gitea.io/octocat/Hello-World"') + expect(helper.provider_project_link('gitea', 'octocat/Hello-World')). + to include('href="https://try.gitea.io/octocat/Hello-World"') end end end diff --git a/spec/helpers/issuables_helper_spec.rb b/spec/helpers/issuables_helper_spec.rb index f3bbb539d2bc45716a8404e6487f48f44cdc0f11..93bb711f29ab3a117abecbfd61e1871cc6e3e5f3 100644 --- a/spec/helpers/issuables_helper_spec.rb +++ b/spec/helpers/issuables_helper_spec.rb @@ -23,23 +23,23 @@ describe IssuablesHelper do end it 'returns "Open" when state is :opened' do - expect(helper.issuables_state_counter_text(:issues, :opened)) - .to eq('<span>Open</span> <span class="badge">42</span>') + expect(helper.issuables_state_counter_text(:issues, :opened)). + to eq('<span>Open</span> <span class="badge">42</span>') end it 'returns "Closed" when state is :closed' do - expect(helper.issuables_state_counter_text(:issues, :closed)) - .to eq('<span>Closed</span> <span class="badge">42</span>') + expect(helper.issuables_state_counter_text(:issues, :closed)). + to eq('<span>Closed</span> <span class="badge">42</span>') end it 'returns "Merged" when state is :merged' do - expect(helper.issuables_state_counter_text(:merge_requests, :merged)) - .to eq('<span>Merged</span> <span class="badge">42</span>') + expect(helper.issuables_state_counter_text(:merge_requests, :merged)). + to eq('<span>Merged</span> <span class="badge">42</span>') end it 'returns "All" when state is :all' do - expect(helper.issuables_state_counter_text(:merge_requests, :all)) - .to eq('<span>All</span> <span class="badge">42</span>') + expect(helper.issuables_state_counter_text(:merge_requests, :all)). + to eq('<span>All</span> <span class="badge">42</span>') end end @@ -64,13 +64,13 @@ describe IssuablesHelper do expect(helper).to receive(:params).twice.and_return(params) expect(helper).to receive(:issuables_count_for_state).with(:issues, :opened).and_return(42) - expect(helper.issuables_state_counter_text(:issues, :opened)) - .to eq('<span>Open</span> <span class="badge">42</span>') + expect(helper.issuables_state_counter_text(:issues, :opened)). + to eq('<span>Open</span> <span class="badge">42</span>') expect(helper).not_to receive(:issuables_count_for_state) - expect(helper.issuables_state_counter_text(:issues, :opened)) - .to eq('<span>Open</span> <span class="badge">42</span>') + expect(helper.issuables_state_counter_text(:issues, :opened)). + to eq('<span>Open</span> <span class="badge">42</span>') end it 'does not take some keys into account in the cache key' do @@ -83,8 +83,8 @@ describe IssuablesHelper do }.with_indifferent_access) expect(helper).to receive(:issuables_count_for_state).with(:issues, :opened).and_return(42) - expect(helper.issuables_state_counter_text(:issues, :opened)) - .to eq('<span>Open</span> <span class="badge">42</span>') + expect(helper.issuables_state_counter_text(:issues, :opened)). + to eq('<span>Open</span> <span class="badge">42</span>') expect(helper).to receive(:params).and_return({ author_id: '11', @@ -95,22 +95,22 @@ describe IssuablesHelper do }.with_indifferent_access) expect(helper).not_to receive(:issuables_count_for_state) - expect(helper.issuables_state_counter_text(:issues, :opened)) - .to eq('<span>Open</span> <span class="badge">42</span>') + expect(helper.issuables_state_counter_text(:issues, :opened)). + to eq('<span>Open</span> <span class="badge">42</span>') end it 'does not take params order into account in the cache key' do expect(helper).to receive(:params).and_return('author_id' => '11', 'state' => 'opened') expect(helper).to receive(:issuables_count_for_state).with(:issues, :opened).and_return(42) - expect(helper.issuables_state_counter_text(:issues, :opened)) - .to eq('<span>Open</span> <span class="badge">42</span>') + expect(helper.issuables_state_counter_text(:issues, :opened)). + to eq('<span>Open</span> <span class="badge">42</span>') expect(helper).to receive(:params).and_return('state' => 'opened', 'author_id' => '11') expect(helper).not_to receive(:issuables_count_for_state) - expect(helper.issuables_state_counter_text(:issues, :opened)) - .to eq('<span>Open</span> <span class="badge">42</span>') + expect(helper.issuables_state_counter_text(:issues, :opened)). + to eq('<span>Open</span> <span class="badge">42</span>') end end end diff --git a/spec/helpers/issues_helper_spec.rb b/spec/helpers/issues_helper_spec.rb index b61cebe6c8a98d0e8bfa4027e27729ef93dfa945..1204d5c98885b33736cd89fd28d59ac7549faac7 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 @@ -93,8 +93,8 @@ describe IssuesHelper do award = build_stubbed(:award_emoji, user: build_stubbed(:user, name: 'Jane')) awards = Array.new(5, award).push(my_award) - expect(award_user_list(awards, current_user, limit: 2)) - .to eq("You, Jane, and 4 more.") + expect(award_user_list(awards, current_user, limit: 2)). + to eq("You, Jane, and 4 more.") end end diff --git a/spec/helpers/labels_helper_spec.rb b/spec/helpers/labels_helper_spec.rb index a8d6044fda7edd3248a6d80080bf6219054704ac..7cf535fadae18c96c729aec385099adafec34dd4 100644 --- a/spec/helpers/labels_helper_spec.rb +++ b/spec/helpers/labels_helper_spec.rb @@ -55,8 +55,8 @@ describe LabelsHelper do context 'without block' do it 'uses render_colored_label as the link content' do - expect(self).to receive(:render_colored_label) - .with(label, tooltip: true).and_return('Foo') + expect(self).to receive(:render_colored_label). + with(label, tooltip: true).and_return('Foo') expect(link_to_label(label)).to match('Foo') end end diff --git a/spec/helpers/merge_requests_helper_spec.rb b/spec/helpers/merge_requests_helper_spec.rb index 67e839878c9b528790ed5f6a217596c9c83f953e..25f2382664829f08005282358aed1052093e501e 100644 --- a/spec/helpers/merge_requests_helper_spec.rb +++ b/spec/helpers/merge_requests_helper_spec.rb @@ -15,8 +15,8 @@ describe MergeRequestsHelper do end it 'does not include api credentials in a link' do - allow(ci_service) - .to receive(:build_page).and_return("http://secretuser:secretpass@jenkins.example.com:8888/job/test1/scm/bySHA1/12d65c") + allow(ci_service). + to receive(:build_page).and_return("http://secretuser:secretpass@jenkins.example.com:8888/job/test1/scm/bySHA1/12d65c") expect(helper.ci_build_details_path(merge_request)).not_to match("secret") end end diff --git a/spec/helpers/page_layout_helper_spec.rb b/spec/helpers/page_layout_helper_spec.rb index 9e18a1f88bfa2ac1e109274285aaa507d0361378..9d7a39d3721a6436fc04180f9ffd2c948376c047 100644 --- a/spec/helpers/page_layout_helper_spec.rb +++ b/spec/helpers/page_layout_helper_spec.rb @@ -86,8 +86,8 @@ describe PageLayoutHelper do it 'raises ArgumentError when given more than two attributes' do map = { foo: 'foo', bar: 'bar', baz: 'baz' } - expect { helper.page_card_attributes(map) } - .to raise_error(ArgumentError, /more than two attributes/) + expect { helper.page_card_attributes(map) }. + to raise_error(ArgumentError, /more than two attributes/) end it 'rejects blank values' do @@ -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/preferences_helper_spec.rb b/spec/helpers/preferences_helper_spec.rb index 2575e8d85682ea2c978c7150ed2f03efa06098ee..f3e79cc729017a6cf91eef8deb4c2e43736c7651 100644 --- a/spec/helpers/preferences_helper_spec.rb +++ b/spec/helpers/preferences_helper_spec.rb @@ -29,15 +29,15 @@ describe PreferencesHelper do describe 'user_color_scheme' do context 'with a user' do it "returns user's scheme's css_class" do - allow(helper).to receive(:current_user) - .and_return(double(color_scheme_id: 3)) + allow(helper).to receive(:current_user). + and_return(double(color_scheme_id: 3)) expect(helper.user_color_scheme).to eq 'solarized-light' end it 'returns the default when id is invalid' do - allow(helper).to receive(:current_user) - .and_return(double(color_scheme_id: Gitlab::ColorSchemes.count + 5)) + allow(helper).to receive(:current_user). + and_return(double(color_scheme_id: Gitlab::ColorSchemes.count + 5)) end end @@ -45,8 +45,8 @@ describe PreferencesHelper do it 'returns the default theme' do stub_user - expect(helper.user_color_scheme) - .to eq Gitlab::ColorSchemes.default.css_class + expect(helper.user_color_scheme). + to eq Gitlab::ColorSchemes.default.css_class end end end @@ -55,8 +55,8 @@ describe PreferencesHelper do if messages.empty? allow(helper).to receive(:current_user).and_return(nil) else - allow(helper).to receive(:current_user) - .and_return(double('user', messages)) + allow(helper).to receive(:current_user). + and_return(double('user', messages)) end end diff --git a/spec/helpers/visibility_level_helper_spec.rb b/spec/helpers/visibility_level_helper_spec.rb index 8942b00b128219918015fb2a6ca36b0e44ff9f0c..387279b20314ce2dca7cc7e8d23738b8506d3761 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 267318faed444c84133afb22ca8d40b6691f7741..152c36a3ae6a86fd22a8d8f6e1b6776e8011caf8 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/cross_project_reference_spec.rb b/spec/lib/banzai/cross_project_reference_spec.rb index 787212581e2e6146e72d13f11a31572e9554a6f7..deaabceef1cb670d74a68fed1024bed4d3ed7196 100644 --- a/spec/lib/banzai/cross_project_reference_spec.rb +++ b/spec/lib/banzai/cross_project_reference_spec.rb @@ -24,8 +24,8 @@ describe Banzai::CrossProjectReference, lib: true do it 'returns the referenced project' do project2 = double('referenced project') - expect(Project).to receive(:find_by_full_path) - .with('cross/reference').and_return(project2) + expect(Project).to receive(:find_by_full_path). + with('cross/reference').and_return(project2) expect(project_from_ref('cross/reference')).to eq project2 end diff --git a/spec/lib/banzai/filter/abstract_reference_filter_spec.rb b/spec/lib/banzai/filter/abstract_reference_filter_spec.rb index fb614762a0da336eae1de8e6c5adb0466bc6f9f1..27684882435ff5cb68109bda62e2d9318324e4cb 100644 --- a/spec/lib/banzai/filter/abstract_reference_filter_spec.rb +++ b/spec/lib/banzai/filter/abstract_reference_filter_spec.rb @@ -23,11 +23,11 @@ describe Banzai::Filter::AbstractReferenceFilter do doc = Nokogiri::HTML.fragment('') filter = described_class.new(doc, project: project) - expect(filter).to receive(:references_per_project) - .and_return({ project.path_with_namespace => Set.new(%w[1]) }) + expect(filter).to receive(:references_per_project). + and_return({ project.path_with_namespace => Set.new(%w[1]) }) - expect(filter.projects_per_reference) - .to eq({ project.path_with_namespace => project }) + expect(filter.projects_per_reference). + to eq({ project.path_with_namespace => project }) end end @@ -37,13 +37,13 @@ describe Banzai::Filter::AbstractReferenceFilter do context 'with RequestStore disabled' do it 'returns a list of Projects for a list of paths' do - expect(filter.find_projects_for_paths([project.path_with_namespace])) - .to eq([project]) + expect(filter.find_projects_for_paths([project.path_with_namespace])). + to eq([project]) end it "return an empty array for paths that don't exist" do - expect(filter.find_projects_for_paths(['nonexistent/project'])) - .to eq([]) + expect(filter.find_projects_for_paths(['nonexistent/project'])). + to eq([]) end end @@ -58,14 +58,14 @@ describe Banzai::Filter::AbstractReferenceFilter do end it 'returns a list of Projects for a list of paths' do - expect(filter.find_projects_for_paths([project.path_with_namespace])) - .to eq([project]) + expect(filter.find_projects_for_paths([project.path_with_namespace])). + to eq([project]) end context "when no project with that path exists" do it "returns no value" do - expect(filter.find_projects_for_paths(['nonexistent/project'])) - .to eq([]) + expect(filter.find_projects_for_paths(['nonexistent/project'])). + to eq([]) end it "adds the ref to the project refs cache" do @@ -84,8 +84,8 @@ describe Banzai::Filter::AbstractReferenceFilter do end it "return an empty array for paths that don't exist" do - expect(filter.find_projects_for_paths(['nonexistent/project'])) - .to eq([]) + expect(filter.find_projects_for_paths(['nonexistent/project'])). + to eq([]) end end end diff --git a/spec/lib/banzai/filter/commit_range_reference_filter_spec.rb b/spec/lib/banzai/filter/commit_range_reference_filter_spec.rb index fc67c7ec3c4e1869ab07ff985abccc311b9242e1..deadc36524cc72ba76069231d7c8f00bd195c290 100644 --- a/spec/lib/banzai/filter/commit_range_reference_filter_spec.rb +++ b/spec/lib/banzai/filter/commit_range_reference_filter_spec.rb @@ -28,15 +28,15 @@ describe Banzai::Filter::CommitRangeReferenceFilter, lib: true do it 'links to a valid two-dot reference' do doc = reference_filter("See #{reference2}") - expect(doc.css('a').first.attr('href')) - .to eq urls.namespace_project_compare_url(project.namespace, project, range2.to_param) + expect(doc.css('a').first.attr('href')). + to eq urls.namespace_project_compare_url(project.namespace, project, range2.to_param) end it 'links to a valid three-dot reference' do doc = reference_filter("See #{reference}") - expect(doc.css('a').first.attr('href')) - .to eq urls.namespace_project_compare_url(project.namespace, project, range.to_param) + expect(doc.css('a').first.attr('href')). + to eq urls.namespace_project_compare_url(project.namespace, project, range.to_param) end it 'links to a valid short ID' do @@ -105,15 +105,15 @@ describe Banzai::Filter::CommitRangeReferenceFilter, lib: true do it 'links to a valid reference' do doc = reference_filter("See #{reference}") - expect(doc.css('a').first.attr('href')) - .to eq urls.namespace_project_compare_url(project2.namespace, project2, range.to_param) + expect(doc.css('a').first.attr('href')). + to eq urls.namespace_project_compare_url(project2.namespace, project2, range.to_param) end it 'link has valid text' do doc = reference_filter("Fixed (#{reference}.)") - expect(doc.css('a').first.text) - .to eql("#{project2.path_with_namespace}@#{commit1.short_id}...#{commit2.short_id}") + expect(doc.css('a').first.text). + to eql("#{project2.path_with_namespace}@#{commit1.short_id}...#{commit2.short_id}") end it 'has valid text' do @@ -140,15 +140,15 @@ describe Banzai::Filter::CommitRangeReferenceFilter, lib: true do it 'links to a valid reference' do doc = reference_filter("See #{reference}") - expect(doc.css('a').first.attr('href')) - .to eq urls.namespace_project_compare_url(project2.namespace, project2, range.to_param) + expect(doc.css('a').first.attr('href')). + to eq urls.namespace_project_compare_url(project2.namespace, project2, range.to_param) end it 'link has valid text' do doc = reference_filter("Fixed (#{reference}.)") - expect(doc.css('a').first.text) - .to eql("#{project2.path}@#{commit1.short_id}...#{commit2.short_id}") + expect(doc.css('a').first.text). + to eql("#{project2.path}@#{commit1.short_id}...#{commit2.short_id}") end it 'has valid text' do @@ -175,15 +175,15 @@ describe Banzai::Filter::CommitRangeReferenceFilter, lib: true do it 'links to a valid reference' do doc = reference_filter("See #{reference}") - expect(doc.css('a').first.attr('href')) - .to eq urls.namespace_project_compare_url(project2.namespace, project2, range.to_param) + expect(doc.css('a').first.attr('href')). + to eq urls.namespace_project_compare_url(project2.namespace, project2, range.to_param) end it 'link has valid text' do doc = reference_filter("Fixed (#{reference}.)") - expect(doc.css('a').first.text) - .to eql("#{project2.path}@#{commit1.short_id}...#{commit2.short_id}") + expect(doc.css('a').first.text). + to eql("#{project2.path}@#{commit1.short_id}...#{commit2.short_id}") end it 'has valid text' do @@ -214,8 +214,8 @@ describe Banzai::Filter::CommitRangeReferenceFilter, lib: true do it 'links to a valid reference' do doc = reference_filter("See #{reference}") - expect(doc.css('a').first.attr('href')) - .to eq reference + expect(doc.css('a').first.attr('href')). + to eq reference end it 'links with adjacent text' do diff --git a/spec/lib/banzai/filter/commit_reference_filter_spec.rb b/spec/lib/banzai/filter/commit_reference_filter_spec.rb index c4d8d3b66826f46025ec64b5a91a479c54246e1a..a19aac61229cd2d08e4027e65a96a64a8c425747 100644 --- a/spec/lib/banzai/filter/commit_reference_filter_spec.rb +++ b/spec/lib/banzai/filter/commit_reference_filter_spec.rb @@ -26,8 +26,8 @@ describe Banzai::Filter::CommitReferenceFilter, lib: true do doc = reference_filter("See #{reference[0...size]}") expect(doc.css('a').first.text).to eq commit.short_id - expect(doc.css('a').first.attr('href')) - .to eq urls.namespace_project_commit_url(project.namespace, project, reference) + expect(doc.css('a').first.attr('href')). + to eq urls.namespace_project_commit_url(project.namespace, project, reference) end end @@ -180,8 +180,8 @@ describe Banzai::Filter::CommitReferenceFilter, lib: true do it 'links to a valid reference' do doc = reference_filter("See #{reference}") - expect(doc.css('a').first.attr('href')) - .to eq urls.namespace_project_commit_url(project2.namespace, project2, commit.id) + expect(doc.css('a').first.attr('href')). + to eq urls.namespace_project_commit_url(project2.namespace, project2, commit.id) end it 'links with adjacent text' do 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 5d625fe05bb5534bdd61518302eb69e6a9b7260b..efd145e9452455f24a5737c85105bdd1c23dc246 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 @@ -58,8 +58,8 @@ describe Banzai::Filter::ExternalIssueReferenceFilter, lib: true do end it 'escapes the title attribute' do - allow(project.external_issue_tracker).to receive(:title) - .and_return(%{"></a>whatever<a title="}) + allow(project.external_issue_tracker).to receive(:title). + and_return(%{"></a>whatever<a title="}) doc = filter("Issue #{reference}") expect(doc.text).to eq "Issue #{reference}" diff --git a/spec/lib/banzai/filter/issue_reference_filter_spec.rb b/spec/lib/banzai/filter/issue_reference_filter_spec.rb index 2fdf3251013675a519c5e67694af938fd437d91f..11607d4fb26916da7327dfc11048b91739adbcdf 100644 --- a/spec/lib/banzai/filter/issue_reference_filter_spec.rb +++ b/spec/lib/banzai/filter/issue_reference_filter_spec.rb @@ -36,8 +36,8 @@ describe Banzai::Filter::IssueReferenceFilter, lib: true do it 'links to a valid reference' do doc = reference_filter("Fixed #{reference}") - expect(doc.css('a').first.attr('href')) - .to eq helper.url_for_issue(issue.iid, project) + expect(doc.css('a').first.attr('href')). + to eq helper.url_for_issue(issue.iid, project) end it 'links with adjacent text' do @@ -124,9 +124,9 @@ describe Banzai::Filter::IssueReferenceFilter, lib: true do let(:reference) { "#{project2.path_with_namespace}##{issue.iid}" } it 'ignores valid references when cross-reference project uses external tracker' do - expect_any_instance_of(described_class).to receive(:find_object) - .with(project2, issue.iid) - .and_return(nil) + expect_any_instance_of(described_class).to receive(:find_object). + with(project2, issue.iid). + and_return(nil) exp = act = "Issue #{reference}" expect(reference_filter(act).to_html).to eq exp @@ -135,8 +135,8 @@ describe Banzai::Filter::IssueReferenceFilter, lib: true do it 'links to a valid reference' do doc = reference_filter("See #{reference}") - expect(doc.css('a').first.attr('href')) - .to eq helper.url_for_issue(issue.iid, project2) + expect(doc.css('a').first.attr('href')). + to eq helper.url_for_issue(issue.iid, project2) end it 'link has valid text' do @@ -168,9 +168,9 @@ describe Banzai::Filter::IssueReferenceFilter, lib: true do let(:reference) { "#{project2.path_with_namespace}##{issue.iid}" } it 'ignores valid references when cross-reference project uses external tracker' do - expect_any_instance_of(described_class).to receive(:find_object) - .with(project2, issue.iid) - .and_return(nil) + expect_any_instance_of(described_class).to receive(:find_object). + with(project2, issue.iid). + and_return(nil) exp = act = "Issue #{reference}" expect(reference_filter(act).to_html).to eq exp @@ -179,8 +179,8 @@ describe Banzai::Filter::IssueReferenceFilter, lib: true do it 'links to a valid reference' do doc = reference_filter("See #{reference}") - expect(doc.css('a').first.attr('href')) - .to eq helper.url_for_issue(issue.iid, project2) + expect(doc.css('a').first.attr('href')). + to eq helper.url_for_issue(issue.iid, project2) end it 'link has valid text' do @@ -212,9 +212,9 @@ describe Banzai::Filter::IssueReferenceFilter, lib: true do let(:reference) { "#{project2.path}##{issue.iid}" } it 'ignores valid references when cross-reference project uses external tracker' do - expect_any_instance_of(described_class).to receive(:find_object) - .with(project2, issue.iid) - .and_return(nil) + expect_any_instance_of(described_class).to receive(:find_object). + with(project2, issue.iid). + and_return(nil) exp = act = "Issue #{reference}" expect(reference_filter(act).to_html).to eq exp @@ -223,8 +223,8 @@ describe Banzai::Filter::IssueReferenceFilter, lib: true do it 'links to a valid reference' do doc = reference_filter("See #{reference}") - expect(doc.css('a').first.attr('href')) - .to eq helper.url_for_issue(issue.iid, project2) + expect(doc.css('a').first.attr('href')). + to eq helper.url_for_issue(issue.iid, project2) end it 'link has valid text' do @@ -257,8 +257,8 @@ describe Banzai::Filter::IssueReferenceFilter, lib: true do it 'links to a valid reference' do doc = reference_filter("See #{reference}") - expect(doc.css('a').first.attr('href')) - .to eq reference + expect(doc.css('a').first.attr('href')). + to eq reference end it 'links with adjacent text' do @@ -279,8 +279,8 @@ describe Banzai::Filter::IssueReferenceFilter, lib: true do it 'links to a valid reference' do doc = reference_filter("See #{reference_link}") - expect(doc.css('a').first.attr('href')) - .to eq helper.url_for_issue(issue.iid, project2) + expect(doc.css('a').first.attr('href')). + to eq helper.url_for_issue(issue.iid, project2) end it 'links with adjacent text' do @@ -301,8 +301,8 @@ describe Banzai::Filter::IssueReferenceFilter, lib: true do it 'links to a valid reference' do doc = reference_filter("See #{reference_link}") - expect(doc.css('a').first.attr('href')) - .to eq helper.url_for_issue(issue.iid, project2) + "#note_123" + expect(doc.css('a').first.attr('href')). + to eq helper.url_for_issue(issue.iid, project2) + "#note_123" end it 'links with adjacent text' do @@ -317,14 +317,14 @@ describe Banzai::Filter::IssueReferenceFilter, lib: true do doc = Nokogiri::HTML.fragment('') filter = described_class.new(doc, project: project) - expect(filter).to receive(:projects_per_reference) - .and_return({ project.path_with_namespace => project }) + expect(filter).to receive(:projects_per_reference). + and_return({ project.path_with_namespace => project }) - expect(filter).to receive(:references_per_project) - .and_return({ project.path_with_namespace => Set.new([issue.iid]) }) + expect(filter).to receive(:references_per_project). + and_return({ project.path_with_namespace => Set.new([issue.iid]) }) - expect(filter.issues_per_project) - .to eq({ project => { issue.iid => issue } }) + expect(filter.issues_per_project). + to eq({ project => { issue.iid => issue } }) end end @@ -335,14 +335,14 @@ describe Banzai::Filter::IssueReferenceFilter, lib: true do expect(project).to receive(:default_issues_tracker?).and_return(false) - expect(filter).to receive(:projects_per_reference) - .and_return({ project.path_with_namespace => project }) + expect(filter).to receive(:projects_per_reference). + and_return({ project.path_with_namespace => project }) - expect(filter).to receive(:references_per_project) - .and_return({ project.path_with_namespace => Set.new([1]) }) + expect(filter).to receive(:references_per_project). + and_return({ project.path_with_namespace => Set.new([1]) }) - expect(filter.issues_per_project[project][1]) - .to be_an_instance_of(ExternalIssue) + expect(filter.issues_per_project[project][1]). + to be_an_instance_of(ExternalIssue) end end end diff --git a/spec/lib/banzai/filter/label_reference_filter_spec.rb b/spec/lib/banzai/filter/label_reference_filter_spec.rb index cb3cf982351f564c06774f705844bf132ce880da..5e16fd10ebedb1588be012592180d0669a3424ac 100644 --- a/spec/lib/banzai/filter/label_reference_filter_spec.rb +++ b/spec/lib/banzai/filter/label_reference_filter_spec.rb @@ -72,8 +72,8 @@ describe Banzai::Filter::LabelReferenceFilter, lib: true do it 'links to a valid reference' do doc = reference_filter("See #{reference}") - expect(doc.css('a').first.attr('href')).to eq urls - .namespace_project_issues_url(project.namespace, project, label_name: label.name) + expect(doc.css('a').first.attr('href')).to eq urls. + namespace_project_issues_url(project.namespace, project, label_name: label.name) end it 'links with adjacent text' do @@ -95,8 +95,8 @@ describe Banzai::Filter::LabelReferenceFilter, lib: true do it 'links to a valid reference' do doc = reference_filter("See #{reference}") - expect(doc.css('a').first.attr('href')).to eq urls - .namespace_project_issues_url(project.namespace, project, label_name: label.name) + expect(doc.css('a').first.attr('href')).to eq urls. + namespace_project_issues_url(project.namespace, project, label_name: label.name) expect(doc.text).to eq 'See gfm' end @@ -119,8 +119,8 @@ describe Banzai::Filter::LabelReferenceFilter, lib: true do it 'links to a valid reference' do doc = reference_filter("See #{reference}") - expect(doc.css('a').first.attr('href')).to eq urls - .namespace_project_issues_url(project.namespace, project, label_name: label.name) + expect(doc.css('a').first.attr('href')).to eq urls. + namespace_project_issues_url(project.namespace, project, label_name: label.name) expect(doc.text).to eq 'See 2fa' end @@ -143,8 +143,8 @@ describe Banzai::Filter::LabelReferenceFilter, lib: true do it 'links to a valid reference' do doc = reference_filter("See #{reference}") - expect(doc.css('a').first.attr('href')).to eq urls - .namespace_project_issues_url(project.namespace, project, label_name: label.name) + expect(doc.css('a').first.attr('href')).to eq urls. + namespace_project_issues_url(project.namespace, project, label_name: label.name) expect(doc.text).to eq 'See ?g.fm&' end @@ -168,8 +168,8 @@ describe Banzai::Filter::LabelReferenceFilter, lib: true do it 'links to a valid reference' do doc = reference_filter("See #{reference}") - expect(doc.css('a').first.attr('href')).to eq urls - .namespace_project_issues_url(project.namespace, project, label_name: label.name) + expect(doc.css('a').first.attr('href')).to eq urls. + namespace_project_issues_url(project.namespace, project, label_name: label.name) expect(doc.text).to eq 'See gfm references' end @@ -192,8 +192,8 @@ describe Banzai::Filter::LabelReferenceFilter, lib: true do it 'links to a valid reference' do doc = reference_filter("See #{reference}") - expect(doc.css('a').first.attr('href')).to eq urls - .namespace_project_issues_url(project.namespace, project, label_name: label.name) + expect(doc.css('a').first.attr('href')).to eq urls. + namespace_project_issues_url(project.namespace, project, label_name: label.name) expect(doc.text).to eq 'See 2 factor authentication' end @@ -216,8 +216,8 @@ describe Banzai::Filter::LabelReferenceFilter, lib: true do it 'links to a valid reference' do doc = reference_filter("See #{reference}") - expect(doc.css('a').first.attr('href')).to eq urls - .namespace_project_issues_url(project.namespace, project, label_name: label.name) + expect(doc.css('a').first.attr('href')).to eq urls. + namespace_project_issues_url(project.namespace, project, label_name: label.name) expect(doc.text).to eq 'See g.fm & references?' end @@ -287,8 +287,8 @@ describe Banzai::Filter::LabelReferenceFilter, lib: true do it 'links to a valid reference' do doc = reference_filter("See #{reference}") - expect(doc.css('a').first.attr('href')).to eq urls - .namespace_project_issues_url(project.namespace, project, label_name: label.name) + expect(doc.css('a').first.attr('href')).to eq urls. + namespace_project_issues_url(project.namespace, project, label_name: label.name) end it 'links with adjacent text' do @@ -324,8 +324,8 @@ describe Banzai::Filter::LabelReferenceFilter, lib: true do it 'links to a valid reference' do doc = reference_filter("See #{reference}", project: project) - expect(doc.css('a').first.attr('href')).to eq urls - .namespace_project_issues_url(project.namespace, project, label_name: group_label.name) + expect(doc.css('a').first.attr('href')).to eq urls. + namespace_project_issues_url(project.namespace, project, label_name: group_label.name) expect(doc.text).to eq 'See gfm references' end @@ -347,8 +347,8 @@ describe Banzai::Filter::LabelReferenceFilter, lib: true do it 'links to a valid reference' do doc = reference_filter("See #{reference}", project: project) - expect(doc.css('a').first.attr('href')).to eq urls - .namespace_project_issues_url(project.namespace, project, label_name: group_label.name) + expect(doc.css('a').first.attr('href')).to eq urls. + namespace_project_issues_url(project.namespace, project, label_name: group_label.name) expect(doc.text).to eq "See gfm references" end @@ -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,15 +440,15 @@ 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 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 @@ -476,25 +476,25 @@ 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 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 - expect(result.css('a').first.text) - .to eq "#{group_label.name} in #{another_project.name_with_namespace}" + expect(result.css('a').first.text). + to eq "#{group_label.name} in #{another_project.name_with_namespace}" end it 'has valid text' do - expect(result.text) - .to eq "See #{group_label.name} in #{another_project.name_with_namespace}" + expect(result.text). + to eq "See #{group_label.name} in #{another_project.name_with_namespace}" end it 'ignores invalid IDs on the referenced label' do @@ -513,25 +513,25 @@ 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 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 - expect(result.css('a').first.text) - .to eq "#{group_label.name} in #{another_project.name}" + expect(result.css('a').first.text). + to eq "#{group_label.name} in #{another_project.name}" end it 'has valid text' do - expect(result.text) - .to eq "See #{group_label.name} in #{another_project.name}" + expect(result.text). + to eq "See #{group_label.name} in #{another_project.name}" end it 'ignores invalid IDs on the referenced label' do @@ -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,15 +583,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 diff --git a/spec/lib/banzai/filter/merge_request_reference_filter_spec.rb b/spec/lib/banzai/filter/merge_request_reference_filter_spec.rb index 0fc017788bd10a27542b38942dd31fad124fd841..3d3d36061f4d3fee00f4818e5bff99a96fcdbd52 100644 --- a/spec/lib/banzai/filter/merge_request_reference_filter_spec.rb +++ b/spec/lib/banzai/filter/merge_request_reference_filter_spec.rb @@ -23,8 +23,8 @@ describe Banzai::Filter::MergeRequestReferenceFilter, lib: true do it 'links to a valid reference' do doc = reference_filter("See #{reference}") - expect(doc.css('a').first.attr('href')).to eq urls - .namespace_project_merge_request_url(project.namespace, project, merge) + expect(doc.css('a').first.attr('href')).to eq urls. + namespace_project_merge_request_url(project.namespace, project, merge) end it 'links with adjacent text' do @@ -94,8 +94,8 @@ describe Banzai::Filter::MergeRequestReferenceFilter, lib: true do it 'links to a valid reference' do doc = reference_filter("See #{reference}") - expect(doc.css('a').first.attr('href')) - .to eq urls.namespace_project_merge_request_url(project2.namespace, + expect(doc.css('a').first.attr('href')). + to eq urls.namespace_project_merge_request_url(project2.namespace, project2, merge) end @@ -128,8 +128,8 @@ describe Banzai::Filter::MergeRequestReferenceFilter, lib: true do it 'links to a valid reference' do doc = reference_filter("See #{reference}") - expect(doc.css('a').first.attr('href')) - .to eq urls.namespace_project_merge_request_url(project2.namespace, + expect(doc.css('a').first.attr('href')). + to eq urls.namespace_project_merge_request_url(project2.namespace, project2, merge) end @@ -162,8 +162,8 @@ describe Banzai::Filter::MergeRequestReferenceFilter, lib: true do it 'links to a valid reference' do doc = reference_filter("See #{reference}") - expect(doc.css('a').first.attr('href')) - .to eq urls.namespace_project_merge_request_url(project2.namespace, + expect(doc.css('a').first.attr('href')). + to eq urls.namespace_project_merge_request_url(project2.namespace, project2, merge) end @@ -195,8 +195,8 @@ describe Banzai::Filter::MergeRequestReferenceFilter, lib: true do it 'links to a valid reference' do doc = reference_filter("See #{reference}") - expect(doc.css('a').first.attr('href')) - .to eq reference + expect(doc.css('a').first.attr('href')). + to eq reference end it 'links with adjacent text' do diff --git a/spec/lib/banzai/filter/milestone_reference_filter_spec.rb b/spec/lib/banzai/filter/milestone_reference_filter_spec.rb index fe88b9cb73ececc1ca67572d82ef27987532e202..a317c751d3275ebc5034e61bc38c9c2b2161e3f8 100644 --- a/spec/lib/banzai/filter/milestone_reference_filter_spec.rb +++ b/spec/lib/banzai/filter/milestone_reference_filter_spec.rb @@ -44,16 +44,16 @@ describe Banzai::Filter::MilestoneReferenceFilter, lib: true do link = doc.css('a').first.attr('href') expect(link).not_to match %r(https?://) - expect(link).to eq urls - .namespace_project_milestone_path(project.namespace, project, milestone) + expect(link).to eq urls. + namespace_project_milestone_path(project.namespace, project, milestone) end context 'Integer-based references' do it 'links to a valid reference' do doc = reference_filter("See #{reference}") - expect(doc.css('a').first.attr('href')).to eq urls - .namespace_project_milestone_url(project.namespace, project, milestone) + expect(doc.css('a').first.attr('href')).to eq urls. + namespace_project_milestone_url(project.namespace, project, milestone) end it 'links with adjacent text' do @@ -75,8 +75,8 @@ describe Banzai::Filter::MilestoneReferenceFilter, lib: true do it 'links to a valid reference' do doc = reference_filter("See #{reference}") - expect(doc.css('a').first.attr('href')).to eq urls - .namespace_project_milestone_url(project.namespace, project, milestone) + expect(doc.css('a').first.attr('href')).to eq urls. + namespace_project_milestone_url(project.namespace, project, milestone) expect(doc.text).to eq 'See gfm' end @@ -99,8 +99,8 @@ describe Banzai::Filter::MilestoneReferenceFilter, lib: true do it 'links to a valid reference' do doc = reference_filter("See #{reference}") - expect(doc.css('a').first.attr('href')).to eq urls - .namespace_project_milestone_url(project.namespace, project, milestone) + expect(doc.css('a').first.attr('href')).to eq urls. + namespace_project_milestone_url(project.namespace, project, milestone) expect(doc.text).to eq 'See gfm references' end @@ -122,8 +122,8 @@ describe Banzai::Filter::MilestoneReferenceFilter, lib: true do it 'links to a valid reference' do doc = reference_filter("See #{reference}") - expect(doc.css('a').first.attr('href')).to eq urls - .namespace_project_milestone_url(project.namespace, project, milestone) + expect(doc.css('a').first.attr('href')).to eq urls. + namespace_project_milestone_url(project.namespace, project, milestone) end it 'links with adjacent text' do @@ -156,8 +156,8 @@ describe Banzai::Filter::MilestoneReferenceFilter, lib: true do let!(:result) { reference_filter("See #{reference}") } it 'points to referenced project milestone page' do - expect(result.css('a').first.attr('href')).to eq urls - .namespace_project_milestone_url(another_project.namespace, + expect(result.css('a').first.attr('href')).to eq urls. + namespace_project_milestone_url(another_project.namespace, another_project, milestone) end @@ -165,15 +165,15 @@ describe Banzai::Filter::MilestoneReferenceFilter, lib: true do it 'link has valid text' do doc = reference_filter("See (#{reference}.)") - expect(doc.css('a').first.text) - .to eq("#{milestone.name} in #{another_project.path_with_namespace}") + expect(doc.css('a').first.text). + to eq("#{milestone.name} in #{another_project.path_with_namespace}") end it 'has valid text' do doc = reference_filter("See (#{reference}.)") - expect(doc.text) - .to eq("See (#{milestone.name} in #{another_project.path_with_namespace}.)") + expect(doc.text). + to eq("See (#{milestone.name} in #{another_project.path_with_namespace}.)") end it 'escapes the name attribute' do @@ -181,8 +181,8 @@ describe Banzai::Filter::MilestoneReferenceFilter, lib: true do doc = reference_filter("See #{reference}") - expect(doc.css('a').first.text) - .to eq "#{milestone.name} in #{another_project.path_with_namespace}" + expect(doc.css('a').first.text). + to eq "#{milestone.name} in #{another_project.path_with_namespace}" end end @@ -195,8 +195,8 @@ describe Banzai::Filter::MilestoneReferenceFilter, lib: true do let!(:result) { reference_filter("See #{reference}") } it 'points to referenced project milestone page' do - expect(result.css('a').first.attr('href')).to eq urls - .namespace_project_milestone_url(another_project.namespace, + expect(result.css('a').first.attr('href')).to eq urls. + namespace_project_milestone_url(another_project.namespace, another_project, milestone) end @@ -204,15 +204,15 @@ describe Banzai::Filter::MilestoneReferenceFilter, lib: true do it 'link has valid text' do doc = reference_filter("See (#{reference}.)") - expect(doc.css('a').first.text) - .to eq("#{milestone.name} in #{another_project.path}") + expect(doc.css('a').first.text). + to eq("#{milestone.name} in #{another_project.path}") end it 'has valid text' do doc = reference_filter("See (#{reference}.)") - expect(doc.text) - .to eq("See (#{milestone.name} in #{another_project.path}.)") + expect(doc.text). + to eq("See (#{milestone.name} in #{another_project.path}.)") end it 'escapes the name attribute' do @@ -220,8 +220,8 @@ describe Banzai::Filter::MilestoneReferenceFilter, lib: true do doc = reference_filter("See #{reference}") - expect(doc.css('a').first.text) - .to eq "#{milestone.name} in #{another_project.path}" + expect(doc.css('a').first.text). + to eq "#{milestone.name} in #{another_project.path}" end end @@ -234,8 +234,8 @@ describe Banzai::Filter::MilestoneReferenceFilter, lib: true do let!(:result) { reference_filter("See #{reference}") } it 'points to referenced project milestone page' do - expect(result.css('a').first.attr('href')).to eq urls - .namespace_project_milestone_url(another_project.namespace, + expect(result.css('a').first.attr('href')).to eq urls. + namespace_project_milestone_url(another_project.namespace, another_project, milestone) end @@ -243,15 +243,15 @@ describe Banzai::Filter::MilestoneReferenceFilter, lib: true do it 'link has valid text' do doc = reference_filter("See (#{reference}.)") - expect(doc.css('a').first.text) - .to eq("#{milestone.name} in #{another_project.path}") + expect(doc.css('a').first.text). + to eq("#{milestone.name} in #{another_project.path}") end it 'has valid text' do doc = reference_filter("See (#{reference}.)") - expect(doc.text) - .to eq("See (#{milestone.name} in #{another_project.path}.)") + expect(doc.text). + to eq("See (#{milestone.name} in #{another_project.path}.)") end it 'escapes the name attribute' do @@ -259,8 +259,8 @@ describe Banzai::Filter::MilestoneReferenceFilter, lib: true do doc = reference_filter("See #{reference}") - expect(doc.css('a').first.text) - .to eq "#{milestone.name} in #{another_project.path}" + expect(doc.css('a').first.text). + to eq "#{milestone.name} in #{another_project.path}" end end end diff --git a/spec/lib/banzai/filter/redactor_filter_spec.rb b/spec/lib/banzai/filter/redactor_filter_spec.rb index 84bddda723aa50b6935730bf7587f07d2cace548..0140a91c7bac23050ad57d3414eff76223501802 100644 --- a/spec/lib/banzai/filter/redactor_filter_spec.rb +++ b/spec/lib/banzai/filter/redactor_filter_spec.rb @@ -23,9 +23,9 @@ describe Banzai::Filter::RedactorFilter, lib: true do end before do - allow(Banzai::ReferenceParser).to receive(:[]) - .with('test') - .and_return(parser_class) + allow(Banzai::ReferenceParser).to receive(:[]). + with('test'). + and_return(parser_class) end context 'valid projects' do diff --git a/spec/lib/banzai/filter/reference_filter_spec.rb b/spec/lib/banzai/filter/reference_filter_spec.rb index ba0fa4a609aa4b8fd0d56c07e923def980280346..55e681f6fafd96b482f2868ce31f34062c647258 100644 --- a/spec/lib/banzai/filter/reference_filter_spec.rb +++ b/spec/lib/banzai/filter/reference_filter_spec.rb @@ -8,8 +8,8 @@ describe Banzai::Filter::ReferenceFilter, lib: true do document = Nokogiri::HTML.fragment('<a href="foo">foo</a>') filter = described_class.new(document, project: project) - expect { |b| filter.each_node(&b) } - .to yield_with_args(an_instance_of(Nokogiri::XML::Element)) + expect { |b| filter.each_node(&b) }. + to yield_with_args(an_instance_of(Nokogiri::XML::Element)) end it 'returns an Enumerator when no block is given' do diff --git a/spec/lib/banzai/filter/relative_link_filter_spec.rb b/spec/lib/banzai/filter/relative_link_filter_spec.rb index 1ce7bd7706eba2dfdb21aafbceaa6c6451f0f91f..1957ba739e267edc14b454f2f7ced2adf7b8b661 100644 --- a/spec/lib/banzai/filter/relative_link_filter_spec.rb +++ b/spec/lib/banzai/filter/relative_link_filter_spec.rb @@ -72,15 +72,15 @@ describe Banzai::Filter::RelativeLinkFilter, lib: true do it 'ignores ref if commit is passed' do doc = filter(link('non/existent.file'), commit: project.commit('empty-branch') ) - expect(doc.at_css('a')['href']) - .to eq "/#{project_path}/#{ref}/non/existent.file" # non-existent files have no leading blob/raw/tree + expect(doc.at_css('a')['href']). + to eq "/#{project_path}/#{ref}/non/existent.file" # non-existent files have no leading blob/raw/tree end shared_examples :valid_repository do it 'rebuilds absolute URL for a file in the repo' do doc = filter(link('/doc/api/README.md')) - expect(doc.at_css('a')['href']) - .to eq "/#{project_path}/blob/#{ref}/doc/api/README.md" + expect(doc.at_css('a')['href']). + to eq "/#{project_path}/blob/#{ref}/doc/api/README.md" end it 'ignores absolute URLs with two leading slashes' do @@ -90,71 +90,71 @@ describe Banzai::Filter::RelativeLinkFilter, lib: true do it 'rebuilds relative URL for a file in the repo' do doc = filter(link('doc/api/README.md')) - expect(doc.at_css('a')['href']) - .to eq "/#{project_path}/blob/#{ref}/doc/api/README.md" + expect(doc.at_css('a')['href']). + to eq "/#{project_path}/blob/#{ref}/doc/api/README.md" end it 'rebuilds relative URL for a file in the repo with leading ./' do doc = filter(link('./doc/api/README.md')) - expect(doc.at_css('a')['href']) - .to eq "/#{project_path}/blob/#{ref}/doc/api/README.md" + expect(doc.at_css('a')['href']). + to eq "/#{project_path}/blob/#{ref}/doc/api/README.md" end it 'rebuilds relative URL for a file in the repo up one directory' do relative_link = link('../api/README.md') doc = filter(relative_link, requested_path: 'doc/update/7.14-to-8.0.md') - expect(doc.at_css('a')['href']) - .to eq "/#{project_path}/blob/#{ref}/doc/api/README.md" + expect(doc.at_css('a')['href']). + to eq "/#{project_path}/blob/#{ref}/doc/api/README.md" end it 'rebuilds relative URL for a file in the repo up multiple directories' do relative_link = link('../../../api/README.md') doc = filter(relative_link, requested_path: 'doc/foo/bar/baz/README.md') - expect(doc.at_css('a')['href']) - .to eq "/#{project_path}/blob/#{ref}/doc/api/README.md" + expect(doc.at_css('a')['href']). + to eq "/#{project_path}/blob/#{ref}/doc/api/README.md" end it 'rebuilds relative URL for a file in the repository root' do relative_link = link('../README.md') doc = filter(relative_link, requested_path: 'doc/some-file.md') - expect(doc.at_css('a')['href']) - .to eq "/#{project_path}/blob/#{ref}/README.md" + expect(doc.at_css('a')['href']). + to eq "/#{project_path}/blob/#{ref}/README.md" end it 'rebuilds relative URL for a file in the repo with an anchor' do doc = filter(link('README.md#section')) - expect(doc.at_css('a')['href']) - .to eq "/#{project_path}/blob/#{ref}/README.md#section" + expect(doc.at_css('a')['href']). + to eq "/#{project_path}/blob/#{ref}/README.md#section" end it 'rebuilds relative URL for a directory in the repo' do doc = filter(link('doc/api/')) - expect(doc.at_css('a')['href']) - .to eq "/#{project_path}/tree/#{ref}/doc/api" + expect(doc.at_css('a')['href']). + to eq "/#{project_path}/tree/#{ref}/doc/api" end it 'rebuilds relative URL for an image in the repo' do doc = filter(image('files/images/logo-black.png')) - expect(doc.at_css('img')['src']) - .to eq "/#{project_path}/raw/#{ref}/files/images/logo-black.png" + expect(doc.at_css('img')['src']). + to eq "/#{project_path}/raw/#{ref}/files/images/logo-black.png" end it 'rebuilds relative URL for link to an image in the repo' do doc = filter(link('files/images/logo-black.png')) - expect(doc.at_css('a')['href']) - .to eq "/#{project_path}/raw/#{ref}/files/images/logo-black.png" + expect(doc.at_css('a')['href']). + to eq "/#{project_path}/raw/#{ref}/files/images/logo-black.png" end it 'rebuilds relative URL for a video in the repo' do doc = filter(video('files/videos/intro.mp4'), commit: project.commit('video'), ref: 'video') - expect(doc.at_css('video')['src']) - .to eq "/#{project_path}/raw/video/files/videos/intro.mp4" + expect(doc.at_css('video')['src']). + to eq "/#{project_path}/raw/video/files/videos/intro.mp4" end it 'does not modify relative URL with an anchor only' do diff --git a/spec/lib/banzai/filter/sanitization_filter_spec.rb b/spec/lib/banzai/filter/sanitization_filter_spec.rb index f2cff6861bc6ac1f9ec8045ee5432ec62169f2a0..b38e3b17e64b062aa6e60ceb61ee90a41d1f3afe 100644 --- a/spec/lib/banzai/filter/sanitization_filter_spec.rb +++ b/spec/lib/banzai/filter/sanitization_filter_spec.rb @@ -194,8 +194,8 @@ describe Banzai::Filter::SanitizationFilter, lib: true do end it 'disallows invalid URIs' do - expect(Addressable::URI).to receive(:parse).with('foo://example.com') - .and_raise(Addressable::URI::InvalidURIError) + expect(Addressable::URI).to receive(:parse).with('foo://example.com'). + and_raise(Addressable::URI::InvalidURIError) input = '<a href="foo://example.com">Foo</a>' output = filter(input) diff --git a/spec/lib/banzai/filter/snippet_reference_filter_spec.rb b/spec/lib/banzai/filter/snippet_reference_filter_spec.rb index e851120bc3ae2c4df1479d2c45a68615e5d4e3e4..e036514d283e3647fd22c65745f63abfaf9b444d 100644 --- a/spec/lib/banzai/filter/snippet_reference_filter_spec.rb +++ b/spec/lib/banzai/filter/snippet_reference_filter_spec.rb @@ -22,8 +22,8 @@ describe Banzai::Filter::SnippetReferenceFilter, lib: true do it 'links to a valid reference' do doc = reference_filter("See #{reference}") - expect(doc.css('a').first.attr('href')).to eq urls - .namespace_project_snippet_url(project.namespace, project, snippet) + expect(doc.css('a').first.attr('href')).to eq urls. + namespace_project_snippet_url(project.namespace, project, snippet) end it 'links with adjacent text' do @@ -88,8 +88,8 @@ describe Banzai::Filter::SnippetReferenceFilter, lib: true do it 'links to a valid reference' do doc = reference_filter("See #{reference}") - expect(doc.css('a').first.attr('href')) - .to eq urls.namespace_project_snippet_url(project2.namespace, project2, snippet) + expect(doc.css('a').first.attr('href')). + to eq urls.namespace_project_snippet_url(project2.namespace, project2, snippet) end it 'link has valid text' do @@ -121,8 +121,8 @@ describe Banzai::Filter::SnippetReferenceFilter, lib: true do it 'links to a valid reference' do doc = reference_filter("See #{reference}") - expect(doc.css('a').first.attr('href')) - .to eq urls.namespace_project_snippet_url(project2.namespace, project2, snippet) + expect(doc.css('a').first.attr('href')). + to eq urls.namespace_project_snippet_url(project2.namespace, project2, snippet) end it 'link has valid text' do @@ -154,8 +154,8 @@ describe Banzai::Filter::SnippetReferenceFilter, lib: true do it 'links to a valid reference' do doc = reference_filter("See #{reference}") - expect(doc.css('a').first.attr('href')) - .to eq urls.namespace_project_snippet_url(project2.namespace, project2, snippet) + expect(doc.css('a').first.attr('href')). + to eq urls.namespace_project_snippet_url(project2.namespace, project2, snippet) end it 'link has valid text' do @@ -186,8 +186,8 @@ describe Banzai::Filter::SnippetReferenceFilter, lib: true do it 'links to a valid reference' do doc = reference_filter("See #{reference}") - expect(doc.css('a').first.attr('href')) - .to eq urls.namespace_project_snippet_url(project2.namespace, project2, snippet) + expect(doc.css('a').first.attr('href')). + to eq urls.namespace_project_snippet_url(project2.namespace, project2, snippet) end it 'links with adjacent text' do diff --git a/spec/lib/banzai/filter/upload_link_filter_spec.rb b/spec/lib/banzai/filter/upload_link_filter_spec.rb index 6327ca8bbfdd17da729ad5b52993e7b708d1e937..639cac6406aa9ede6440ddbc9077433d5910b8a7 100644 --- a/spec/lib/banzai/filter/upload_link_filter_spec.rb +++ b/spec/lib/banzai/filter/upload_link_filter_spec.rb @@ -51,22 +51,22 @@ describe Banzai::Filter::UploadLinkFilter, lib: true do context 'with a valid repository' do it 'rebuilds relative URL for a link' do doc = filter(link('/uploads/e90decf88d8f96fe9e1389afc2e4a91f/test.jpg')) - expect(doc.at_css('a')['href']) - .to eq "#{Gitlab.config.gitlab.url}/#{project.path_with_namespace}/uploads/e90decf88d8f96fe9e1389afc2e4a91f/test.jpg" + expect(doc.at_css('a')['href']). + to eq "#{Gitlab.config.gitlab.url}/#{project.path_with_namespace}/uploads/e90decf88d8f96fe9e1389afc2e4a91f/test.jpg" doc = filter(nested_link('/uploads/e90decf88d8f96fe9e1389afc2e4a91f/test.jpg')) - expect(doc.at_css('a')['href']) - .to eq "#{Gitlab.config.gitlab.url}/#{project.path_with_namespace}/uploads/e90decf88d8f96fe9e1389afc2e4a91f/test.jpg" + expect(doc.at_css('a')['href']). + to eq "#{Gitlab.config.gitlab.url}/#{project.path_with_namespace}/uploads/e90decf88d8f96fe9e1389afc2e4a91f/test.jpg" end it 'rebuilds relative URL for an image' do doc = filter(image('/uploads/e90decf88d8f96fe9e1389afc2e4a91f/test.jpg')) - expect(doc.at_css('img')['src']) - .to eq "#{Gitlab.config.gitlab.url}/#{project.path_with_namespace}/uploads/e90decf88d8f96fe9e1389afc2e4a91f/test.jpg" + expect(doc.at_css('img')['src']). + to eq "#{Gitlab.config.gitlab.url}/#{project.path_with_namespace}/uploads/e90decf88d8f96fe9e1389afc2e4a91f/test.jpg" doc = filter(nested_image('/uploads/e90decf88d8f96fe9e1389afc2e4a91f/test.jpg')) - expect(doc.at_css('img')['src']) - .to eq "#{Gitlab.config.gitlab.url}/#{project.path_with_namespace}/uploads/e90decf88d8f96fe9e1389afc2e4a91f/test.jpg" + expect(doc.at_css('img')['src']). + to eq "#{Gitlab.config.gitlab.url}/#{project.path_with_namespace}/uploads/e90decf88d8f96fe9e1389afc2e4a91f/test.jpg" end it 'does not modify absolute URL' do @@ -79,10 +79,10 @@ describe Banzai::Filter::UploadLinkFilter, lib: true do escaped = Addressable::URI.escape(path) # Stub these methods so the file doesn't actually need to be in the repo - allow_any_instance_of(described_class) - .to receive(:file_exists?).and_return(true) - allow_any_instance_of(described_class) - .to receive(:image?).with(path).and_return(true) + allow_any_instance_of(described_class). + to receive(:file_exists?).and_return(true) + allow_any_instance_of(described_class). + to receive(:image?).with(path).and_return(true) doc = filter(image(escaped)) expect(doc.at_css('img')['src']).to match "#{Gitlab.config.gitlab.url}/#{project.path_with_namespace}/uploads/%ED%95%9C%EA%B8%80.png" diff --git a/spec/lib/banzai/filter/user_reference_filter_spec.rb b/spec/lib/banzai/filter/user_reference_filter_spec.rb index d5d128c19075d94f3f39702bf5e309c33c936127..e9b7b566806f621a0f8018a2226b4001d2bb1a0e 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/banzai/note_renderer_spec.rb b/spec/lib/banzai/note_renderer_spec.rb index 32764bee5eb178cd94cfbd113afc2cc4bc09a7e6..49556074278ae67931989f84dc48d1a8248ae1e2 100644 --- a/spec/lib/banzai/note_renderer_spec.rb +++ b/spec/lib/banzai/note_renderer_spec.rb @@ -8,15 +8,15 @@ describe Banzai::NoteRenderer do wiki = double(:wiki) user = double(:user) - expect(Banzai::ObjectRenderer).to receive(:new) - .with(project, user, + expect(Banzai::ObjectRenderer).to receive(:new). + with(project, user, requested_path: 'foo', project_wiki: wiki, - ref: 'bar') - .and_call_original + ref: 'bar'). + and_call_original - expect_any_instance_of(Banzai::ObjectRenderer) - .to receive(:render).with([note], :note) + expect_any_instance_of(Banzai::ObjectRenderer). + to receive(:render).with([note], :note) described_class.render([note], project, user, 'foo', wiki, 'bar') end diff --git a/spec/lib/banzai/object_renderer_spec.rb b/spec/lib/banzai/object_renderer_spec.rb index 2ce72a4c92e99a998e40ff6554e71bf1af72c96a..6bcda87c99971cd00bdce9c0a86b4da8f0f7bb6d 100644 --- a/spec/lib/banzai/object_renderer_spec.rb +++ b/spec/lib/banzai/object_renderer_spec.rb @@ -17,12 +17,12 @@ describe Banzai::ObjectRenderer do renderer = described_class.new(project, user) object = fake_object(note: 'hello', note_html: nil) - expect(renderer).to receive(:render_objects).with([object], :note) - .and_call_original + expect(renderer).to receive(:render_objects).with([object], :note). + and_call_original - expect(renderer).to receive(:redact_documents) - .with(an_instance_of(Array)) - .and_call_original + expect(renderer).to receive(:redact_documents). + with(an_instance_of(Array)). + and_call_original expect(object).to receive(:redacted_note_html=).with('<p dir="auto">hello</p>') expect(object).to receive(:user_visible_reference_count=).with(0) @@ -37,8 +37,8 @@ describe Banzai::ObjectRenderer do renderer = described_class.new(project, user) - expect(renderer).to receive(:render_attributes).with([object], :note) - .and_call_original + expect(renderer).to receive(:render_attributes).with([object], :note). + and_call_original rendered = renderer.render_objects([object], :note) @@ -52,9 +52,9 @@ describe Banzai::ObjectRenderer do doc = Nokogiri::HTML.fragment('<p>hello</p>') renderer = described_class.new(project, user) - expect_any_instance_of(Banzai::Redactor).to receive(:redact) - .with([doc]) - .and_call_original + expect_any_instance_of(Banzai::Redactor).to receive(:redact). + with([doc]). + and_call_original redacted = renderer.redact_documents([doc]) diff --git a/spec/lib/banzai/redactor_spec.rb b/spec/lib/banzai/redactor_spec.rb index a14a1405ca60b2cefd762ed63d6c5cfa3507e5e1..6d2c141e18b2bde4978b731bc88aaa598042a408 100644 --- a/spec/lib/banzai/redactor_spec.rb +++ b/spec/lib/banzai/redactor_spec.rb @@ -12,11 +12,11 @@ describe Banzai::Redactor do end it 'redacts an array of documents' do - doc1 = Nokogiri::HTML - .fragment('<a class="gfm" data-reference-type="issue">foo</a>') + doc1 = Nokogiri::HTML. + fragment('<a class="gfm" data-reference-type="issue">foo</a>') - doc2 = Nokogiri::HTML - .fragment('<a class="gfm" data-reference-type="issue">bar</a>') + doc2 = Nokogiri::HTML. + fragment('<a class="gfm" data-reference-type="issue">bar</a>') redacted_data = redactor.redact([doc1, doc2]) @@ -68,9 +68,9 @@ describe Banzai::Redactor do doc = Nokogiri::HTML.fragment('<a href="foo">foo</a>') node = doc.children[0] - expect(redactor).to receive(:nodes_visible_to_user) - .with([node]) - .and_return(Set.new) + expect(redactor).to receive(:nodes_visible_to_user). + with([node]). + and_return(Set.new) redactor.redact_document_nodes([{ document: doc, nodes: [node] }]) @@ -83,10 +83,10 @@ describe Banzai::Redactor do doc = Nokogiri::HTML.fragment('<a data-reference-type="issue"></a>') node = doc.children[0] - expect_any_instance_of(Banzai::ReferenceParser::IssueParser) - .to receive(:nodes_visible_to_user) - .with(user, [node]) - .and_return([node]) + expect_any_instance_of(Banzai::ReferenceParser::IssueParser). + to receive(:nodes_visible_to_user). + with(user, [node]). + and_return([node]) expect(redactor.nodes_visible_to_user([node])).to eq(Set.new([node])) end diff --git a/spec/lib/banzai/reference_parser/base_parser_spec.rb b/spec/lib/banzai/reference_parser/base_parser_spec.rb index 9126afb0693e9a27c20a065386cdc332b293e547..aa127f0179dd4d0bedd317b01b763bf920967ea1 100644 --- a/spec/lib/banzai/reference_parser/base_parser_spec.rb +++ b/spec/lib/banzai/reference_parser/base_parser_spec.rb @@ -54,8 +54,8 @@ describe Banzai::ReferenceParser::BaseParser, lib: true do describe '#referenced_by' do context 'when references_relation is implemented' do it 'returns a collection of objects' do - links = Nokogiri::HTML.fragment("<a data-foo='#{user.id}'></a>") - .children + links = Nokogiri::HTML.fragment("<a data-foo='#{user.id}'></a>"). + children expect(subject).to receive(:references_relation).and_return(User) expect(subject.referenced_by(links)).to eq([user]) @@ -66,8 +66,8 @@ describe Banzai::ReferenceParser::BaseParser, lib: true do it 'raises NotImplementedError' do links = Nokogiri::HTML.fragment('<a data-foo="1"></a>').children - expect { subject.referenced_by(links) } - .to raise_error(NotImplementedError) + expect { subject.referenced_by(links) }. + to raise_error(NotImplementedError) end end end @@ -80,8 +80,8 @@ describe Banzai::ReferenceParser::BaseParser, lib: true do describe '#gather_attributes_per_project' do it 'returns a Hash containing attribute values per project' do - link = Nokogiri::HTML.fragment('<a data-project="1" data-foo="2"></a>') - .children[0] + link = Nokogiri::HTML.fragment('<a data-project="1" data-foo="2"></a>'). + children[0] hash = subject.gather_attributes_per_project([link], 'data-foo') @@ -95,9 +95,9 @@ describe Banzai::ReferenceParser::BaseParser, lib: true do it 'returns a Hash grouping objects per ID' do nodes = [double(:node)] - expect(subject).to receive(:unique_attribute_values) - .with(nodes, 'data-user') - .and_return([user.id]) + expect(subject).to receive(:unique_attribute_values). + with(nodes, 'data-user'). + and_return([user.id]) hash = subject.grouped_objects_for_nodes(nodes, User, 'data-user') @@ -113,15 +113,15 @@ describe Banzai::ReferenceParser::BaseParser, lib: true do it 'returns an Array of unique values' do link = double(:link) - expect(link).to receive(:has_attribute?) - .with('data-foo') - .twice - .and_return(true) + expect(link).to receive(:has_attribute?). + with('data-foo'). + twice. + and_return(true) - expect(link).to receive(:attr) - .with('data-foo') - .twice - .and_return('1') + expect(link).to receive(:attr). + with('data-foo'). + twice. + and_return('1') nodes = [link, link] @@ -138,9 +138,9 @@ describe Banzai::ReferenceParser::BaseParser, lib: true do instance = dummy.new(project, user) document = Nokogiri::HTML.fragment('<a class="gfm"></a><a class="gfm" data-reference-type="test"></a>') - expect(instance).to receive(:gather_references) - .with([document.children[1]]) - .and_return([user]) + expect(instance).to receive(:gather_references). + with([document.children[1]]). + and_return([user]) expect(instance.process([document])).to eq([user]) end @@ -150,9 +150,9 @@ describe Banzai::ReferenceParser::BaseParser, lib: true do let(:link) { double(:link) } it 'does not process links a user can not reference' do - expect(subject).to receive(:nodes_user_can_reference) - .with(user, [link]) - .and_return([]) + expect(subject).to receive(:nodes_user_can_reference). + with(user, [link]). + and_return([]) expect(subject).to receive(:referenced_by).with([]) @@ -160,13 +160,13 @@ describe Banzai::ReferenceParser::BaseParser, lib: true do end it 'does not process links a user can not see' do - expect(subject).to receive(:nodes_user_can_reference) - .with(user, [link]) - .and_return([link]) + expect(subject).to receive(:nodes_user_can_reference). + with(user, [link]). + and_return([link]) - expect(subject).to receive(:nodes_visible_to_user) - .with(user, [link]) - .and_return([]) + expect(subject).to receive(:nodes_visible_to_user). + with(user, [link]). + and_return([]) expect(subject).to receive(:referenced_by).with([]) @@ -174,13 +174,13 @@ describe Banzai::ReferenceParser::BaseParser, lib: true do end it 'returns the references if a user can reference and see a link' do - expect(subject).to receive(:nodes_user_can_reference) - .with(user, [link]) - .and_return([link]) + expect(subject).to receive(:nodes_user_can_reference). + with(user, [link]). + and_return([link]) - expect(subject).to receive(:nodes_visible_to_user) - .with(user, [link]) - .and_return([link]) + expect(subject).to receive(:nodes_visible_to_user). + with(user, [link]). + and_return([link]) expect(subject).to receive(:referenced_by).with([link]) @@ -192,8 +192,8 @@ describe Banzai::ReferenceParser::BaseParser, lib: true do it 'delegates the permissions check to the Ability class' do user = double(:user) - expect(Ability).to receive(:allowed?) - .with(user, :read_project, project) + expect(Ability).to receive(:allowed?). + with(user, :read_project, project) subject.can?(user, :read_project, project) end @@ -201,8 +201,8 @@ describe Banzai::ReferenceParser::BaseParser, lib: true do describe '#find_projects_for_hash_keys' do it 'returns a list of Projects' do - expect(subject.find_projects_for_hash_keys(project.id => project)) - .to eq([project]) + expect(subject.find_projects_for_hash_keys(project.id => project)). + to eq([project]) end end @@ -214,8 +214,8 @@ describe Banzai::ReferenceParser::BaseParser, lib: true do expect(collection).to receive(:where).twice.and_call_original 2.times do - expect(subject.collection_objects_for_ids(collection, [user.id])) - .to eq([user]) + expect(subject.collection_objects_for_ids(collection, [user.id])). + to eq([user]) end end end @@ -229,8 +229,8 @@ describe Banzai::ReferenceParser::BaseParser, lib: true do end it 'queries the collection on the first call' do - expect(subject.collection_objects_for_ids(User, [user.id])) - .to eq([user]) + expect(subject.collection_objects_for_ids(User, [user.id])). + to eq([user]) end it 'does not query previously queried objects' do @@ -239,34 +239,34 @@ describe Banzai::ReferenceParser::BaseParser, lib: true do expect(collection).to receive(:where).once.and_call_original 2.times do - expect(subject.collection_objects_for_ids(collection, [user.id])) - .to eq([user]) + expect(subject.collection_objects_for_ids(collection, [user.id])). + to eq([user]) end end it 'casts String based IDs to Fixnums before querying objects' do 2.times do - expect(subject.collection_objects_for_ids(User, [user.id.to_s])) - .to eq([user]) + expect(subject.collection_objects_for_ids(User, [user.id.to_s])). + to eq([user]) end end it 'queries any additional objects after the first call' do other_user = create(:user) - expect(subject.collection_objects_for_ids(User, [user.id])) - .to eq([user]) + expect(subject.collection_objects_for_ids(User, [user.id])). + to eq([user]) - expect(subject.collection_objects_for_ids(User, [user.id, other_user.id])) - .to eq([user, other_user]) + expect(subject.collection_objects_for_ids(User, [user.id, other_user.id])). + to eq([user, other_user]) end it 'caches objects on a per collection class basis' do - expect(subject.collection_objects_for_ids(User, [user.id])) - .to eq([user]) + expect(subject.collection_objects_for_ids(User, [user.id])). + to eq([user]) - expect(subject.collection_objects_for_ids(Project, [project.id])) - .to eq([project]) + expect(subject.collection_objects_for_ids(Project, [project.id])). + to eq([project]) end end end diff --git a/spec/lib/banzai/reference_parser/commit_parser_spec.rb b/spec/lib/banzai/reference_parser/commit_parser_spec.rb index 9c2b2c0a1a91586ff9e73b4e56772d01b8153c85..412ffa77c36fa2b1a17de8c0484cf4e54f1b2cdb 100644 --- a/spec/lib/banzai/reference_parser/commit_parser_spec.rb +++ b/spec/lib/banzai/reference_parser/commit_parser_spec.rb @@ -30,30 +30,30 @@ describe Banzai::ReferenceParser::CommitParser, lib: true do it 'returns an Array of commits' do commit = double(:commit) - allow_any_instance_of(Project).to receive(:valid_repo?) - .and_return(true) + allow_any_instance_of(Project).to receive(:valid_repo?). + and_return(true) - expect(subject).to receive(:find_commits) - .with(project, ['123']) - .and_return([commit]) + expect(subject).to receive(:find_commits). + with(project, ['123']). + and_return([commit]) expect(subject.referenced_by([link])).to eq([commit]) end it 'returns an empty Array when the commit could not be found' do - allow_any_instance_of(Project).to receive(:valid_repo?) - .and_return(true) + allow_any_instance_of(Project).to receive(:valid_repo?). + and_return(true) - expect(subject).to receive(:find_commits) - .with(project, ['123']) - .and_return([]) + expect(subject).to receive(:find_commits). + with(project, ['123']). + and_return([]) expect(subject.referenced_by([link])).to eq([]) end it 'skips projects without valid repositories' do - allow_any_instance_of(Project).to receive(:valid_repo?) - .and_return(false) + allow_any_instance_of(Project).to receive(:valid_repo?). + and_return(false) expect(subject.referenced_by([link])).to eq([]) end @@ -61,8 +61,8 @@ describe Banzai::ReferenceParser::CommitParser, lib: true do context 'when the link does not have a data-commit attribute' do it 'returns an empty Array' do - allow_any_instance_of(Project).to receive(:valid_repo?) - .and_return(true) + allow_any_instance_of(Project).to receive(:valid_repo?). + and_return(true) expect(subject.referenced_by([link])).to eq([]) end @@ -71,8 +71,8 @@ describe Banzai::ReferenceParser::CommitParser, lib: true do context 'when the link does not have a data-project attribute' do it 'returns an empty Array' do - allow_any_instance_of(Project).to receive(:valid_repo?) - .and_return(true) + allow_any_instance_of(Project).to receive(:valid_repo?). + and_return(true) expect(subject.referenced_by([link])).to eq([]) end diff --git a/spec/lib/banzai/reference_parser/commit_range_parser_spec.rb b/spec/lib/banzai/reference_parser/commit_range_parser_spec.rb index 5aec04e8d5b34330553842b65feaa95392cc3d99..96e55b0997ae12601f1e98d0e3874d57d0754f0b 100644 --- a/spec/lib/banzai/reference_parser/commit_range_parser_spec.rb +++ b/spec/lib/banzai/reference_parser/commit_range_parser_spec.rb @@ -30,17 +30,17 @@ describe Banzai::ReferenceParser::CommitRangeParser, lib: true do it 'returns an Array of commit ranges' do range = double(:range) - expect(subject).to receive(:find_object) - .with(project, '123..456') - .and_return(range) + expect(subject).to receive(:find_object). + with(project, '123..456'). + and_return(range) expect(subject.referenced_by([link])).to eq([range]) end it 'returns an empty Array when the commit range could not be found' do - expect(subject).to receive(:find_object) - .with(project, '123..456') - .and_return(nil) + expect(subject).to receive(:find_object). + with(project, '123..456'). + and_return(nil) expect(subject.referenced_by([link])).to eq([]) end @@ -86,17 +86,17 @@ describe Banzai::ReferenceParser::CommitRangeParser, lib: true do it 'returns an Array of range objects' do range = double(:commit) - expect(subject).to receive(:find_object) - .with(project, '123..456') - .and_return(range) + expect(subject).to receive(:find_object). + with(project, '123..456'). + and_return(range) expect(subject.find_ranges(project, ['123..456'])).to eq([range]) end it 'skips ranges that could not be found' do - expect(subject).to receive(:find_object) - .with(project, '123..456') - .and_return(nil) + expect(subject).to receive(:find_object). + with(project, '123..456'). + and_return(nil) expect(subject.find_ranges(project, ['123..456'])).to eq([]) end diff --git a/spec/lib/banzai/reference_parser/issue_parser_spec.rb b/spec/lib/banzai/reference_parser/issue_parser_spec.rb index bc81d2808b50f49594bf5e6dab26bb8e1ad38a69..6873b7b85f9efa7a09a117e23e0d7923147895e7 100644 --- a/spec/lib/banzai/reference_parser/issue_parser_spec.rb +++ b/spec/lib/banzai/reference_parser/issue_parser_spec.rb @@ -18,17 +18,17 @@ describe Banzai::ReferenceParser::IssueParser, lib: true do it_behaves_like "referenced feature visibility", "issues" it 'returns the nodes when the user can read the issue' do - expect(Ability).to receive(:issues_readable_by_user) - .with([issue], user) - .and_return([issue]) + expect(Ability).to receive(:issues_readable_by_user). + with([issue], user). + and_return([issue]) expect(subject.nodes_visible_to_user(user, [link])).to eq([link]) end it 'returns an empty Array when the user can not read the issue' do - expect(Ability).to receive(:issues_readable_by_user) - .with([issue], user) - .and_return([]) + expect(Ability).to receive(:issues_readable_by_user). + with([issue], user). + and_return([]) expect(subject.nodes_visible_to_user(user, [link])).to eq([]) end diff --git a/spec/lib/banzai/reference_parser/user_parser_spec.rb b/spec/lib/banzai/reference_parser/user_parser_spec.rb index f2f11cd508870b2344076fee59c969b488323130..31ca9d27b0bded68dfa987cd1b351d793801f5ad 100644 --- a/spec/lib/banzai/reference_parser/user_parser_spec.rb +++ b/spec/lib/banzai/reference_parser/user_parser_spec.rb @@ -82,17 +82,17 @@ describe Banzai::ReferenceParser::UserParser, lib: true do end it 'returns the nodes if the user can read the group' do - expect(Ability).to receive(:allowed?) - .with(user, :read_group, group) - .and_return(true) + expect(Ability).to receive(:allowed?). + with(user, :read_group, group). + and_return(true) expect(subject.nodes_visible_to_user(user, [link])).to eq([link]) end it 'returns an empty Array if the user can not read the group' do - expect(Ability).to receive(:allowed?) - .with(user, :read_group, group) - .and_return(false) + expect(Ability).to receive(:allowed?). + with(user, :read_group, group). + and_return(false) expect(subject.nodes_visible_to_user(user, [link])).to eq([]) end @@ -115,9 +115,9 @@ describe Banzai::ReferenceParser::UserParser, lib: true do link['data-project'] = other_project.id.to_s - expect(Ability).to receive(:allowed?) - .with(user, :read_project, other_project) - .and_return(true) + expect(Ability).to receive(:allowed?). + with(user, :read_project, other_project). + and_return(true) expect(subject.nodes_visible_to_user(user, [link])).to eq([link]) end @@ -127,9 +127,9 @@ describe Banzai::ReferenceParser::UserParser, lib: true do link['data-project'] = other_project.id.to_s - expect(Ability).to receive(:allowed?) - .with(user, :read_project, other_project) - .and_return(false) + expect(Ability).to receive(:allowed?). + with(user, :read_project, other_project). + and_return(false) expect(subject.nodes_visible_to_user(user, [link])).to eq([]) end diff --git a/spec/lib/ci/gitlab_ci_yaml_processor_spec.rb b/spec/lib/ci/gitlab_ci_yaml_processor_spec.rb index 7145f0da1d31ddd590baf2d0f7f0ff1f32bf1014..ae3253777c30c90e978d5bacfd83296a9dfd1864 100644 --- a/spec/lib/ci/gitlab_ci_yaml_processor_spec.rb +++ b/spec/lib/ci/gitlab_ci_yaml_processor_spec.rb @@ -25,8 +25,8 @@ module Ci end it 'includes coverage regexp in build attributes' do - expect(subject) - .to include(coverage_regex: 'Code coverage: \d+\.\d+') + expect(subject). + to include(coverage_regex: 'Code coverage: \d+\.\d+') end end end @@ -584,8 +584,8 @@ module Ci end it 'raises error' do - expect { subject } - .to raise_error(GitlabCiYamlProcessor::ValidationError, + expect { subject }. + to raise_error(GitlabCiYamlProcessor::ValidationError, /jobs:rspec:variables config should be a hash of key value pairs/) end end @@ -1365,8 +1365,8 @@ EOT it "returns an error about invalid configutaion" do content = YAML.dump("invalid: yaml: test") - expect(GitlabCiYamlProcessor.validation_message(content)) - .to eq "Invalid configuration format" + expect(GitlabCiYamlProcessor.validation_message(content)). + to eq "Invalid configuration format" end end @@ -1374,15 +1374,15 @@ EOT it "returns an error about invalid tags" do content = YAML.dump({ rspec: { script: "test", tags: "mysql" } }) - expect(GitlabCiYamlProcessor.validation_message(content)) - .to eq "jobs:rspec tags should be an array of strings" + expect(GitlabCiYamlProcessor.validation_message(content)). + to eq "jobs:rspec tags should be an array of strings" end end context "when YAML content is empty" do it "returns an error about missing content" do - expect(GitlabCiYamlProcessor.validation_message('')) - .to eq "Please provide content of .gitlab-ci.yml" + expect(GitlabCiYamlProcessor.validation_message('')). + to eq "Please provide content of .gitlab-ci.yml" end end diff --git a/spec/lib/container_registry/blob_spec.rb b/spec/lib/container_registry/blob_spec.rb index 7fd2321d18a7870bea1edcdb50ada2caffa9cb5f..bbacdc67ebd30d8dd7eb2c39da9cebf4762147b0 100644 --- a/spec/lib/container_registry/blob_spec.rb +++ b/spec/lib/container_registry/blob_spec.rb @@ -51,8 +51,8 @@ describe ContainerRegistry::Blob do context '#delete' do before do - stub_request(:delete, 'http://example.com/v2/group/test/blobs/sha256:0123456789012345') - .to_return(status: 200) + stub_request(:delete, 'http://example.com/v2/group/test/blobs/sha256:0123456789012345'). + to_return(status: 200) end subject { blob.delete } @@ -67,8 +67,8 @@ describe ContainerRegistry::Blob do context 'when locally stored' do before do - stub_request(:get, 'http://example.com/v2/group/test/blobs/sha256:0123456789012345') - .to_return( + stub_request(:get, 'http://example.com/v2/group/test/blobs/sha256:0123456789012345'). + to_return( status: 200, headers: { 'Content-Type' => 'application/json' }, body: data) @@ -79,9 +79,9 @@ describe ContainerRegistry::Blob do context 'when externally stored' do before do - stub_request(:get, 'http://example.com/v2/group/test/blobs/sha256:0123456789012345') - .with(headers: { 'Authorization' => "bearer #{token}" }) - .to_return( + stub_request(:get, 'http://example.com/v2/group/test/blobs/sha256:0123456789012345'). + with(headers: { 'Authorization' => "bearer #{token}" }). + to_return( status: 307, headers: { 'Location' => location }) end @@ -90,9 +90,9 @@ describe ContainerRegistry::Blob do let(:location) { 'http://external.com/blob/file' } before do - stub_request(:get, location) - .with(headers: { 'Authorization' => nil }) - .to_return( + stub_request(:get, location). + with(headers: { 'Authorization' => nil }). + to_return( status: 200, headers: { 'Content-Type' => 'application/json' }, body: data) diff --git a/spec/lib/container_registry/repository_spec.rb b/spec/lib/container_registry/repository_spec.rb index eeb924ebe4869b463756564d37d514c6973ddd79..c364e7591086619051256b475d24b64a15aaa4f1 100644 --- a/spec/lib/container_registry/repository_spec.rb +++ b/spec/lib/container_registry/repository_spec.rb @@ -16,9 +16,9 @@ describe ContainerRegistry::Repository do context 'manifest processing' do before do - stub_request(:get, 'http://example.com/v2/group/test/tags/list') - .with(headers: { 'Accept' => 'application/vnd.docker.distribution.manifest.v2+json' }) - .to_return( + stub_request(:get, 'http://example.com/v2/group/test/tags/list'). + with(headers: { 'Accept' => 'application/vnd.docker.distribution.manifest.v2+json' }). + to_return( status: 200, body: JSON.dump(tags: ['test']), headers: { 'Content-Type' => 'application/json' }) diff --git a/spec/lib/container_registry/tag_spec.rb b/spec/lib/container_registry/tag_spec.rb index 2d7e355a7379fd9156ed3c9ac47a69b4cc395fe9..c5e31ae82b6a2cf1d709bafef3bc39bb8385b6b0 100644 --- a/spec/lib/container_registry/tag_spec.rb +++ b/spec/lib/container_registry/tag_spec.rb @@ -19,9 +19,9 @@ describe ContainerRegistry::Tag do context 'manifest processing' do context 'schema v1' do before do - stub_request(:get, 'http://example.com/v2/group/test/manifests/tag') - .with(headers: headers) - .to_return( + stub_request(:get, 'http://example.com/v2/group/test/manifests/tag'). + with(headers: headers). + to_return( status: 200, body: File.read(Rails.root + 'spec/fixtures/container_registry/tag_manifest_1.json'), headers: { 'Content-Type' => 'application/vnd.docker.distribution.manifest.v1+prettyjws' }) @@ -56,9 +56,9 @@ describe ContainerRegistry::Tag do context 'schema v2' do before do - stub_request(:get, 'http://example.com/v2/group/test/manifests/tag') - .with(headers: headers) - .to_return( + stub_request(:get, 'http://example.com/v2/group/test/manifests/tag'). + with(headers: headers). + to_return( status: 200, body: File.read(Rails.root + 'spec/fixtures/container_registry/tag_manifest.json'), headers: { 'Content-Type' => 'application/vnd.docker.distribution.manifest.v2+json' }) @@ -93,9 +93,9 @@ describe ContainerRegistry::Tag do context 'when locally stored' do before do - stub_request(:get, 'http://example.com/v2/group/test/blobs/sha256:d7a513a663c1a6dcdba9ed832ca53c02ac2af0c333322cd6ca92936d1d9917ac') - .with(headers: { 'Accept' => 'application/octet-stream' }) - .to_return( + stub_request(:get, 'http://example.com/v2/group/test/blobs/sha256:d7a513a663c1a6dcdba9ed832ca53c02ac2af0c333322cd6ca92936d1d9917ac'). + with(headers: { 'Accept' => 'application/octet-stream' }). + to_return( status: 200, body: File.read(Rails.root + 'spec/fixtures/container_registry/config_blob.json')) end @@ -105,14 +105,14 @@ describe ContainerRegistry::Tag do context 'when externally stored' do before do - stub_request(:get, 'http://example.com/v2/group/test/blobs/sha256:d7a513a663c1a6dcdba9ed832ca53c02ac2af0c333322cd6ca92936d1d9917ac') - .with(headers: { 'Accept' => 'application/octet-stream' }) - .to_return( + stub_request(:get, 'http://example.com/v2/group/test/blobs/sha256:d7a513a663c1a6dcdba9ed832ca53c02ac2af0c333322cd6ca92936d1d9917ac'). + with(headers: { 'Accept' => 'application/octet-stream' }). + to_return( status: 307, headers: { 'Location' => 'http://external.com/blob/file' }) - stub_request(:get, 'http://external.com/blob/file') - .to_return( + stub_request(:get, 'http://external.com/blob/file'). + to_return( status: 200, body: File.read(Rails.root + 'spec/fixtures/container_registry/config_blob.json')) end @@ -125,9 +125,9 @@ describe ContainerRegistry::Tag do context 'manifest digest' do before do - stub_request(:head, 'http://example.com/v2/group/test/manifests/tag') - .with(headers: headers) - .to_return(status: 200, headers: { 'Docker-Content-Digest' => 'sha256:digest' }) + stub_request(:head, 'http://example.com/v2/group/test/manifests/tag'). + with(headers: headers). + to_return(status: 200, headers: { 'Docker-Content-Digest' => 'sha256:digest' }) end context '#digest' do @@ -138,9 +138,9 @@ describe ContainerRegistry::Tag do context '#delete' do before do - stub_request(:delete, 'http://example.com/v2/group/test/manifests/sha256:digest') - .with(headers: headers) - .to_return(status: 200) + stub_request(:delete, 'http://example.com/v2/group/test/manifests/sha256:digest'). + with(headers: headers). + to_return(status: 200) end subject { tag.delete } diff --git a/spec/lib/extracts_path_spec.rb b/spec/lib/extracts_path_spec.rb index 27f4a96832144e004518e75f19bf3c913340abb6..33ab005667a01755e2d07495127a666ca935839d 100644 --- a/spec/lib/extracts_path_spec.rb +++ b/spec/lib/extracts_path_spec.rb @@ -14,8 +14,8 @@ describe ExtractsPath, lib: true do repo = double(ref_names: ['master', 'foo/bar/baz', 'v1.0.0', 'v2.0.0', 'release/app', 'release/app/v1.0.0']) allow(project).to receive(:repository).and_return(repo) - allow(project).to receive(:path_with_namespace) - .and_return('gitlab/gitlab-ci') + allow(project).to receive(:path_with_namespace). + and_return('gitlab/gitlab-ci') allow(request).to receive(:format=) end diff --git a/spec/lib/gitlab/asciidoc_spec.rb b/spec/lib/gitlab/asciidoc_spec.rb index bca57105d1d22227efa4444b1a883b1a832a7e8b..e193a3b79a66065fd3c55422fd9e053b8e10d165 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 b234de4c77267fa3ede434a071366b65332c176e..57c416fb35a222ef3c2c2ee2a257c01431bfd128 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 f84782ab440b6f002a75741b4a3eb6f9c024c822..e9c69183d000518b96d5e101a30a28c68e87c7b1 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 3c5414701a7e7dccebe7e2495ff651f4d9de84f5..8a4bf4dc89b8fa1e48c93737c8d23ce8f0a4d314 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 aceb6bf871cdfac869d5f91fa0622f65af11fdf5..1da145e7b6816181755f6a28861489df9563ac5b 100644 --- a/spec/lib/gitlab/bitbucket_import/importer_spec.rb +++ b/spec/lib/gitlab/bitbucket_import/importer_spec.rb @@ -86,11 +86,11 @@ describe Gitlab::BitbucketImport::Importer, lib: true do headers: { "Content-Type" => "application/json" }, body: issues_statuses_sample_data.to_json) - stub_request(:get, "https://api.bitbucket.org/2.0/repositories/namespace/repo?pagelen=50&sort=created_on") - .with(headers: { 'Accept' => '*/*', 'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Authorization' => 'Bearer', 'User-Agent' => 'Faraday v0.9.2' }) - .to_return(status: 200, - body: "", - headers: {}) + 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: {}) sample_issues_statuses.each_with_index do |issue, index| stub_request( diff --git a/spec/lib/gitlab/ci/build/artifacts/metadata_spec.rb b/spec/lib/gitlab/ci/build/artifacts/metadata_spec.rb index 6a52ae01b2fc258cc96ea1687fdeb3d943f64bea..eea01f91879ec97d2ded8e56b17119ff4b74e6c5 100644 --- a/spec/lib/gitlab/ci/build/artifacts/metadata_spec.rb +++ b/spec/lib/gitlab/ci/build/artifacts/metadata_spec.rb @@ -33,8 +33,8 @@ describe Gitlab::Ci::Build::Artifacts::Metadata do subject { metadata('other_artifacts_0.1.2/').find_entries! } it 'matches correct paths' do - expect(subject.keys) - .to contain_exactly 'other_artifacts_0.1.2/', + expect(subject.keys). + to contain_exactly 'other_artifacts_0.1.2/', 'other_artifacts_0.1.2/doc_sample.txt', 'other_artifacts_0.1.2/another-subdirectory/' end @@ -44,8 +44,8 @@ describe Gitlab::Ci::Build::Artifacts::Metadata do subject { metadata('other_artifacts_0.1.2/another-subdirectory/').find_entries! } it 'matches correct paths' do - expect(subject.keys) - .to contain_exactly 'other_artifacts_0.1.2/another-subdirectory/', + expect(subject.keys). + to contain_exactly 'other_artifacts_0.1.2/another-subdirectory/', 'other_artifacts_0.1.2/another-subdirectory/empty_directory/', 'other_artifacts_0.1.2/another-subdirectory/banana_sample.gif' end @@ -55,8 +55,8 @@ describe Gitlab::Ci::Build::Artifacts::Metadata do subject { metadata('other_artifacts_0.1.2/', recursive: true).find_entries! } it 'matches correct paths' do - expect(subject.keys) - .to contain_exactly 'other_artifacts_0.1.2/', + expect(subject.keys). + to contain_exactly 'other_artifacts_0.1.2/', 'other_artifacts_0.1.2/doc_sample.txt', 'other_artifacts_0.1.2/another-subdirectory/', 'other_artifacts_0.1.2/another-subdirectory/empty_directory/', diff --git a/spec/lib/gitlab/ci/config/entry/artifacts_spec.rb b/spec/lib/gitlab/ci/config/entry/artifacts_spec.rb index 5c31423fdee6c2431a325e87a3b1f17225fa4ba5..987a0b1f67fc58955b4f95c6bb6c7a1c318ab01a 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 fde03c51e2c6da895a2d2c5175c1e2e070a5e21a..efb8c5adab169d09a5e42aa184b27b107417be00 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 5f067cad93c2975e5a649b8b85e66b4ee1427c10..8987c0549c5bb68b74107e7961f7e3463c493845 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 70a327c5183c3b16780899bb98d1eddeb528af61..e91f049ee7262337f078e48dd67c64d6fa8760a1 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 afa4a089418ebaf3aa12aa1bcf1c329d8f94e008..8fe82bc2ebd0faabfa6208bfb51b652610bc733e 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 ae7e628b5b5eb1af3dd00402d5dc0a05972cfa0c..490ba9b7df11b47251f3a6a87d9ae7487e92e476 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 2adbed2154fcd79c390d30bb5fd7f8debf753381..fab2825fbb023e5836abe8263f844bcde91bbc2e 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 3395b3c645b3ad308c6cb466c3bc0e3a14812d5a..5c5ce2d6f39fcb6d3bc168e225cdbaf551159582 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 ebd80ac5e1dece740c0a99f1f1ef0d2b1aca25a8..67a6b3cc98dc1629f96c9d5cde8a73475daa2ae0 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 3c99cb0a1eedef9dce795a3a5637134bff743d23..062817e07fd254bb09afe9fea9abb6c4ee58919e 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 d20f4ec207d68bc8b49004455bc73d235586901d..82feff0af1cc82c930d9c621e5fdd4971ca8f781 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 aaebf7839624aa3d798c46e852630812935e5e66..c332b70dc710cf408b85c51bbbd423ccef6203e2 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 0dd36fe1f44cbb28c229aa61f302afb3ad9bc55c..cd7b03ffb1106b1b7f97e2fd7622c9f7ef9762f5 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 1d9c5ddee9b952b471d156c3ee591a4269050b1d..b0ac90f1d9417e32d55f33a4d4b953d154782d0f 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 069eaa264227915ab436a90e6362f630876d640b..49cca49509c4a111bda1e997f43660ef66d09bbe 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 66fad3b6b16e19384f5a22e4370d15d99ab5efef..c31a7c0ec3e26ada19648cc4fe9a61aba827434f 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 70c8a0a355ac9fcae721d7276e38099f5b6a126e..cefef7a805a5bab601de5b972870b1e621dce464 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 182c8d867c77945cc6bb5092655bd8c90281433c..bdcd6c98a85e7c69c68dbb30737520dc39255c10 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 e4ee44f127426101849264fdf144472335ac05a4..13b00a98b6a61275d655477d77b8961278650a2e 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 d1856801827e838dcd08a47fbe36cc1d93caa94a..e31e85538b94e4664d42e60628e1ba4038cd555d 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 ad7e6f07d3cd5c73f39e1c36315eb849bae2cd5d..c6e21cd67b0230a82bc23ee416c8667a378489f6 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 f15f02f403edfda32f44bfd783b06692e895add4..c117f35c906ab07206796c9681c16e4ef6e27861 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 40b96b1807b096a553dd5028ba30da93d11d9e35..cd893a09748c98d8c770752ea4f0d37ea34a5abb 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 0c40fca0c1a649186c5ecb7d2c869144270ae369..aa026a664602a59cbb51a296b61125cd9011e9a5 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 c2d74ca5cde0cbad5026e10fd590829d02b33c9d..459044eb9684add1b2513fd06c30c88b0280659f 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 5a97d98b55f674db8cd23da51ddffcb4846fe4fd..6a564eeb8b75eba05fecdf35523aef27581590f0 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 bbf9c7c83a3877aaf0180d4c504c192da3c39a68..45fd49b91ea454868b2369796268d4aafdec019c 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 d665674bf70095e8ff8ae2726c3b33a198dee2ab..35dad60febf54a7291deed4d976de3c18f62d729 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 b10a447c27a8dade794b3dbfcd06368937e57834..7cee4435931acd9604da82dd4b5e50f1f76716e0 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 8814a7614a0715ff95da507f92cc38fee506f0fb..3b25893d8c78aa630cd22ee2b39d0546620adf0b 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 bbb40e2c1abbad8af5f4b35bd8886bc48073f985..c8503392b34dbf8134c2f30e191cec6cd2368002 100644 --- a/spec/lib/gitlab/ci/status/stage/factory_spec.rb +++ b/spec/lib/gitlab/ci/status/stage/factory_spec.rb @@ -55,8 +55,8 @@ describe Gitlab::Ci::Status::Stage::Factory do end it 'fabricates extended "success with warnings" status' do - expect(status) - .to be_a Gitlab::Ci::Status::SuccessWarning + expect(status). + to be_a Gitlab::Ci::Status::SuccessWarning end it 'extends core status with common stage method' do diff --git a/spec/lib/gitlab/closing_issue_extractor_spec.rb b/spec/lib/gitlab/closing_issue_extractor_spec.rb index ca68010cb895d0447dce4834c8a530460a043bdd..97af1c2523dc3caf0075eb90d413875ef0b60152 100644 --- a/spec/lib/gitlab/closing_issue_extractor_spec.rb +++ b/spec/lib/gitlab/closing_issue_extractor_spec.rb @@ -306,58 +306,58 @@ describe Gitlab::ClosingIssueExtractor, lib: true do it 'fetches issues in single line message' do message = "Closes #{reference} and fix #{reference2}" - expect(subject.closed_by_message(message)) - .to match_array([issue, other_issue]) + expect(subject.closed_by_message(message)). + to match_array([issue, other_issue]) end it 'fetches comma-separated issues references in single line message' do message = "Closes #{reference}, closes #{reference2}" - expect(subject.closed_by_message(message)) - .to match_array([issue, other_issue]) + expect(subject.closed_by_message(message)). + to match_array([issue, other_issue]) end it 'fetches comma-separated issues numbers in single line message' do message = "Closes #{reference}, #{reference2} and #{reference3}" - expect(subject.closed_by_message(message)) - .to match_array([issue, other_issue, third_issue]) + expect(subject.closed_by_message(message)). + to match_array([issue, other_issue, third_issue]) end it 'fetches issues in multi-line message' do message = "Awesome commit (closes #{reference})\nAlso fixes #{reference2}" - expect(subject.closed_by_message(message)) - .to match_array([issue, other_issue]) + expect(subject.closed_by_message(message)). + to match_array([issue, other_issue]) end it 'fetches issues in hybrid message' do message = "Awesome commit (closes #{reference})\n"\ "Also fixing issues #{reference2}, #{reference3} and #4" - expect(subject.closed_by_message(message)) - .to match_array([issue, other_issue, third_issue]) + expect(subject.closed_by_message(message)). + to match_array([issue, other_issue, third_issue]) end it "fetches cross-project references" do message = "Closes #{reference} and #{cross_reference}" - expect(subject.closed_by_message(message)) - .to match_array([issue, issue2]) + expect(subject.closed_by_message(message)). + to match_array([issue, issue2]) end it "fetches cross-project URL references" do message = "Closes #{urls.namespace_project_issue_url(issue2.project.namespace, issue2.project, issue2)} and #{reference}" - expect(subject.closed_by_message(message)) - .to match_array([issue, issue2]) + expect(subject.closed_by_message(message)). + to match_array([issue, issue2]) end it "ignores invalid cross-project URL references" do message = "Closes https://google.com#{urls.namespace_project_issue_path(issue2.project.namespace, issue2.project, issue2)} and #{reference}" - expect(subject.closed_by_message(message)) - .to match_array([issue]) + expect(subject.closed_by_message(message)). + to match_array([issue]) end end end diff --git a/spec/lib/gitlab/conflict/file_spec.rb b/spec/lib/gitlab/conflict/file_spec.rb index b3e107dca7269a5084f1e812a3917d841125b287..7e5531d92dc5141d2b590733ed51fb1d4935b509 100644 --- a/spec/lib/gitlab/conflict/file_spec.rb +++ b/spec/lib/gitlab/conflict/file_spec.rb @@ -43,8 +43,8 @@ describe Gitlab::Conflict::File, lib: true do end it 'returns a file containing only the chosen parts of the resolved sections' do - expect(resolved_lines.chunk { |line| line.type || 'both' }.map(&:first)) - .to eq(%w(both new both old both new both)) + expect(resolved_lines.chunk { |line| line.type || 'both' }.map(&:first)). + to eq(%w(both new both old both new both)) end end @@ -52,14 +52,14 @@ describe Gitlab::Conflict::File, lib: true do empty_hash = section_keys.map { |key| [key, nil] }.to_h invalid_hash = section_keys.map { |key| [key, 'invalid'] }.to_h - expect { conflict_file.resolve_lines({}) } - .to raise_error(Gitlab::Conflict::File::MissingResolution) + expect { conflict_file.resolve_lines({}) }. + to raise_error(Gitlab::Conflict::File::MissingResolution) - expect { conflict_file.resolve_lines(empty_hash) } - .to raise_error(Gitlab::Conflict::File::MissingResolution) + expect { conflict_file.resolve_lines(empty_hash) }. + to raise_error(Gitlab::Conflict::File::MissingResolution) - expect { conflict_file.resolve_lines(invalid_hash) } - .to raise_error(Gitlab::Conflict::File::MissingResolution) + expect { conflict_file.resolve_lines(invalid_hash) }. + to raise_error(Gitlab::Conflict::File::MissingResolution) end end @@ -250,8 +250,8 @@ FILE describe '#as_json' do it 'includes the blob path for the file' do - expect(conflict_file.as_json[:blob_path]) - .to eq("/#{project.namespace.to_param}/#{merge_request.project.to_param}/blob/#{our_commit.oid}/files/ruby/regex.rb") + expect(conflict_file.as_json[:blob_path]). + to eq("/#{project.namespace.to_param}/#{merge_request.project.to_param}/blob/#{our_commit.oid}/files/ruby/regex.rb") end it 'includes the blob icon for the file' do @@ -264,8 +264,8 @@ FILE end it 'includes the detected language of the conflict file' do - expect(conflict_file.as_json(full_content: true)[:blob_ace_mode]) - .to eq('ruby') + expect(conflict_file.as_json(full_content: true)[:blob_ace_mode]). + to eq('ruby') end end end diff --git a/spec/lib/gitlab/conflict/parser_spec.rb b/spec/lib/gitlab/conflict/parser_spec.rb index ca4bdcc3672c2d2be14f0ba10a9b3c584763a64b..16eb376635644762dcb29f047b5a3149161f33f1 100644 --- a/spec/lib/gitlab/conflict/parser_spec.rb +++ b/spec/lib/gitlab/conflict/parser_spec.rb @@ -121,72 +121,72 @@ CONFLICT context 'when the file contents include conflict delimiters' do it 'raises UnexpectedDelimiter when there is a non-start delimiter first' do - expect { parse_text('=======') } - .to raise_error(Gitlab::Conflict::Parser::UnexpectedDelimiter) + expect { parse_text('=======') }. + to raise_error(Gitlab::Conflict::Parser::UnexpectedDelimiter) - expect { parse_text('>>>>>>> README.md') } - .to raise_error(Gitlab::Conflict::Parser::UnexpectedDelimiter) + expect { parse_text('>>>>>>> README.md') }. + to raise_error(Gitlab::Conflict::Parser::UnexpectedDelimiter) - expect { parse_text('>>>>>>> some-other-path.md') } - .not_to raise_error + expect { parse_text('>>>>>>> some-other-path.md') }. + not_to raise_error end it 'raises UnexpectedDelimiter when a start delimiter is followed by a non-middle delimiter' do start_text = "<<<<<<< README.md\n" end_text = "\n=======\n>>>>>>> README.md" - expect { parse_text(start_text + '>>>>>>> README.md' + end_text) } - .to raise_error(Gitlab::Conflict::Parser::UnexpectedDelimiter) + expect { parse_text(start_text + '>>>>>>> README.md' + end_text) }. + to raise_error(Gitlab::Conflict::Parser::UnexpectedDelimiter) - expect { parse_text(start_text + start_text + end_text) } - .to raise_error(Gitlab::Conflict::Parser::UnexpectedDelimiter) + expect { parse_text(start_text + start_text + end_text) }. + to raise_error(Gitlab::Conflict::Parser::UnexpectedDelimiter) - expect { parse_text(start_text + '>>>>>>> some-other-path.md' + end_text) } - .not_to raise_error + expect { parse_text(start_text + '>>>>>>> some-other-path.md' + end_text) }. + not_to raise_error end it 'raises UnexpectedDelimiter when a middle delimiter is followed by a non-end delimiter' do start_text = "<<<<<<< README.md\n=======\n" end_text = "\n>>>>>>> README.md" - expect { parse_text(start_text + '=======' + end_text) } - .to raise_error(Gitlab::Conflict::Parser::UnexpectedDelimiter) + expect { parse_text(start_text + '=======' + end_text) }. + to raise_error(Gitlab::Conflict::Parser::UnexpectedDelimiter) - expect { parse_text(start_text + start_text + end_text) } - .to raise_error(Gitlab::Conflict::Parser::UnexpectedDelimiter) + expect { parse_text(start_text + start_text + end_text) }. + to raise_error(Gitlab::Conflict::Parser::UnexpectedDelimiter) - expect { parse_text(start_text + '>>>>>>> some-other-path.md' + end_text) } - .not_to raise_error + expect { parse_text(start_text + '>>>>>>> some-other-path.md' + end_text) }. + not_to raise_error end it 'raises MissingEndDelimiter when there is no end delimiter at the end' do start_text = "<<<<<<< README.md\n=======\n" - expect { parse_text(start_text) } - .to raise_error(Gitlab::Conflict::Parser::MissingEndDelimiter) + expect { parse_text(start_text) }. + to raise_error(Gitlab::Conflict::Parser::MissingEndDelimiter) - expect { parse_text(start_text + '>>>>>>> some-other-path.md') } - .to raise_error(Gitlab::Conflict::Parser::MissingEndDelimiter) + expect { parse_text(start_text + '>>>>>>> some-other-path.md') }. + to raise_error(Gitlab::Conflict::Parser::MissingEndDelimiter) end end context 'other file types' do it 'raises UnmergeableFile when lines is blank, indicating a binary file' do - expect { parse_text('') } - .to raise_error(Gitlab::Conflict::Parser::UnmergeableFile) + expect { parse_text('') }. + to raise_error(Gitlab::Conflict::Parser::UnmergeableFile) - expect { parse_text(nil) } - .to raise_error(Gitlab::Conflict::Parser::UnmergeableFile) + expect { parse_text(nil) }. + to raise_error(Gitlab::Conflict::Parser::UnmergeableFile) end it 'raises UnmergeableFile when the file is over 200 KB' do - expect { parse_text('a' * 204801) } - .to raise_error(Gitlab::Conflict::Parser::UnmergeableFile) + expect { parse_text('a' * 204801) }. + to raise_error(Gitlab::Conflict::Parser::UnmergeableFile) end it 'raises UnsupportedEncoding when the file contains non-UTF-8 characters' do - expect { parse_text("a\xC4\xFC".force_encoding(Encoding::ASCII_8BIT)) } - .to raise_error(Gitlab::Conflict::Parser::UnsupportedEncoding) + expect { parse_text("a\xC4\xFC".force_encoding(Encoding::ASCII_8BIT)) }. + to raise_error(Gitlab::Conflict::Parser::UnsupportedEncoding) end end end diff --git a/spec/lib/gitlab/data_builder/note_spec.rb b/spec/lib/gitlab/data_builder/note_spec.rb index 04ec34492e1809ed7d9a052b72a8f0e3b1a9ce17..7658153df0bdf4e3ca12fb70c9db1b801f8daf02 100644 --- a/spec/lib/gitlab/data_builder/note_spec.rb +++ b/spec/lib/gitlab/data_builder/note_spec.rb @@ -9,8 +9,8 @@ describe Gitlab::DataBuilder::Note, lib: true do before(:each) do expect(data).to have_key(:object_attributes) expect(data[:object_attributes]).to have_key(:url) - expect(data[:object_attributes][:url]) - .to eq(Gitlab::UrlBuilder.build(note)) + expect(data[:object_attributes][:url]). + to eq(Gitlab::UrlBuilder.build(note)) expect(data[:object_kind]).to eq('note') expect(data[:user]).to eq(user.hook_attrs) end @@ -49,10 +49,10 @@ describe Gitlab::DataBuilder::Note, lib: true do it 'returns the note and issue-specific data' do expect(data).to have_key(:issue) - expect(data[:issue].except('updated_at')) - .to eq(issue.reload.hook_attrs.except('updated_at')) - expect(data[:issue]['updated_at']) - .to be > issue.hook_attrs['updated_at'] + expect(data[:issue].except('updated_at')). + to eq(issue.reload.hook_attrs.except('updated_at')) + expect(data[:issue]['updated_at']). + to be > issue.hook_attrs['updated_at'] end include_examples 'project hook data' @@ -73,10 +73,10 @@ describe Gitlab::DataBuilder::Note, lib: true do it 'returns the note and merge request data' do expect(data).to have_key(:merge_request) - expect(data[:merge_request].except('updated_at')) - .to eq(merge_request.reload.hook_attrs.except('updated_at')) - expect(data[:merge_request]['updated_at']) - .to be > merge_request.hook_attrs['updated_at'] + expect(data[:merge_request].except('updated_at')). + to eq(merge_request.reload.hook_attrs.except('updated_at')) + expect(data[:merge_request]['updated_at']). + to be > merge_request.hook_attrs['updated_at'] end include_examples 'project hook data' @@ -96,10 +96,10 @@ describe Gitlab::DataBuilder::Note, lib: true do it 'returns the note and merge request diff data' do expect(data).to have_key(:merge_request) - expect(data[:merge_request].except('updated_at')) - .to eq(merge_request.reload.hook_attrs.except('updated_at')) - expect(data[:merge_request]['updated_at']) - .to be > merge_request.hook_attrs['updated_at'] + expect(data[:merge_request].except('updated_at')). + to eq(merge_request.reload.hook_attrs.except('updated_at')) + expect(data[:merge_request]['updated_at']). + to be > merge_request.hook_attrs['updated_at'] end include_examples 'project hook data' @@ -119,10 +119,10 @@ describe Gitlab::DataBuilder::Note, lib: true do it 'returns the note and project snippet data' do expect(data).to have_key(:snippet) - expect(data[:snippet].except('updated_at')) - .to eq(snippet.reload.hook_attrs.except('updated_at')) - expect(data[:snippet]['updated_at']) - .to be > snippet.hook_attrs['updated_at'] + expect(data[:snippet].except('updated_at')). + to eq(snippet.reload.hook_attrs.except('updated_at')) + expect(data[:snippet]['updated_at']). + to be > snippet.hook_attrs['updated_at'] end include_examples 'project hook data' diff --git a/spec/lib/gitlab/data_builder/push_spec.rb b/spec/lib/gitlab/data_builder/push_spec.rb index 019d7d758148e35798f0ace6bda81da1f511600d..dbcfb9b7400ad7c4ca525cf1b1658d9e9fc5e198 100644 --- a/spec/lib/gitlab/data_builder/push_spec.rb +++ b/spec/lib/gitlab/data_builder/push_spec.rb @@ -46,8 +46,8 @@ describe Gitlab::DataBuilder::Push, lib: true do include_examples 'deprecated repository hook data' it 'does not raise an error when given nil commits' do - expect { described_class.build(spy, spy, spy, spy, spy, nil) } - .not_to raise_error + expect { described_class.build(spy, spy, spy, spy, spy, nil) }. + not_to raise_error end end end diff --git a/spec/lib/gitlab/database/migration_helpers_spec.rb b/spec/lib/gitlab/database/migration_helpers_spec.rb index 511b4a988aa4aec3ac2965670d28bbb54d7d2e33..e007044868c1a173df2e5f1d32ca15cdd3221435 100644 --- a/spec/lib/gitlab/database/migration_helpers_spec.rb +++ b/spec/lib/gitlab/database/migration_helpers_spec.rb @@ -22,15 +22,15 @@ describe Gitlab::Database::MigrationHelpers, lib: true do end it 'creates the index concurrently' do - expect(model).to receive(:add_index) - .with(:users, :foo, algorithm: :concurrently) + expect(model).to receive(:add_index). + with(:users, :foo, algorithm: :concurrently) model.add_concurrent_index(:users, :foo) end it 'creates unique index concurrently' do - expect(model).to receive(:add_index) - .with(:users, :foo, { algorithm: :concurrently, unique: true }) + expect(model).to receive(:add_index). + with(:users, :foo, { algorithm: :concurrently, unique: true }) model.add_concurrent_index(:users, :foo, unique: true) end @@ -40,8 +40,8 @@ describe Gitlab::Database::MigrationHelpers, lib: true do it 'creates a regular index' do expect(Gitlab::Database).to receive(:postgresql?).and_return(false) - expect(model).to receive(:add_index) - .with(:users, :foo, {}) + expect(model).to receive(:add_index). + with(:users, :foo, {}) model.add_concurrent_index(:users, :foo) end @@ -52,8 +52,8 @@ describe Gitlab::Database::MigrationHelpers, lib: true do it 'raises RuntimeError' do expect(model).to receive(:transaction_open?).and_return(true) - expect { model.add_concurrent_index(:users, :foo) } - .to raise_error(RuntimeError) + expect { model.add_concurrent_index(:users, :foo) }. + to raise_error(RuntimeError) end end end @@ -78,8 +78,8 @@ describe Gitlab::Database::MigrationHelpers, lib: true do it 'creates a regular foreign key' do allow(Gitlab::Database).to receive(:mysql?).and_return(true) - expect(model).to receive(:add_foreign_key) - .with(:projects, :users, column: :user_id, on_delete: :cascade) + expect(model).to receive(:add_foreign_key). + with(:projects, :users, column: :user_id, on_delete: :cascade) model.add_concurrent_foreign_key(:projects, :users, column: :user_id) end @@ -171,16 +171,16 @@ describe Gitlab::Database::MigrationHelpers, lib: true do expect(model).to receive(:transaction).and_yield - expect(model).to receive(:add_column) - .with(:projects, :foo, :integer, default: nil) + expect(model).to receive(:add_column). + with(:projects, :foo, :integer, default: nil) - expect(model).to receive(:change_column_default) - .with(:projects, :foo, 10) + expect(model).to receive(:change_column_default). + with(:projects, :foo, 10) end it 'adds the column while allowing NULL values' do - expect(model).to receive(:update_column_in_batches) - .with(:projects, :foo, 10) + expect(model).to receive(:update_column_in_batches). + with(:projects, :foo, 10) expect(model).not_to receive(:change_column_null) @@ -190,22 +190,22 @@ describe Gitlab::Database::MigrationHelpers, lib: true do end it 'adds the column while not allowing NULL values' do - expect(model).to receive(:update_column_in_batches) - .with(:projects, :foo, 10) + expect(model).to receive(:update_column_in_batches). + with(:projects, :foo, 10) - expect(model).to receive(:change_column_null) - .with(:projects, :foo, false) + expect(model).to receive(:change_column_null). + with(:projects, :foo, false) model.add_column_with_default(:projects, :foo, :integer, default: 10) end it 'removes the added column whenever updating the rows fails' do - expect(model).to receive(:update_column_in_batches) - .with(:projects, :foo, 10) - .and_raise(RuntimeError) + expect(model).to receive(:update_column_in_batches). + with(:projects, :foo, 10). + and_raise(RuntimeError) - expect(model).to receive(:remove_column) - .with(:projects, :foo) + expect(model).to receive(:remove_column). + with(:projects, :foo) expect do model.add_column_with_default(:projects, :foo, :integer, default: 10) @@ -213,12 +213,12 @@ describe Gitlab::Database::MigrationHelpers, lib: true do end it 'removes the added column whenever changing a column NULL constraint fails' do - expect(model).to receive(:change_column_null) - .with(:projects, :foo, false) - .and_raise(RuntimeError) + expect(model).to receive(:change_column_null). + with(:projects, :foo, false). + and_raise(RuntimeError) - expect(model).to receive(:remove_column) - .with(:projects, :foo) + expect(model).to receive(:remove_column). + with(:projects, :foo) expect do model.add_column_with_default(:projects, :foo, :integer, default: 10) @@ -234,8 +234,8 @@ describe Gitlab::Database::MigrationHelpers, lib: true do allow(model).to receive(:change_column_null).with(:projects, :foo, false) allow(model).to receive(:change_column_default).with(:projects, :foo, 10) - expect(model).to receive(:add_column) - .with(:projects, :foo, :integer, default: nil, limit: 8) + expect(model).to receive(:add_column). + with(:projects, :foo, :integer, default: nil, limit: 8) model.add_column_with_default(:projects, :foo, :integer, default: 10, limit: 8) end diff --git a/spec/lib/gitlab/database_spec.rb b/spec/lib/gitlab/database_spec.rb index 053ce1d9e68d9adc9928b1f47f23b9fad2e6ed64..5eff7e8425b84f1581949e5befa3d89fe593be24 100644 --- a/spec/lib/gitlab/database_spec.rb +++ b/spec/lib/gitlab/database_spec.rb @@ -28,8 +28,8 @@ describe Gitlab::Database, lib: true do describe '.version' do context "on mysql" do it "extracts the version number" do - allow(described_class).to receive(:database_version) - .and_return("5.7.12-standard") + allow(described_class).to receive(:database_version). + and_return("5.7.12-standard") expect(described_class.version).to eq '5.7.12-standard' end @@ -37,8 +37,8 @@ describe Gitlab::Database, lib: true do context "on postgresql" do it "extracts the version number" do - allow(described_class).to receive(:database_version) - .and_return("PostgreSQL 9.4.4 on x86_64-apple-darwin14.3.0") + allow(described_class).to receive(:database_version). + and_return("PostgreSQL 9.4.4 on x86_64-apple-darwin14.3.0") expect(described_class.version).to eq '9.4.4' end @@ -120,8 +120,8 @@ describe Gitlab::Database, lib: true do pool = described_class.create_connection_pool(5) begin - expect(pool) - .to be_kind_of(ActiveRecord::ConnectionAdapters::ConnectionPool) + expect(pool). + to be_kind_of(ActiveRecord::ConnectionAdapters::ConnectionPool) expect(pool.spec.config[:pool]).to eq(5) ensure diff --git a/spec/lib/gitlab/downtime_check_spec.rb b/spec/lib/gitlab/downtime_check_spec.rb index 1f1e4e0216c4267dc9ae34aca4929102e62ff3aa..42d895e548e3aa97b948034d83a8148f46c77f4e 100644 --- a/spec/lib/gitlab/downtime_check_spec.rb +++ b/spec/lib/gitlab/downtime_check_spec.rb @@ -11,12 +11,12 @@ describe Gitlab::DowntimeCheck do context 'when a migration does not specify if downtime is required' do it 'raises RuntimeError' do - expect(subject).to receive(:class_for_migration_file) - .with(path) - .and_return(Class.new) + expect(subject).to receive(:class_for_migration_file). + with(path). + and_return(Class.new) - expect { subject.check([path]) } - .to raise_error(RuntimeError, /it requires downtime/) + expect { subject.check([path]) }. + to raise_error(RuntimeError, /it requires downtime/) end end @@ -25,12 +25,12 @@ describe Gitlab::DowntimeCheck do it 'raises RuntimeError' do stub_const('TestMigration::DOWNTIME', true) - expect(subject).to receive(:class_for_migration_file) - .with(path) - .and_return(TestMigration) + expect(subject).to receive(:class_for_migration_file). + with(path). + and_return(TestMigration) - expect { subject.check([path]) } - .to raise_error(RuntimeError, /no reason was given/) + expect { subject.check([path]) }. + to raise_error(RuntimeError, /no reason was given/) end end @@ -39,9 +39,9 @@ describe Gitlab::DowntimeCheck do stub_const('TestMigration::DOWNTIME', true) stub_const('TestMigration::DOWNTIME_REASON', 'foo') - expect(subject).to receive(:class_for_migration_file) - .with(path) - .and_return(TestMigration) + expect(subject).to receive(:class_for_migration_file). + with(path). + and_return(TestMigration) messages = subject.check([path]) @@ -65,9 +65,9 @@ describe Gitlab::DowntimeCheck do expect(subject).to receive(:require).with(path) - expect(subject).to receive(:class_for_migration_file) - .with(path) - .and_return(TestMigration) + expect(subject).to receive(:class_for_migration_file). + with(path). + and_return(TestMigration) expect(subject).to receive(:puts).with(an_instance_of(String)) diff --git a/spec/lib/gitlab/email/reply_parser_spec.rb b/spec/lib/gitlab/email/reply_parser_spec.rb index 02ff2a46c4888e53d8f44718fd67f4de7a463653..28698e89c338cee596d73e3cb9ddebc370c9b3cd 100644 --- a/spec/lib/gitlab/email/reply_parser_spec.rb +++ b/spec/lib/gitlab/email/reply_parser_spec.rb @@ -20,8 +20,8 @@ describe Gitlab::Email::ReplyParser, lib: true do end it "properly renders plaintext-only email" do - expect(test_parse_body(fixture_file("emails/plaintext_only.eml"))) - .to eq( + expect(test_parse_body(fixture_file("emails/plaintext_only.eml"))). + to eq( <<-BODY.strip_heredoc.chomp ### reply from default mail client in Windows 8.1 Metro @@ -46,8 +46,8 @@ describe Gitlab::Email::ReplyParser, lib: true do end it "handles multiple paragraphs" do - expect(test_parse_body(fixture_file("emails/paragraphs.eml"))) - .to eq( + expect(test_parse_body(fixture_file("emails/paragraphs.eml"))). + to eq( <<-BODY.strip_heredoc.chomp Is there any reason the *old* candy can't be be kept in silos while the new candy is imported into *new* silos? @@ -61,8 +61,8 @@ describe Gitlab::Email::ReplyParser, lib: true do end it "handles multiple paragraphs when parsing html" do - expect(test_parse_body(fixture_file("emails/html_paragraphs.eml"))) - .to eq( + expect(test_parse_body(fixture_file("emails/html_paragraphs.eml"))). + to eq( <<-BODY.strip_heredoc.chomp Awesome! @@ -74,8 +74,8 @@ describe Gitlab::Email::ReplyParser, lib: true do end it "handles newlines" do - expect(test_parse_body(fixture_file("emails/newlines.eml"))) - .to eq( + expect(test_parse_body(fixture_file("emails/newlines.eml"))). + to eq( <<-BODY.strip_heredoc.chomp This is my reply. It is my best reply. @@ -85,8 +85,8 @@ describe Gitlab::Email::ReplyParser, lib: true do end it "handles inline reply" do - expect(test_parse_body(fixture_file("emails/inline_reply.eml"))) - .to eq( + expect(test_parse_body(fixture_file("emails/inline_reply.eml"))). + to eq( <<-BODY.strip_heredoc.chomp > techAPJ <https://meta.discourse.org/users/techapj> > November 28 @@ -132,8 +132,8 @@ describe Gitlab::Email::ReplyParser, lib: true do end it "properly renders email reply from gmail web client" do - expect(test_parse_body(fixture_file("emails/gmail_web.eml"))) - .to eq( + expect(test_parse_body(fixture_file("emails/gmail_web.eml"))). + to eq( <<-BODY.strip_heredoc.chomp ### This is a reply from standard GMail in Google Chrome. @@ -151,8 +151,8 @@ describe Gitlab::Email::ReplyParser, lib: true do end it "properly renders email reply from iOS default mail client" do - expect(test_parse_body(fixture_file("emails/ios_default.eml"))) - .to eq( + expect(test_parse_body(fixture_file("emails/ios_default.eml"))). + to eq( <<-BODY.strip_heredoc.chomp ### this is a reply from iOS default mail @@ -166,8 +166,8 @@ describe Gitlab::Email::ReplyParser, lib: true do end it "properly renders email reply from Android 5 gmail client" do - expect(test_parse_body(fixture_file("emails/android_gmail.eml"))) - .to eq( + expect(test_parse_body(fixture_file("emails/android_gmail.eml"))). + to eq( <<-BODY.strip_heredoc.chomp ### this is a reply from Android 5 gmail @@ -184,8 +184,8 @@ describe Gitlab::Email::ReplyParser, lib: true do end it "properly renders email reply from Windows 8.1 Metro default mail client" do - expect(test_parse_body(fixture_file("emails/windows_8_metro.eml"))) - .to eq( + expect(test_parse_body(fixture_file("emails/windows_8_metro.eml"))). + to eq( <<-BODY.strip_heredoc.chomp ### reply from default mail client in Windows 8.1 Metro diff --git a/spec/lib/gitlab/file_detector_spec.rb b/spec/lib/gitlab/file_detector_spec.rb index 695fd6f8573ae1e5cc8ecc9366f2a80d959e89d9..e5ba13bbaf84bec9fda75257e7b6525d7037cc3d 100644 --- a/spec/lib/gitlab/file_detector_spec.rb +++ b/spec/lib/gitlab/file_detector_spec.rb @@ -3,13 +3,13 @@ require 'spec_helper' describe Gitlab::FileDetector do describe '.types_in_paths' do it 'returns the file types for the given paths' do - expect(described_class.types_in_paths(%w(README.md CHANGELOG VERSION VERSION))) - .to eq(%i{readme changelog version}) + expect(described_class.types_in_paths(%w(README.md CHANGELOG VERSION VERSION))). + to eq(%i{readme changelog version}) end it 'does not include unrecognized file paths' do - expect(described_class.types_in_paths(%w(README.md foo.txt))) - .to eq(%i{readme}) + expect(described_class.types_in_paths(%w(README.md foo.txt))). + to eq(%i{readme}) end end diff --git a/spec/lib/gitlab/git/attributes_spec.rb b/spec/lib/gitlab/git/attributes_spec.rb index b29107eece4c483692ee5f9b12f1c8679d2f41f4..9c011e34c113f53f4f39c25f76106c7f45762a87 100644 --- a/spec/lib/gitlab/git/attributes_spec.rb +++ b/spec/lib/gitlab/git/attributes_spec.rb @@ -14,13 +14,13 @@ describe Gitlab::Git::Attributes, seed_helper: true do end it 'returns a Hash containing multiple attributes' do - expect(subject.attributes('test.sh')) - .to eq({ 'eol' => 'lf', 'gitlab-language' => 'shell' }) + expect(subject.attributes('test.sh')). + to eq({ 'eol' => 'lf', 'gitlab-language' => 'shell' }) end it 'returns a Hash containing attributes for a file with multiple extensions' do - expect(subject.attributes('test.haml.html')) - .to eq({ 'gitlab-language' => 'haml' }) + expect(subject.attributes('test.haml.html')). + to eq({ 'gitlab-language' => 'haml' }) end it 'returns a Hash containing attributes for a file in a directory' do @@ -28,8 +28,8 @@ describe Gitlab::Git::Attributes, seed_helper: true do end it 'returns a Hash containing attributes with query string parameters' do - expect(subject.attributes('foo.cgi')) - .to eq({ 'key' => 'value?p1=v1&p2=v2' }) + expect(subject.attributes('foo.cgi')). + to eq({ 'key' => 'value?p1=v1&p2=v2' }) end it 'returns a Hash containing the attributes for an absolute path' do @@ -39,11 +39,11 @@ describe Gitlab::Git::Attributes, seed_helper: true do it 'returns a Hash containing the attributes when a pattern is defined using an absolute path' do # When a path is given without a leading slash it should still match # patterns defined with a leading slash. - expect(subject.attributes('foo.png')) - .to eq({ 'gitlab-language' => 'png' }) + expect(subject.attributes('foo.png')). + to eq({ 'gitlab-language' => 'png' }) - expect(subject.attributes('/foo.png')) - .to eq({ 'gitlab-language' => 'png' }) + expect(subject.attributes('/foo.png')). + to eq({ 'gitlab-language' => 'png' }) end it 'returns an empty Hash for a defined path without attributes' do @@ -74,8 +74,8 @@ describe Gitlab::Git::Attributes, seed_helper: true do end it 'parses an entry that uses a tab to separate the pattern and attributes' do - expect(subject.patterns[File.join(path, '*.md')]) - .to eq({ 'gitlab-language' => 'markdown' }) + expect(subject.patterns[File.join(path, '*.md')]). + to eq({ 'gitlab-language' => 'markdown' }) end it 'stores patterns in reverse order' do @@ -91,9 +91,9 @@ describe Gitlab::Git::Attributes, seed_helper: true do end it 'does not parse anything when the attributes file does not exist' do - expect(File).to receive(:exist?) - .with(File.join(path, 'info/attributes')) - .and_return(false) + expect(File).to receive(:exist?). + with(File.join(path, 'info/attributes')). + and_return(false) expect(subject.patterns).to eq({}) end @@ -115,13 +115,13 @@ describe Gitlab::Git::Attributes, seed_helper: true do it 'parses multiple attributes' do input = 'boolean key=value -negated' - expect(subject.parse_attributes(input)) - .to eq({ 'boolean' => true, 'key' => 'value', 'negated' => false }) + expect(subject.parse_attributes(input)). + to eq({ 'boolean' => true, 'key' => 'value', 'negated' => false }) end it 'parses attributes with query string parameters' do - expect(subject.parse_attributes('foo=bar?baz=1')) - .to eq({ 'foo' => 'bar?baz=1' }) + expect(subject.parse_attributes('foo=bar?baz=1')). + to eq({ 'foo' => 'bar?baz=1' }) end end @@ -133,9 +133,9 @@ describe Gitlab::Git::Attributes, seed_helper: true do end it 'does not yield when the attributes file does not exist' do - expect(File).to receive(:exist?) - .with(File.join(path, 'info/attributes')) - .and_return(false) + expect(File).to receive(:exist?). + with(File.join(path, 'info/attributes')). + and_return(false) expect { |b| subject.each_line(&b) }.not_to yield_control end diff --git a/spec/lib/gitlab/git/blob_spec.rb b/spec/lib/gitlab/git/blob_spec.rb index 327aba9cae7d01a57ede1c37625f9964b69cffc9..0c321f0343ca6075eb813e5ac1f572065c4feb61 100644 --- a/spec/lib/gitlab/git/blob_spec.rb +++ b/spec/lib/gitlab/git/blob_spec.rb @@ -92,9 +92,9 @@ describe Gitlab::Git::Blob, seed_helper: true do end it 'marks the blob as binary' do - expect(Gitlab::Git::Blob).to receive(:new) - .with(hash_including(binary: true)) - .and_call_original + expect(Gitlab::Git::Blob).to receive(:new). + with(hash_including(binary: true)). + and_call_original expect(blob).to be_binary end diff --git a/spec/lib/gitlab/git/diff_collection_spec.rb b/spec/lib/gitlab/git/diff_collection_spec.rb index c6ff864268d3fa922749bf3fb4d9c6cdfcc36b7e..47bdd7310d5c79c0d07af6b989c745e3f54f20b1 100644 --- a/spec/lib/gitlab/git/diff_collection_spec.rb +++ b/spec/lib/gitlab/git/diff_collection_spec.rb @@ -309,8 +309,8 @@ describe Gitlab::Git::DiffCollection, seed_helper: true do end it 'yields Diff instances even when they are too large' do - expect { |b| collection.each(&b) } - .to yield_with_args(an_instance_of(Gitlab::Git::Diff)) + expect { |b| collection.each(&b) }. + to yield_with_args(an_instance_of(Gitlab::Git::Diff)) end it 'prunes diffs that are too large' do @@ -331,8 +331,8 @@ describe Gitlab::Git::DiffCollection, seed_helper: true do let(:no_collapse) { true } it 'yields Diff instances even when they are quite big' do - expect { |b| subject.each(&b) } - .to yield_with_args(an_instance_of(Gitlab::Git::Diff)) + expect { |b| subject.each(&b) }. + to yield_with_args(an_instance_of(Gitlab::Git::Diff)) end it 'does not prune diffs' do @@ -350,8 +350,8 @@ describe Gitlab::Git::DiffCollection, seed_helper: true do let(:no_collapse) { false } it 'yields Diff instances even when they are quite big' do - expect { |b| subject.each(&b) } - .to yield_with_args(an_instance_of(Gitlab::Git::Diff)) + expect { |b| subject.each(&b) }. + to yield_with_args(an_instance_of(Gitlab::Git::Diff)) end it 'prunes diffs that are quite big' do @@ -437,8 +437,8 @@ describe Gitlab::Git::DiffCollection, seed_helper: true do let(:all_diffs) { true } it 'yields Diff instances even when they are quite big' do - expect { |b| subject.each(&b) } - .to yield_with_args(an_instance_of(Gitlab::Git::Diff)) + expect { |b| subject.each(&b) }. + to yield_with_args(an_instance_of(Gitlab::Git::Diff)) end it 'does not prune diffs' do diff --git a/spec/lib/gitlab/git/diff_spec.rb b/spec/lib/gitlab/git/diff_spec.rb index 70d3b1a9f81c9a7c10a12594f7348ceb95f0279b..4c55532d165f7461c2a5648a6d02af2b08b69687 100644 --- a/spec/lib/gitlab/git/diff_spec.rb +++ b/spec/lib/gitlab/git/diff_spec.rb @@ -70,8 +70,8 @@ EOT context 'using a diff that is too large' do it 'prunes the diff' do - expect_any_instance_of(String).to receive(:bytesize) - .and_return(1024 * 1024 * 1024) + expect_any_instance_of(String).to receive(:bytesize). + and_return(1024 * 1024 * 1024) diff = described_class.new(@rugged_diff) @@ -100,8 +100,8 @@ EOT context 'using a large binary diff' do it 'does not prune the diff' do - expect_any_instance_of(Rugged::Diff::Delta).to receive(:binary?) - .and_return(true) + expect_any_instance_of(Rugged::Diff::Delta).to receive(:binary?). + and_return(true) diff = described_class.new(@rugged_diff) diff --git a/spec/lib/gitlab/git/repository_spec.rb b/spec/lib/gitlab/git/repository_spec.rb index 5e0c3a530e9e14452b7f6ac068773175a1033c38..2a915bf426f9849542c99f06b347f8e82e915fc5 100644 --- a/spec/lib/gitlab/git/repository_spec.rb +++ b/spec/lib/gitlab/git/repository_spec.rb @@ -315,8 +315,8 @@ describe Gitlab::Git::Repository, seed_helper: true do end it "should move the tip of the master branch to the correct commit" do - new_tip = @normal_repo.rugged.references["refs/heads/master"] - .target.oid + new_tip = @normal_repo.rugged.references["refs/heads/master"]. + target.oid expect(new_tip).to eq(reset_commit) end diff --git a/spec/lib/gitlab/gitlab_import/importer_spec.rb b/spec/lib/gitlab/gitlab_import/importer_spec.rb index 4f588da0a8350859e593608932eb2a576c802e78..9b499b593d32ced37b99ab25a72b56699ac2c1df 100644 --- a/spec/lib/gitlab/gitlab_import/importer_spec.rb +++ b/spec/lib/gitlab/gitlab_import/importer_spec.rb @@ -45,8 +45,8 @@ describe Gitlab::GitlabImport::Importer, lib: true do def stub_request(path, body) url = "https://gitlab.com/api/v3/projects/asd%2Fvim/#{path}?page=1&per_page=100" - WebMock.stub_request(:get, url) - .to_return( + WebMock.stub_request(:get, url). + to_return( headers: { 'Content-Type' => 'application/json' }, body: body ) diff --git a/spec/lib/gitlab/identifier_spec.rb b/spec/lib/gitlab/identifier_spec.rb index 29912da2e252038fcbd2bd33e2f19c4b8e38f631..bb758a8a2029edd712c811e2ae5830742517eb95 100644 --- a/spec/lib/gitlab/identifier_spec.rb +++ b/spec/lib/gitlab/identifier_spec.rb @@ -12,8 +12,8 @@ describe Gitlab::Identifier do describe '#identify' do context 'without an identifier' do it 'identifies the user using a commit' do - expect(identifier).to receive(:identify_using_commit) - .with(project, '123') + expect(identifier).to receive(:identify_using_commit). + with(project, '123') identifier.identify('', project, '123') end @@ -21,8 +21,8 @@ describe Gitlab::Identifier do context 'with a user identifier' do it 'identifies the user using a user ID' do - expect(identifier).to receive(:identify_using_user) - .with("user-#{user.id}") + expect(identifier).to receive(:identify_using_user). + with("user-#{user.id}") identifier.identify("user-#{user.id}", project, '123') end @@ -30,8 +30,8 @@ describe Gitlab::Identifier do context 'with an SSH key identifier' do it 'identifies the user using an SSH key ID' do - expect(identifier).to receive(:identify_using_ssh_key) - .with("key-#{key.id}") + expect(identifier).to receive(:identify_using_ssh_key). + with("key-#{key.id}") identifier.identify("key-#{key.id}", project, '123') end diff --git a/spec/lib/gitlab/import_export/avatar_restorer_spec.rb b/spec/lib/gitlab/import_export/avatar_restorer_spec.rb index 08a42fd27a255bf1577adc61f75b5695734ad3ff..c141762421f872645d16dea42734ff4a7c7edd09 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 698bd72d0f8f99535881b6389045db774a0e5c90..d54753ccf905acd07d2f80fbfe5903aec6b2c527 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/job_waiter_spec.rb b/spec/lib/gitlab/job_waiter_spec.rb index 6186cec268993200b7cd0b4334fbb503fd530a69..780f5b1f8d7a4abaa49c42ac33f20ee5125e138e 100644 --- a/spec/lib/gitlab/job_waiter_spec.rb +++ b/spec/lib/gitlab/job_waiter_spec.rb @@ -4,8 +4,8 @@ describe Gitlab::JobWaiter do describe '#wait' do let(:waiter) { described_class.new(%w(a)) } it 'returns when all jobs have been completed' do - expect(Gitlab::SidekiqStatus).to receive(:all_completed?).with(%w(a)) - .and_return(true) + expect(Gitlab::SidekiqStatus).to receive(:all_completed?).with(%w(a)). + and_return(true) expect(waiter).not_to receive(:sleep) @@ -13,9 +13,9 @@ describe Gitlab::JobWaiter do end it 'sleeps between checking the job statuses' do - expect(Gitlab::SidekiqStatus).to receive(:all_completed?) - .with(%w(a)) - .and_return(false, true) + expect(Gitlab::SidekiqStatus).to receive(:all_completed?). + with(%w(a)). + and_return(false, true) expect(waiter).to receive(:sleep).with(described_class::INTERVAL) diff --git a/spec/lib/gitlab/ldap/adapter_spec.rb b/spec/lib/gitlab/ldap/adapter_spec.rb index 563c074017a5a72676c214faf7188dbc39afb882..fe3709f30e18ff15e763c53498e88c4876f275db 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/ldap/authentication_spec.rb b/spec/lib/gitlab/ldap/authentication_spec.rb index f689b47fec4c2c3f9bb91bc5085d4a2f589d1aaf..b8f3290e84c9cd4013f25900e91130f2de31b52b 100644 --- a/spec/lib/gitlab/ldap/authentication_spec.rb +++ b/spec/lib/gitlab/ldap/authentication_spec.rb @@ -16,8 +16,8 @@ describe Gitlab::LDAP::Authentication, lib: true do # try only to fake the LDAP call adapter = double('adapter', dn: dn).as_null_object - allow_any_instance_of(described_class) - .to receive(:adapter).and_return(adapter) + allow_any_instance_of(described_class). + to receive(:adapter).and_return(adapter) expect(described_class.login(login, password)).to be_truthy end @@ -25,8 +25,8 @@ describe Gitlab::LDAP::Authentication, lib: true do it "is false if the user does not exist" do # try only to fake the LDAP call adapter = double('adapter', dn: dn).as_null_object - allow_any_instance_of(described_class) - .to receive(:adapter).and_return(adapter) + allow_any_instance_of(described_class). + to receive(:adapter).and_return(adapter) expect(described_class.login(login, password)).to be_falsey end @@ -36,8 +36,8 @@ describe Gitlab::LDAP::Authentication, lib: true do # try only to fake the LDAP call adapter = double('adapter', bind_as: nil).as_null_object - allow_any_instance_of(described_class) - .to receive(:adapter).and_return(adapter) + allow_any_instance_of(described_class). + to receive(:adapter).and_return(adapter) expect(described_class.login(login, password)).to be_falsey end diff --git a/spec/lib/gitlab/ldap/user_spec.rb b/spec/lib/gitlab/ldap/user_spec.rb index 5c56c21012395889f059fbefda6b66e05d02dc46..89790c9e1af45db0eab05055be93375fd33c11a8 100644 --- a/spec/lib/gitlab/ldap/user_spec.rb +++ b/spec/lib/gitlab/ldap/user_spec.rb @@ -138,8 +138,8 @@ describe Gitlab::LDAP::User, lib: true do describe 'blocking' do def configure_block(value) - allow_any_instance_of(Gitlab::LDAP::Config) - .to receive(:block_auto_created_users).and_return(value) + allow_any_instance_of(Gitlab::LDAP::Config). + to receive(:block_auto_created_users).and_return(value) end context 'signup' do diff --git a/spec/lib/gitlab/metrics/instrumentation_spec.rb b/spec/lib/gitlab/metrics/instrumentation_spec.rb index 4b19ee19103661583725a445f0913952807e2002..a986cb520fb0c30d032caaa8c5cb13412d8aaca0 100644 --- a/spec/lib/gitlab/metrics/instrumentation_spec.rb +++ b/spec/lib/gitlab/metrics/instrumentation_spec.rb @@ -78,11 +78,11 @@ describe Gitlab::Metrics::Instrumentation do end it 'tracks the call duration upon calling the method' do - allow(Gitlab::Metrics).to receive(:method_call_threshold) - .and_return(0) + allow(Gitlab::Metrics).to receive(:method_call_threshold). + and_return(0) - allow(described_class).to receive(:transaction) - .and_return(transaction) + allow(described_class).to receive(:transaction). + and_return(transaction) expect_any_instance_of(Gitlab::Metrics::MethodCall).to receive(:measure) @@ -90,8 +90,8 @@ describe Gitlab::Metrics::Instrumentation do end it 'does not track method calls below a given duration threshold' do - allow(Gitlab::Metrics).to receive(:method_call_threshold) - .and_return(100) + allow(Gitlab::Metrics).to receive(:method_call_threshold). + and_return(100) expect(transaction).not_to receive(:add_metric) @@ -137,8 +137,8 @@ describe Gitlab::Metrics::Instrumentation do before do allow(Gitlab::Metrics).to receive(:enabled?).and_return(true) - described_class - .instrument_instance_method(@dummy, :bar) + described_class. + instrument_instance_method(@dummy, :bar) end it 'instruments instances of the Class' do @@ -156,11 +156,11 @@ describe Gitlab::Metrics::Instrumentation do end it 'tracks the call duration upon calling the method' do - allow(Gitlab::Metrics).to receive(:method_call_threshold) - .and_return(0) + allow(Gitlab::Metrics).to receive(:method_call_threshold). + and_return(0) - allow(described_class).to receive(:transaction) - .and_return(transaction) + allow(described_class).to receive(:transaction). + and_return(transaction) expect_any_instance_of(Gitlab::Metrics::MethodCall).to receive(:measure) @@ -168,8 +168,8 @@ describe Gitlab::Metrics::Instrumentation do end it 'does not track method calls below a given duration threshold' do - allow(Gitlab::Metrics).to receive(:method_call_threshold) - .and_return(100) + allow(Gitlab::Metrics).to receive(:method_call_threshold). + and_return(100) expect(transaction).not_to receive(:add_metric) @@ -183,8 +183,8 @@ describe Gitlab::Metrics::Instrumentation do end it 'does not instrument the method' do - described_class - .instrument_instance_method(@dummy, :bar) + described_class. + instrument_instance_method(@dummy, :bar) expect(described_class.instrumented?(@dummy)).to eq(false) end diff --git a/spec/lib/gitlab/metrics/rack_middleware_spec.rb b/spec/lib/gitlab/metrics/rack_middleware_spec.rb index ec415f2bd8598c4418d1f8a39108a16109b4719a..fb470ea75684f567dd05e86106e7742f44272207 100644 --- a/spec/lib/gitlab/metrics/rack_middleware_spec.rb +++ b/spec/lib/gitlab/metrics/rack_middleware_spec.rb @@ -26,8 +26,8 @@ describe Gitlab::Metrics::RackMiddleware do allow(app).to receive(:call).with(env) - expect(middleware).to receive(:tag_controller) - .with(an_instance_of(Gitlab::Metrics::Transaction), env) + expect(middleware).to receive(:tag_controller). + with(an_instance_of(Gitlab::Metrics::Transaction), env) middleware.call(env) end @@ -40,8 +40,8 @@ describe Gitlab::Metrics::RackMiddleware do allow(app).to receive(:call).with(env) - expect(middleware).to receive(:tag_endpoint) - .with(an_instance_of(Gitlab::Metrics::Transaction), env) + expect(middleware).to receive(:tag_endpoint). + with(an_instance_of(Gitlab::Metrics::Transaction), env) middleware.call(env) end @@ -49,8 +49,8 @@ describe Gitlab::Metrics::RackMiddleware do it 'tracks any raised exceptions' do expect(app).to receive(:call).with(env).and_raise(RuntimeError) - expect_any_instance_of(Gitlab::Metrics::Transaction) - .to receive(:add_event).with(:rails_exception) + expect_any_instance_of(Gitlab::Metrics::Transaction). + to receive(:add_event).with(:rails_exception) expect { middleware.call(env) }.to raise_error(RuntimeError) end diff --git a/spec/lib/gitlab/metrics/sampler_spec.rb b/spec/lib/gitlab/metrics/sampler_spec.rb index d07ce6f81af2450eb6234bd7a65af5a75062991d..1ab923b58cf6881b901a5c0445b1231ab00648b9 100644 --- a/spec/lib/gitlab/metrics/sampler_spec.rb +++ b/spec/lib/gitlab/metrics/sampler_spec.rb @@ -38,8 +38,8 @@ describe Gitlab::Metrics::Sampler do describe '#flush' do it 'schedules the metrics using Sidekiq' do - expect(Gitlab::Metrics).to receive(:submit_metrics) - .with([an_instance_of(Hash)]) + expect(Gitlab::Metrics).to receive(:submit_metrics). + with([an_instance_of(Hash)]) sampler.sample_memory_usage sampler.flush @@ -48,12 +48,12 @@ describe Gitlab::Metrics::Sampler do describe '#sample_memory_usage' do it 'adds a metric containing the memory usage' do - expect(Gitlab::Metrics::System).to receive(:memory_usage) - .and_return(9000) + expect(Gitlab::Metrics::System).to receive(:memory_usage). + and_return(9000) - expect(sampler).to receive(:add_metric) - .with(/memory_usage/, value: 9000) - .and_call_original + expect(sampler).to receive(:add_metric). + with(/memory_usage/, value: 9000). + and_call_original sampler.sample_memory_usage end @@ -61,12 +61,12 @@ describe Gitlab::Metrics::Sampler do describe '#sample_file_descriptors' do it 'adds a metric containing the amount of open file descriptors' do - expect(Gitlab::Metrics::System).to receive(:file_descriptor_count) - .and_return(4) + expect(Gitlab::Metrics::System).to receive(:file_descriptor_count). + and_return(4) - expect(sampler).to receive(:add_metric) - .with(/file_descriptors/, value: 4) - .and_call_original + expect(sampler).to receive(:add_metric). + with(/file_descriptors/, value: 4). + and_call_original sampler.sample_file_descriptors end @@ -75,10 +75,10 @@ describe Gitlab::Metrics::Sampler do if Gitlab::Metrics.mri? describe '#sample_objects' do it 'adds a metric containing the amount of allocated objects' do - expect(sampler).to receive(:add_metric) - .with(/object_counts/, an_instance_of(Hash), an_instance_of(Hash)) - .at_least(:once) - .and_call_original + expect(sampler).to receive(:add_metric). + with(/object_counts/, an_instance_of(Hash), an_instance_of(Hash)). + at_least(:once). + and_call_original sampler.sample_objects end @@ -86,8 +86,8 @@ describe Gitlab::Metrics::Sampler do it 'ignores classes without a name' do expect(Allocations).to receive(:to_hash).and_return({ Class.new => 4 }) - expect(sampler).not_to receive(:add_metric) - .with('object_counts', an_instance_of(Hash), type: nil) + expect(sampler).not_to receive(:add_metric). + with('object_counts', an_instance_of(Hash), type: nil) sampler.sample_objects end @@ -98,9 +98,9 @@ describe Gitlab::Metrics::Sampler do it 'adds a metric containing garbage collection statistics' do expect(GC::Profiler).to receive(:total_time).and_return(0.24) - expect(sampler).to receive(:add_metric) - .with(/gc_statistics/, an_instance_of(Hash)) - .and_call_original + expect(sampler).to receive(:add_metric). + with(/gc_statistics/, an_instance_of(Hash)). + and_call_original sampler.sample_gc end @@ -110,9 +110,9 @@ describe Gitlab::Metrics::Sampler do it 'prefixes the series name for a Rails process' do expect(sampler).to receive(:sidekiq?).and_return(false) - expect(Gitlab::Metrics::Metric).to receive(:new) - .with('rails_cats', { value: 10 }, {}) - .and_call_original + expect(Gitlab::Metrics::Metric).to receive(:new). + with('rails_cats', { value: 10 }, {}). + and_call_original sampler.add_metric('cats', value: 10) end @@ -120,9 +120,9 @@ describe Gitlab::Metrics::Sampler do it 'prefixes the series name for a Sidekiq process' do expect(sampler).to receive(:sidekiq?).and_return(true) - expect(Gitlab::Metrics::Metric).to receive(:new) - .with('sidekiq_cats', { value: 10 }, {}) - .and_call_original + expect(Gitlab::Metrics::Metric).to receive(:new). + with('sidekiq_cats', { value: 10 }, {}). + and_call_original sampler.add_metric('cats', value: 10) end diff --git a/spec/lib/gitlab/metrics/sidekiq_middleware_spec.rb b/spec/lib/gitlab/metrics/sidekiq_middleware_spec.rb index b576d7173f5a040b5a0fdf6d2364ea96f7bbddb7..acaba785606e13e9b43348a3fa4247eb3ac56d91 100644 --- a/spec/lib/gitlab/metrics/sidekiq_middleware_spec.rb +++ b/spec/lib/gitlab/metrics/sidekiq_middleware_spec.rb @@ -8,12 +8,12 @@ describe Gitlab::Metrics::SidekiqMiddleware do it 'tracks the transaction' do worker = double(:worker, class: double(:class, name: 'TestWorker')) - expect(Gitlab::Metrics::Transaction).to receive(:new) - .with('TestWorker#perform') - .and_call_original + expect(Gitlab::Metrics::Transaction).to receive(:new). + with('TestWorker#perform'). + and_call_original - expect_any_instance_of(Gitlab::Metrics::Transaction).to receive(:set) - .with(:sidekiq_queue_duration, instance_of(Float)) + expect_any_instance_of(Gitlab::Metrics::Transaction).to receive(:set). + with(:sidekiq_queue_duration, instance_of(Float)) expect_any_instance_of(Gitlab::Metrics::Transaction).to receive(:finish) @@ -23,12 +23,12 @@ describe Gitlab::Metrics::SidekiqMiddleware do it 'tracks the transaction (for messages without `enqueued_at`)' do worker = double(:worker, class: double(:class, name: 'TestWorker')) - expect(Gitlab::Metrics::Transaction).to receive(:new) - .with('TestWorker#perform') - .and_call_original + expect(Gitlab::Metrics::Transaction).to receive(:new). + with('TestWorker#perform'). + and_call_original - expect_any_instance_of(Gitlab::Metrics::Transaction).to receive(:set) - .with(:sidekiq_queue_duration, instance_of(Float)) + expect_any_instance_of(Gitlab::Metrics::Transaction).to receive(:set). + with(:sidekiq_queue_duration, instance_of(Float)) expect_any_instance_of(Gitlab::Metrics::Transaction).to receive(:finish) @@ -38,17 +38,17 @@ describe Gitlab::Metrics::SidekiqMiddleware do it 'tracks any raised exceptions' do worker = double(:worker, class: double(:class, name: 'TestWorker')) - expect_any_instance_of(Gitlab::Metrics::Transaction) - .to receive(:run).and_raise(RuntimeError) + expect_any_instance_of(Gitlab::Metrics::Transaction). + to receive(:run).and_raise(RuntimeError) - expect_any_instance_of(Gitlab::Metrics::Transaction) - .to receive(:add_event).with(:sidekiq_exception) + expect_any_instance_of(Gitlab::Metrics::Transaction). + to receive(:add_event).with(:sidekiq_exception) - expect_any_instance_of(Gitlab::Metrics::Transaction) - .to receive(:finish) + expect_any_instance_of(Gitlab::Metrics::Transaction). + to receive(:finish) - expect { middleware.call(worker, message, :test) } - .to raise_error(RuntimeError) + expect { middleware.call(worker, message, :test) }. + to raise_error(RuntimeError) end end end diff --git a/spec/lib/gitlab/metrics/subscribers/action_view_spec.rb b/spec/lib/gitlab/metrics/subscribers/action_view_spec.rb index e7b595405a81272cd8b8a96b530ad59a52bb283b..0695c5ce096fca07564bfe53d9397955797cdee6 100644 --- a/spec/lib/gitlab/metrics/subscribers/action_view_spec.rb +++ b/spec/lib/gitlab/metrics/subscribers/action_view_spec.rb @@ -21,11 +21,11 @@ describe Gitlab::Metrics::Subscribers::ActionView do values = { duration: 2.1 } tags = { view: 'app/views/x.html.haml' } - expect(transaction).to receive(:increment) - .with(:view_duration, 2.1) + expect(transaction).to receive(:increment). + with(:view_duration, 2.1) - expect(transaction).to receive(:add_metric) - .with(described_class::SERIES, values, tags) + expect(transaction).to receive(:add_metric). + with(described_class::SERIES, values, tags) subscriber.render_template(event) end diff --git a/spec/lib/gitlab/metrics/subscribers/active_record_spec.rb b/spec/lib/gitlab/metrics/subscribers/active_record_spec.rb index ce6587e993f429b9e86e2c7c7c233d829cfde42c..49699ffe28f0a1875e8b1a2134f7ad23104ac7eb 100644 --- a/spec/lib/gitlab/metrics/subscribers/active_record_spec.rb +++ b/spec/lib/gitlab/metrics/subscribers/active_record_spec.rb @@ -12,8 +12,8 @@ describe Gitlab::Metrics::Subscribers::ActiveRecord do describe '#sql' do describe 'without a current transaction' do it 'simply returns' do - expect_any_instance_of(Gitlab::Metrics::Transaction) - .not_to receive(:increment) + expect_any_instance_of(Gitlab::Metrics::Transaction). + not_to receive(:increment) subscriber.sql(event) end @@ -21,15 +21,15 @@ describe Gitlab::Metrics::Subscribers::ActiveRecord do describe 'with a current transaction' do it 'increments the :sql_duration value' do - expect(subscriber).to receive(:current_transaction) - .at_least(:once) - .and_return(transaction) + expect(subscriber).to receive(:current_transaction). + at_least(:once). + and_return(transaction) - expect(transaction).to receive(:increment) - .with(:sql_duration, 0.2) + expect(transaction).to receive(:increment). + with(:sql_duration, 0.2) - expect(transaction).to receive(:increment) - .with(:sql_count, 1) + expect(transaction).to receive(:increment). + with(:sql_count, 1) subscriber.sql(event) end diff --git a/spec/lib/gitlab/metrics/subscribers/rails_cache_spec.rb b/spec/lib/gitlab/metrics/subscribers/rails_cache_spec.rb index f04dc8dcc02b58991b454721d831753c6a93ffd5..d986c6fac4380224837888008be0933918c1c686 100644 --- a/spec/lib/gitlab/metrics/subscribers/rails_cache_spec.rb +++ b/spec/lib/gitlab/metrics/subscribers/rails_cache_spec.rb @@ -8,26 +8,26 @@ describe Gitlab::Metrics::Subscribers::RailsCache do describe '#cache_read' do it 'increments the cache_read duration' do - expect(subscriber).to receive(:increment) - .with(:cache_read, event.duration) + expect(subscriber).to receive(:increment). + with(:cache_read, event.duration) subscriber.cache_read(event) end context 'with a transaction' do before do - allow(subscriber).to receive(:current_transaction) - .and_return(transaction) + allow(subscriber).to receive(:current_transaction). + and_return(transaction) end context 'with hit event' do let(:event) { double(:event, duration: 15.2, payload: { hit: true }) } it 'increments the cache_read_hit count' do - expect(transaction).to receive(:increment) - .with(:cache_read_hit_count, 1) - expect(transaction).to receive(:increment) - .with(any_args).at_least(1) # Other calls + expect(transaction).to receive(:increment). + with(:cache_read_hit_count, 1) + expect(transaction).to receive(:increment). + with(any_args).at_least(1) # Other calls subscriber.cache_read(event) end @@ -36,8 +36,8 @@ describe Gitlab::Metrics::Subscribers::RailsCache do let(:event) { double(:event, duration: 15.2, payload: { hit: true, super_operation: :fetch }) } it 'does not increment cache read miss' do - expect(transaction).not_to receive(:increment) - .with(:cache_read_hit_count, 1) + expect(transaction).not_to receive(:increment). + with(:cache_read_hit_count, 1) subscriber.cache_read(event) end @@ -48,10 +48,10 @@ describe Gitlab::Metrics::Subscribers::RailsCache do let(:event) { double(:event, duration: 15.2, payload: { hit: false }) } it 'increments the cache_read_miss count' do - expect(transaction).to receive(:increment) - .with(:cache_read_miss_count, 1) - expect(transaction).to receive(:increment) - .with(any_args).at_least(1) # Other calls + expect(transaction).to receive(:increment). + with(:cache_read_miss_count, 1) + expect(transaction).to receive(:increment). + with(any_args).at_least(1) # Other calls subscriber.cache_read(event) end @@ -60,8 +60,8 @@ describe Gitlab::Metrics::Subscribers::RailsCache do let(:event) { double(:event, duration: 15.2, payload: { hit: false, super_operation: :fetch }) } it 'does not increment cache read miss' do - expect(transaction).not_to receive(:increment) - .with(:cache_read_miss_count, 1) + expect(transaction).not_to receive(:increment). + with(:cache_read_miss_count, 1) subscriber.cache_read(event) end @@ -72,8 +72,8 @@ describe Gitlab::Metrics::Subscribers::RailsCache do describe '#cache_write' do it 'increments the cache_write duration' do - expect(subscriber).to receive(:increment) - .with(:cache_write, event.duration) + expect(subscriber).to receive(:increment). + with(:cache_write, event.duration) subscriber.cache_write(event) end @@ -81,8 +81,8 @@ describe Gitlab::Metrics::Subscribers::RailsCache do describe '#cache_delete' do it 'increments the cache_delete duration' do - expect(subscriber).to receive(:increment) - .with(:cache_delete, event.duration) + expect(subscriber).to receive(:increment). + with(:cache_delete, event.duration) subscriber.cache_delete(event) end @@ -90,8 +90,8 @@ describe Gitlab::Metrics::Subscribers::RailsCache do describe '#cache_exist?' do it 'increments the cache_exists duration' do - expect(subscriber).to receive(:increment) - .with(:cache_exists, event.duration) + expect(subscriber).to receive(:increment). + with(:cache_exists, event.duration) subscriber.cache_exist?(event) end @@ -108,13 +108,13 @@ describe Gitlab::Metrics::Subscribers::RailsCache do context 'with a transaction' do before do - allow(subscriber).to receive(:current_transaction) - .and_return(transaction) + allow(subscriber).to receive(:current_transaction). + and_return(transaction) end it 'increments the cache_read_hit count' do - expect(transaction).to receive(:increment) - .with(:cache_read_hit_count, 1) + expect(transaction).to receive(:increment). + with(:cache_read_hit_count, 1) subscriber.cache_fetch_hit(event) end @@ -132,13 +132,13 @@ describe Gitlab::Metrics::Subscribers::RailsCache do context 'with a transaction' do before do - allow(subscriber).to receive(:current_transaction) - .and_return(transaction) + allow(subscriber).to receive(:current_transaction). + and_return(transaction) end it 'increments the cache_fetch_miss count' do - expect(transaction).to receive(:increment) - .with(:cache_read_miss_count, 1) + expect(transaction).to receive(:increment). + with(:cache_read_miss_count, 1) subscriber.cache_generate(event) end @@ -156,22 +156,22 @@ describe Gitlab::Metrics::Subscribers::RailsCache do context 'with a transaction' do before do - allow(subscriber).to receive(:current_transaction) - .and_return(transaction) + allow(subscriber).to receive(:current_transaction). + and_return(transaction) end it 'increments the total and specific cache duration' do - expect(transaction).to receive(:increment) - .with(:cache_duration, event.duration) + expect(transaction).to receive(:increment). + with(:cache_duration, event.duration) - expect(transaction).to receive(:increment) - .with(:cache_count, 1) + expect(transaction).to receive(:increment). + with(:cache_count, 1) - expect(transaction).to receive(:increment) - .with(:cache_delete_duration, event.duration) + expect(transaction).to receive(:increment). + with(:cache_delete_duration, event.duration) - expect(transaction).to receive(:increment) - .with(:cache_delete_count, 1) + expect(transaction).to receive(:increment). + with(:cache_delete_count, 1) subscriber.increment(:cache_delete, event.duration) end diff --git a/spec/lib/gitlab/metrics/transaction_spec.rb b/spec/lib/gitlab/metrics/transaction_spec.rb index 3779af8151207b65d2e3b0d744f654b1eade0537..0c5a6246d85156eed8714fc9955f5c662bdf08a7 100644 --- a/spec/lib/gitlab/metrics/transaction_spec.rb +++ b/spec/lib/gitlab/metrics/transaction_spec.rb @@ -39,8 +39,8 @@ describe Gitlab::Metrics::Transaction do describe '#add_metric' do it 'adds a metric to the transaction' do - expect(Gitlab::Metrics::Metric).to receive(:new) - .with('rails_foo', { number: 10 }, {}) + expect(Gitlab::Metrics::Metric).to receive(:new). + with('rails_foo', { number: 10 }, {}) transaction.add_metric('foo', number: 10) end @@ -61,8 +61,8 @@ describe Gitlab::Metrics::Transaction do values = { duration: 0.0, time: 3, allocated_memory: a_kind_of(Numeric) } - expect(transaction).to receive(:add_metric) - .with('transactions', values, {}) + expect(transaction).to receive(:add_metric). + with('transactions', values, {}) transaction.track_self end @@ -78,8 +78,8 @@ describe Gitlab::Metrics::Transaction do allocated_memory: a_kind_of(Numeric) } - expect(transaction).to receive(:add_metric) - .with('transactions', values, {}) + expect(transaction).to receive(:add_metric). + with('transactions', values, {}) transaction.track_self end @@ -109,8 +109,8 @@ describe Gitlab::Metrics::Transaction do allocated_memory: a_kind_of(Numeric) } - expect(transaction).to receive(:add_metric) - .with('transactions', values, {}) + expect(transaction).to receive(:add_metric). + with('transactions', values, {}) transaction.track_self end @@ -120,8 +120,8 @@ describe Gitlab::Metrics::Transaction do it 'submits the metrics to Sidekiq' do transaction.track_self - expect(Gitlab::Metrics).to receive(:submit_metrics) - .with([an_instance_of(Hash)]) + expect(Gitlab::Metrics).to receive(:submit_metrics). + with([an_instance_of(Hash)]) transaction.submit end @@ -137,8 +137,8 @@ describe Gitlab::Metrics::Transaction do timestamp: a_kind_of(Integer) } - expect(Gitlab::Metrics).to receive(:submit_metrics) - .with([hash]) + expect(Gitlab::Metrics).to receive(:submit_metrics). + with([hash]) transaction.submit end @@ -154,8 +154,8 @@ describe Gitlab::Metrics::Transaction do timestamp: a_kind_of(Integer) } - expect(Gitlab::Metrics).to receive(:submit_metrics) - .with([hash]) + expect(Gitlab::Metrics).to receive(:submit_metrics). + with([hash]) transaction.submit end diff --git a/spec/lib/gitlab/metrics_spec.rb b/spec/lib/gitlab/metrics_spec.rb index c8d292f4566248d1b874556f325c2ea3601ce353..ab6e311b1e80b4034febc97db91c69f4393a8bfd 100644 --- a/spec/lib/gitlab/metrics_spec.rb +++ b/spec/lib/gitlab/metrics_spec.rb @@ -28,8 +28,8 @@ describe Gitlab::Metrics do describe '.prepare_metrics' do it 'returns a Hash with the keys as Symbols' do - metrics = described_class - .prepare_metrics([{ 'values' => {}, 'tags' => {} }]) + metrics = described_class. + prepare_metrics([{ 'values' => {}, 'tags' => {} }]) expect(metrics).to eq([{ values: {}, tags: {} }]) end @@ -74,19 +74,19 @@ describe Gitlab::Metrics do let(:transaction) { Gitlab::Metrics::Transaction.new } before do - allow(Gitlab::Metrics).to receive(:current_transaction) - .and_return(transaction) + allow(Gitlab::Metrics).to receive(:current_transaction). + and_return(transaction) end it 'adds a metric to the current transaction' do - expect(transaction).to receive(:increment) - .with('foo_real_time', a_kind_of(Numeric)) + expect(transaction).to receive(:increment). + with('foo_real_time', a_kind_of(Numeric)) - expect(transaction).to receive(:increment) - .with('foo_cpu_time', a_kind_of(Numeric)) + expect(transaction).to receive(:increment). + with('foo_cpu_time', a_kind_of(Numeric)) - expect(transaction).to receive(:increment) - .with('foo_call_count', 1) + expect(transaction).to receive(:increment). + with('foo_call_count', 1) Gitlab::Metrics.measure(:foo) { 10 } end @@ -102,8 +102,8 @@ describe Gitlab::Metrics do describe '.tag_transaction' do context 'without a transaction' do it 'does nothing' do - expect_any_instance_of(Gitlab::Metrics::Transaction) - .not_to receive(:add_tag) + expect_any_instance_of(Gitlab::Metrics::Transaction). + not_to receive(:add_tag) Gitlab::Metrics.tag_transaction(:foo, 'bar') end @@ -113,11 +113,11 @@ describe Gitlab::Metrics do let(:transaction) { Gitlab::Metrics::Transaction.new } it 'adds the tag to the transaction' do - expect(Gitlab::Metrics).to receive(:current_transaction) - .and_return(transaction) + expect(Gitlab::Metrics).to receive(:current_transaction). + and_return(transaction) - expect(transaction).to receive(:add_tag) - .with(:foo, 'bar') + expect(transaction).to receive(:add_tag). + with(:foo, 'bar') Gitlab::Metrics.tag_transaction(:foo, 'bar') end @@ -127,8 +127,8 @@ describe Gitlab::Metrics do describe '.action=' do context 'without a transaction' do it 'does nothing' do - expect_any_instance_of(Gitlab::Metrics::Transaction) - .not_to receive(:action=) + expect_any_instance_of(Gitlab::Metrics::Transaction). + not_to receive(:action=) Gitlab::Metrics.action = 'foo' end @@ -138,8 +138,8 @@ describe Gitlab::Metrics do it 'sets the action of a transaction' do trans = Gitlab::Metrics::Transaction.new - expect(Gitlab::Metrics).to receive(:current_transaction) - .and_return(trans) + expect(Gitlab::Metrics).to receive(:current_transaction). + and_return(trans) expect(trans).to receive(:action=).with('foo') @@ -157,8 +157,8 @@ describe Gitlab::Metrics do describe '.add_event' do context 'without a transaction' do it 'does nothing' do - expect_any_instance_of(Gitlab::Metrics::Transaction) - .not_to receive(:add_event) + expect_any_instance_of(Gitlab::Metrics::Transaction). + not_to receive(:add_event) Gitlab::Metrics.add_event(:meow) end @@ -170,8 +170,8 @@ describe Gitlab::Metrics do expect(transaction).to receive(:add_event).with(:meow) - expect(Gitlab::Metrics).to receive(:current_transaction) - .and_return(transaction) + expect(Gitlab::Metrics).to receive(:current_transaction). + and_return(transaction) Gitlab::Metrics.add_event(:meow) end diff --git a/spec/lib/gitlab/o_auth/user_spec.rb b/spec/lib/gitlab/o_auth/user_spec.rb index c49d2b286ff7016012c703f6d5ed337a80516fe7..4de5991db37585248573fc8f9982b21b0e4f8cd0 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/route_map_spec.rb b/spec/lib/gitlab/route_map_spec.rb index 21c00c6e5b80a3c511bb74e5364c54cbc4499ff2..2370f56a6131a994a7c27e0c7e74456a519b2029 100644 --- a/spec/lib/gitlab/route_map_spec.rb +++ b/spec/lib/gitlab/route_map_spec.rb @@ -4,43 +4,43 @@ describe Gitlab::RouteMap, lib: true do describe '#initialize' do context 'when the data is not YAML' do it 'raises an error' do - expect { described_class.new('"') } - .to raise_error(Gitlab::RouteMap::FormatError, /valid YAML/) + expect { described_class.new('"') }. + to raise_error(Gitlab::RouteMap::FormatError, /valid YAML/) end end context 'when the data is not a YAML array' do it 'raises an error' do - expect { described_class.new(YAML.dump('foo')) } - .to raise_error(Gitlab::RouteMap::FormatError, /an array/) + expect { described_class.new(YAML.dump('foo')) }. + to raise_error(Gitlab::RouteMap::FormatError, /an array/) end end context 'when an entry is not a hash' do it 'raises an error' do - expect { described_class.new(YAML.dump(['foo'])) } - .to raise_error(Gitlab::RouteMap::FormatError, /a hash/) + expect { described_class.new(YAML.dump(['foo'])) }. + to raise_error(Gitlab::RouteMap::FormatError, /a hash/) end end context 'when an entry does not have a source key' do it 'raises an error' do - expect { described_class.new(YAML.dump([{ 'public' => 'index.html' }])) } - .to raise_error(Gitlab::RouteMap::FormatError, /source key/) + expect { described_class.new(YAML.dump([{ 'public' => 'index.html' }])) }. + to raise_error(Gitlab::RouteMap::FormatError, /source key/) end end context 'when an entry does not have a public key' do it 'raises an error' do - expect { described_class.new(YAML.dump([{ 'source' => '/index\.html/' }])) } - .to raise_error(Gitlab::RouteMap::FormatError, /public key/) + expect { described_class.new(YAML.dump([{ 'source' => '/index\.html/' }])) }. + to raise_error(Gitlab::RouteMap::FormatError, /public key/) end end context 'when an entry source is not a valid regex' do it 'raises an error' do - expect { described_class.new(YAML.dump([{ 'source' => '/[/', 'public' => 'index.html' }])) } - .to raise_error(Gitlab::RouteMap::FormatError, /regular expression/) + expect { described_class.new(YAML.dump([{ 'source' => '/[/', 'public' => 'index.html' }])) }. + to raise_error(Gitlab::RouteMap::FormatError, /regular expression/) end end diff --git a/spec/lib/gitlab/serializer/pagination_spec.rb b/spec/lib/gitlab/serializer/pagination_spec.rb index 519eb1b274fb5fa601526e1dbbd5993ec8995b00..e05160da7a6a693332eea74d205f09bb5fedd0e4 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/lib/gitlab/sherlock/file_sample_spec.rb b/spec/lib/gitlab/sherlock/file_sample_spec.rb index 4989d14def30a83e641092039fb5f441eaa93c6e..cadf8bbce78057558264b159703a2d95517227bc 100644 --- a/spec/lib/gitlab/sherlock/file_sample_spec.rb +++ b/spec/lib/gitlab/sherlock/file_sample_spec.rb @@ -35,8 +35,8 @@ describe Gitlab::Sherlock::FileSample, lib: true do describe '#relative_path' do it 'returns the relative path' do - expect(sample.relative_path) - .to eq('spec/lib/gitlab/sherlock/file_sample_spec.rb') + expect(sample.relative_path). + to eq('spec/lib/gitlab/sherlock/file_sample_spec.rb') end end diff --git a/spec/lib/gitlab/sherlock/line_profiler_spec.rb b/spec/lib/gitlab/sherlock/line_profiler_spec.rb index 39c6b2a48445da4d396f758cbc507f1b390d156a..d57627bba2b4ab885d793a8313067fae8e21b816 100644 --- a/spec/lib/gitlab/sherlock/line_profiler_spec.rb +++ b/spec/lib/gitlab/sherlock/line_profiler_spec.rb @@ -20,9 +20,9 @@ describe Gitlab::Sherlock::LineProfiler, lib: true do describe '#profile_mri' do it 'returns an Array containing the return value and profiling samples' do - allow(profiler).to receive(:lineprof) - .and_yield - .and_return({ __FILE__ => [[0, 0, 0, 0]] }) + allow(profiler).to receive(:lineprof). + and_yield. + and_return({ __FILE__ => [[0, 0, 0, 0]] }) retval, samples = profiler.profile_mri { 42 } diff --git a/spec/lib/gitlab/sherlock/middleware_spec.rb b/spec/lib/gitlab/sherlock/middleware_spec.rb index b98ab0b14a2abe3a69a665d3a2e9c947a26b15a8..2bbeb25ce98341bbaa68d16b9615f9e89c557ac4 100644 --- a/spec/lib/gitlab/sherlock/middleware_spec.rb +++ b/spec/lib/gitlab/sherlock/middleware_spec.rb @@ -72,8 +72,8 @@ describe Gitlab::Sherlock::Middleware, lib: true do 'REQUEST_URI' => '/cats' } - expect(middleware.transaction_from_env(env)) - .to be_an_instance_of(Gitlab::Sherlock::Transaction) + expect(middleware.transaction_from_env(env)). + to be_an_instance_of(Gitlab::Sherlock::Transaction) end end end diff --git a/spec/lib/gitlab/sherlock/query_spec.rb b/spec/lib/gitlab/sherlock/query_spec.rb index d97b5eef573930d5288834827b1cd4e807dd5d5c..0a62042813883267a2952d42897be0ccea68d868 100644 --- a/spec/lib/gitlab/sherlock/query_spec.rb +++ b/spec/lib/gitlab/sherlock/query_spec.rb @@ -13,8 +13,8 @@ describe Gitlab::Sherlock::Query, lib: true do sql = 'SELECT COUNT(*) FROM users WHERE id = $1' bindings = [[double(:column), 10]] - query = described_class - .new_with_bindings(sql, bindings, started_at, finished_at) + query = described_class. + new_with_bindings(sql, bindings, started_at, finished_at) expect(query.query).to eq('SELECT COUNT(*) FROM users WHERE id = 10;') end diff --git a/spec/lib/gitlab/sherlock/transaction_spec.rb b/spec/lib/gitlab/sherlock/transaction_spec.rb index 6ae1aa20ea720d12ad1d53e28d38a68b5f555e6d..9fe18f253f0bc3dea82f887f6cc7bf1769c87b9a 100644 --- a/spec/lib/gitlab/sherlock/transaction_spec.rb +++ b/spec/lib/gitlab/sherlock/transaction_spec.rb @@ -109,8 +109,8 @@ describe Gitlab::Sherlock::Transaction, lib: true do query1 = Gitlab::Sherlock::Query.new('SELECT 1', start_time, start_time) - query2 = Gitlab::Sherlock::Query - .new('SELECT 2', start_time, start_time + 5) + query2 = Gitlab::Sherlock::Query. + new('SELECT 2', start_time, start_time + 5) transaction.queries << query1 transaction.queries << query2 @@ -162,11 +162,11 @@ describe Gitlab::Sherlock::Transaction, lib: true do describe '#profile_lines' do describe 'when line profiling is enabled' do it 'yields the block using the line profiler' do - allow(Gitlab::Sherlock).to receive(:enable_line_profiler?) - .and_return(true) + allow(Gitlab::Sherlock).to receive(:enable_line_profiler?). + and_return(true) - allow_any_instance_of(Gitlab::Sherlock::LineProfiler) - .to receive(:profile).and_return('cats are amazing', []) + allow_any_instance_of(Gitlab::Sherlock::LineProfiler). + to receive(:profile).and_return('cats are amazing', []) retval = transaction.profile_lines { 'cats are amazing' } @@ -176,8 +176,8 @@ describe Gitlab::Sherlock::Transaction, lib: true do describe 'when line profiling is disabled' do it 'yields the block' do - allow(Gitlab::Sherlock).to receive(:enable_line_profiler?) - .and_return(false) + allow(Gitlab::Sherlock).to receive(:enable_line_profiler?). + and_return(false) retval = transaction.profile_lines { 'cats are amazing' } @@ -196,8 +196,8 @@ describe Gitlab::Sherlock::Transaction, lib: true do end it 'tracks executed queries' do - expect(transaction).to receive(:track_query) - .with('SELECT 1', [], time, time) + expect(transaction).to receive(:track_query). + with('SELECT 1', [], time, time) subscription.publish('test', time, time, nil, query_data) end @@ -205,8 +205,8 @@ describe Gitlab::Sherlock::Transaction, lib: true do it 'only tracks queries triggered from the transaction thread' do expect(transaction).not_to receive(:track_query) - Thread.new { subscription.publish('test', time, time, nil, query_data) } - .join + Thread.new { subscription.publish('test', time, time, nil, query_data) }. + join end end @@ -228,8 +228,8 @@ describe Gitlab::Sherlock::Transaction, lib: true do it 'only tracks views rendered from the transaction thread' do expect(transaction).not_to receive(:track_view) - Thread.new { subscription.publish('test', time, time, nil, view_data) } - .join + Thread.new { subscription.publish('test', time, time, nil, view_data) }. + join end end end diff --git a/spec/lib/gitlab/sidekiq_status/client_middleware_spec.rb b/spec/lib/gitlab/sidekiq_status/client_middleware_spec.rb index 5faa5597aa5fa587c779ce419738f5b91fcd0259..287bf62d9bdca1f4e900491a7375bf807025f721 100644 --- a/spec/lib/gitlab/sidekiq_status/client_middleware_spec.rb +++ b/spec/lib/gitlab/sidekiq_status/client_middleware_spec.rb @@ -5,8 +5,8 @@ describe Gitlab::SidekiqStatus::ClientMiddleware do it 'tracks the job in Redis' do expect(Gitlab::SidekiqStatus).to receive(:set).with('123') - described_class.new - .call('Foo', { 'jid' => '123' }, double(:queue), double(:pool)) { nil } + described_class.new. + call('Foo', { 'jid' => '123' }, double(:queue), double(:pool)) { nil } end end end diff --git a/spec/lib/gitlab/sidekiq_status/server_middleware_spec.rb b/spec/lib/gitlab/sidekiq_status/server_middleware_spec.rb index 04e09d3dec81befa74414ae974c055f5aa823f73..80728197b8cf313fe960f880ca69f498a7499f12 100644 --- a/spec/lib/gitlab/sidekiq_status/server_middleware_spec.rb +++ b/spec/lib/gitlab/sidekiq_status/server_middleware_spec.rb @@ -5,8 +5,8 @@ describe Gitlab::SidekiqStatus::ServerMiddleware do it 'stops tracking of a job upon completion' do expect(Gitlab::SidekiqStatus).to receive(:unset).with('123') - ret = described_class.new - .call(double(:worker), { 'jid' => '123' }, double(:queue)) { 10 } + ret = described_class.new. + call(double(:worker), { 'jid' => '123' }, double(:queue)) { 10 } expect(ret).to eq(10) end diff --git a/spec/lib/gitlab/url_builder_spec.rb b/spec/lib/gitlab/url_builder_spec.rb index 027d832308cda8d45d6270d3f899bb589dea9897..3fe8cf43934d0e988ea475515c52ce4c74a4ea4e 100644 --- a/spec/lib/gitlab/url_builder_spec.rb +++ b/spec/lib/gitlab/url_builder_spec.rb @@ -101,8 +101,8 @@ describe Gitlab::UrlBuilder, lib: true do it 'returns a proper URL' do project = build_stubbed(:empty_project) - expect { described_class.build(project) } - .to raise_error(NotImplementedError, 'No URL builder defined for Project') + expect { described_class.build(project) }. + to raise_error(NotImplementedError, 'No URL builder defined for Project') end end end diff --git a/spec/lib/gitlab/view/presenter/delegated_spec.rb b/spec/lib/gitlab/view/presenter/delegated_spec.rb index 940a2ce6ebd9fa7d5894b15c88acb7fcb360c0df..e9d4af54389aac41a73237ea89b0b9d3709265b6 100644 --- a/spec/lib/gitlab/view/presenter/delegated_spec.rb +++ b/spec/lib/gitlab/view/presenter/delegated_spec.rb @@ -18,8 +18,8 @@ describe Gitlab::View::Presenter::Delegated do end it 'raise an error if the presentee already respond to method' do - expect { presenter_class.new(project, user: 'Jane Doe') } - .to raise_error Gitlab::View::Presenter::CannotOverrideMethodError + expect { presenter_class.new(project, user: 'Jane Doe') }. + to raise_error Gitlab::View::Presenter::CannotOverrideMethodError end end diff --git a/spec/lib/light_url_builder_spec.rb b/spec/lib/light_url_builder_spec.rb index 027d832308cda8d45d6270d3f899bb589dea9897..3fe8cf43934d0e988ea475515c52ce4c74a4ea4e 100644 --- a/spec/lib/light_url_builder_spec.rb +++ b/spec/lib/light_url_builder_spec.rb @@ -101,8 +101,8 @@ describe Gitlab::UrlBuilder, lib: true do it 'returns a proper URL' do project = build_stubbed(:empty_project) - expect { described_class.build(project) } - .to raise_error(NotImplementedError, 'No URL builder defined for Project') + expect { described_class.build(project) }. + to raise_error(NotImplementedError, 'No URL builder defined for Project') end end end diff --git a/spec/lib/mattermost/command_spec.rb b/spec/lib/mattermost/command_spec.rb index 369e7b181b9cc7d237f826e16e429d1667f067d2..4b5938edeb9a6f681083933eed36efdaf18e7895 100644 --- a/spec/lib/mattermost/command_spec.rb +++ b/spec/lib/mattermost/command_spec.rb @@ -6,8 +6,8 @@ describe Mattermost::Command do before do Mattermost::Session.base_uri('http://mattermost.example.com') - allow_any_instance_of(Mattermost::Client).to receive(:with_session) - .and_yield(Mattermost::Session.new(nil)) + allow_any_instance_of(Mattermost::Client).to receive(:with_session). + and_yield(Mattermost::Session.new(nil)) end describe '#create' do @@ -20,12 +20,12 @@ describe Mattermost::Command do context 'for valid trigger word' do before do - stub_request(:post, 'http://mattermost.example.com/api/v3/teams/abc/commands/create') - .with(body: { + stub_request(:post, 'http://mattermost.example.com/api/v3/teams/abc/commands/create'). + with(body: { team_id: 'abc', trigger: 'gitlab' - }.to_json) - .to_return( + }.to_json). + to_return( status: 200, headers: { 'Content-Type' => 'application/json' }, body: { token: 'token' }.to_json @@ -39,8 +39,8 @@ describe Mattermost::Command do context 'for error message' do before do - stub_request(:post, 'http://mattermost.example.com/api/v3/teams/abc/commands/create') - .to_return( + stub_request(:post, 'http://mattermost.example.com/api/v3/teams/abc/commands/create'). + to_return( status: 500, headers: { 'Content-Type' => 'application/json' }, body: { diff --git a/spec/lib/mattermost/session_spec.rb b/spec/lib/mattermost/session_spec.rb index be3908e8f6ab4b33fe9018e27ce27a7fe2e593b2..74d12e3718105f58afdc828b83a3196220d4c0fd 100644 --- a/spec/lib/mattermost/session_spec.rb +++ b/spec/lib/mattermost/session_spec.rb @@ -21,8 +21,8 @@ describe Mattermost::Session, type: :request do describe '#with session' do let(:location) { 'http://location.tld' } let!(:stub) do - WebMock.stub_request(:get, "#{mattermost_url}/api/v3/oauth/gitlab/login") - .to_return(headers: { 'location' => location }, status: 307) + WebMock.stub_request(:get, "#{mattermost_url}/api/v3/oauth/gitlab/login"). + to_return(headers: { 'location' => location }, status: 307) end context 'without oauth uri' do @@ -60,9 +60,9 @@ describe Mattermost::Session, type: :request do end before do - WebMock.stub_request(:get, "#{mattermost_url}/signup/gitlab/complete") - .with(query: hash_including({ 'state' => state })) - .to_return do |request| + WebMock.stub_request(:get, "#{mattermost_url}/signup/gitlab/complete"). + with(query: hash_including({ 'state' => state })). + to_return do |request| post "/oauth/token", client_id: doorkeeper.uid, client_secret: doorkeeper.secret, @@ -75,8 +75,8 @@ describe Mattermost::Session, type: :request do end end - WebMock.stub_request(:post, "#{mattermost_url}/api/v3/users/logout") - .to_return(headers: { Authorization: 'token thisworksnow' }, status: 200) + WebMock.stub_request(:post, "#{mattermost_url}/api/v3/users/logout"). + to_return(headers: { Authorization: 'token thisworksnow' }, status: 200) end it 'can setup a session' do diff --git a/spec/lib/mattermost/team_spec.rb b/spec/lib/mattermost/team_spec.rb index 339178954eaed85f182afb0aebf23003db9b74fa..6a9c7cebffffbf02cd3ccc634711ca774d205f78 100644 --- a/spec/lib/mattermost/team_spec.rb +++ b/spec/lib/mattermost/team_spec.rb @@ -4,8 +4,8 @@ describe Mattermost::Team do before do Mattermost::Session.base_uri('http://mattermost.example.com') - allow_any_instance_of(Mattermost::Client).to receive(:with_session) - .and_yield(Mattermost::Session.new(nil)) + allow_any_instance_of(Mattermost::Client).to receive(:with_session). + and_yield(Mattermost::Session.new(nil)) end describe '#all' do @@ -30,8 +30,8 @@ describe Mattermost::Team do end before do - stub_request(:get, 'http://mattermost.example.com/api/v3/teams/all') - .to_return( + stub_request(:get, 'http://mattermost.example.com/api/v3/teams/all'). + to_return( status: 200, headers: { 'Content-Type' => 'application/json' }, body: response.to_json @@ -45,8 +45,8 @@ describe Mattermost::Team do context 'for error message' do before do - stub_request(:get, 'http://mattermost.example.com/api/v3/teams/all') - .to_return( + stub_request(:get, 'http://mattermost.example.com/api/v3/teams/all'). + to_return( status: 500, headers: { 'Content-Type' => 'application/json' }, body: { diff --git a/spec/mailers/abuse_report_mailer_spec.rb b/spec/mailers/abuse_report_mailer_spec.rb index bda892083b377febc277987dd6bf2221379ff9c5..eb433c38873e7279d498c0841438e68f04f7f7ce 100644 --- a/spec/mailers/abuse_report_mailer_spec.rb +++ b/spec/mailers/abuse_report_mailer_spec.rb @@ -30,8 +30,8 @@ describe AbuseReportMailer do it 'returns early' do stub_application_setting(admin_notification_email: nil) - expect { described_class.notify(spy).deliver_now } - .not_to change { ActionMailer::Base.deliveries.count } + expect { described_class.notify(spy).deliver_now }. + not_to change { ActionMailer::Base.deliveries.count } end end end diff --git a/spec/migrations/migrate_process_commit_worker_jobs_spec.rb b/spec/migrations/migrate_process_commit_worker_jobs_spec.rb index 1cbaa90151f7af5be2205ebf1794ad97f1cd8dc5..b6d678bac18db20e65c84d62d5b6a7b59cee8faf 100644 --- a/spec/migrations/migrate_process_commit_worker_jobs_spec.rb +++ b/spec/migrations/migrate_process_commit_worker_jobs_spec.rb @@ -11,33 +11,33 @@ describe MigrateProcessCommitWorkerJobs do describe 'Project' do describe 'find_including_path' do it 'returns Project instances' do - expect(described_class::Project.find_including_path(project.id)) - .to be_an_instance_of(described_class::Project) + expect(described_class::Project.find_including_path(project.id)). + to be_an_instance_of(described_class::Project) end it 'selects the full path for every Project' do - migration_project = described_class::Project - .find_including_path(project.id) + migration_project = described_class::Project. + find_including_path(project.id) - expect(migration_project[:path_with_namespace]) - .to eq(project.path_with_namespace) + expect(migration_project[:path_with_namespace]). + to eq(project.path_with_namespace) end end describe '#repository_storage_path' do it 'returns the storage path for the repository' do - migration_project = described_class::Project - .find_including_path(project.id) + migration_project = described_class::Project. + find_including_path(project.id) - expect(File.directory?(migration_project.repository_storage_path)) - .to eq(true) + expect(File.directory?(migration_project.repository_storage_path)). + to eq(true) end end describe '#repository_path' do it 'returns the path to the repository' do - migration_project = described_class::Project - .find_including_path(project.id) + migration_project = described_class::Project. + find_including_path(project.id) expect(File.directory?(migration_project.repository_path)).to eq(true) end @@ -45,11 +45,11 @@ describe MigrateProcessCommitWorkerJobs do describe '#repository' do it 'returns a Rugged::Repository' do - migration_project = described_class::Project - .find_including_path(project.id) + migration_project = described_class::Project. + find_including_path(project.id) - expect(migration_project.repository) - .to be_an_instance_of(Rugged::Repository) + expect(migration_project.repository). + to be_an_instance_of(Rugged::Repository) end end end @@ -73,9 +73,9 @@ describe MigrateProcessCommitWorkerJobs do end it 'skips jobs using a project that no longer exists' do - allow(described_class::Project).to receive(:find_including_path) - .with(project.id) - .and_return(nil) + allow(described_class::Project).to receive(:find_including_path). + with(project.id). + and_return(nil) migration.up @@ -83,9 +83,9 @@ describe MigrateProcessCommitWorkerJobs do end it 'skips jobs using commits that no longer exist' do - allow_any_instance_of(Rugged::Repository).to receive(:lookup) - .with(commit.oid) - .and_raise(Rugged::OdbError) + allow_any_instance_of(Rugged::Repository).to receive(:lookup). + with(commit.oid). + and_raise(Rugged::OdbError) migration.up @@ -99,12 +99,12 @@ describe MigrateProcessCommitWorkerJobs do end it 'encodes data to UTF-8' do - allow_any_instance_of(Rugged::Repository).to receive(:lookup) - .with(commit.oid) - .and_return(commit) + allow_any_instance_of(Rugged::Repository).to receive(:lookup). + with(commit.oid). + and_return(commit) - allow(commit).to receive(:message) - .and_return('김치'.force_encoding('BINARY')) + allow(commit).to receive(:message). + and_return('김치'.force_encoding('BINARY')) migration.up diff --git a/spec/models/ability_spec.rb b/spec/models/ability_spec.rb index c34e58afaaf5c039744bd579f4f825040eebf4e2..30f8fdf91b2204a686b1b7e3d4ef71eb61ac6ea8 100644 --- a/spec/models/ability_spec.rb +++ b/spec/models/ability_spec.rb @@ -63,8 +63,8 @@ describe Ability, lib: true do project = create(:empty_project, :public) user = build(:user) - expect(described_class.users_that_can_read_project([user], project)) - .to eq([user]) + expect(described_class.users_that_can_read_project([user], project)). + to eq([user]) end end @@ -74,8 +74,8 @@ describe Ability, lib: true do it 'returns users that are administrators' do user = build(:user, admin: true) - expect(described_class.users_that_can_read_project([user], project)) - .to eq([user]) + expect(described_class.users_that_can_read_project([user], project)). + to eq([user]) end it 'returns internal users while skipping external users' do @@ -83,8 +83,8 @@ describe Ability, lib: true do user2 = build(:user, external: true) users = [user1, user2] - expect(described_class.users_that_can_read_project(users, project)) - .to eq([user1]) + expect(described_class.users_that_can_read_project(users, project)). + to eq([user1]) end it 'returns external users if they are the project owner' do @@ -94,8 +94,8 @@ describe Ability, lib: true do expect(project).to receive(:owner).twice.and_return(user1) - expect(described_class.users_that_can_read_project(users, project)) - .to eq([user1]) + expect(described_class.users_that_can_read_project(users, project)). + to eq([user1]) end it 'returns external users if they are project members' do @@ -105,8 +105,8 @@ describe Ability, lib: true do expect(project.team).to receive(:members).twice.and_return([user1]) - expect(described_class.users_that_can_read_project(users, project)) - .to eq([user1]) + expect(described_class.users_that_can_read_project(users, project)). + to eq([user1]) end it 'returns an empty Array if all users are external users without access' do @@ -114,8 +114,8 @@ describe Ability, lib: true do user2 = build(:user, external: true) users = [user1, user2] - expect(described_class.users_that_can_read_project(users, project)) - .to eq([]) + expect(described_class.users_that_can_read_project(users, project)). + to eq([]) end end @@ -125,8 +125,8 @@ describe Ability, lib: true do it 'returns users that are administrators' do user = build(:user, admin: true) - expect(described_class.users_that_can_read_project([user], project)) - .to eq([user]) + expect(described_class.users_that_can_read_project([user], project)). + to eq([user]) end it 'returns external users if they are the project owner' do @@ -136,8 +136,8 @@ describe Ability, lib: true do expect(project).to receive(:owner).twice.and_return(user1) - expect(described_class.users_that_can_read_project(users, project)) - .to eq([user1]) + expect(described_class.users_that_can_read_project(users, project)). + to eq([user1]) end it 'returns external users if they are project members' do @@ -147,8 +147,8 @@ describe Ability, lib: true do expect(project.team).to receive(:members).twice.and_return([user1]) - expect(described_class.users_that_can_read_project(users, project)) - .to eq([user1]) + expect(described_class.users_that_can_read_project(users, project)). + to eq([user1]) end it 'returns an empty Array if all users are internal users without access' do @@ -156,8 +156,8 @@ describe Ability, lib: true do user2 = build(:user) users = [user1, user2] - expect(described_class.users_that_can_read_project(users, project)) - .to eq([]) + expect(described_class.users_that_can_read_project(users, project)). + to eq([]) end it 'returns an empty Array if all users are external users without access' do @@ -165,8 +165,8 @@ describe Ability, lib: true do user2 = build(:user, external: true) users = [user1, user2] - expect(described_class.users_that_can_read_project(users, project)) - .to eq([]) + expect(described_class.users_that_can_read_project(users, project)). + to eq([]) end end end @@ -204,8 +204,8 @@ describe Ability, lib: true do user = build(:user, admin: true) issue = build(:issue) - expect(described_class.issues_readable_by_user([issue], user)) - .to eq([issue]) + expect(described_class.issues_readable_by_user([issue], user)). + to eq([issue]) end end @@ -216,8 +216,8 @@ describe Ability, lib: true do expect(issue).to receive(:readable_by?).with(user).and_return(true) - expect(described_class.issues_readable_by_user([issue], user)) - .to eq([issue]) + expect(described_class.issues_readable_by_user([issue], user)). + to eq([issue]) end it 'returns an empty Array when no issues are readable' do @@ -238,8 +238,8 @@ describe Ability, lib: true do expect(hidden_issue).to receive(:publicly_visible?).and_return(false) expect(visible_issue).to receive(:publicly_visible?).and_return(true) - issues = described_class - .issues_readable_by_user([hidden_issue, visible_issue]) + issues = described_class. + issues_readable_by_user([hidden_issue, visible_issue]) expect(issues).to eq([visible_issue]) end diff --git a/spec/models/abuse_report_spec.rb b/spec/models/abuse_report_spec.rb index d26e491e548bcfc45e205bd82bbbe53aa351be75..c4486a3208266126637380e4bc1dbd930c32033b 100644 --- a/spec/models/abuse_report_spec.rb +++ b/spec/models/abuse_report_spec.rb @@ -37,8 +37,8 @@ RSpec.describe AbuseReport, type: :model do describe '#notify' do it 'delivers' do - expect(AbuseReportMailer).to receive(:notify).with(subject.id) - .and_return(spy) + expect(AbuseReportMailer).to receive(:notify).with(subject.id). + and_return(spy) subject.notify end diff --git a/spec/models/application_setting_spec.rb b/spec/models/application_setting_spec.rb index 4086e00e363f6bbab344a056defc616f0600c1d8..8688639168b74d690766e6214e777b91ee92941b 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 355b8bf3af81aca7c81fedff6243cf232bf17b88..a173e3aeff6706e4d11cb5af3db465a425c03b1e 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 @@ -784,8 +784,8 @@ describe Ci::Build, :models do pipeline2 = create(:ci_pipeline, project: project) @build2 = create(:ci_build, pipeline: pipeline2) - allow(@merge_request).to receive(:commits_sha) - .and_return([pipeline.sha, pipeline2.sha]) + allow(@merge_request).to receive(:commits_sha). + and_return([pipeline.sha, pipeline2.sha]) allow(MergeRequest).to receive_message_chain(:includes, :where, :reorder).and_return([@merge_request]) 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/ci/pipeline_spec.rb b/spec/models/ci/pipeline_spec.rb index 9eff58880e3ac3c470885d27f55940c541f0b062..c2fc8c02bb3f69ce5dc3718ab0eb0f6ffd3b579f 100644 --- a/spec/models/ci/pipeline_spec.rb +++ b/spec/models/ci/pipeline_spec.rb @@ -455,8 +455,8 @@ describe Ci::Pipeline, models: true do it 'returns the latest pipeline for the same ref and different sha' do expect(pipelines.map(&:sha)).to contain_exactly('A', 'B', 'C') - expect(pipelines.map(&:status)) - .to contain_exactly('success', 'failed', 'skipped') + expect(pipelines.map(&:status)). + to contain_exactly('success', 'failed', 'skipped') end end @@ -465,8 +465,8 @@ describe Ci::Pipeline, models: true do it 'returns the latest pipeline for ref and different sha' do expect(pipelines.map(&:sha)).to contain_exactly('A', 'B') - expect(pipelines.map(&:status)) - .to contain_exactly('success', 'failed') + expect(pipelines.map(&:status)). + to contain_exactly('success', 'failed') end end end @@ -501,8 +501,8 @@ describe Ci::Pipeline, models: true do end it 'returns the latest successful pipeline' do - expect(described_class.latest_successful_for('ref')) - .to eq(latest_successful_pipeline) + expect(described_class.latest_successful_for('ref')). + to eq(latest_successful_pipeline) end end diff --git a/spec/models/ci/variable_spec.rb b/spec/models/ci/variable_spec.rb index 674c52eecb2c57db7a35aca6a86aa1bf11fc8948..bee9f7148497e91c2e59ff3f3b84f99cb208fc20 100644 --- a/spec/models/ci/variable_spec.rb +++ b/spec/models/ci/variable_spec.rb @@ -32,8 +32,8 @@ describe Ci::Variable, models: true do it 'fails to decrypt if iv is incorrect' do subject.encrypted_value_iv = SecureRandom.hex subject.instance_variable_set(:@value, nil) - expect { subject.value } - .to raise_error(OpenSSL::Cipher::CipherError, 'bad decrypt') + expect { subject.value }. + to raise_error(OpenSSL::Cipher::CipherError, 'bad decrypt') end end end diff --git a/spec/models/commit_range_spec.rb b/spec/models/commit_range_spec.rb index ba9c3f66d213a196dcfb8924d5b8a69d2aca60d9..e4bddf670964e5101629134fe607cf36b4cecc49 100644 --- a/spec/models/commit_range_spec.rb +++ b/spec/models/commit_range_spec.rb @@ -147,9 +147,9 @@ describe CommitRange, models: true do note: commit1.revert_description(user), project: issue.project) - expect_any_instance_of(Commit).to receive(:reverts_commit?) - .with(commit1, user) - .and_return(true) + expect_any_instance_of(Commit).to receive(:reverts_commit?). + with(commit1, user). + and_return(true) expect(commit1.has_been_reverted?(user, issue)).to eq(true) end diff --git a/spec/models/commit_status_spec.rb b/spec/models/commit_status_spec.rb index 36533bdd11e32103c0bfcabafee19eac4fec896a..f770e6a9e34aeb86e845fada713a1b1bfea7232d 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/concerns/case_sensitivity_spec.rb b/spec/models/concerns/case_sensitivity_spec.rb index a6fccb668e3a8762a378a3a9eeb2070d82b1ab71..92fdc5cd65da4008f691869bdbd8ea87649dc077 100644 --- a/spec/models/concerns/case_sensitivity_spec.rb +++ b/spec/models/concerns/case_sensitivity_spec.rb @@ -15,13 +15,13 @@ describe CaseSensitivity, models: true do it 'returns the criteria for a column and a value' do criteria = double(:criteria) - expect(connection).to receive(:quote_table_name) - .with(:foo) - .and_return('"foo"') + expect(connection).to receive(:quote_table_name). + with(:foo). + and_return('"foo"') - expect(model).to receive(:where) - .with(%q{LOWER("foo") = LOWER(:value)}, value: 'bar') - .and_return(criteria) + expect(model).to receive(:where). + with(%q{LOWER("foo") = LOWER(:value)}, value: 'bar'). + and_return(criteria) expect(model.iwhere(foo: 'bar')).to eq(criteria) end @@ -29,13 +29,13 @@ describe CaseSensitivity, models: true do it 'returns the criteria for a column with a table, and a value' do criteria = double(:criteria) - expect(connection).to receive(:quote_table_name) - .with(:'foo.bar') - .and_return('"foo"."bar"') + expect(connection).to receive(:quote_table_name). + with(:'foo.bar'). + and_return('"foo"."bar"') - expect(model).to receive(:where) - .with(%q{LOWER("foo"."bar") = LOWER(:value)}, value: 'bar') - .and_return(criteria) + expect(model).to receive(:where). + with(%q{LOWER("foo"."bar") = LOWER(:value)}, value: 'bar'). + and_return(criteria) expect(model.iwhere('foo.bar'.to_sym => 'bar')).to eq(criteria) end @@ -46,21 +46,21 @@ describe CaseSensitivity, models: true do initial = double(:criteria) final = double(:criteria) - expect(connection).to receive(:quote_table_name) - .with(:foo) - .and_return('"foo"') + expect(connection).to receive(:quote_table_name). + with(:foo). + and_return('"foo"') - expect(connection).to receive(:quote_table_name) - .with(:bar) - .and_return('"bar"') + expect(connection).to receive(:quote_table_name). + with(:bar). + and_return('"bar"') - expect(model).to receive(:where) - .with(%q{LOWER("foo") = LOWER(:value)}, value: 'bar') - .and_return(initial) + expect(model).to receive(:where). + with(%q{LOWER("foo") = LOWER(:value)}, value: 'bar'). + and_return(initial) - expect(initial).to receive(:where) - .with(%q{LOWER("bar") = LOWER(:value)}, value: 'baz') - .and_return(final) + expect(initial).to receive(:where). + with(%q{LOWER("bar") = LOWER(:value)}, value: 'baz'). + and_return(final) got = model.iwhere(foo: 'bar', bar: 'baz') @@ -71,21 +71,21 @@ describe CaseSensitivity, models: true do initial = double(:criteria) final = double(:criteria) - expect(connection).to receive(:quote_table_name) - .with(:'foo.bar') - .and_return('"foo"."bar"') + expect(connection).to receive(:quote_table_name). + with(:'foo.bar'). + and_return('"foo"."bar"') - expect(connection).to receive(:quote_table_name) - .with(:'foo.baz') - .and_return('"foo"."baz"') + expect(connection).to receive(:quote_table_name). + with(:'foo.baz'). + and_return('"foo"."baz"') - expect(model).to receive(:where) - .with(%q{LOWER("foo"."bar") = LOWER(:value)}, value: 'bar') - .and_return(initial) + expect(model).to receive(:where). + with(%q{LOWER("foo"."bar") = LOWER(:value)}, value: 'bar'). + and_return(initial) - expect(initial).to receive(:where) - .with(%q{LOWER("foo"."baz") = LOWER(:value)}, value: 'baz') - .and_return(final) + expect(initial).to receive(:where). + with(%q{LOWER("foo"."baz") = LOWER(:value)}, value: 'baz'). + and_return(final) got = model.iwhere('foo.bar'.to_sym => 'bar', 'foo.baz'.to_sym => 'baz') @@ -105,13 +105,13 @@ describe CaseSensitivity, models: true do it 'returns the criteria for a column and a value' do criteria = double(:criteria) - expect(connection).to receive(:quote_table_name) - .with(:foo) - .and_return('`foo`') + expect(connection).to receive(:quote_table_name). + with(:foo). + and_return('`foo`') - expect(model).to receive(:where) - .with(%q{`foo` = :value}, value: 'bar') - .and_return(criteria) + expect(model).to receive(:where). + with(%q{`foo` = :value}, value: 'bar'). + and_return(criteria) expect(model.iwhere(foo: 'bar')).to eq(criteria) end @@ -119,16 +119,16 @@ describe CaseSensitivity, models: true do it 'returns the criteria for a column with a table, and a value' do criteria = double(:criteria) - expect(connection).to receive(:quote_table_name) - .with(:'foo.bar') - .and_return('`foo`.`bar`') + expect(connection).to receive(:quote_table_name). + with(:'foo.bar'). + and_return('`foo`.`bar`') - expect(model).to receive(:where) - .with(%q{`foo`.`bar` = :value}, value: 'bar') - .and_return(criteria) + expect(model).to receive(:where). + with(%q{`foo`.`bar` = :value}, value: 'bar'). + and_return(criteria) - expect(model.iwhere('foo.bar'.to_sym => 'bar')) - .to eq(criteria) + expect(model.iwhere('foo.bar'.to_sym => 'bar')). + to eq(criteria) end end @@ -137,21 +137,21 @@ describe CaseSensitivity, models: true do initial = double(:criteria) final = double(:criteria) - expect(connection).to receive(:quote_table_name) - .with(:foo) - .and_return('`foo`') + expect(connection).to receive(:quote_table_name). + with(:foo). + and_return('`foo`') - expect(connection).to receive(:quote_table_name) - .with(:bar) - .and_return('`bar`') + expect(connection).to receive(:quote_table_name). + with(:bar). + and_return('`bar`') - expect(model).to receive(:where) - .with(%q{`foo` = :value}, value: 'bar') - .and_return(initial) + expect(model).to receive(:where). + with(%q{`foo` = :value}, value: 'bar'). + and_return(initial) - expect(initial).to receive(:where) - .with(%q{`bar` = :value}, value: 'baz') - .and_return(final) + expect(initial).to receive(:where). + with(%q{`bar` = :value}, value: 'baz'). + and_return(final) got = model.iwhere(foo: 'bar', bar: 'baz') @@ -162,21 +162,21 @@ describe CaseSensitivity, models: true do initial = double(:criteria) final = double(:criteria) - expect(connection).to receive(:quote_table_name) - .with(:'foo.bar') - .and_return('`foo`.`bar`') + expect(connection).to receive(:quote_table_name). + with(:'foo.bar'). + and_return('`foo`.`bar`') - expect(connection).to receive(:quote_table_name) - .with(:'foo.baz') - .and_return('`foo`.`baz`') + expect(connection).to receive(:quote_table_name). + with(:'foo.baz'). + and_return('`foo`.`baz`') - expect(model).to receive(:where) - .with(%q{`foo`.`bar` = :value}, value: 'bar') - .and_return(initial) + expect(model).to receive(:where). + with(%q{`foo`.`bar` = :value}, value: 'bar'). + and_return(initial) - expect(initial).to receive(:where) - .with(%q{`foo`.`baz` = :value}, value: 'baz') - .and_return(final) + expect(initial).to receive(:where). + with(%q{`foo`.`baz` = :value}, value: 'baz'). + and_return(final) got = model.iwhere('foo.bar'.to_sym => 'bar', 'foo.baz'.to_sym => 'baz') diff --git a/spec/models/concerns/has_status_spec.rb b/spec/models/concerns/has_status_spec.rb index e61071973685e856bf2a5a4fccf4f5e9db4dbba2..dbfe3cd2d3631e16d6676c5bf10a733a78b1f9cf 100644 --- a/spec/models/concerns/has_status_spec.rb +++ b/spec/models/concerns/has_status_spec.rb @@ -132,8 +132,8 @@ describe HasStatus do describe ".#{status}" do it 'contains the job' do - expect(CommitStatus.public_send(status).all) - .to contain_exactly(job) + expect(CommitStatus.public_send(status).all). + to contain_exactly(job) end end diff --git a/spec/models/concerns/issuable_spec.rb b/spec/models/concerns/issuable_spec.rb index a372824b6e5d015b2e20c83e73804829e7a1b61b..545a11912e37c0805fa6165a03fbd5048905849f 100644 --- a/spec/models/concerns/issuable_spec.rb +++ b/spec/models/concerns/issuable_spec.rb @@ -87,8 +87,8 @@ describe Issue, "Issuable" do let!(:searchable_issue) { create(:issue, title: "Searchable issue") } it 'returns notes with a matching title' do - expect(described_class.search(searchable_issue.title)) - .to eq([searchable_issue]) + expect(described_class.search(searchable_issue.title)). + to eq([searchable_issue]) end it 'returns notes with a partially matching title' do @@ -96,8 +96,8 @@ describe Issue, "Issuable" do end it 'returns notes with a matching title regardless of the casing' do - expect(described_class.search(searchable_issue.title.upcase)) - .to eq([searchable_issue]) + expect(described_class.search(searchable_issue.title.upcase)). + to eq([searchable_issue]) end end @@ -107,8 +107,8 @@ describe Issue, "Issuable" do end it 'returns notes with a matching title' do - expect(described_class.full_search(searchable_issue.title)) - .to eq([searchable_issue]) + expect(described_class.full_search(searchable_issue.title)). + to eq([searchable_issue]) end it 'returns notes with a partially matching title' do @@ -116,23 +116,23 @@ describe Issue, "Issuable" do end it 'returns notes with a matching title regardless of the casing' do - expect(described_class.full_search(searchable_issue.title.upcase)) - .to eq([searchable_issue]) + expect(described_class.full_search(searchable_issue.title.upcase)). + to eq([searchable_issue]) end it 'returns notes with a matching description' do - expect(described_class.full_search(searchable_issue.description)) - .to eq([searchable_issue]) + expect(described_class.full_search(searchable_issue.description)). + to eq([searchable_issue]) end it 'returns notes with a partially matching description' do - expect(described_class.full_search(searchable_issue.description)) - .to eq([searchable_issue]) + expect(described_class.full_search(searchable_issue.description)). + to eq([searchable_issue]) end it 'returns notes with a matching description regardless of the casing' do - expect(described_class.full_search(searchable_issue.description.upcase)) - .to eq([searchable_issue]) + expect(described_class.full_search(searchable_issue.description.upcase)). + to eq([searchable_issue]) end end @@ -287,16 +287,16 @@ describe Issue, "Issuable" do allow(issue).to receive(:author).and_return(double(name: 'Robert')) allow(issue).to receive(:assignee).and_return(nil) - expect(issue.card_attributes) - .to eq({ 'Author' => 'Robert', 'Assignee' => nil }) + expect(issue.card_attributes). + to eq({ 'Author' => 'Robert', 'Assignee' => nil }) end it 'includes the assignee name' do allow(issue).to receive(:author).and_return(double(name: 'Robert')) allow(issue).to receive(:assignee).and_return(double(name: 'Douwe')) - expect(issue.card_attributes) - .to eq({ 'Author' => 'Robert', 'Assignee' => 'Douwe' }) + expect(issue.card_attributes). + to eq({ 'Author' => 'Robert', 'Assignee' => 'Douwe' }) end end diff --git a/spec/models/discussion_spec.rb b/spec/models/discussion_spec.rb index 47c22a03797f1ec48eb3497a11356ed4d05a5f41..bc32fadd39173e18c80075102a7aa36d861e9abe 100644 --- a/spec/models/discussion_spec.rb +++ b/spec/models/discussion_spec.rb @@ -304,22 +304,22 @@ describe Discussion, model: true do it "doesn't change resolved_at on the resolved note" do expect(first_note.resolved_at).not_to be_nil - expect { subject.resolve!(current_user) } - .not_to change { first_note.reload.resolved_at } + expect { subject.resolve!(current_user) }. + not_to change { first_note.reload.resolved_at } end it "doesn't change resolved_by on the resolved note" do expect(first_note.resolved_by).to eq(user) - expect { subject.resolve!(current_user) } - .not_to change { first_note.reload && first_note.resolved_by } + expect { subject.resolve!(current_user) }. + not_to change { first_note.reload && first_note.resolved_by } end it "doesn't change the resolved state on the resolved note" do expect(first_note.resolved?).to be true - expect { subject.resolve!(current_user) } - .not_to change { first_note.reload && first_note.resolved? } + expect { subject.resolve!(current_user) }. + not_to change { first_note.reload && first_note.resolved? } end it "sets resolved_at on the unresolved note" do diff --git a/spec/models/email_spec.rb b/spec/models/email_spec.rb index fe4de1b2afb162b8e655f0b2e0fb59d558447ba4..4652af1cb97f4153037c34fe0e82eb5b5adf0822 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/environment_spec.rb b/spec/models/environment_spec.rb index 3198f67a041c4abf7de3ef0c6f0ecf5487120107..dce18f008f849ef90c572a83646b3c4b62a83ff2 100644 --- a/spec/models/environment_spec.rb +++ b/spec/models/environment_spec.rb @@ -284,9 +284,9 @@ describe Environment, models: true do before { allow(environment).to receive(:has_terminals?).and_return(true) } it 'returns the terminals from the deployment service' do - expect(project.deployment_service) - .to receive(:terminals).with(environment) - .and_return(:fake_terminals) + expect(project.deployment_service). + to receive(:terminals).with(environment). + and_return(:fake_terminals) is_expected.to eq(:fake_terminals) end diff --git a/spec/models/event_spec.rb b/spec/models/event_spec.rb index c5acfceb85352006a7913a24656ee660aa27ff96..8c90a538f5723d44ccae52ecbd7d8c9521b3c81d 100644 --- a/spec/models/event_spec.rb +++ b/spec/models/event_spec.rb @@ -240,8 +240,8 @@ describe Event, models: true do it 'does not update the project' do project.update(last_activity_at: Time.now) - expect(project).not_to receive(:update_column) - .with(:last_activity_at, a_kind_of(Time)) + expect(project).not_to receive(:update_column). + with(:last_activity_at, a_kind_of(Time)) create_event(project, project.owner) end diff --git a/spec/models/group_label_spec.rb b/spec/models/group_label_spec.rb index 555a876daeb6743dce2d786fb1793c679c9461be..c8d88022ec77194bf05f96eb467488aa37196af8 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/group_spec.rb b/spec/models/group_spec.rb index 57975d6c70b11c16e74f16f434f80915111163b3..a4e6eb4e3a6e3f0181a1263b73bfbba47b638aa8 100644 --- a/spec/models/group_spec.rb +++ b/spec/models/group_spec.rb @@ -309,8 +309,8 @@ describe Group, models: true do group.add_user(master, GroupMember::MASTER) group.add_user(developer, GroupMember::DEVELOPER) - expect(group.user_ids_for_project_authorizations) - .to include(master.id, developer.id) + expect(group.user_ids_for_project_authorizations). + to include(master.id, developer.id) end end end diff --git a/spec/models/issue_collection_spec.rb b/spec/models/issue_collection_spec.rb index 79584f94a4cc4d4913b27edf928a2850e17ef233..d8aed25c041f5a97d63bbdbf8dff83fdf9d02655 100644 --- a/spec/models/issue_collection_spec.rb +++ b/spec/models/issue_collection_spec.rb @@ -50,8 +50,8 @@ describe IssueCollection do context 'using a user that is the owner of a project' do it 'returns the issues of the project' do - expect(collection.updatable_by_user(project.namespace.owner)) - .to eq([issue1, issue2]) + expect(collection.updatable_by_user(project.namespace.owner)). + to eq([issue1, issue2]) end end end diff --git a/spec/models/issue_spec.rb b/spec/models/issue_spec.rb index 143e84dac9605a309ddd81bdfae4729970797144..bba9058f3941e7326c528a9d4148555a1eee665c 100644 --- a/spec/models/issue_spec.rb +++ b/spec/models/issue_spec.rb @@ -239,8 +239,8 @@ describe Issue, models: true do let(:user) { build(:admin) } before do - allow(subject.project.repository).to receive(:branch_names) - .and_return(["mpempe", "#{subject.iid}mepmep", subject.to_branch_name, "#{subject.iid}-branch"]) + allow(subject.project.repository).to receive(:branch_names). + and_return(["mpempe", "#{subject.iid}mepmep", subject.to_branch_name, "#{subject.iid}-branch"]) # Without this stub, the `create(:merge_request)` above fails because it can't find # the source branch. This seems like a reasonable compromise, in comparison with @@ -262,8 +262,8 @@ describe Issue, models: true do end it 'excludes stable branches from the related branches' do - allow(subject.project.repository).to receive(:branch_names) - .and_return(["#{subject.iid}-0-stable"]) + allow(subject.project.repository).to receive(:branch_names). + and_return(["#{subject.iid}-0-stable"]) expect(subject.related_branches(user)).to eq [] end diff --git a/spec/models/key_spec.rb b/spec/models/key_spec.rb index f5f7e82480e90d866afbe2372ccdee226f45b8a1..7c40cfd82531b9028a2ffd0f785381356584a768 100644 --- a/spec/models/key_spec.rb +++ b/spec/models/key_spec.rb @@ -34,8 +34,8 @@ describe Key, models: true do context 'when key was not updated during the last day' do before do - allow_any_instance_of(Gitlab::ExclusiveLease).to receive(:try_obtain) - .and_return('000000') + allow_any_instance_of(Gitlab::ExclusiveLease).to receive(:try_obtain). + and_return('000000') end it 'enqueues a UseKeyWorker job' do @@ -46,8 +46,8 @@ describe Key, models: true do context 'when key was updated during the last day' do before do - allow_any_instance_of(Gitlab::ExclusiveLease).to receive(:try_obtain) - .and_return(false) + allow_any_instance_of(Gitlab::ExclusiveLease).to receive(:try_obtain). + and_return(false) end it 'does not enqueue a UseKeyWorker job' do diff --git a/spec/models/lfs_objects_project_spec.rb b/spec/models/lfs_objects_project_spec.rb index 7bc278e350f6abe9953d16dbb4d8d1adf032d4dc..a2031beeab2adea029add328a08d8ba6a5430133 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/member_spec.rb b/spec/models/member_spec.rb index ec17000d17a989ed09c5a7e86bbfa9d18db76851..c720cc9f2c2e3d1e1939590ae3a601b70a79786c 100644 --- a/spec/models/member_spec.rb +++ b/spec/models/member_spec.rb @@ -83,8 +83,8 @@ describe Member, models: true do @accepted_invite_member = create(:project_member, :developer, project: project, invite_token: '1234', - invite_email: 'toto2@example.com') - .tap { |u| u.accept_invite!(accepted_invite_user) } + invite_email: 'toto2@example.com'). + tap { |u| u.accept_invite!(accepted_invite_user) } requested_user = create(:user).tap { |u| project.request_access(u) } @requested_member = project.requesters.find_by(user_id: requested_user.id) @@ -265,8 +265,8 @@ describe Member, models: true do expect(source.users).not_to include(user) expect(source.requesters.exists?(user_id: user)).to be_truthy - expect { described_class.add_user(source, user, :master) } - .to raise_error(Gitlab::Access::AccessDeniedError) + expect { described_class.add_user(source, user, :master) }. + to raise_error(Gitlab::Access::AccessDeniedError) expect(source.users.reload).not_to include(user) expect(source.requesters.reload.exists?(user_id: user)).to be_truthy diff --git a/spec/models/members/group_member_spec.rb b/spec/models/members/group_member_spec.rb index 4a8ea3b6893fe1a30d6fa8fd9f4a154a4179fc9a..370aeb9e0a920adf692e3eeb358748bdaf4422e4 100644 --- a/spec/models/members/group_member_spec.rb +++ b/spec/models/members/group_member_spec.rb @@ -33,8 +33,8 @@ describe GroupMember, models: true do it "sends email to user" do membership = build(:group_member) - allow(membership).to receive(:notification_service) - .and_return(double('NotificationService').as_null_object) + allow(membership).to receive(:notification_service). + and_return(double('NotificationService').as_null_object) expect(membership).to receive(:notification_service) membership.save @@ -44,8 +44,8 @@ describe GroupMember, models: true do describe "#after_update" do before do @group_member = create :group_member - allow(@group_member).to receive(:notification_service) - .and_return(double('NotificationService').as_null_object) + allow(@group_member).to receive(:notification_service). + and_return(double('NotificationService').as_null_object) end it "sends email to user" do diff --git a/spec/models/merge_request_diff_spec.rb b/spec/models/merge_request_diff_spec.rb index 0a10ee015062f638fc9021026fbd22fea8405515..e74e4ae0e96cb43e1c273bbb4b23c3982cf7b016 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 6a1f6cee03ff5b7ba87328d974cae04628efad1a..810c08256dcc5231b5740f6b54d7078b146f1e1d 100644 --- a/spec/models/merge_request_spec.rb +++ b/spec/models/merge_request_spec.rb @@ -270,8 +270,8 @@ describe MergeRequest, models: true do end it 'accesses the set of issues that will be closed on acceptance' do - allow(subject.project).to receive(:default_branch) - .and_return(subject.target_branch) + allow(subject.project).to receive(:default_branch). + and_return(subject.target_branch) closed = subject.closes_issues @@ -297,8 +297,8 @@ describe MergeRequest, models: true do subject.description = "Is related to #{mentioned_issue.to_reference} and #{closing_issue.to_reference}" allow(subject).to receive(:commits).and_return([commit]) - allow(subject.project).to receive(:default_branch) - .and_return(subject.target_branch) + allow(subject.project).to receive(:default_branch). + and_return(subject.target_branch) expect(subject.issues_mentioned_but_not_closing(subject.author)).to match_array([mentioned_issue]) end @@ -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 @@ -429,18 +429,18 @@ describe MergeRequest, models: true do subject.project.team << [subject.author, :developer] subject.description = "This issue Closes #{issue.to_reference}" - allow(subject.project).to receive(:default_branch) - .and_return(subject.target_branch) + 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 @@ -551,18 +551,18 @@ describe MergeRequest, models: true do end it 'caches the output' do - expect(subject).to receive(:compute_diverged_commits_count) - .once - .and_return(2) + expect(subject).to receive(:compute_diverged_commits_count). + once. + and_return(2) subject.diverged_commits_count subject.diverged_commits_count end it 'invalidates the cache when the source sha changes' do - expect(subject).to receive(:compute_diverged_commits_count) - .twice - .and_return(2) + expect(subject).to receive(:compute_diverged_commits_count). + twice. + and_return(2) subject.diverged_commits_count allow(subject).to receive(:source_branch_sha).and_return('123abc') @@ -570,9 +570,9 @@ describe MergeRequest, models: true do end it 'invalidates the cache when the target sha changes' do - expect(subject).to receive(:compute_diverged_commits_count) - .twice - .and_return(2) + expect(subject).to receive(:compute_diverged_commits_count). + twice. + and_return(2) subject.diverged_commits_count allow(subject).to receive(:target_branch_sha).and_return('123abc') @@ -594,8 +594,8 @@ describe MergeRequest, models: true do describe '#commits_sha' do before do - allow(subject.merge_request_diff).to receive(:commits_sha) - .and_return(['sha1']) + allow(subject.merge_request_diff).to receive(:commits_sha). + and_return(['sha1']) end it 'delegates to merge request diff' do @@ -610,9 +610,9 @@ describe MergeRequest, models: true do allow(subject).to receive(:diff_head_sha).and_return('123abc') - expect(subject.source_project).to receive(:pipeline_for) - .with('master', '123abc') - .and_return(pipeline) + expect(subject.source_project).to receive(:pipeline_for). + with('master', '123abc'). + and_return(pipeline) expect(subject.head_pipeline).to eq(pipeline) end @@ -1632,8 +1632,8 @@ describe MergeRequest, models: true do describe '#has_commits?' do before do - allow(subject.merge_request_diff).to receive(:commits_count) - .and_return(2) + allow(subject.merge_request_diff).to receive(:commits_count). + and_return(2) end it 'returns true when merge request diff has commits' do @@ -1643,8 +1643,8 @@ describe MergeRequest, models: true do describe '#has_no_commits?' do before do - allow(subject.merge_request_diff).to receive(:commits_count) - .and_return(0) + allow(subject.merge_request_diff).to receive(:commits_count). + and_return(0) end it 'returns true when merge request diff has 0 commits' do diff --git a/spec/models/milestone_spec.rb b/spec/models/milestone_spec.rb index 0ffcbf7e3f64706fc3824ad5afef95b209f4e0f2..3cee2b7714f29b88371e1cb50c24c9239f3d4163 100644 --- a/spec/models/milestone_spec.rb +++ b/spec/models/milestone_spec.rb @@ -205,13 +205,13 @@ describe Milestone, models: true do end it 'returns milestones with a partially matching description' do - expect(described_class.search(milestone.description[0..2])) - .to eq([milestone]) + expect(described_class.search(milestone.description[0..2])). + to eq([milestone]) end it 'returns milestones with a matching description regardless of the casing' do - expect(described_class.search(milestone.description.upcase)) - .to eq([milestone]) + expect(described_class.search(milestone.description.upcase)). + to eq([milestone]) end end diff --git a/spec/models/namespace_spec.rb b/spec/models/namespace_spec.rb index 74fbae07a6ffd6106cde2c271e6471e30b974247..35d932f1c64da7175340c11ef74861299fdad07f 100644 --- a/spec/models/namespace_spec.rb +++ b/spec/models/namespace_spec.rb @@ -216,8 +216,8 @@ describe Namespace, models: true do describe '#user_ids_for_project_authorizations' do it 'returns the user IDs for which to refresh authorizations' do - expect(namespace.user_ids_for_project_authorizations) - .to eq([namespace.owner_id]) + expect(namespace.user_ids_for_project_authorizations). + to eq([namespace.owner_id]) end end end diff --git a/spec/models/note_spec.rb b/spec/models/note_spec.rb index 973a0b9d592ff59774550985fa8a26a35de3e04f..1cde9e049518f2dc1e614d4f872a62c096b6eb23 100644 --- a/spec/models/note_spec.rb +++ b/spec/models/note_spec.rb @@ -148,8 +148,8 @@ describe Note, models: true do let!(:note2) { create(:note_on_issue) } it "reads the rendered note body from the cache" do - expect(Banzai::Renderer).to receive(:cache_collection_render) - .with([{ + expect(Banzai::Renderer).to receive(:cache_collection_render). + with([{ text: note1.note, context: { skip_project_check: false, @@ -160,8 +160,8 @@ describe Note, models: true do } }]).and_call_original - expect(Banzai::Renderer).to receive(:cache_collection_render) - .with([{ + expect(Banzai::Renderer).to receive(:cache_collection_render). + with([{ text: note2.note, context: { skip_project_check: false, @@ -361,8 +361,8 @@ describe Note, models: true do let(:note) { build(:note_on_project_snippet) } before do - expect(Banzai::Renderer).to receive(:cacheless_render_field) - .with(note, :note, { skip_project_check: false }).and_return(html) + expect(Banzai::Renderer).to receive(:cacheless_render_field). + with(note, :note, { skip_project_check: false }).and_return(html) note.save end @@ -376,8 +376,8 @@ describe Note, models: true do let(:note) { build(:note_on_personal_snippet) } before do - expect(Banzai::Renderer).to receive(:cacheless_render_field) - .with(note, :note, { skip_project_check: true }).and_return(html) + expect(Banzai::Renderer).to receive(:cacheless_render_field). + with(note, :note, { skip_project_check: true }).and_return(html) note.save end diff --git a/spec/models/project_authorization_spec.rb b/spec/models/project_authorization_spec.rb index 4001851b9ec1d6571a47691bdcb2e8c96b43bdd1..33ef67f97a7c11b28f8dbb5beb5278c434aa6aaa 100644 --- a/spec/models/project_authorization_spec.rb +++ b/spec/models/project_authorization_spec.rb @@ -7,8 +7,8 @@ describe ProjectAuthorization do describe '.insert_authorizations' do it 'inserts the authorizations' do - described_class - .insert_authorizations([[user.id, project1.id, Gitlab::Access::MASTER]]) + described_class. + insert_authorizations([[user.id, project1.id, Gitlab::Access::MASTER]]) expect(user.project_authorizations.count).to eq(1) end diff --git a/spec/models/project_label_spec.rb b/spec/models/project_label_spec.rb index 9cdbfa44e5b0f3ed00d3ad4181500831f1e45fb1..3e9dd3758edf554bc28c0969ecd2300b73bcb075 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/project_services/mattermost_slash_commands_service_spec.rb b/spec/models/project_services/mattermost_slash_commands_service_spec.rb index 9082156788e871ab67e774bf1033e24ba6b400a0..598ff232c82ac291e4526e9ac14f92a089b5cc74 100644 --- a/spec/models/project_services/mattermost_slash_commands_service_spec.rb +++ b/spec/models/project_services/mattermost_slash_commands_service_spec.rb @@ -11,8 +11,8 @@ describe MattermostSlashCommandsService, :models do before do Mattermost::Session.base_uri("http://mattermost.example.com") - allow_any_instance_of(Mattermost::Client).to receive(:with_session) - .and_yield(Mattermost::Session.new(nil)) + allow_any_instance_of(Mattermost::Client).to receive(:with_session). + and_yield(Mattermost::Session.new(nil)) end describe '#configure' do @@ -24,8 +24,8 @@ describe MattermostSlashCommandsService, :models do context 'the requests succeeds' do before do - stub_request(:post, 'http://mattermost.example.com/api/v3/teams/abc/commands/create') - .with(body: { + stub_request(:post, 'http://mattermost.example.com/api/v3/teams/abc/commands/create'). + with(body: { team_id: 'abc', trigger: 'gitlab', url: 'http://trigger.url', @@ -37,8 +37,8 @@ describe MattermostSlashCommandsService, :models do display_name: "GitLab / #{project.name_with_namespace}", method: 'P', username: 'GitLab' - }.to_json) - .to_return( + }.to_json). + to_return( status: 200, headers: { 'Content-Type' => 'application/json' }, body: { token: 'token' }.to_json @@ -58,8 +58,8 @@ describe MattermostSlashCommandsService, :models do context 'an error is received' do before do - stub_request(:post, 'http://mattermost.example.com/api/v3/teams/abc/commands/create') - .to_return( + stub_request(:post, 'http://mattermost.example.com/api/v3/teams/abc/commands/create'). + to_return( status: 500, headers: { 'Content-Type' => 'application/json' }, body: { @@ -88,8 +88,8 @@ describe MattermostSlashCommandsService, :models do context 'the requests succeeds' do before do - stub_request(:get, 'http://mattermost.example.com/api/v3/teams/all') - .to_return( + stub_request(:get, 'http://mattermost.example.com/api/v3/teams/all'). + to_return( status: 200, headers: { 'Content-Type' => 'application/json' }, body: ['list'].to_json @@ -103,8 +103,8 @@ describe MattermostSlashCommandsService, :models do context 'an error is received' do before do - stub_request(:get, 'http://mattermost.example.com/api/v3/teams/all') - .to_return( + stub_request(:get, 'http://mattermost.example.com/api/v3/teams/all'). + to_return( status: 500, headers: { 'Content-Type' => 'application/json' }, body: { diff --git a/spec/models/project_spec.rb b/spec/models/project_spec.rb index 66e0ea6d9a5734772fe57da4cd949b00e46f30e0..b0087a9e15da4e3d11f4e434014393ddd6ba2426 100644 --- a/spec/models/project_spec.rb +++ b/spec/models/project_spec.rb @@ -1150,23 +1150,23 @@ describe Project, models: true do it 'renames a repository' do ns = project.namespace_dir - expect(gitlab_shell).to receive(:mv_repository) - .ordered - .with(project.repository_storage_path, "#{ns}/foo", "#{ns}/#{project.path}") - .and_return(true) + expect(gitlab_shell).to receive(:mv_repository). + ordered. + with(project.repository_storage_path, "#{ns}/foo", "#{ns}/#{project.path}"). + and_return(true) - expect(gitlab_shell).to receive(:mv_repository) - .ordered - .with(project.repository_storage_path, "#{ns}/foo.wiki", "#{ns}/#{project.path}.wiki") - .and_return(true) + expect(gitlab_shell).to receive(:mv_repository). + ordered. + with(project.repository_storage_path, "#{ns}/foo.wiki", "#{ns}/#{project.path}.wiki"). + and_return(true) - expect_any_instance_of(SystemHooksService) - .to receive(:execute_hooks_for) - .with(project, :rename) + expect_any_instance_of(SystemHooksService). + to receive(:execute_hooks_for). + with(project, :rename) - expect_any_instance_of(Gitlab::UploadsTransfer) - .to receive(:rename_project) - .with('foo', project.path, ns) + expect_any_instance_of(Gitlab::UploadsTransfer). + to receive(:rename_project). + with('foo', project.path, ns) expect(project).to receive(:expire_caches_before_rename) @@ -1191,13 +1191,13 @@ describe Project, models: true do let(:wiki) { double(:wiki, exists?: true) } it 'expires the caches of the repository and wiki' do - allow(Repository).to receive(:new) - .with('foo', project) - .and_return(repo) + allow(Repository).to receive(:new). + with('foo', project). + and_return(repo) - allow(Repository).to receive(:new) - .with('foo.wiki', project) - .and_return(wiki) + allow(Repository).to receive(:new). + with('foo.wiki', project). + and_return(wiki) expect(repo).to receive(:before_delete) expect(wiki).to receive(:before_delete) @@ -1248,9 +1248,9 @@ describe Project, models: true do context 'using a regular repository' do it 'creates the repository' do - expect(shell).to receive(:add_repository) - .with(project.repository_storage_path, project.path_with_namespace) - .and_return(true) + expect(shell).to receive(:add_repository). + with(project.repository_storage_path, project.path_with_namespace). + and_return(true) expect(project.repository).to receive(:after_create) @@ -1258,9 +1258,9 @@ describe Project, models: true do end it 'adds an error if the repository could not be created' do - expect(shell).to receive(:add_repository) - .with(project.repository_storage_path, project.path_with_namespace) - .and_return(false) + expect(shell).to receive(:add_repository). + with(project.repository_storage_path, project.path_with_namespace). + and_return(false) expect(project.repository).not_to receive(:after_create) @@ -1536,8 +1536,8 @@ describe Project, models: true do let(:project) { forked_project_link.forked_to_project } it 'schedules a RepositoryForkWorker job' do - expect(RepositoryForkWorker).to receive(:perform_async) - .with(project.id, forked_from_project.repository_storage_path, + expect(RepositoryForkWorker).to receive(:perform_async). + with(project.id, forked_from_project.repository_storage_path, forked_from_project.path_with_namespace, project.namespace.path) project.add_import_job diff --git a/spec/models/project_wiki_spec.rb b/spec/models/project_wiki_spec.rb index 8c43937c398180a44dfae67d050beddcc2ee43d6..58b57bd4fef4dc94d1eecd60f2d6f4ae33f6c5c3 100644 --- a/spec/models/project_wiki_spec.rb +++ b/spec/models/project_wiki_spec.rb @@ -143,15 +143,15 @@ describe ProjectWiki, models: true do describe '#find_file' do before do file = Gollum::File.new(subject.wiki) - allow_any_instance_of(Gollum::Wiki) - .to receive(:file).with('image.jpg', 'master', true) - .and_return(file) - allow_any_instance_of(Gollum::File) - .to receive(:mime_type) - .and_return('image/jpeg') - allow_any_instance_of(Gollum::Wiki) - .to receive(:file).with('non-existant', 'master', true) - .and_return(nil) + allow_any_instance_of(Gollum::Wiki). + to receive(:file).with('image.jpg', 'master', true). + and_return(file) + allow_any_instance_of(Gollum::File). + to receive(:mime_type). + and_return('image/jpeg') + allow_any_instance_of(Gollum::Wiki). + to receive(:file).with('non-existant', 'master', true). + and_return(nil) end after do @@ -253,9 +253,9 @@ describe ProjectWiki, models: true do describe '#create_repo!' do it 'creates a repository' do - expect(subject).to receive(:init_repo) - .with(subject.path_with_namespace) - .and_return(true) + expect(subject).to receive(:init_repo). + with(subject.path_with_namespace). + and_return(true) expect(subject.repository).to receive(:after_create) diff --git a/spec/models/repository_spec.rb b/spec/models/repository_spec.rb index dfa019d28b08fdaf99cb651b52e5717d6f48a163..a3fe412b22996e4ade29be7c414e2f6e5eb72ef4 100644 --- a/spec/models/repository_spec.rb +++ b/spec/models/repository_spec.rb @@ -125,8 +125,8 @@ describe Repository, models: true do describe '#ref_name_for_sha' do context 'ref found' do it 'returns the ref' do - allow_any_instance_of(Gitlab::Popen).to receive(:popen) - .and_return(["b8d95eb4969eefacb0a58f6a28f6803f8070e7b9 commit\trefs/environments/production/77\n", 0]) + allow_any_instance_of(Gitlab::Popen).to receive(:popen). + and_return(["b8d95eb4969eefacb0a58f6a28f6803f8070e7b9 commit\trefs/environments/production/77\n", 0]) expect(repository.ref_name_for_sha('bla', '0' * 40)).to eq 'refs/environments/production/77' end @@ -134,8 +134,8 @@ describe Repository, models: true do context 'ref not found' do it 'returns nil' do - allow_any_instance_of(Gitlab::Popen).to receive(:popen) - .and_return(["", 0]) + allow_any_instance_of(Gitlab::Popen).to receive(:popen). + and_return(["", 0]) expect(repository.ref_name_for_sha('bla', '0' * 40)).to eq nil end @@ -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 @@ -596,8 +596,8 @@ describe Repository, models: true do user, 'LICENSE', 'Copyright!', message: 'Add LICENSE', branch_name: 'master', update: false) - allow(repository).to receive(:file_on_head) - .and_raise(Rugged::ReferenceError) + allow(repository).to receive(:file_on_head). + and_raise(Rugged::ReferenceError) expect(repository.license_blob).to be_nil end @@ -749,8 +749,8 @@ describe Repository, models: true do context 'when pre hooks were successful' do it 'runs without errors' do - expect_any_instance_of(GitHooksService).to receive(:execute) - .with(user, project.repository.path_to_repo, old_rev, blank_sha, 'refs/heads/feature') + expect_any_instance_of(GitHooksService).to receive(:execute). + with(user, project.repository.path_to_repo, old_rev, blank_sha, 'refs/heads/feature') expect { repository.rm_branch(user, 'feature') }.not_to raise_error end @@ -792,14 +792,14 @@ describe Repository, models: true do before do service = GitHooksService.new expect(GitHooksService).to receive(:new).and_return(service) - expect(service).to receive(:execute) - .with( + expect(service).to receive(:execute). + with( user, repository.path_to_repo, old_rev, new_rev, - 'refs/heads/feature') - .and_yield(service).and_return(true) + 'refs/heads/feature'). + and_yield(service).and_return(true) end it 'runs without errors' do @@ -893,8 +893,8 @@ describe Repository, models: true do expect(repository).not_to receive(:expire_emptiness_caches) expect(repository).to receive(:expire_branches_cache) - GitOperationService.new(user, repository) - .with_branch('new-feature') do + GitOperationService.new(user, repository). + with_branch('new-feature') do new_rev end end @@ -978,8 +978,8 @@ describe Repository, models: true do end it 'does nothing' do - expect(repository.raw_repository).not_to receive(:autocrlf=) - .with(:input) + expect(repository.raw_repository).not_to receive(:autocrlf=). + with(:input) GitOperationService.new(nil, repository).send(:update_autocrlf_option) end @@ -998,9 +998,9 @@ describe Repository, models: true do end it 'caches the output' do - expect(repository.raw_repository).to receive(:empty?) - .once - .and_return(false) + expect(repository.raw_repository).to receive(:empty?). + once. + and_return(false) repository.empty? repository.empty? @@ -1013,9 +1013,9 @@ describe Repository, models: true do end it 'caches the output' do - expect(repository.raw_repository).to receive(:root_ref) - .once - .and_return('master') + expect(repository.raw_repository).to receive(:root_ref). + once. + and_return('master') repository.root_ref repository.root_ref @@ -1026,9 +1026,9 @@ describe Repository, models: true do it 'expires the root reference cache' do repository.root_ref - expect(repository.raw_repository).to receive(:root_ref) - .once - .and_return('foo') + expect(repository.raw_repository).to receive(:root_ref). + once. + and_return('foo') repository.expire_root_ref_cache @@ -1042,17 +1042,17 @@ describe Repository, models: true do let(:cache) { repository.send(:cache) } it 'expires the cache for all branches' do - expect(cache).to receive(:expire) - .at_least(repository.branches.length) - .times + expect(cache).to receive(:expire). + at_least(repository.branches.length). + times repository.expire_branch_cache end it 'expires the cache for all branches when the root branch is given' do - expect(cache).to receive(:expire) - .at_least(repository.branches.length) - .times + expect(cache).to receive(:expire). + at_least(repository.branches.length). + times repository.expire_branch_cache(repository.root_ref) end @@ -1314,12 +1314,12 @@ describe Repository, models: true do describe '#after_push_commit' do it 'expires statistics caches' do - expect(repository).to receive(:expire_statistics_caches) - .and_call_original + expect(repository).to receive(:expire_statistics_caches). + and_call_original - expect(repository).to receive(:expire_branch_cache) - .with('master') - .and_call_original + expect(repository).to receive(:expire_branch_cache). + with('master'). + and_call_original repository.after_push_commit('master') end @@ -1394,9 +1394,9 @@ describe Repository, models: true do describe '#expire_branches_cache' do it 'expires the cache' do - expect(repository).to receive(:expire_method_caches) - .with(%i(branch_names branch_count)) - .and_call_original + expect(repository).to receive(:expire_method_caches). + with(%i(branch_names branch_count)). + and_call_original repository.expire_branches_cache end @@ -1404,9 +1404,9 @@ describe Repository, models: true do describe '#expire_tags_cache' do it 'expires the cache' do - expect(repository).to receive(:expire_method_caches) - .with(%i(tag_names tag_count)) - .and_call_original + expect(repository).to receive(:expire_method_caches). + with(%i(tag_names tag_count)). + and_call_original repository.expire_tags_cache end @@ -1417,11 +1417,11 @@ describe Repository, models: true do let(:user) { build_stubbed(:user) } it 'creates the tag using rugged' do - expect(repository.rugged.tags).to receive(:create) - .with('8.5', repository.commit('master').id, + expect(repository.rugged.tags).to receive(:create). + with('8.5', repository.commit('master').id, hash_including(message: 'foo', - tagger: hash_including(name: user.name, email: user.email))) - .and_call_original + tagger: hash_including(name: user.name, email: user.email))). + and_call_original repository.add_tag(user, '8.5', 'master', 'foo') end @@ -1438,8 +1438,8 @@ describe Repository, models: true do update_hook = Gitlab::Git::Hook.new('update', repository.path_to_repo) post_receive_hook = Gitlab::Git::Hook.new('post-receive', repository.path_to_repo) - allow(Gitlab::Git::Hook).to receive(:new) - .and_return(pre_receive_hook, update_hook, post_receive_hook) + allow(Gitlab::Git::Hook).to receive(:new). + and_return(pre_receive_hook, update_hook, post_receive_hook) allow(pre_receive_hook).to receive(:trigger).and_call_original allow(update_hook).to receive(:trigger).and_call_original @@ -1450,12 +1450,12 @@ describe Repository, models: true do commit_sha = repository.commit('master').id tag_sha = tag.target - expect(pre_receive_hook).to have_received(:trigger) - .with(anything, anything, commit_sha, anything) - expect(update_hook).to have_received(:trigger) - .with(anything, anything, commit_sha, anything) - expect(post_receive_hook).to have_received(:trigger) - .with(anything, anything, tag_sha, anything) + expect(pre_receive_hook).to have_received(:trigger). + with(anything, anything, commit_sha, anything) + expect(update_hook).to have_received(:trigger). + with(anything, anything, commit_sha, anything) + expect(post_receive_hook).to have_received(:trigger). + with(anything, anything, tag_sha, anything) end end @@ -1489,25 +1489,25 @@ describe Repository, models: true do describe '#avatar' do it 'returns nil if repo does not exist' do - expect(repository).to receive(:file_on_head) - .and_raise(Rugged::ReferenceError) + expect(repository).to receive(:file_on_head). + and_raise(Rugged::ReferenceError) expect(repository.avatar).to eq(nil) end it 'returns the first avatar file found in the repository' do - expect(repository).to receive(:file_on_head) - .with(:avatar) - .and_return(double(:tree, path: 'logo.png')) + expect(repository).to receive(:file_on_head). + with(:avatar). + and_return(double(:tree, path: 'logo.png')) expect(repository.avatar).to eq('logo.png') end it 'caches the output' do - expect(repository).to receive(:file_on_head) - .with(:avatar) - .once - .and_return(double(:tree, path: 'logo.png')) + expect(repository).to receive(:file_on_head). + with(:avatar). + once. + and_return(double(:tree, path: 'logo.png')) 2.times { expect(repository.avatar).to eq('logo.png') } end @@ -1567,24 +1567,24 @@ describe Repository, models: true do describe '#contribution_guide', caching: true do it 'returns and caches the output' do - expect(repository).to receive(:file_on_head) - .with(:contributing) - .and_return(Gitlab::Git::Tree.new(path: 'CONTRIBUTING.md')) - .once + expect(repository).to receive(:file_on_head). + with(:contributing). + and_return(Gitlab::Git::Tree.new(path: 'CONTRIBUTING.md')). + once 2.times do - expect(repository.contribution_guide) - .to be_an_instance_of(Gitlab::Git::Tree) + expect(repository.contribution_guide). + to be_an_instance_of(Gitlab::Git::Tree) end end end describe '#gitignore', caching: true do it 'returns and caches the output' do - expect(repository).to receive(:file_on_head) - .with(:gitignore) - .and_return(Gitlab::Git::Tree.new(path: '.gitignore')) - .once + expect(repository).to receive(:file_on_head). + with(:gitignore). + and_return(Gitlab::Git::Tree.new(path: '.gitignore')). + once 2.times do expect(repository.gitignore).to be_an_instance_of(Gitlab::Git::Tree) @@ -1594,10 +1594,10 @@ describe Repository, models: true do describe '#koding_yml', caching: true do it 'returns and caches the output' do - expect(repository).to receive(:file_on_head) - .with(:koding) - .and_return(Gitlab::Git::Tree.new(path: '.koding.yml')) - .once + expect(repository).to receive(:file_on_head). + with(:koding). + and_return(Gitlab::Git::Tree.new(path: '.koding.yml')). + once 2.times do expect(repository.koding_yml).to be_an_instance_of(Gitlab::Git::Tree) @@ -1623,8 +1623,8 @@ describe Repository, models: true do describe '#expire_statistics_caches' do it 'expires the caches' do - expect(repository).to receive(:expire_method_caches) - .with(%i(size commit_count)) + expect(repository).to receive(:expire_method_caches). + with(%i(size commit_count)) repository.expire_statistics_caches end @@ -1641,8 +1641,8 @@ describe Repository, models: true do describe '#expire_all_method_caches' do it 'expires the caches of all methods' do - expect(repository).to receive(:expire_method_caches) - .with(Repository::CACHED_METHODS) + expect(repository).to receive(:expire_method_caches). + with(Repository::CACHED_METHODS) repository.expire_all_method_caches end @@ -1667,8 +1667,8 @@ describe Repository, models: true do context 'with an existing repository' do it 'returns a Gitlab::Git::Tree' do - expect(repository.file_on_head(:readme)) - .to be_an_instance_of(Gitlab::Git::Tree) + expect(repository.file_on_head(:readme)). + to be_an_instance_of(Gitlab::Git::Tree) end end end @@ -1783,8 +1783,8 @@ describe Repository, models: true do describe '#refresh_method_caches' do it 'refreshes the caches of the given types' do - expect(repository).to receive(:expire_method_caches) - .with(%i(readme license_blob license_key)) + expect(repository).to receive(:expire_method_caches). + with(%i(readme license_blob license_key)) expect(repository).to receive(:readme) expect(repository).to receive(:license_blob) diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index 2c03a48582386216aca8acc9b8c70e37cb39a26a..d7aa77548344fedd17a09ae4f5a67e4360a4aa26 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -808,8 +808,8 @@ describe User, models: true do describe '.find_by_username!' do it 'raises RecordNotFound' do - expect { described_class.find_by_username!('JohnDoe') } - .to raise_error(ActiveRecord::RecordNotFound) + expect { described_class.find_by_username!('JohnDoe') }. + to raise_error(ActiveRecord::RecordNotFound) end it 'is case-insensitive' do @@ -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 @@ -1385,8 +1385,8 @@ describe User, models: true do end it 'returns the projects when using an ActiveRecord relation' do - projects = user - .projects_with_reporter_access_limited_to(Project.select(:id)) + projects = user. + projects_with_reporter_access_limited_to(Project.select(:id)) expect(projects).to eq([project1]) end diff --git a/spec/models/wiki_page_spec.rb b/spec/models/wiki_page_spec.rb index 4a73552b8a6f6a230d4979fe609254132dfbc582..753dc938c52dc4a8fbdb0a0dc165a51e426bf3bf 100644 --- a/spec/models/wiki_page_spec.rb +++ b/spec/models/wiki_page_spec.rb @@ -61,8 +61,8 @@ describe WikiPage, models: true do actual_order = grouped_entries.map do |page_or_dir| get_slugs(page_or_dir) - end - .flatten + end. + flatten expect(actual_order).to eq(expected_order) end end diff --git a/spec/policies/project_policy_spec.rb b/spec/policies/project_policy_spec.rb index 29315821ab74684552530cf1cca5621cc440d049..0a5edf35f592ec35aed1aa56dc595dbab0e2aef9 100644 --- a/spec/policies/project_policy_spec.rb +++ b/spec/policies/project_policy_spec.rb @@ -80,8 +80,8 @@ describe ProjectPolicy, models: true do expect(project.team.member?(issue.author)).to eq(false) - expect(BasePolicy.class_for(project).abilities(user, project).can_set) - .not_to include(:read_issue) + expect(BasePolicy.class_for(project).abilities(user, project).can_set). + not_to include(:read_issue) expect(Ability.allowed?(user, :read_issue, project)).to be_falsy end diff --git a/spec/presenters/ci/build_presenter_spec.rb b/spec/presenters/ci/build_presenter_spec.rb index 14290350c1363b624ff36f97336c3383737528ca..7a35da38b2be9deec3aab4103aa22d74fb571150 100644 --- a/spec/presenters/ci/build_presenter_spec.rb +++ b/spec/presenters/ci/build_presenter_spec.rb @@ -47,8 +47,8 @@ describe Ci::BuildPresenter do context 'when build is erased' do before do expect(presenter).to receive(:erased_by_user?).and_return(true) - expect(build).to receive(:erased_by) - .and_return(double(:user, name: 'John Doe')) + expect(build).to receive(:erased_by). + and_return(double(:user, name: 'John Doe')) end it 'returns the name of the eraser' do diff --git a/spec/requests/api/broadcast_messages_spec.rb b/spec/requests/api/broadcast_messages_spec.rb index 921d8714173a2f6636959c70d3f49d9190eb3e02..576eb80605b6f23ca1d66d5cbc4afc6819f9f9c1 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 81a8856b8f1154c9f7b5b22396a7c37ec7cb8824..eface28976e832b9219c2f59620fbbe7300abad3 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/files_spec.rb b/spec/requests/api/files_spec.rb index b1380f660f9451eac0712e8b75427b42e4e07668..a8ce04304018466d12a70a2cf815e626476fe571 100644 --- a/spec/requests/api/files_spec.rb +++ b/spec/requests/api/files_spec.rb @@ -127,8 +127,8 @@ describe API::Files, api: true do end it "returns a 400 if editor fails to create file" do - allow_any_instance_of(Repository).to receive(:commit_file) - .and_return(false) + allow_any_instance_of(Repository).to receive(:commit_file). + and_return(false) post api("/projects/#{project.id}/repository/files", user), valid_params diff --git a/spec/requests/api/groups_spec.rb b/spec/requests/api/groups_spec.rb index d13c67aa2200f6885d2e80251b4311a5e18c8665..b82372b1b601b2687de8ad924a407312b91fd146 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 @@ -522,8 +522,8 @@ describe API::Groups, api: true do let(:project_path) { "#{project.namespace.path}%2F#{project.path}" } before(:each) do - allow_any_instance_of(Projects::TransferService) - .to receive(:execute).and_return(true) + allow_any_instance_of(Projects::TransferService). + to receive(:execute).and_return(true) end context "when authenticated as user" do diff --git a/spec/requests/api/internal_spec.rb b/spec/requests/api/internal_spec.rb index ffeacb15f17a81843b4a7bf1fa7e45c7bf83f28c..d1e765d1fdd820f7412878c0bf4ad0b6f06c2b23 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/merge_requests_spec.rb b/spec/requests/api/merge_requests_spec.rb index 9f26560be787a78ade7b6aab1b1a4e1d22e57814..b87d0cd7de9462a151c2dfae91bbaa1b92a8a8e2 100644 --- a/spec/requests/api/merge_requests_spec.rb +++ b/spec/requests/api/merge_requests_spec.rb @@ -426,8 +426,8 @@ describe API::MergeRequests, api: true do end it "returns 406 if branch can't be merged" do - allow_any_instance_of(MergeRequest) - .to receive(:can_be_merged?).and_return(false) + allow_any_instance_of(MergeRequest). + to receive(:can_be_merged?).and_return(false) put api("/projects/#{project.id}/merge_requests/#{merge_request.id}/merge", user) diff --git a/spec/requests/api/notes_spec.rb b/spec/requests/api/notes_spec.rb index 5d5e57aa1ca16d50f309f0ed318a34475749503d..3cca4468be71d43ea85b28cd62263ca96898c72a 100644 --- a/spec/requests/api/notes_spec.rb +++ b/spec/requests/api/notes_spec.rb @@ -14,8 +14,8 @@ describe API::Notes, api: true do # For testing the cross-reference of a private issue in a public issue let(:private_user) { create(:user) } let(:private_project) do - create(:empty_project, namespace: private_user.namespace) - .tap { |p| p.team << [private_user, :master] } + create(:empty_project, namespace: private_user.namespace). + tap { |p| p.team << [private_user, :master] } end let(:private_issue) { create(:issue, project: private_project) } diff --git a/spec/requests/api/project_snippets_spec.rb b/spec/requests/api/project_snippets_spec.rb index e79de9aacf2818e7fef6fb425d2e23b4e3d244c1..da9df56401b02b1841fe218b07c1200c6ef33618 100644 --- a/spec/requests/api/project_snippets_spec.rb +++ b/spec/requests/api/project_snippets_spec.rb @@ -80,23 +80,23 @@ describe API::ProjectSnippets, api: true do context 'when the snippet is private' do it 'creates the snippet' do - expect { create_snippet(project, visibility_level: Snippet::PRIVATE) } - .to change { Snippet.count }.by(1) + expect { create_snippet(project, visibility_level: Snippet::PRIVATE) }. + to change { Snippet.count }.by(1) end end context 'when the snippet is public' do it 'rejects the shippet' do - expect { create_snippet(project, visibility_level: Snippet::PUBLIC) } - .not_to change { Snippet.count } + expect { create_snippet(project, visibility_level: Snippet::PUBLIC) }. + not_to change { Snippet.count } expect(response).to have_http_status(400) expect(json_response['message']).to eq({ "error" => "Spam detected" }) end it 'creates a spam log' do - expect { create_snippet(project, visibility_level: Snippet::PUBLIC) } - .to change { SpamLog.count }.by(1) + expect { create_snippet(project, visibility_level: Snippet::PUBLIC) }. + to change { SpamLog.count }.by(1) end end end @@ -142,8 +142,8 @@ describe API::ProjectSnippets, api: true do let(:visibility_level) { Snippet::PRIVATE } it 'creates the snippet' do - expect { update_snippet(title: 'Foo') } - .to change { snippet.reload.title }.to('Foo') + expect { update_snippet(title: 'Foo') }. + to change { snippet.reload.title }.to('Foo') end end @@ -151,13 +151,13 @@ describe API::ProjectSnippets, api: true do let(:visibility_level) { Snippet::PUBLIC } it 'rejects the snippet' do - expect { update_snippet(title: 'Foo') } - .not_to change { snippet.reload.title } + expect { update_snippet(title: 'Foo') }. + not_to change { snippet.reload.title } end it 'creates a spam log' do - expect { update_snippet(title: 'Foo') } - .to change { SpamLog.count }.by(1) + expect { update_snippet(title: 'Foo') }. + to change { SpamLog.count }.by(1) end end @@ -165,16 +165,16 @@ describe API::ProjectSnippets, api: true do let(:visibility_level) { Snippet::PRIVATE } it 'rejects the snippet' do - expect { update_snippet(title: 'Foo', visibility_level: Snippet::PUBLIC) } - .not_to change { snippet.reload.title } + expect { update_snippet(title: 'Foo', visibility_level: Snippet::PUBLIC) }. + not_to change { snippet.reload.title } expect(response).to have_http_status(400) expect(json_response['message']).to eq({ "error" => "Spam detected" }) end it 'creates a spam log' do - expect { update_snippet(title: 'Foo', visibility_level: Snippet::PUBLIC) } - .to change { SpamLog.count }.by(1) + expect { update_snippet(title: 'Foo', visibility_level: Snippet::PUBLIC) }. + to change { SpamLog.count }.by(1) end end end diff --git a/spec/requests/api/projects_spec.rb b/spec/requests/api/projects_spec.rb index 30247b3bcc80b27d7adbd95cd83d5d4cf53c7100..8d139782fdfa69d1507366447dd5f5e719101cbb 100644 --- a/spec/requests/api/projects_spec.rb +++ b/spec/requests/api/projects_spec.rb @@ -263,15 +263,15 @@ describe API::Projects, api: true do context 'maximum number of projects reached' do it 'does not create new project and respond with 403' do allow_any_instance_of(User).to receive(:projects_limit_left).and_return(0) - expect { post api('/projects', user2), name: 'foo' } - .to change {Project.count}.by(0) + expect { post api('/projects', user2), name: 'foo' }. + to change {Project.count}.by(0) expect(response).to have_http_status(403) end end it 'creates new project without path and return 201' do - expect { post api('/projects', user), name: 'foo' } - .to change { Project.count }.by(1) + expect { post api('/projects', user), name: 'foo' }. + to change { Project.count }.by(1) expect(response).to have_http_status(201) end @@ -406,8 +406,8 @@ describe API::Projects, api: true do end it 'responds with 400 on failure and not project' do - expect { post api("/projects/user/#{user.id}", admin) } - .not_to change { Project.count } + expect { post api("/projects/user/#{user.id}", admin) }. + not_to change { Project.count } expect(response).to have_http_status(400) expect(json_response['error']).to eq('name is missing') @@ -611,8 +611,8 @@ describe API::Projects, api: true do get api("/projects", user) expect(response).to have_http_status(200) - expect(json_response.first['permissions']['project_access']['access_level']) - .to eq(Gitlab::Access::MASTER) + expect(json_response.first['permissions']['project_access']['access_level']). + to eq(Gitlab::Access::MASTER) expect(json_response.first['permissions']['group_access']).to be_nil end end @@ -623,8 +623,8 @@ describe API::Projects, api: true do get api("/projects/#{project.id}", user) expect(response).to have_http_status(200) - expect(json_response['permissions']['project_access']['access_level']) - .to eq(Gitlab::Access::MASTER) + expect(json_response['permissions']['project_access']['access_level']). + to eq(Gitlab::Access::MASTER) expect(json_response['permissions']['group_access']).to be_nil end end @@ -639,8 +639,8 @@ describe API::Projects, api: true do expect(response).to have_http_status(200) expect(json_response['permissions']['project_access']).to be_nil - expect(json_response['permissions']['group_access']['access_level']) - .to eq(Gitlab::Access::OWNER) + expect(json_response['permissions']['group_access']['access_level']). + to eq(Gitlab::Access::OWNER) end end end diff --git a/spec/requests/api/runners_spec.rb b/spec/requests/api/runners_spec.rb index 103d6755888b15c874b7a3cab4c94dfedd87f3ec..2e596f4197edea920e5439cbac36404133f05ef0 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/api/snippets_spec.rb b/spec/requests/api/snippets_spec.rb index 25cb75d86851b1f6110987556aab05e7da85ca22..41def7cd1d44c8189246d4ffda81649982378e54 100644 --- a/spec/requests/api/snippets_spec.rb +++ b/spec/requests/api/snippets_spec.rb @@ -120,23 +120,23 @@ describe API::Snippets, api: true do context 'when the snippet is private' do it 'creates the snippet' do - expect { create_snippet(visibility_level: Snippet::PRIVATE) } - .to change { Snippet.count }.by(1) + expect { create_snippet(visibility_level: Snippet::PRIVATE) }. + to change { Snippet.count }.by(1) end end context 'when the snippet is public' do it 'rejects the shippet' do - expect { create_snippet(visibility_level: Snippet::PUBLIC) } - .not_to change { Snippet.count } + expect { create_snippet(visibility_level: Snippet::PUBLIC) }. + not_to change { Snippet.count } expect(response).to have_http_status(400) expect(json_response['message']).to eq({ "error" => "Spam detected" }) end it 'creates a spam log' do - expect { create_snippet(visibility_level: Snippet::PUBLIC) } - .to change { SpamLog.count }.by(1) + expect { create_snippet(visibility_level: Snippet::PUBLIC) }. + to change { SpamLog.count }.by(1) end end end @@ -192,8 +192,8 @@ describe API::Snippets, api: true do let(:visibility_level) { Snippet::PRIVATE } it 'updates the snippet' do - expect { update_snippet(title: 'Foo') } - .to change { snippet.reload.title }.to('Foo') + expect { update_snippet(title: 'Foo') }. + to change { snippet.reload.title }.to('Foo') end end @@ -201,16 +201,16 @@ describe API::Snippets, api: true do let(:visibility_level) { Snippet::PUBLIC } it 'rejects the shippet' do - expect { update_snippet(title: 'Foo') } - .not_to change { snippet.reload.title } + expect { update_snippet(title: 'Foo') }. + not_to change { snippet.reload.title } expect(response).to have_http_status(400) expect(json_response['message']).to eq({ "error" => "Spam detected" }) end it 'creates a spam log' do - expect { update_snippet(title: 'Foo') } - .to change { SpamLog.count }.by(1) + expect { update_snippet(title: 'Foo') }. + to change { SpamLog.count }.by(1) end end @@ -218,13 +218,13 @@ describe API::Snippets, api: true do let(:visibility_level) { Snippet::PRIVATE } it 'rejects the snippet' do - expect { update_snippet(title: 'Foo', visibility_level: Snippet::PUBLIC) } - .not_to change { snippet.reload.title } + expect { update_snippet(title: 'Foo', visibility_level: Snippet::PUBLIC) }. + not_to change { snippet.reload.title } end it 'creates a spam log' do - expect { update_snippet(title: 'Foo', visibility_level: Snippet::PUBLIC) } - .to change { SpamLog.count }.by(1) + expect { update_snippet(title: 'Foo', visibility_level: Snippet::PUBLIC) }. + to change { SpamLog.count }.by(1) end end end diff --git a/spec/requests/api/users_spec.rb b/spec/requests/api/users_spec.rb index b1bdf76d6b2100e9abada96214c14a756da73eaa..603da9f49fca9fe1c4f81fb0ac73fb1baa7eb043 100644 --- a/spec/requests/api/users_spec.rb +++ b/spec/requests/api/users_spec.rb @@ -247,14 +247,14 @@ describe API::Users, api: true do bio: 'g' * 256, projects_limit: -1 expect(response).to have_http_status(400) - expect(json_response['message']['password']) - .to eq(['is too short (minimum is 8 characters)']) - expect(json_response['message']['bio']) - .to eq(['is too long (maximum is 255 characters)']) - expect(json_response['message']['projects_limit']) - .to eq(['must be greater than or equal to 0']) - expect(json_response['message']['username']) - .to eq([Gitlab::Regex.namespace_regex_message]) + expect(json_response['message']['password']). + to eq(['is too short (minimum is 8 characters)']) + expect(json_response['message']['bio']). + to eq(['is too long (maximum is 255 characters)']) + expect(json_response['message']['projects_limit']). + to eq(['must be greater than or equal to 0']) + expect(json_response['message']['username']). + to eq([Gitlab::Regex.namespace_regex_message]) end it "is not available for non admin users" do @@ -421,14 +421,14 @@ describe API::Users, api: true do bio: 'g' * 256, projects_limit: -1 expect(response).to have_http_status(400) - expect(json_response['message']['password']) - .to eq(['is too short (minimum is 8 characters)']) - expect(json_response['message']['bio']) - .to eq(['is too long (maximum is 255 characters)']) - expect(json_response['message']['projects_limit']) - .to eq(['must be greater than or equal to 0']) - expect(json_response['message']['username']) - .to eq([Gitlab::Regex.namespace_regex_message]) + expect(json_response['message']['password']). + to eq(['is too short (minimum is 8 characters)']) + expect(json_response['message']['bio']). + to eq(['is too long (maximum is 255 characters)']) + expect(json_response['message']['projects_limit']). + to eq(['must be greater than or equal to 0']) + expect(json_response['message']['username']). + to eq([Gitlab::Regex.namespace_regex_message]) end it 'returns 400 if provider is missing for identity update' do diff --git a/spec/requests/api/v3/files_spec.rb b/spec/requests/api/v3/files_spec.rb index 2099e386c858afd14ed9b21fec86d8da170501e2..4af05605ec66698b17e5fe4326f4a7f9367800c2 100644 --- a/spec/requests/api/v3/files_spec.rb +++ b/spec/requests/api/v3/files_spec.rb @@ -127,8 +127,8 @@ describe API::V3::Files, api: true do end it "returns a 400 if editor fails to create file" do - allow_any_instance_of(Repository).to receive(:commit_file) - .and_return(false) + allow_any_instance_of(Repository).to receive(:commit_file). + and_return(false) post v3_api("/projects/#{project.id}/repository/files", user), valid_params diff --git a/spec/requests/api/v3/merge_requests_spec.rb b/spec/requests/api/v3/merge_requests_spec.rb index cb370418e9c99affff78ae80f986941ce894e2ae..51764d1000e192db0bfa2fd78d0d7720f3faa39e 100644 --- a/spec/requests/api/v3/merge_requests_spec.rb +++ b/spec/requests/api/v3/merge_requests_spec.rb @@ -413,8 +413,8 @@ describe API::MergeRequests, api: true do end it "returns 406 if branch can't be merged" do - allow_any_instance_of(MergeRequest) - .to receive(:can_be_merged?).and_return(false) + allow_any_instance_of(MergeRequest). + to receive(:can_be_merged?).and_return(false) put v3_api("/projects/#{project.id}/merge_requests/#{merge_request.id}/merge", user) diff --git a/spec/requests/api/v3/project_snippets_spec.rb b/spec/requests/api/v3/project_snippets_spec.rb index 0b3b39ddabac1b14302310c34a95f17cf79cbb63..957a3bf97ef51ccd55d4fcd3f1ed9a682241a029 100644 --- a/spec/requests/api/v3/project_snippets_spec.rb +++ b/spec/requests/api/v3/project_snippets_spec.rb @@ -87,23 +87,23 @@ describe API::ProjectSnippets, api: true do context 'when the snippet is private' do it 'creates the snippet' do - expect { create_snippet(project, visibility_level: Snippet::PRIVATE) } - .to change { Snippet.count }.by(1) + expect { create_snippet(project, visibility_level: Snippet::PRIVATE) }. + to change { Snippet.count }.by(1) end end context 'when the snippet is public' do it 'rejects the shippet' do - expect { create_snippet(project, visibility_level: Snippet::PUBLIC) } - .not_to change { Snippet.count } + expect { create_snippet(project, visibility_level: Snippet::PUBLIC) }. + not_to change { Snippet.count } expect(response).to have_http_status(400) expect(json_response['message']).to eq({ "error" => "Spam detected" }) end it 'creates a spam log' do - expect { create_snippet(project, visibility_level: Snippet::PUBLIC) } - .to change { SpamLog.count }.by(1) + expect { create_snippet(project, visibility_level: Snippet::PUBLIC) }. + to change { SpamLog.count }.by(1) end end end @@ -149,8 +149,8 @@ describe API::ProjectSnippets, api: true do let(:visibility_level) { Snippet::PRIVATE } it 'creates the snippet' do - expect { update_snippet(title: 'Foo') } - .to change { snippet.reload.title }.to('Foo') + expect { update_snippet(title: 'Foo') }. + to change { snippet.reload.title }.to('Foo') end end @@ -158,13 +158,13 @@ describe API::ProjectSnippets, api: true do let(:visibility_level) { Snippet::PUBLIC } it 'rejects the snippet' do - expect { update_snippet(title: 'Foo') } - .not_to change { snippet.reload.title } + expect { update_snippet(title: 'Foo') }. + not_to change { snippet.reload.title } end it 'creates a spam log' do - expect { update_snippet(title: 'Foo') } - .to change { SpamLog.count }.by(1) + expect { update_snippet(title: 'Foo') }. + to change { SpamLog.count }.by(1) end end @@ -172,16 +172,16 @@ describe API::ProjectSnippets, api: true do let(:visibility_level) { Snippet::PRIVATE } it 'rejects the snippet' do - expect { update_snippet(title: 'Foo', visibility_level: Snippet::PUBLIC) } - .not_to change { snippet.reload.title } + expect { update_snippet(title: 'Foo', visibility_level: Snippet::PUBLIC) }. + not_to change { snippet.reload.title } expect(response).to have_http_status(400) expect(json_response['message']).to eq({ "error" => "Spam detected" }) end it 'creates a spam log' do - expect { update_snippet(title: 'Foo', visibility_level: Snippet::PUBLIC) } - .to change { SpamLog.count }.by(1) + expect { update_snippet(title: 'Foo', visibility_level: Snippet::PUBLIC) }. + to change { SpamLog.count }.by(1) end end end diff --git a/spec/requests/api/v3/projects_spec.rb b/spec/requests/api/v3/projects_spec.rb index 273a4a58224de3990f6a1c787670cf02aeaa7746..662be3f35312cf157c3c87c7b9cca22837b8b12c 100644 --- a/spec/requests/api/v3/projects_spec.rb +++ b/spec/requests/api/v3/projects_spec.rb @@ -303,15 +303,15 @@ describe API::V3::Projects, api: true do context 'maximum number of projects reached' do it 'does not create new project and respond with 403' do allow_any_instance_of(User).to receive(:projects_limit_left).and_return(0) - expect { post v3_api('/projects', user2), name: 'foo' } - .to change {Project.count}.by(0) + expect { post v3_api('/projects', user2), name: 'foo' }. + to change {Project.count}.by(0) expect(response).to have_http_status(403) end end it 'creates new project without path and return 201' do - expect { post v3_api('/projects', user), name: 'foo' } - .to change { Project.count }.by(1) + expect { post v3_api('/projects', user), name: 'foo' }. + to change { Project.count }.by(1) expect(response).to have_http_status(201) end @@ -465,8 +465,8 @@ describe API::V3::Projects, api: true do end it 'responds with 400 on failure and not project' do - expect { post v3_api("/projects/user/#{user.id}", admin) } - .not_to change { Project.count } + expect { post v3_api("/projects/user/#{user.id}", admin) }. + not_to change { Project.count } expect(response).to have_http_status(400) expect(json_response['error']).to eq('name is missing') @@ -694,8 +694,8 @@ describe API::V3::Projects, api: true do get v3_api("/projects", user) expect(response).to have_http_status(200) - expect(json_response.first['permissions']['project_access']['access_level']) - .to eq(Gitlab::Access::MASTER) + expect(json_response.first['permissions']['project_access']['access_level']). + to eq(Gitlab::Access::MASTER) expect(json_response.first['permissions']['group_access']).to be_nil end end @@ -706,8 +706,8 @@ describe API::V3::Projects, api: true do get v3_api("/projects/#{project.id}", user) expect(response).to have_http_status(200) - expect(json_response['permissions']['project_access']['access_level']) - .to eq(Gitlab::Access::MASTER) + expect(json_response['permissions']['project_access']['access_level']). + to eq(Gitlab::Access::MASTER) expect(json_response['permissions']['group_access']).to be_nil end end @@ -722,8 +722,8 @@ describe API::V3::Projects, api: true do expect(response).to have_http_status(200) expect(json_response['permissions']['project_access']).to be_nil - expect(json_response['permissions']['group_access']['access_level']) - .to eq(Gitlab::Access::OWNER) + expect(json_response['permissions']['group_access']['access_level']). + to eq(Gitlab::Access::OWNER) end end end diff --git a/spec/requests/ci/api/builds_spec.rb b/spec/requests/ci/api/builds_spec.rb index 5ba1209af5d512a3751fc2d8b7a5fe5c2e4593a3..6d79f2e7b4128be0d5b10f44896b820c3e617628 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 @@ -93,8 +93,8 @@ describe Ci::API::Builds do context 'when concurrently updating build' do before do - expect_any_instance_of(Ci::Build).to receive(:run!) - .and_raise(ActiveRecord::StaleObjectError.new(nil, nil)) + expect_any_instance_of(Ci::Build).to receive(:run!). + and_raise(ActiveRecord::StaleObjectError.new(nil, nil)) end it 'returns a conflict' do @@ -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/requests/git_http_spec.rb b/spec/requests/git_http_spec.rb index 9adbcc3f814ae4e11edbc2f95cd596f00f711b74..87786e8562113de7f91009d1a39bcae59cf5bdd4 100644 --- a/spec/requests/git_http_spec.rb +++ b/spec/requests/git_http_spec.rb @@ -389,8 +389,8 @@ describe 'Git HTTP requests', lib: true do shared_examples 'can download code only' do it 'downloads get status 200' do - allow_any_instance_of(Repository) - .to receive(:exists?).and_return(true) + allow_any_instance_of(Repository). + to receive(:exists?).and_return(true) clone_get "#{project.path_with_namespace}.git", user: 'gitlab-ci-token', password: build.token @@ -400,8 +400,8 @@ describe 'Git HTTP requests', lib: true do end it 'downloads from non-existing repository and gets 403' do - allow_any_instance_of(Repository) - .to receive(:exists?).and_return(false) + allow_any_instance_of(Repository). + to receive(:exists?).and_return(false) clone_get "#{project.path_with_namespace}.git", user: 'gitlab-ci-token', password: build.token diff --git a/spec/serializers/analytics_build_serializer_spec.rb b/spec/serializers/analytics_build_serializer_spec.rb index e3b1dd93dc2b8c3517a50ce6312ed50ac00efaf8..c8bad5ef105332c5630b76a22cf9ca88c7d9f7bb 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 2f08958a783d4b1a55f6c484915628f8233041eb..fe26b001740b4eaf4c53f935572e6652e98fcab3 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 62067cc0ef20518958dc38b9200def9f389b7375..ee08762d2374b45efc5e629f9b66156ccfd1d509 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 5d7a94c2d0267ebc2ec6692859e7690987300f0f..3106af0ded7907bd869021e675b5b51d402187b9 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 2fc60aa9de660c43bcf11bdcd2aa66633acae710..6ccea1993763f94cce792f13b4ca35c6a970ee22 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 0333d73b5b51351469a6516aec347630ab882e62..895aeb300353020d6d0c496c77c8bc5d44f18e3d 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 6a6df377b35337fe8a45c353fcaaf2e0a08a30b6..61b2fce8e8a99eda232d28aa59df32b0fbf96bb8 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 ccb72973f9c2de19db795e56c85b70206fbaf8d0..96ef1d3c071ab0240bf28d2e5d46249d41161749 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 2aaef03cb935b9dd79e0145d38c9e7e9cd36dc95..5f84a98f06d3e794919641352af58f0bee9fe4ca 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 aa666b961dc26b82620554e46eeb5e44fa675ea5..94dbf02aee8df78a0c0364294b7466f3590384e7 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 4ab40d08432a79e098ade6de1dc10964c26dfae3..42f19935453ffff7d6029f806f058ae40d6cd570 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 b818dfdd50c1c0d60e71078afe3c8bce47b79e67..65544c574314da08430ca5cdda6853ba0e07c02b 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 d03f7505eacc59eb8e63cd21a0f8d6e3b49304ce..6499c7ad63e7382f2e2ef1d00d17e030945e2cd5 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 c0af8b8450a4a02fbb03a7a4a4dbcd9cd61bc6db..84915b5f1aa10e61132ba378f15caba6bb42f6dc 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 560f83d94f7c7204116caca15b63f6039a427d1e..23e0856fecdb49505c421189b658e2f45a33b7ed 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 f01a388b895ea31a6031725f78d33c9137e7eec7..14092d9dcca0fb694d868c5e5c697a30221ce67e 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/files/update_service_spec.rb b/spec/services/files/update_service_spec.rb index 3e0a0e9587009fba3374fb990803b0cd0e2c2676..35e6e1392385c2f7a8773345d7e66a111ae98cb5 100644 --- a/spec/services/files/update_service_spec.rb +++ b/spec/services/files/update_service_spec.rb @@ -32,8 +32,8 @@ describe Files::UpdateService do let(:last_commit_sha) { "foo" } it "returns a hash with the correct error message and a :error status " do - expect { subject.execute } - .to raise_error(Files::UpdateService::FileChangedError, + expect { subject.execute }. + to raise_error(Files::UpdateService::FileChangedError, "You are attempting to update a file that has changed since you started editing it.") end end diff --git a/spec/services/git_push_service_spec.rb b/spec/services/git_push_service_spec.rb index d4fc4611bed099df707cf1602431edbcd85f506c..2a0f00ce93721f49e203d9a5890e7f3e81929071 100644 --- a/spec/services/git_push_service_spec.rb +++ b/spec/services/git_push_service_spec.rb @@ -145,8 +145,8 @@ describe GitPushService, services: true do context "Updates merge requests" do it "when pushing a new branch for the first time" do - expect(UpdateMergeRequestsWorker).to receive(:perform_async) - .with(project.id, user.id, @blankrev, 'newrev', 'refs/heads/master') + expect(UpdateMergeRequestsWorker).to receive(:perform_async). + with(project.id, user.id, @blankrev, 'newrev', 'refs/heads/master') execute_service(project, user, @blankrev, 'newrev', 'refs/heads/master' ) end end @@ -263,8 +263,8 @@ describe GitPushService, services: true do author_email: commit_author.email ) - allow_any_instance_of(ProcessCommitWorker).to receive(:build_commit) - .and_return(commit) + allow_any_instance_of(ProcessCommitWorker).to receive(:build_commit). + and_return(commit) allow(project.repository).to receive(:commits_between).and_return([commit]) end @@ -321,8 +321,8 @@ describe GitPushService, services: true do committed_date: commit_time ) - allow_any_instance_of(ProcessCommitWorker).to receive(:build_commit) - .and_return(commit) + allow_any_instance_of(ProcessCommitWorker).to receive(:build_commit). + and_return(commit) allow(project.repository).to receive(:commits_between).and_return([commit]) end @@ -357,11 +357,11 @@ describe GitPushService, services: true do author_email: commit_author.email ) - allow(project.repository).to receive(:commits_between) - .and_return([closing_commit]) + allow(project.repository).to receive(:commits_between). + and_return([closing_commit]) - allow_any_instance_of(ProcessCommitWorker).to receive(:build_commit) - .and_return(closing_commit) + allow_any_instance_of(ProcessCommitWorker).to receive(:build_commit). + and_return(closing_commit) project.team << [commit_author, :master] end @@ -383,8 +383,8 @@ describe GitPushService, services: true do end it "doesn't close issues when external issue tracker is in use" do - allow_any_instance_of(Project).to receive(:default_issues_tracker?) - .and_return(false) + allow_any_instance_of(Project).to receive(:default_issues_tracker?). + and_return(false) external_issue_tracker = double(title: 'My Tracker', issue_path: issue.iid, reference_pattern: project.issue_reference_pattern) allow_any_instance_of(Project).to receive(:external_issue_tracker).and_return(external_issue_tracker) @@ -577,13 +577,13 @@ describe GitPushService, services: true do commit = double(:commit) diff = double(:diff, new_path: 'README.md') - expect(commit).to receive(:raw_diffs).with(deltas_only: true) - .and_return([diff]) + expect(commit).to receive(:raw_diffs).with(deltas_only: true). + and_return([diff]) service.push_commits = [commit] - expect(ProjectCacheWorker).to receive(:perform_async) - .with(project.id, %i(readme), %i(commit_count repository_size)) + expect(ProjectCacheWorker).to receive(:perform_async). + with(project.id, %i(readme), %i(commit_count repository_size)) service.update_caches end @@ -595,9 +595,9 @@ describe GitPushService, services: true do end it 'does not flush any conditional caches' do - expect(ProjectCacheWorker).to receive(:perform_async) - .with(project.id, [], %i(commit_count repository_size)) - .and_call_original + expect(ProjectCacheWorker).to receive(:perform_async). + with(project.id, [], %i(commit_count repository_size)). + and_call_original service.update_caches end @@ -614,8 +614,8 @@ describe GitPushService, services: true do end it 'only schedules a limited number of commits' do - allow(service).to receive(:push_commits) - .and_return(Array.new(1000, double(:commit, to_hash: {}))) + allow(service).to receive(:push_commits). + and_return(Array.new(1000, double(:commit, to_hash: {}))) expect(ProcessCommitWorker).to receive(:perform_async).exactly(100).times diff --git a/spec/services/issuable/bulk_update_service_spec.rb b/spec/services/issuable/bulk_update_service_spec.rb index 0475f38fe5effa2c4150cff46ff43db7f81bed21..87da8581e680e741ca4f3a281916fe8265c675b5 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/close_service_spec.rb b/spec/services/issues/close_service_spec.rb index 8f5bd4566ecfa903bc2f8f4b8395ebbe908f6d69..7a54373963e54bbba865402155a0f3d8c3012015 100644 --- a/spec/services/issues/close_service_spec.rb +++ b/spec/services/issues/close_service_spec.rb @@ -18,26 +18,26 @@ describe Issues::CloseService, services: true do let(:service) { described_class.new(project, user) } it 'checks if the user is authorized to update the issue' do - expect(service).to receive(:can?).with(user, :update_issue, issue) - .and_call_original + expect(service).to receive(:can?).with(user, :update_issue, issue). + and_call_original service.execute(issue) end it 'does not close the issue when the user is not authorized to do so' do - allow(service).to receive(:can?).with(user, :update_issue, issue) - .and_return(false) + allow(service).to receive(:can?).with(user, :update_issue, issue). + and_return(false) expect(service).not_to receive(:close_issue) expect(service.execute(issue)).to eq(issue) end it 'closes the issue when the user is authorized to do so' do - allow(service).to receive(:can?).with(user, :update_issue, issue) - .and_return(true) + allow(service).to receive(:can?).with(user, :update_issue, issue). + and_return(true) - expect(service).to receive(:close_issue) - .with(issue, commit: nil, notifications: true, system_note: true) + expect(service).to receive(:close_issue). + with(issue, commit: nil, notifications: true, system_note: true) service.execute(issue) end diff --git a/spec/services/issues/move_service_spec.rb b/spec/services/issues/move_service_spec.rb index db196ed575161f168cdcab11d500635ce402cf04..59c0fa509948a5c33a562561b3e12ac03a6f4ce7 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/labels/promote_service_spec.rb b/spec/services/labels/promote_service_spec.rb index 500afdfb9161bd5e5178e4c56e0b1fe8b724c4c8..4b90ad19640cf07eb95540eb69b4e172fe950f92 100644 --- a/spec/services/labels/promote_service_spec.rb +++ b/spec/services/labels/promote_service_spec.rb @@ -66,9 +66,9 @@ describe Labels::PromoteService, services: true do end it 'recreates the label as a group label' do - expect { service.execute(project_label_1_1) } - .to change(project_1.labels, :count).by(-1) - .and change(group_1.labels, :count).by(1) + expect { service.execute(project_label_1_1) }. + to change(project_1.labels, :count).by(-1). + and change(group_1.labels, :count).by(1) expect(new_label).not_to be_nil end diff --git a/spec/services/members/destroy_service_spec.rb b/spec/services/members/destroy_service_spec.rb index e6160e0ad42b1fc92c2de9201826510dcd3b9434..574df6e0f421d1b9bd8789bcc053ef1970dba4fc 100644 --- a/spec/services/members/destroy_service_spec.rb +++ b/spec/services/members/destroy_service_spec.rb @@ -104,8 +104,8 @@ describe Members::DestroyService, services: true do let(:params) { { id: project.members.find_by!(user_id: user.id).id } } it 'destroys the member' do - expect { described_class.new(project, user, params).execute } - .to change { project.members.count }.by(-1) + expect { described_class.new(project, user, params).execute }. + to change { project.members.count }.by(-1) 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 d80fb8a1af19c107b923c05188f16f885c51db87..881458c190fdbe29548fcb4466822a56f4a2dffc 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/close_service_spec.rb b/spec/services/merge_requests/close_service_spec.rb index abc266b3aa793a24d2f003dd5d7c04a5d272e730..d55a7657c0ea2acb160ae58aa1c448ee427ce660 100644 --- a/spec/services/merge_requests/close_service_spec.rb +++ b/spec/services/merge_requests/close_service_spec.rb @@ -30,8 +30,8 @@ describe MergeRequests::CloseService, services: true do it { expect(@merge_request).to be_closed } it 'executes hooks with close action' do - expect(service).to have_received(:execute_hooks) - .with(@merge_request, 'close') + expect(service).to have_received(:execute_hooks). + with(@merge_request, 'close') end it 'sends email to user2 about assign of new merge_request' do diff --git a/spec/services/merge_requests/merge_service_spec.rb b/spec/services/merge_requests/merge_service_spec.rb index 1dcb4f6b3ee8aca4a899f18008b7613444211320..d96f819e66ac6c666b4ddca23f066fed3349b7aa 100644 --- a/spec/services/merge_requests/merge_service_spec.rb +++ b/spec/services/merge_requests/merge_service_spec.rb @@ -139,9 +139,9 @@ describe MergeRequests::MergeService, services: true do end it 'removes the source branch' do - expect(DeleteBranchService).to receive(:new) - .with(merge_request.source_project, merge_request.author) - .and_call_original + expect(DeleteBranchService).to receive(:new). + with(merge_request.source_project, merge_request.author). + and_call_original service.execute(merge_request) 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 f92978a33a3dabce6990b9d818e991fa018e078e..65c08ce15f77b76f014511c2a28a2627b6ec952a 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/refresh_service_spec.rb b/spec/services/merge_requests/refresh_service_spec.rb index af951588fc65b8fd40ecbdbbb94ea6dfa8babb8b..983dac6efdb10101b9ccf56c70654f09575e562f 100644 --- a/spec/services/merge_requests/refresh_service_spec.rb +++ b/spec/services/merge_requests/refresh_service_spec.rb @@ -56,8 +56,8 @@ describe MergeRequests::RefreshService, services: true do end it 'executes hooks with update action' do - expect(refresh_service).to have_received(:execute_hooks) - .with(@merge_request, 'update', @oldrev) + expect(refresh_service).to have_received(:execute_hooks). + with(@merge_request, 'update', @oldrev) end it { expect(@merge_request.notes).not_to be_empty } @@ -115,8 +115,8 @@ describe MergeRequests::RefreshService, services: true do end it 'executes hooks with update action' do - expect(refresh_service).to have_received(:execute_hooks) - .with(@fork_merge_request, 'update', @oldrev) + expect(refresh_service).to have_received(:execute_hooks). + with(@fork_merge_request, 'update', @oldrev) end it { expect(@merge_request.notes).to be_empty } @@ -191,8 +191,8 @@ describe MergeRequests::RefreshService, services: true do let(:refresh_service) { service.new(@fork_project, @user) } it 'refreshes the merge request' do - expect(refresh_service).to receive(:execute_hooks) - .with(@fork_merge_request, 'update', Gitlab::Git::BLANK_SHA) + expect(refresh_service).to receive(:execute_hooks). + with(@fork_merge_request, 'update', Gitlab::Git::BLANK_SHA) allow_any_instance_of(Repository).to receive(:merge_base).and_return(@oldrev) refresh_service.execute(Gitlab::Git::BLANK_SHA, @newrev, 'refs/heads/master') diff --git a/spec/services/merge_requests/reopen_service_spec.rb b/spec/services/merge_requests/reopen_service_spec.rb index 3fda94a8bc52c2211a6c4032a7ecef29fdc94cc5..a99d4eac9bde5db6288496b3c8cc6597218029e0 100644 --- a/spec/services/merge_requests/reopen_service_spec.rb +++ b/spec/services/merge_requests/reopen_service_spec.rb @@ -29,8 +29,8 @@ describe MergeRequests::ReopenService, services: true do it { expect(merge_request).to be_reopened } it 'executes hooks with reopen action' do - expect(service).to have_received(:execute_hooks) - .with(merge_request, 'reopen') + expect(service).to have_received(:execute_hooks). + with(merge_request, 'reopen') end it 'sends email to user2 about reopen of merge_request' do diff --git a/spec/services/merge_requests/resolve_service_spec.rb b/spec/services/merge_requests/resolve_service_spec.rb index b7f475597b4e11e4b7b4aede3940573237607efe..57b1c088ce4d41cf22cba2d5d3e82eccc58d5750 100644 --- a/spec/services/merge_requests/resolve_service_spec.rb +++ b/spec/services/merge_requests/resolve_service_spec.rb @@ -58,8 +58,8 @@ describe MergeRequests::ResolveService do end it 'creates a commit with the correct parents' do - expect(merge_request.source_branch_head.parents.map(&:id)) - .to eq(%w(1450cd639e0bc6721eb02800169e464f212cde06 + expect(merge_request.source_branch_head.parents.map(&:id)). + to eq(%w(1450cd639e0bc6721eb02800169e464f212cde06 824be604a34828eb682305f0d963056cfac87b2d)) end end @@ -84,8 +84,8 @@ describe MergeRequests::ResolveService do end it 'creates a commit with the correct parents' do - expect(merge_request_from_fork.source_branch_head.parents.map(&:id)) - .to eq(['404fa3fc7c2c9b5dacff102f353bdf55b1be2813', + expect(merge_request_from_fork.source_branch_head.parents.map(&:id)). + to eq(['404fa3fc7c2c9b5dacff102f353bdf55b1be2813', target_head]) end end @@ -124,8 +124,8 @@ describe MergeRequests::ResolveService do end it 'creates a commit with the correct parents' do - expect(merge_request.source_branch_head.parents.map(&:id)) - .to eq(%w(1450cd639e0bc6721eb02800169e464f212cde06 + expect(merge_request.source_branch_head.parents.map(&:id)). + to eq(%w(1450cd639e0bc6721eb02800169e464f212cde06 824be604a34828eb682305f0d963056cfac87b2d)) end @@ -158,8 +158,8 @@ describe MergeRequests::ResolveService do let(:service) { MergeRequests::ResolveService.new(project, user, invalid_params) } it 'raises a MissingResolution error' do - expect { service.execute(merge_request) } - .to raise_error(Gitlab::Conflict::File::MissingResolution) + expect { service.execute(merge_request) }. + to raise_error(Gitlab::Conflict::File::MissingResolution) end end @@ -184,8 +184,8 @@ describe MergeRequests::ResolveService do let(:service) { MergeRequests::ResolveService.new(project, user, invalid_params) } it 'raises a MissingResolution error' do - expect { service.execute(merge_request) } - .to raise_error(Gitlab::Conflict::File::MissingResolution) + expect { service.execute(merge_request) }. + to raise_error(Gitlab::Conflict::File::MissingResolution) end end @@ -206,8 +206,8 @@ describe MergeRequests::ResolveService do let(:service) { MergeRequests::ResolveService.new(project, user, invalid_params) } it 'raises a MissingFiles error' do - expect { service.execute(merge_request) } - .to raise_error(MergeRequests::ResolveService::MissingFiles) + expect { service.execute(merge_request) }. + to raise_error(MergeRequests::ResolveService::MissingFiles) end end end diff --git a/spec/services/merge_requests/update_service_spec.rb b/spec/services/merge_requests/update_service_spec.rb index b67874ed4c37a488456fb3963d016534a47b25be..7d73c0ea5d0e7dd70ec748ba5b99de9adbc2bc4f 100644 --- a/spec/services/merge_requests/update_service_spec.rb +++ b/spec/services/merge_requests/update_service_spec.rb @@ -68,8 +68,8 @@ describe MergeRequests::UpdateService, services: true do it { expect(@merge_request.merge_params['force_remove_source_branch']).to eq('1') } it 'executes hooks with update action' do - expect(service).to have_received(:execute_hooks) - .with(@merge_request, 'update') + expect(service).to have_received(:execute_hooks). + with(@merge_request, 'update') end it 'sends email to user2 about assign of new merge request and email to user3 about merge request unassignment' do @@ -171,8 +171,8 @@ describe MergeRequests::UpdateService, services: true do ref: merge_request.source_branch, sha: merge_request.diff_head_sha) - expect(MergeRequests::MergeWhenPipelineSucceedsService).to receive(:new).with(project, user) - .and_return(service_mock) + expect(MergeRequests::MergeWhenPipelineSucceedsService).to receive(:new).with(project, user). + and_return(service_mock) expect(service_mock).to receive(:execute).with(merge_request) end diff --git a/spec/services/projects/housekeeping_service_spec.rb b/spec/services/projects/housekeeping_service_spec.rb index 471ba78714bad291510f0c0380d7949158294583..57a5aa5cedc11d22082c932466f73bce98f74fcf 100644 --- a/spec/services/projects/housekeeping_service_spec.rb +++ b/spec/services/projects/housekeeping_service_spec.rb @@ -66,14 +66,14 @@ describe Projects::HousekeepingService do allow(subject).to receive(:lease_key).and_return(:the_lease_key) # At push 200 - expect(GitGarbageCollectWorker).to receive(:perform_async).with(project.id, :gc, :the_lease_key, :the_uuid) - .exactly(1).times + expect(GitGarbageCollectWorker).to receive(:perform_async).with(project.id, :gc, :the_lease_key, :the_uuid). + exactly(1).times # At push 50, 100, 150 - expect(GitGarbageCollectWorker).to receive(:perform_async).with(project.id, :full_repack, :the_lease_key, :the_uuid) - .exactly(3).times + expect(GitGarbageCollectWorker).to receive(:perform_async).with(project.id, :full_repack, :the_lease_key, :the_uuid). + exactly(3).times # At push 10, 20, ... (except those above) - expect(GitGarbageCollectWorker).to receive(:perform_async).with(project.id, :incremental_repack, :the_lease_key, :the_uuid) - .exactly(16).times + expect(GitGarbageCollectWorker).to receive(:perform_async).with(project.id, :incremental_repack, :the_lease_key, :the_uuid). + exactly(16).times 201.times do subject.increment! diff --git a/spec/services/projects/import_service_spec.rb b/spec/services/projects/import_service_spec.rb index 297837537a374079a5de1c7c8e234627c7cd581b..ab6e8f537bac91e1f6d89c55adf0c848eacae554 100644 --- a/spec/services/projects/import_service_spec.rb +++ b/spec/services/projects/import_service_spec.rb @@ -73,18 +73,18 @@ describe Projects::ImportService, services: true do end it 'flushes various caches' do - expect_any_instance_of(Gitlab::Shell).to receive(:import_repository) - .with(project.repository_storage_path, project.path_with_namespace, project.import_url) - .and_return(true) + expect_any_instance_of(Gitlab::Shell).to receive(:import_repository). + with(project.repository_storage_path, project.path_with_namespace, project.import_url). + and_return(true) - expect_any_instance_of(Gitlab::GithubImport::Importer).to receive(:execute) - .and_return(true) + expect_any_instance_of(Gitlab::GithubImport::Importer).to receive(:execute). + and_return(true) - expect_any_instance_of(Repository).to receive(:expire_emptiness_caches) - .and_call_original + expect_any_instance_of(Repository).to receive(:expire_emptiness_caches). + and_call_original - expect_any_instance_of(Repository).to receive(:expire_exists_cache) - .and_call_original + expect_any_instance_of(Repository).to receive(:expire_exists_cache). + and_call_original subject.execute end diff --git a/spec/services/projects/transfer_service_spec.rb b/spec/services/projects/transfer_service_spec.rb index b6b7f94061ece38cb66ac7bb7457904300a926cb..5c6fbea8d0e218d2bcd93e7c339d5a9f1bc3a90d 100644 --- a/spec/services/projects/transfer_service_spec.rb +++ b/spec/services/projects/transfer_service_spec.rb @@ -7,10 +7,10 @@ describe Projects::TransferService, services: true do context 'namespace -> namespace' do before do - allow_any_instance_of(Gitlab::UploadsTransfer) - .to receive(:move_project).and_return(true) - allow_any_instance_of(Gitlab::PagesTransfer) - .to receive(:move_project).and_return(true) + allow_any_instance_of(Gitlab::UploadsTransfer). + to receive(:move_project).and_return(true) + allow_any_instance_of(Gitlab::PagesTransfer). + to receive(:move_project).and_return(true) group.add_owner(user) @result = transfer_project(project, user, group) end @@ -102,9 +102,9 @@ describe Projects::TransferService, services: true do end it 'only schedules a single job for every user' do - expect(UserProjectAccessChangedService).to receive(:new) - .with([owner.id, group_member.id]) - .and_call_original + expect(UserProjectAccessChangedService).to receive(:new). + with([owner.id, group_member.id]). + and_call_original transfer_project(project, owner, group) end diff --git a/spec/services/projects/unlink_fork_service_spec.rb b/spec/services/projects/unlink_fork_service_spec.rb index d34652bd7acf9e01231c597dacef013aecd0155e..23f5555d3e0e98af66c906adf887af50a8deaa54 100644 --- a/spec/services/projects/unlink_fork_service_spec.rb +++ b/spec/services/projects/unlink_fork_service_spec.rb @@ -12,9 +12,9 @@ describe Projects::UnlinkForkService, services: true do let(:mr_close_service) { MergeRequests::CloseService.new(fork_project, user) } before do - allow(MergeRequests::CloseService).to receive(:new) - .with(fork_project, user) - .and_return(mr_close_service) + allow(MergeRequests::CloseService).to receive(:new). + with(fork_project, user). + and_return(mr_close_service) end it 'close all pending merge requests' do diff --git a/spec/services/system_note_service_spec.rb b/spec/services/system_note_service_spec.rb index dfa5175b7d8b5ace0b5445b966796068b1098f17..eca5a418f2a31cc2e76e09bb4e47439dcac724f2 100644 --- a/spec/services/system_note_service_spec.rb +++ b/spec/services/system_note_service_spec.rb @@ -253,8 +253,8 @@ describe SystemNoteService, services: true do it_behaves_like 'a system note' it 'sets the note text' do - expect(subject.note) - .to eq "changed title from **{-Old title-}** to **{+Lorem ipsum+}**" + expect(subject.note). + to eq "changed title from **{-Old title-}** to **{+Lorem ipsum+}**" end end end @@ -388,8 +388,8 @@ describe SystemNoteService, services: true do context 'when mentioner is not a MergeRequest' do it 'is falsey' do mentioner = noteable.dup - expect(described_class.cross_reference_disallowed?(noteable, mentioner)) - .to be_falsey + expect(described_class.cross_reference_disallowed?(noteable, mentioner)). + to be_falsey end end @@ -399,14 +399,14 @@ describe SystemNoteService, services: true do it 'is truthy when noteable is in commits' do expect(mentioner).to receive(:commits).and_return([noteable]) - expect(described_class.cross_reference_disallowed?(noteable, mentioner)) - .to be_truthy + expect(described_class.cross_reference_disallowed?(noteable, mentioner)). + to be_truthy end it 'is falsey when noteable is not in commits' do expect(mentioner).to receive(:commits).and_return([]) - expect(described_class.cross_reference_disallowed?(noteable, mentioner)) - .to be_falsey + expect(described_class.cross_reference_disallowed?(noteable, mentioner)). + to be_falsey end end @@ -414,8 +414,8 @@ describe SystemNoteService, services: true do let(:noteable) { ExternalIssue.new('EXT-1234', project) } it 'is truthy' do mentioner = noteable.dup - expect(described_class.cross_reference_disallowed?(noteable, mentioner)) - .to be_truthy + expect(described_class.cross_reference_disallowed?(noteable, mentioner)). + to be_truthy end end @@ -425,13 +425,13 @@ describe SystemNoteService, services: true do it 'is truthy when issue is closed' do issue.close - expect(described_class.cross_reference_disallowed?(issue, project.commit)) - .to be_truthy + expect(described_class.cross_reference_disallowed?(issue, project.commit)). + to be_truthy end it 'is falsey when issue is open' do - expect(described_class.cross_reference_disallowed?(issue, project.commit)) - .to be_falsy + expect(described_class.cross_reference_disallowed?(issue, project.commit)). + to be_falsy end end @@ -441,20 +441,20 @@ describe SystemNoteService, services: true do it 'is truthy when merge request is closed' do allow(merge_request).to receive(:closed?).and_return(:true) - expect(described_class.cross_reference_disallowed?(merge_request, project.commit)) - .to be_truthy + expect(described_class.cross_reference_disallowed?(merge_request, project.commit)). + to be_truthy end it 'is truthy when merge request is merged' do allow(merge_request).to receive(:closed?).and_return(:true) - expect(described_class.cross_reference_disallowed?(merge_request, project.commit)) - .to be_truthy + expect(described_class.cross_reference_disallowed?(merge_request, project.commit)). + to be_truthy end it 'is falsey when merge request is open' do - expect(described_class.cross_reference_disallowed?(merge_request, project.commit)) - .to be_falsy + expect(described_class.cross_reference_disallowed?(merge_request, project.commit)). + to be_falsy end end end @@ -470,13 +470,13 @@ describe SystemNoteService, services: true do end it 'is truthy when already mentioned' do - expect(described_class.cross_reference_exists?(noteable, commit0)) - .to be_truthy + expect(described_class.cross_reference_exists?(noteable, commit0)). + to be_truthy end it 'is falsey when not already mentioned' do - expect(described_class.cross_reference_exists?(noteable, commit1)) - .to be_falsey + expect(described_class.cross_reference_exists?(noteable, commit1)). + to be_falsey end context 'legacy capitalized cross reference' do @@ -487,8 +487,8 @@ describe SystemNoteService, services: true do end it 'is truthy when already mentioned' do - expect(described_class.cross_reference_exists?(noteable, commit0)) - .to be_truthy + expect(described_class.cross_reference_exists?(noteable, commit0)). + to be_truthy end end end @@ -500,13 +500,13 @@ describe SystemNoteService, services: true do end it 'is truthy when already mentioned' do - expect(described_class.cross_reference_exists?(commit0, commit1)) - .to be_truthy + expect(described_class.cross_reference_exists?(commit0, commit1)). + to be_truthy end it 'is falsey when not already mentioned' do - expect(described_class.cross_reference_exists?(commit1, commit0)) - .to be_falsey + expect(described_class.cross_reference_exists?(commit1, commit0)). + to be_falsey end context 'legacy capitalized cross reference' do @@ -517,8 +517,8 @@ describe SystemNoteService, services: true do end it 'is truthy when already mentioned' do - expect(described_class.cross_reference_exists?(commit0, commit1)) - .to be_truthy + expect(described_class.cross_reference_exists?(commit0, commit1)). + to be_truthy end end end @@ -533,8 +533,8 @@ describe SystemNoteService, services: true do end it 'is true when a fork mentions an external issue' do - expect(described_class.cross_reference_exists?(noteable, commit2)) - .to be true + expect(described_class.cross_reference_exists?(noteable, commit2)). + to be true end context 'legacy capitalized cross reference' do @@ -544,8 +544,8 @@ describe SystemNoteService, services: true do end it 'is true when a fork mentions an external issue' do - expect(described_class.cross_reference_exists?(noteable, commit2)) - .to be true + expect(described_class.cross_reference_exists?(noteable, commit2)). + to be true end end end @@ -771,8 +771,8 @@ describe SystemNoteService, services: true do it 'creates a new note in the discussion' do # we need to completely rebuild the merge request object, or the `@discussions` on the merge request are not reloaded. - expect { SystemNoteService.discussion_continued_in_issue(discussion, project, user, issue) } - .to change { reloaded_merge_request.discussions.first.notes.size }.by(1) + expect { SystemNoteService.discussion_continued_in_issue(discussion, project, user, issue) }. + to change { reloaded_merge_request.discussions.first.notes.size }.by(1) end it 'mentions the created issue in the system note' do diff --git a/spec/services/tags/create_service_spec.rb b/spec/services/tags/create_service_spec.rb index 4bb8a0ec290aa45271f45cb1d7521c683d0758ed..5478b8c9ec0690f8a9b53d72905fc2f44cd87cdb 100644 --- a/spec/services/tags/create_service_spec.rb +++ b/spec/services/tags/create_service_spec.rb @@ -26,9 +26,9 @@ describe Tags::CreateService, services: true do context 'when tag already exists' do it 'returns an error' do - expect(repository).to receive(:add_tag) - .with(user, 'v1.1.0', 'master', 'Foo') - .and_raise(Rugged::TagError) + expect(repository).to receive(:add_tag). + with(user, 'v1.1.0', 'master', 'Foo'). + and_raise(Rugged::TagError) response = service.execute('v1.1.0', 'master', 'Foo') @@ -39,9 +39,9 @@ describe Tags::CreateService, services: true do context 'when pre-receive hook fails' do it 'returns an error' do - expect(repository).to receive(:add_tag) - .with(user, 'v1.1.0', 'master', 'Foo') - .and_raise(GitHooksService::PreReceiveError, 'something went wrong') + expect(repository).to receive(:add_tag). + with(user, 'v1.1.0', 'master', 'Foo'). + and_raise(GitHooksService::PreReceiveError, 'something went wrong') response = service.execute('v1.1.0', 'master', 'Foo') diff --git a/spec/services/todo_service_spec.rb b/spec/services/todo_service_spec.rb index 9f24cc0f3f230fde10873c1d41cd8108b536bcde..6dfcb702510fb61160f3936178f0eca9f28a555b 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/services/user_project_access_changed_service_spec.rb b/spec/services/user_project_access_changed_service_spec.rb index 14a5e40350a7d1bb042ccb7c27f2636dbd2c0818..b4efe7de4318cc64147ed9ba6423076861468889 100644 --- a/spec/services/user_project_access_changed_service_spec.rb +++ b/spec/services/user_project_access_changed_service_spec.rb @@ -3,8 +3,8 @@ require 'spec_helper' describe UserProjectAccessChangedService do describe '#execute' do it 'schedules the user IDs' do - expect(AuthorizedProjectsWorker).to receive(:bulk_perform_and_wait) - .with([[1], [2]]) + expect(AuthorizedProjectsWorker).to receive(:bulk_perform_and_wait). + with([[1], [2]]) described_class.new([1, 2]).execute end diff --git a/spec/services/users/refresh_authorized_projects_service_spec.rb b/spec/services/users/refresh_authorized_projects_service_spec.rb index 0a527c7c5d198741283e5594a3f7955757f2f272..690fe9794928ac5f1f90b6bb1370f85022a17a10 100644 --- a/spec/services/users/refresh_authorized_projects_service_spec.rb +++ b/spec/services/users/refresh_authorized_projects_service_spec.rb @@ -6,17 +6,17 @@ describe Users::RefreshAuthorizedProjectsService do let(:service) { described_class.new(user) } def create_authorization(project, user, access_level = Gitlab::Access::MASTER) - ProjectAuthorization - .create!(project: project, user: user, access_level: access_level) + ProjectAuthorization. + create!(project: project, user: user, access_level: access_level) end describe '#execute', :redis do it 'refreshes the authorizations using a lease' do - expect_any_instance_of(Gitlab::ExclusiveLease).to receive(:try_obtain) - .and_return('foo') + expect_any_instance_of(Gitlab::ExclusiveLease).to receive(:try_obtain). + and_return('foo') - expect(Gitlab::ExclusiveLease).to receive(:cancel) - .with(an_instance_of(String), 'foo') + expect(Gitlab::ExclusiveLease).to receive(:cancel). + with(an_instance_of(String), 'foo') expect(service).to receive(:execute_without_lease) @@ -33,8 +33,8 @@ describe Users::RefreshAuthorizedProjectsService do project2 = create(:empty_project) to_remove = create_authorization(project2, user) - expect(service).to receive(:update_authorizations) - .with([to_remove.project_id], [[user.id, project.id, Gitlab::Access::MASTER]]) + expect(service).to receive(:update_authorizations). + with([to_remove.project_id], [[user.id, project.id, Gitlab::Access::MASTER]]) service.execute_without_lease end @@ -42,8 +42,8 @@ describe Users::RefreshAuthorizedProjectsService do it 'sets the access level of a project to the highest available level' do to_remove = create_authorization(project, user, Gitlab::Access::DEVELOPER) - expect(service).to receive(:update_authorizations) - .with([to_remove.project_id], [[user.id, project.id, Gitlab::Access::MASTER]]) + expect(service).to receive(:update_authorizations). + with([to_remove.project_id], [[user.id, project.id, Gitlab::Access::MASTER]]) service.execute_without_lease end diff --git a/spec/support/controllers/githubish_import_controller_shared_examples.rb b/spec/support/controllers/githubish_import_controller_shared_examples.rb index c8f8d2d57b4b5980fe7d1d5da5b2224763522099..d0fd2d52004f62e8185e3701b6435ea94162a75f 100644 --- a/spec/support/controllers/githubish_import_controller_shared_examples.rb +++ b/spec/support/controllers/githubish_import_controller_shared_examples.rb @@ -14,8 +14,8 @@ shared_examples 'a GitHub-ish import controller: POST personal_access_token' do it "updates access token" do token = 'asdfasdf9876' - allow_any_instance_of(Gitlab::GithubImport::Client) - .to receive(:user).and_return(true) + allow_any_instance_of(Gitlab::GithubImport::Client). + to receive(:user).and_return(true) post :personal_access_token, personal_access_token: token @@ -79,8 +79,8 @@ shared_examples 'a GitHub-ish import controller: GET status' do end it "handles an invalid access token" do - allow_any_instance_of(Gitlab::GithubImport::Client) - .to receive(:repos).and_raise(Octokit::Unauthorized) + allow_any_instance_of(Gitlab::GithubImport::Client). + to receive(:repos).and_raise(Octokit::Unauthorized) get :status @@ -110,9 +110,9 @@ shared_examples 'a GitHub-ish import controller: POST create' do context "when the repository owner is the provider user" do context "when the provider user and GitLab user's usernames match" do it "takes the current user's namespace" do - expect(Gitlab::GithubImport::ProjectCreator) - .to receive(:new).with(provider_repo, provider_repo.name, user.namespace, user, access_params, type: provider) - .and_return(double(execute: true)) + expect(Gitlab::GithubImport::ProjectCreator). + to receive(:new).with(provider_repo, provider_repo.name, user.namespace, user, access_params, type: provider). + and_return(double(execute: true)) post :create, format: :js end @@ -122,9 +122,9 @@ shared_examples 'a GitHub-ish import controller: POST create' do let(:provider_username) { "someone_else" } it "takes the current user's namespace" do - expect(Gitlab::GithubImport::ProjectCreator) - .to receive(:new).with(provider_repo, provider_repo.name, user.namespace, user, access_params, type: provider) - .and_return(double(execute: true)) + expect(Gitlab::GithubImport::ProjectCreator). + to receive(:new).with(provider_repo, provider_repo.name, user.namespace, user, access_params, type: provider). + and_return(double(execute: true)) post :create, format: :js end @@ -144,9 +144,9 @@ shared_examples 'a GitHub-ish import controller: POST create' do context "when the namespace is owned by the GitLab user" do it "takes the existing namespace" do - expect(Gitlab::GithubImport::ProjectCreator) - .to receive(:new).with(provider_repo, provider_repo.name, existing_namespace, user, access_params, type: provider) - .and_return(double(execute: true)) + expect(Gitlab::GithubImport::ProjectCreator). + to receive(:new).with(provider_repo, provider_repo.name, existing_namespace, user, access_params, type: provider). + and_return(double(execute: true)) post :create, format: :js end @@ -159,9 +159,9 @@ shared_examples 'a GitHub-ish import controller: POST create' do end it "creates a project using user's namespace" do - expect(Gitlab::GithubImport::ProjectCreator) - .to receive(:new).with(provider_repo, provider_repo.name, user.namespace, user, access_params, type: provider) - .and_return(double(execute: true)) + expect(Gitlab::GithubImport::ProjectCreator). + to receive(:new).with(provider_repo, provider_repo.name, user.namespace, user, access_params, type: provider). + and_return(double(execute: true)) post :create, format: :js end @@ -171,16 +171,16 @@ shared_examples 'a GitHub-ish import controller: POST create' do context "when a namespace with the provider user's username doesn't exist" do context "when current user can create namespaces" do it "creates the namespace" do - expect(Gitlab::GithubImport::ProjectCreator) - .to receive(:new).and_return(double(execute: true)) + expect(Gitlab::GithubImport::ProjectCreator). + to receive(:new).and_return(double(execute: true)) expect { post :create, target_namespace: provider_repo.name, format: :js }.to change(Namespace, :count).by(1) end it "takes the new namespace" do - expect(Gitlab::GithubImport::ProjectCreator) - .to receive(:new).with(provider_repo, provider_repo.name, an_instance_of(Group), user, access_params, type: provider) - .and_return(double(execute: true)) + expect(Gitlab::GithubImport::ProjectCreator). + to receive(:new).with(provider_repo, provider_repo.name, an_instance_of(Group), user, access_params, type: provider). + and_return(double(execute: true)) post :create, target_namespace: provider_repo.name, format: :js end @@ -192,16 +192,16 @@ shared_examples 'a GitHub-ish import controller: POST create' do end it "doesn't create the namespace" do - expect(Gitlab::GithubImport::ProjectCreator) - .to receive(:new).and_return(double(execute: true)) + expect(Gitlab::GithubImport::ProjectCreator). + to receive(:new).and_return(double(execute: true)) expect { post :create, format: :js }.not_to change(Namespace, :count) end it "takes the current user's namespace" do - expect(Gitlab::GithubImport::ProjectCreator) - .to receive(:new).with(provider_repo, provider_repo.name, user.namespace, user, access_params, type: provider) - .and_return(double(execute: true)) + expect(Gitlab::GithubImport::ProjectCreator). + to receive(:new).with(provider_repo, provider_repo.name, user.namespace, user, access_params, type: provider). + and_return(double(execute: true)) post :create, format: :js end @@ -213,17 +213,17 @@ shared_examples 'a GitHub-ish import controller: POST create' do let(:test_name) { 'test_name' } it 'takes the selected namespace and name' do - expect(Gitlab::GithubImport::ProjectCreator) - .to receive(:new).with(provider_repo, test_name, test_namespace, user, access_params, type: provider) - .and_return(double(execute: true)) + expect(Gitlab::GithubImport::ProjectCreator). + to receive(:new).with(provider_repo, test_name, test_namespace, user, access_params, type: provider). + and_return(double(execute: true)) post :create, { target_namespace: test_namespace.name, new_name: test_name, format: :js } end it 'takes the selected name and default namespace' do - expect(Gitlab::GithubImport::ProjectCreator) - .to receive(:new).with(provider_repo, test_name, user.namespace, user, access_params, type: provider) - .and_return(double(execute: true)) + expect(Gitlab::GithubImport::ProjectCreator). + to receive(:new).with(provider_repo, test_name, user.namespace, user, access_params, type: provider). + and_return(double(execute: true)) post :create, { new_name: test_name, format: :js } end diff --git a/spec/support/ldap_helpers.rb b/spec/support/ldap_helpers.rb index 079f244475cf721c37726ee74af57738c651e122..ab635711cf764b6e67c8c89bfdc324fba6e12d1d 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/mentionable_shared_examples.rb b/spec/support/mentionable_shared_examples.rb index 3ac201f1fb195f80384b22ee1677597a5f709792..87936bb485941ee0295659aa6f4234b0fe5c8571 100644 --- a/spec/support/mentionable_shared_examples.rb +++ b/spec/support/mentionable_shared_examples.rb @@ -81,8 +81,8 @@ shared_examples 'a mentionable' do ext_issue, ext_mr, ext_commit] mentioned_objects.each do |referenced| - expect(SystemNoteService).to receive(:cross_reference) - .with(referenced, subject.local_reference, author) + expect(SystemNoteService).to receive(:cross_reference). + with(referenced, subject.local_reference, author) end subject.create_cross_references! @@ -127,15 +127,15 @@ shared_examples 'an editable mentionable' do # These three objects were already referenced, and should not receive new # notes [mentioned_issue, mentioned_commit, ext_issue].each do |oldref| - expect(SystemNoteService).not_to receive(:cross_reference) - .with(oldref, any_args) + expect(SystemNoteService).not_to receive(:cross_reference). + with(oldref, any_args) end # These two issues are new and should receive reference notes # In the case of MergeRequests remember that cannot mention commits included in the MergeRequest new_issues.each do |newref| - expect(SystemNoteService).to receive(:cross_reference) - .with(newref, subject.local_reference, author) + expect(SystemNoteService).to receive(:cross_reference). + with(newref, subject.local_reference, author) end set_mentionable_text.call(new_text) diff --git a/spec/support/reactive_caching_helpers.rb b/spec/support/reactive_caching_helpers.rb index 34124f02133328ad2e48b2025b5dd255b842b60c..98eb57f8b54b97352b852ad5310502c4aa5ba193 100644 --- a/spec/support/reactive_caching_helpers.rb +++ b/spec/support/reactive_caching_helpers.rb @@ -35,8 +35,8 @@ module ReactiveCachingHelpers end def expect_reactive_cache_update_queued(subject) - expect(ReactiveCachingWorker) - .to receive(:perform_in) - .with(subject.class.reactive_cache_refresh_interval, subject.class, subject.id) + expect(ReactiveCachingWorker). + to receive(:perform_in). + with(subject.class.reactive_cache_refresh_interval, subject.class, subject.id) end end diff --git a/spec/support/services_shared_context.rb b/spec/support/services_shared_context.rb index 7457484a932fa4d3d8e6ff245af525ff55d97e02..66c93890e31ef202211c7d1643f206f8e7567ddf 100644 --- a/spec/support/services_shared_context.rb +++ b/spec/support/services_shared_context.rb @@ -6,9 +6,9 @@ Service.available_services_names.each do |service| let(:service_fields) { service_klass.new.fields } let(:service_attrs_list) { service_fields.inject([]) {|arr, hash| arr << hash[:name].to_sym } } let(:service_attrs_list_without_passwords) do - service_fields - .select { |field| field[:type] != 'password' } - .map { |field| field[:name].to_sym} + service_fields. + select { |field| field[:type] != 'password' }. + map { |field| field[:name].to_sym} end let(:service_attrs) do service_attrs_list.inject({}) do |hash, k| diff --git a/spec/support/slack_mattermost_notifications_shared_examples.rb b/spec/support/slack_mattermost_notifications_shared_examples.rb index e18b79c89d19b18e3e8d9128b369609594cb67ae..704922b6cf4c92b0df48bba134ac089b26f5f0fc 100644 --- a/spec/support/slack_mattermost_notifications_shared_examples.rb +++ b/spec/support/slack_mattermost_notifications_shared_examples.rb @@ -104,9 +104,9 @@ RSpec.shared_examples 'slack or mattermost notifications' do it 'uses the username as an option for slack when configured' do allow(chat_service).to receive(:username).and_return(username) - expect(Slack::Notifier).to receive(:new) - .with(webhook_url, username: username) - .and_return( + expect(Slack::Notifier).to receive(:new). + with(webhook_url, username: username). + and_return( double(:slack_service).as_null_object ) @@ -115,9 +115,9 @@ RSpec.shared_examples 'slack or mattermost notifications' do it 'uses the channel as an option when it is configured' do allow(chat_service).to receive(:channel).and_return(channel) - expect(Slack::Notifier).to receive(:new) - .with(webhook_url, channel: channel) - .and_return( + expect(Slack::Notifier).to receive(:new). + with(webhook_url, channel: channel). + and_return( double(:slack_service).as_null_object ) chat_service.execute(push_sample_data) @@ -127,9 +127,9 @@ RSpec.shared_examples 'slack or mattermost notifications' do it "uses the right channel for push event" do chat_service.update_attributes(push_channel: "random") - expect(Slack::Notifier).to receive(:new) - .with(webhook_url, channel: "random") - .and_return( + expect(Slack::Notifier).to receive(:new). + with(webhook_url, channel: "random"). + and_return( double(:slack_service).as_null_object ) @@ -139,9 +139,9 @@ RSpec.shared_examples 'slack or mattermost notifications' do it "uses the right channel for merge request event" do chat_service.update_attributes(merge_request_channel: "random") - expect(Slack::Notifier).to receive(:new) - .with(webhook_url, channel: "random") - .and_return( + expect(Slack::Notifier).to receive(:new). + with(webhook_url, channel: "random"). + and_return( double(:slack_service).as_null_object ) @@ -151,9 +151,9 @@ RSpec.shared_examples 'slack or mattermost notifications' do it "uses the right channel for issue event" do chat_service.update_attributes(issue_channel: "random") - expect(Slack::Notifier).to receive(:new) - .with(webhook_url, channel: "random") - .and_return( + expect(Slack::Notifier).to receive(:new). + with(webhook_url, channel: "random"). + and_return( double(:slack_service).as_null_object ) @@ -163,9 +163,9 @@ RSpec.shared_examples 'slack or mattermost notifications' do it "uses the right channel for wiki event" do chat_service.update_attributes(wiki_page_channel: "random") - expect(Slack::Notifier).to receive(:new) - .with(webhook_url, channel: "random") - .and_return( + expect(Slack::Notifier).to receive(:new). + with(webhook_url, channel: "random"). + and_return( double(:slack_service).as_null_object ) @@ -182,9 +182,9 @@ RSpec.shared_examples 'slack or mattermost notifications' do note_data = Gitlab::DataBuilder::Note.build(issue_note, user) - expect(Slack::Notifier).to receive(:new) - .with(webhook_url, channel: "random") - .and_return( + expect(Slack::Notifier).to receive(:new). + with(webhook_url, channel: "random"). + and_return( double(:slack_service).as_null_object ) diff --git a/spec/support/stub_configuration.rb b/spec/support/stub_configuration.rb index a04714622fc6066b3e038897b97b79e98694ee8d..f40ee862df84054bccf2ad66fcc8d055a2471455 100644 --- a/spec/support/stub_configuration.rb +++ b/spec/support/stub_configuration.rb @@ -5,8 +5,8 @@ module StubConfiguration # Stubbing both of these because we're not yet consistent with how we access # current application settings allow_any_instance_of(ApplicationSetting).to receive_messages(messages) - allow(Gitlab::CurrentSettings.current_application_settings) - .to receive_messages(messages) + allow(Gitlab::CurrentSettings.current_application_settings). + to receive_messages(messages) end def stub_config_setting(messages) diff --git a/spec/support/stub_gitlab_calls.rb b/spec/support/stub_gitlab_calls.rb index 69e1ad18b15ceac2c4143758e22c2297ed2a8372..07602c0cb406b30ff3f9b0f8eca06da7e1823e02 100644 --- a/spec/support/stub_gitlab_calls.rb +++ b/spec/support/stub_gitlab_calls.rb @@ -51,22 +51,22 @@ module StubGitlabCalls def stub_session f = File.read(Rails.root.join('spec/support/gitlab_stubs/session.json')) - stub_request(:post, "#{gitlab_url}api/v3/session.json") - .with(body: "{\"email\":\"test@test.com\",\"password\":\"123456\"}", - headers: { 'Content-Type' => 'application/json' }) - .to_return(status: 201, body: f, headers: { 'Content-Type' => 'application/json' }) + stub_request(:post, "#{gitlab_url}api/v3/session.json"). + with(body: "{\"email\":\"test@test.com\",\"password\":\"123456\"}", + headers: { 'Content-Type' => 'application/json' }). + to_return(status: 201, body: f, headers: { 'Content-Type' => 'application/json' }) end def stub_user f = File.read(Rails.root.join('spec/support/gitlab_stubs/user.json')) - stub_request(:get, "#{gitlab_url}api/v3/user?private_token=Wvjy2Krpb7y8xi93owUz") - .with(headers: { 'Content-Type' => 'application/json' }) - .to_return(status: 200, body: f, headers: { 'Content-Type' => 'application/json' }) + stub_request(:get, "#{gitlab_url}api/v3/user?private_token=Wvjy2Krpb7y8xi93owUz"). + with(headers: { 'Content-Type' => 'application/json' }). + to_return(status: 200, body: f, headers: { 'Content-Type' => 'application/json' }) - stub_request(:get, "#{gitlab_url}api/v3/user?access_token=some_token") - .with(headers: { 'Content-Type' => 'application/json' }) - .to_return(status: 200, body: f, headers: { 'Content-Type' => 'application/json' }) + stub_request(:get, "#{gitlab_url}api/v3/user?access_token=some_token"). + with(headers: { 'Content-Type' => 'application/json' }). + to_return(status: 200, body: f, headers: { 'Content-Type' => 'application/json' }) end def stub_project_8 @@ -82,21 +82,21 @@ module StubGitlabCalls def stub_projects f = File.read(Rails.root.join('spec/support/gitlab_stubs/projects.json')) - stub_request(:get, "#{gitlab_url}api/v3/projects.json?archived=false&ci_enabled_first=true&private_token=Wvjy2Krpb7y8xi93owUz") - .with(headers: { 'Content-Type' => 'application/json' }) - .to_return(status: 200, body: f, headers: { 'Content-Type' => 'application/json' }) + stub_request(:get, "#{gitlab_url}api/v3/projects.json?archived=false&ci_enabled_first=true&private_token=Wvjy2Krpb7y8xi93owUz"). + with(headers: { 'Content-Type' => 'application/json' }). + to_return(status: 200, body: f, headers: { 'Content-Type' => 'application/json' }) end def stub_projects_owned - stub_request(:get, "#{gitlab_url}api/v3/projects/owned.json?archived=false&ci_enabled_first=true&private_token=Wvjy2Krpb7y8xi93owUz") - .with(headers: { 'Content-Type' => 'application/json' }) - .to_return(status: 200, body: "", headers: {}) + stub_request(:get, "#{gitlab_url}api/v3/projects/owned.json?archived=false&ci_enabled_first=true&private_token=Wvjy2Krpb7y8xi93owUz"). + with(headers: { 'Content-Type' => 'application/json' }). + to_return(status: 200, body: "", headers: {}) end def stub_ci_enable - stub_request(:put, "#{gitlab_url}api/v3/projects/2/services/gitlab-ci.json?private_token=Wvjy2Krpb7y8xi93owUz") - .with(headers: { 'Content-Type' => 'application/json' }) - .to_return(status: 200, body: "", headers: {}) + stub_request(:put, "#{gitlab_url}api/v3/projects/2/services/gitlab-ci.json?private_token=Wvjy2Krpb7y8xi93owUz"). + with(headers: { 'Content-Type' => 'application/json' }). + to_return(status: 200, body: "", headers: {}) end def project_hash_array diff --git a/spec/support/test_env.rb b/spec/support/test_env.rb index 21ff688f6dd6edf0b2750f58de2c9c4e05146924..4e63a4cd53706899bc0ad114848f6eb310d1c34a 100644 --- a/spec/support/test_env.rb +++ b/spec/support/test_env.rb @@ -74,13 +74,13 @@ module TestEnv end def disable_mailer - allow_any_instance_of(NotificationService).to receive(:mailer) - .and_return(double.as_null_object) + allow_any_instance_of(NotificationService).to receive(:mailer). + and_return(double.as_null_object) end def enable_mailer - allow_any_instance_of(NotificationService).to receive(:mailer) - .and_call_original + allow_any_instance_of(NotificationService).to receive(:mailer). + and_call_original end def disable_pre_receive diff --git a/spec/tasks/gitlab/backup_rake_spec.rb b/spec/tasks/gitlab/backup_rake_spec.rb index 85c34a00b11f237cf602c2fb44c6b9763d894644..df8a47893f9034935a6ba159ec8852c4cbc4619a 100644 --- a/spec/tasks/gitlab/backup_rake_spec.rb +++ b/spec/tasks/gitlab/backup_rake_spec.rb @@ -47,24 +47,24 @@ describe 'gitlab:app namespace rake task' do allow(Kernel).to receive(:system).and_return(true) allow(FileUtils).to receive(:cp_r).and_return(true) allow(FileUtils).to receive(:mv).and_return(true) - allow(Rake::Task["gitlab:shell:setup"]) - .to receive(:invoke).and_return(true) + allow(Rake::Task["gitlab:shell:setup"]). + to receive(:invoke).and_return(true) ENV['force'] = 'yes' end let(:gitlab_version) { Gitlab::VERSION } it 'fails on mismatch' do - allow(YAML).to receive(:load_file) - .and_return({ gitlab_version: "not #{gitlab_version}" }) + allow(YAML).to receive(:load_file). + and_return({ gitlab_version: "not #{gitlab_version}" }) - expect { run_rake_task('gitlab:backup:restore') } - .to raise_error(SystemExit) + expect { run_rake_task('gitlab:backup:restore') }. + to raise_error(SystemExit) end it 'invokes restoration on match' do - allow(YAML).to receive(:load_file) - .and_return({ gitlab_version: gitlab_version }) + allow(YAML).to receive(:load_file). + and_return({ gitlab_version: gitlab_version }) expect(Rake::Task['gitlab:db:drop_tables']).to receive(:invoke) expect(Rake::Task['gitlab:backup:db:restore']).to receive(:invoke) expect(Rake::Task['gitlab:backup:repo:restore']).to receive(:invoke) @@ -320,8 +320,8 @@ describe 'gitlab:app namespace rake task' do end it 'does not invoke repositories restore' do - allow(Rake::Task['gitlab:shell:setup']) - .to receive(:invoke).and_return(true) + allow(Rake::Task['gitlab:shell:setup']). + to receive(:invoke).and_return(true) allow($stdout).to receive :write expect(Rake::Task['gitlab:db:drop_tables']).to receive :invoke diff --git a/spec/tasks/gitlab/check_rake_spec.rb b/spec/tasks/gitlab/check_rake_spec.rb index 538ff952bf4aba04652c4e9808a42308a6e84993..a808ef7dcc0fad8f55ed4f6bf8df4eeae3f86789 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 226d34fe2c98bc6a6539033c558be61e97469135..0787894ad2c2b3e48b02ba0a41606c3fe6634fa2 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/tasks/gitlab/task_helpers_spec.rb b/spec/tasks/gitlab/task_helpers_spec.rb index 528fdbaaa747dbd82af23a4a95a8221056c602bd..86e42d845cea48de85c8c290d8be9e0b6335c420 100644 --- a/spec/tasks/gitlab/task_helpers_spec.rb +++ b/spec/tasks/gitlab/task_helpers_spec.rb @@ -41,8 +41,8 @@ describe Gitlab::TaskHelpers do describe '#clone_repo' do it 'clones the repo in the target dir' do - expect(subject) - .to receive(:run_command!).with(%W[#{Gitlab.config.git.bin_path} clone -- #{repo} #{clone_path}]) + expect(subject). + to receive(:run_command!).with(%W[#{Gitlab.config.git.bin_path} clone -- #{repo} #{clone_path}]) subject.clone_repo(repo, clone_path) end @@ -50,10 +50,10 @@ describe Gitlab::TaskHelpers do describe '#checkout_tag' do it 'clones the repo in the target dir' do - expect(subject) - .to receive(:run_command!).with(%W[#{Gitlab.config.git.bin_path} -C #{clone_path} fetch --tags --quiet]) - expect(subject) - .to receive(:run_command!).with(%W[#{Gitlab.config.git.bin_path} -C #{clone_path} checkout --quiet #{tag}]) + expect(subject). + to receive(:run_command!).with(%W[#{Gitlab.config.git.bin_path} -C #{clone_path} fetch --tags --quiet]) + expect(subject). + to receive(:run_command!).with(%W[#{Gitlab.config.git.bin_path} -C #{clone_path} checkout --quiet #{tag}]) subject.checkout_tag(tag, clone_path) end @@ -62,21 +62,21 @@ describe Gitlab::TaskHelpers do describe '#reset_to_tag' do let(:tag) { 'v1.1.0' } before do - expect(subject) - .to receive(:run_command!).with(%W[#{Gitlab.config.git.bin_path} -C #{clone_path} reset --hard #{tag}]) + expect(subject). + to receive(:run_command!).with(%W[#{Gitlab.config.git.bin_path} -C #{clone_path} reset --hard #{tag}]) end context 'when the tag is not checked out locally' do before do - expect(subject) - .to receive(:run_command!).with(%W[#{Gitlab.config.git.bin_path} -C #{clone_path} describe -- #{tag}]).and_raise(Gitlab::TaskFailedError) + expect(subject). + to receive(:run_command!).with(%W[#{Gitlab.config.git.bin_path} -C #{clone_path} describe -- #{tag}]).and_raise(Gitlab::TaskFailedError) end it 'fetch origin, ensure the tag exists, and resets --hard to the given tag' do - expect(subject) - .to receive(:run_command!).with(%W[#{Gitlab.config.git.bin_path} -C #{clone_path} fetch origin]) - expect(subject) - .to receive(:run_command!).with(%W[#{Gitlab.config.git.bin_path} -C #{clone_path} describe -- origin/#{tag}]).and_return(tag) + expect(subject). + to receive(:run_command!).with(%W[#{Gitlab.config.git.bin_path} -C #{clone_path} fetch origin]) + expect(subject). + to receive(:run_command!).with(%W[#{Gitlab.config.git.bin_path} -C #{clone_path} describe -- origin/#{tag}]).and_return(tag) subject.reset_to_tag(tag, clone_path) end @@ -84,8 +84,8 @@ describe Gitlab::TaskHelpers do context 'when the tag is checked out locally' do before do - expect(subject) - .to receive(:run_command!).with(%W[#{Gitlab.config.git.bin_path} -C #{clone_path} describe -- #{tag}]).and_return(tag) + expect(subject). + to receive(:run_command!).with(%W[#{Gitlab.config.git.bin_path} -C #{clone_path} describe -- #{tag}]).and_return(tag) end it 'resets --hard to the given tag' do diff --git a/spec/tasks/gitlab/workhorse_rake_spec.rb b/spec/tasks/gitlab/workhorse_rake_spec.rb index da4b408023c85e2a7ae3ea21647409130b68d889..6de66c3cf07af2e74a211ab233053ae77eff1441 100644 --- a/spec/tasks/gitlab/workhorse_rake_spec.rb +++ b/spec/tasks/gitlab/workhorse_rake_spec.rb @@ -23,8 +23,8 @@ describe 'gitlab:workhorse namespace rake task' do context 'when an underlying Git command fail' do it 'aborts and display a help message' do - expect_any_instance_of(Object) - .to receive(:checkout_or_clone_tag).and_raise 'Git error' + expect_any_instance_of(Object). + to receive(:checkout_or_clone_tag).and_raise 'Git error' expect { run_rake_task('gitlab:workhorse:install', clone_path) }.to raise_error 'Git error' end @@ -36,8 +36,8 @@ describe 'gitlab:workhorse namespace rake task' do end it 'calls checkout_or_clone_tag with the right arguments' do - expect_any_instance_of(Object) - .to receive(:checkout_or_clone_tag).with(tag: tag, repo: repo, target_dir: clone_path) + expect_any_instance_of(Object). + to receive(:checkout_or_clone_tag).with(tag: tag, repo: repo, target_dir: clone_path) run_rake_task('gitlab:workhorse:install', clone_path) end diff --git a/spec/views/devise/shared/_signin_box.html.haml_spec.rb b/spec/views/devise/shared/_signin_box.html.haml_spec.rb index 9adbb0476bed319a175b62557ecff1e39b5c26ae..1397bfa5864e8991f3b24a7fb8548467cb3435a1 100644 --- a/spec/views/devise/shared/_signin_box.html.haml_spec.rb +++ b/spec/views/devise/shared/_signin_box.html.haml_spec.rb @@ -31,7 +31,7 @@ describe 'devise/shared/_signin_box' do def enable_crowd allow(view).to receive(:form_based_providers).and_return([:crowd]) allow(view).to receive(:crowd_enabled?).and_return(true) - allow(view).to receive(:omniauth_authorize_path).with(:user, :crowd) - .and_return('/crowd') + allow(view).to receive(:omniauth_authorize_path).with(:user, :crowd). + and_return('/crowd') end end diff --git a/spec/views/layouts/_head.html.haml_spec.rb b/spec/views/layouts/_head.html.haml_spec.rb index 8020faa1f9cfc91ff07c4639ecf1f1882e988231..254672a56120783e4aff4266768146c67b758471 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 3650b22c389774a685025c159f5390c6070c765e..2e4390d6797befb920d8a0d81b856912b4ff7e37 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 ba20488f66343b2dfba8d18145986819bb6621ef..8ebf00374a1b4cfe4a228f19049df2d7c8177593 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 2868167c7d41917c39172a051f777c3076faaa63..f81199131168fb99ccb562b7e59556cae2210fcd 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 97654a93f5c51f5b89708f0a4d3f0c849f16d102..51abc1d89a17cfc93d488757f1773673f6c259cf 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 dba7088313093ecd51217930c9c33ed86a5f3679..d016ecbb738277ae54e96704fa03729e65ac7608 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/delete_user_worker_spec.rb b/spec/workers/delete_user_worker_spec.rb index 06b470f68f2431a448d95a07cce98a56ac58ea7e..0765573408cf3cc403e77d234dba3f89703f7754 100644 --- a/spec/workers/delete_user_worker_spec.rb +++ b/spec/workers/delete_user_worker_spec.rb @@ -5,15 +5,15 @@ describe DeleteUserWorker do let!(:current_user) { create(:user) } it "calls the DeleteUserWorker with the params it was given" do - expect_any_instance_of(Users::DestroyService).to receive(:execute) - .with(user, {}) + expect_any_instance_of(Users::DestroyService).to receive(:execute). + with(user, {}) DeleteUserWorker.new.perform(current_user.id, user.id) end it "uses symbolized keys" do - expect_any_instance_of(Users::DestroyService).to receive(:execute) - .with(user, test: "test") + expect_any_instance_of(Users::DestroyService).to receive(:execute). + with(user, test: "test") DeleteUserWorker.new.perform(current_user.id, user.id, "test" => "test") end diff --git a/spec/workers/every_sidekiq_worker_spec.rb b/spec/workers/every_sidekiq_worker_spec.rb index 30908534eb3b6e1399086ec88b07d6bb9d5c5e37..fc9adf47c1e833ee529bea87e3666dff8d16a9ac 100644 --- a/spec/workers/every_sidekiq_worker_spec.rb +++ b/spec/workers/every_sidekiq_worker_spec.rb @@ -5,8 +5,8 @@ describe 'Every Sidekiq worker' do root = Rails.root.join('app', 'workers') concerns = root.join('concerns').to_s - workers = Dir[root.join('**', '*.rb')] - .reject { |path| path.start_with?(concerns) } + workers = Dir[root.join('**', '*.rb')]. + reject { |path| path.start_with?(concerns) } workers.map do |path| ns = Pathname.new(path).relative_path_from(root).to_s.gsub('.rb', '') @@ -22,9 +22,9 @@ describe 'Every Sidekiq worker' do end it 'uses the cronjob queue when the worker runs as a cronjob' do - cron_workers = Settings.cron_jobs - .map { |job_name, options| options['job_class'].constantize } - .to_set + cron_workers = Settings.cron_jobs. + map { |job_name, options| options['job_class'].constantize }. + to_set workers.each do |worker| next unless cron_workers.include?(worker) diff --git a/spec/workers/git_garbage_collect_worker_spec.rb b/spec/workers/git_garbage_collect_worker_spec.rb index e4c4a9ac17a33d911bddec0858e2fac8196ffd1d..a60af574a08e36e5eba4cb4df848eee9ff09b780 100644 --- a/spec/workers/git_garbage_collect_worker_spec.rb +++ b/spec/workers/git_garbage_collect_worker_spec.rb @@ -11,8 +11,8 @@ describe GitGarbageCollectWorker do describe "#perform" do it "flushes ref caches when the task is 'gc'" do expect(subject).to receive(:command).with(:gc).and_return([:the, :command]) - expect(Gitlab::Popen).to receive(:popen) - .with([:the, :command], project.repository.path_to_repo).and_return(["", 0]) + expect(Gitlab::Popen).to receive(:popen). + with([:the, :command], project.repository.path_to_repo).and_return(["", 0]) expect_any_instance_of(Repository).to receive(:after_create_branch).and_call_original expect_any_instance_of(Repository).to receive(:branch_names).and_call_original diff --git a/spec/workers/new_note_worker_spec.rb b/spec/workers/new_note_worker_spec.rb index 575361c93d4ac99641926b2543d036b7189ccf99..8fdbb35afd0d640b64283b0638c2d1cc7db85f29 100644 --- a/spec/workers/new_note_worker_spec.rb +++ b/spec/workers/new_note_worker_spec.rb @@ -24,8 +24,8 @@ describe NewNoteWorker do let(:unexistent_note_id) { 999 } it 'logs NewNoteWorker process skipping' do - expect(Rails.logger).to receive(:error) - .with("NewNoteWorker: couldn't find note with ID=999, skipping job") + expect(Rails.logger).to receive(:error). + with("NewNoteWorker: couldn't find note with ID=999, skipping job") described_class.new.perform(unexistent_note_id) end diff --git a/spec/workers/pipeline_hooks_worker_spec.rb b/spec/workers/pipeline_hooks_worker_spec.rb index 035e329839fd7a5f8f910b5118d9f88c895c45ad..061f4bda36c33a604337d32769fc57811d4a635c 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_notification_worker_spec.rb b/spec/workers/pipeline_notification_worker_spec.rb index b9bd234d168ec93c1e33897a02ef7dc0ed0991e3..603ae52ed1e88ab6e7863cf558ebb22fdbfdab53 100644 --- a/spec/workers/pipeline_notification_worker_spec.rb +++ b/spec/workers/pipeline_notification_worker_spec.rb @@ -56,8 +56,8 @@ describe PipelineNotificationWorker do context 'with success pipeline notification on' do before do - watcher.global_notification_setting - .update(level: 'custom', success_pipeline: true) + watcher.global_notification_setting. + update(level: 'custom', success_pipeline: true) end it_behaves_like 'sending emails' @@ -67,8 +67,8 @@ describe PipelineNotificationWorker do let(:receivers) { [pusher] } before do - watcher.global_notification_setting - .update(level: 'custom', success_pipeline: false) + watcher.global_notification_setting. + update(level: 'custom', success_pipeline: false) end it_behaves_like 'sending emails' @@ -87,8 +87,8 @@ describe PipelineNotificationWorker do context 'with failed pipeline notification on' do before do - watcher.global_notification_setting - .update(level: 'custom', failed_pipeline: true) + watcher.global_notification_setting. + update(level: 'custom', failed_pipeline: true) end it_behaves_like 'sending emails' @@ -98,8 +98,8 @@ describe PipelineNotificationWorker do let(:receivers) { [pusher] } before do - watcher.global_notification_setting - .update(level: 'custom', failed_pipeline: false) + watcher.global_notification_setting. + update(level: 'custom', failed_pipeline: false) end it_behaves_like 'sending emails' @@ -117,8 +117,8 @@ describe PipelineNotificationWorker do before do pipeline.project.team << [watcher, Gitlab::Access::GUEST] - watcher.global_notification_setting - .update(level: 'custom', failed_pipeline: true) + watcher.global_notification_setting. + update(level: 'custom', failed_pipeline: true) perform_enqueued_jobs do subject.perform(pipeline.id) diff --git a/spec/workers/pipeline_proccess_worker_spec.rb b/spec/workers/pipeline_proccess_worker_spec.rb index 86e9d7f6684080813747f6e111ebf211a2778fb3..fd6ee0714ea520907477f6690c5f1b7f644d6470 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 d1c84adda6f9fb91aa5b08f9919e5e0e58a9f98c..f6c56465feb4435454ac983b6c463d1adc770ab9 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 0b456cfd0dac10e7a60d8bb6ca2035e967e20049..24d78aae11217ddf89b8c044ee43ee0fa0e419f4 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/post_receive_spec.rb b/spec/workers/post_receive_spec.rb index e0bdbab3f15c3ab02579e2480cd2c6d2a6e493e0..5919b99a6ed5652f67e37026ddcefbd7b10f1020 100644 --- a/spec/workers/post_receive_spec.rb +++ b/spec/workers/post_receive_spec.rb @@ -79,9 +79,9 @@ describe PostReceive do end it "does not run if the author is not in the project" do - allow_any_instance_of(Gitlab::GitPostReceive) - .to receive(:identify_using_ssh_key) - .and_return(nil) + allow_any_instance_of(Gitlab::GitPostReceive). + to receive(:identify_using_ssh_key). + and_return(nil) expect(project).not_to receive(:execute_hooks) diff --git a/spec/workers/process_commit_worker_spec.rb b/spec/workers/process_commit_worker_spec.rb index dfa0ffb1314ade46ff56dc473fe423ed3a3d0abb..75c7fc1efd2a0b2b8adf693f49e6ae87169c3cf5 100644 --- a/spec/workers/process_commit_worker_spec.rb +++ b/spec/workers/process_commit_worker_spec.rb @@ -36,11 +36,11 @@ describe ProcessCommitWorker do describe '#process_commit_message' do context 'when pushing to the default branch' do it 'closes issues that should be closed per the commit message' do - allow(commit).to receive(:safe_message) - .and_return("Closes #{issue.to_reference}") + allow(commit).to receive(:safe_message). + and_return("Closes #{issue.to_reference}") - expect(worker).to receive(:close_issues) - .with(project, user, user, commit, [issue]) + expect(worker).to receive(:close_issues). + with(project, user, user, commit, [issue]) worker.process_commit_message(project, commit, user, user, true) end @@ -48,8 +48,8 @@ describe ProcessCommitWorker do context 'when pushing to a non-default branch' do it 'does not close any issues' do - allow(commit).to receive(:safe_message) - .and_return("Closes #{issue.to_reference}") + allow(commit).to receive(:safe_message). + and_return("Closes #{issue.to_reference}") expect(worker).not_to receive(:close_issues) @@ -90,8 +90,8 @@ describe ProcessCommitWorker do describe '#update_issue_metrics' do it 'updates any existing issue metrics' do - allow(commit).to receive(:safe_message) - .and_return("Closes #{issue.to_reference}") + allow(commit).to receive(:safe_message). + and_return("Closes #{issue.to_reference}") worker.update_issue_metrics(commit, user) @@ -109,8 +109,8 @@ describe ProcessCommitWorker do end it 'parses date strings into Time instances' do - commit = worker - .build_commit(project, id: '123', authored_date: Time.now.to_s) + commit = worker. + build_commit(project, id: '123', authored_date: Time.now.to_s) expect(commit.authored_date).to be_an_instance_of(Time) end diff --git a/spec/workers/project_cache_worker_spec.rb b/spec/workers/project_cache_worker_spec.rb index da9136282e4ab6d5a5de815068438b8673c57da9..0fc274f1a01110c6159db17683e92159528c553f 100644 --- a/spec/workers/project_cache_worker_spec.rb +++ b/spec/workers/project_cache_worker_spec.rb @@ -7,8 +7,8 @@ describe ProjectCacheWorker do describe '#perform' do before do - allow_any_instance_of(Gitlab::ExclusiveLease).to receive(:try_obtain) - .and_return(true) + allow_any_instance_of(Gitlab::ExclusiveLease).to receive(:try_obtain). + and_return(true) end context 'with a non-existing project' do @@ -31,17 +31,17 @@ 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 it 'refreshes the method caches' do - expect_any_instance_of(Repository).to receive(:refresh_method_caches) - .with(%i(readme)) - .and_call_original + expect_any_instance_of(Repository).to receive(:refresh_method_caches). + with(%i(readme)). + and_call_original worker.perform(project.id, %w(readme)) end @@ -51,9 +51,9 @@ describe ProjectCacheWorker do describe '#update_statistics' do context 'when a lease could not be obtained' do it 'does not update the repository size' do - allow(worker).to receive(:try_obtain_lease_for) - .with(project.id, :update_statistics) - .and_return(false) + allow(worker).to receive(:try_obtain_lease_for). + with(project.id, :update_statistics). + and_return(false) expect(statistics).not_to receive(:refresh!) @@ -63,13 +63,13 @@ describe ProjectCacheWorker do context 'when a lease could be obtained' do it 'updates the project statistics' do - allow(worker).to receive(:try_obtain_lease_for) - .with(project.id, :update_statistics) - .and_return(true) + allow(worker).to receive(:try_obtain_lease_for). + 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/repository_fork_worker_spec.rb b/spec/workers/repository_fork_worker_spec.rb index b9d8af4d8b08daada427ce57ec9d7df17eaf66ad..60605460adbebde182e448888bf0a1ee41f09651 100644 --- a/spec/workers/repository_fork_worker_spec.rb +++ b/spec/workers/repository_fork_worker_spec.rb @@ -35,11 +35,11 @@ describe RepositoryForkWorker do fork_project.namespace.path ).and_return(true) - expect_any_instance_of(Repository).to receive(:expire_emptiness_caches) - .and_call_original + expect_any_instance_of(Repository).to receive(:expire_emptiness_caches). + and_call_original - expect_any_instance_of(Repository).to receive(:expire_exists_cache) - .and_call_original + expect_any_instance_of(Repository).to receive(:expire_exists_cache). + and_call_original subject.perform(project.id, '/test/path', project.path_with_namespace, fork_project.namespace.path) diff --git a/spec/workers/repository_import_worker_spec.rb b/spec/workers/repository_import_worker_spec.rb index 0faf9bff9c378c1dc599c74b6024450c7006d527..c42f3147b7ae6042c0c57f956d97d86458b73e67 100644 --- a/spec/workers/repository_import_worker_spec.rb +++ b/spec/workers/repository_import_worker_spec.rb @@ -8,8 +8,8 @@ describe RepositoryImportWorker do describe '#perform' do context 'when the import was successful' do it 'imports a project' do - expect_any_instance_of(Projects::ImportService).to receive(:execute) - .and_return({ status: :ok }) + expect_any_instance_of(Projects::ImportService).to receive(:execute). + and_return({ status: :ok }) expect_any_instance_of(Repository).to receive(:expire_emptiness_caches) expect_any_instance_of(Project).to receive(:import_finish) @@ -21,8 +21,8 @@ describe RepositoryImportWorker do context 'when the import has failed' do it 'hide the credentials that were used in the import URL' do error = %q{remote: Not Found fatal: repository 'https://user:pass@test.com/root/repoC.git/' not found } - expect_any_instance_of(Projects::ImportService).to receive(:execute) - .and_return({ status: :error, message: error }) + expect_any_instance_of(Projects::ImportService).to receive(:execute). + and_return({ status: :error, message: error }) subject.perform(project.id) diff --git a/spec/workers/use_key_worker_spec.rb b/spec/workers/use_key_worker_spec.rb index e50c788b82aa8172b1c38f6987f4990d62616827..f8752c42a497e223a5ed3702a04c95d317b3c797 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