Commit 3dadf306 authored by Douwe Maan's avatar Douwe Maan

Enable Style/DotPosition

parent 547063b3
......@@ -136,6 +136,10 @@ Style/DefWithParentheses:
Style/Documentation:
Enabled: false
Style/DotPosition:
Enabled: true
EnforcedStyle: trailing
# Align elses and elsifs correctly.
Style/ElseAlignment:
Enabled: true
......
......@@ -305,13 +305,6 @@ Style/CommentAnnotation:
Style/ConditionalAssignment:
Enabled: false
# Offense count: 1304
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles.
# SupportedStyles: leading, trailing
Style/DotPosition:
Enabled: false
# Offense count: 21
Style/DoubleNegation:
Exclude:
......
......@@ -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,
......
......@@ -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)
......
......@@ -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)
......
......@@ -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
......
......@@ -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
......
......@@ -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!
......
......@@ -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
......
......@@ -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
......
......@@ -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
}
......
......@@ -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?
......@@ -639,8 +639,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
......
......@@ -7,32 +7,32 @@ 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
@running_count = PipelinesFinder.
.new(project).execute(scope: 'running').count
@pending_count = PipelinesFinder
@pending_count = PipelinesFinder.
.new(project).execute(scope: 'pending').count
@finished_count = PipelinesFinder
@finished_count = PipelinesFinder.
.new(project).execute(scope: 'finished').count
@pipelines_count = PipelinesFinder
@pipelines_count = PipelinesFinder.
.new(project).execute.count
respond_to do |format|
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
......
......@@ -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
......
......@@ -118,8 +118,8 @@ class UsersController < ApplicationController
def load_projects
@projects =
PersonalProjectsFinder.new(user).execute(current_user)
.page(params[:page])
PersonalProjectsFinder.new(user).execute(current_user).
page(params[:page])
end
def load_contributed_projects
......
......@@ -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)
......
......@@ -63,9 +63,9 @@ module Ci
end
def retry(build, current_user)
Ci::RetryBuildService
.new(build.project, current_user)
.execute(build)
Ci::RetryBuildService.
new(build.project, current_user).
execute(build)
end
end
......@@ -96,9 +96,9 @@ module Ci
end
def detailed_status(current_user)
Gitlab::Ci::Status::Build::Factory
.new(self, current_user)
.fabricate!
Gitlab::Ci::Status::Build::Factory.
new(self, current_user).
fabricate!
end
def manual?
......@@ -220,9 +220,9 @@ module Ci
end
def merge_request
merge_requests = MergeRequest.includes(:merge_request_diff)
.where(source_branch: ref, source_project_id: pipeline.gl_project_id)
.reorder(iid: :asc)
merge_requests = MergeRequest.includes(:merge_request_diff).
where(source_branch: ref, source_project_id: pipeline.gl_project_id).
reorder(iid: :asc)
merge_requests.find do |merge_request|
merge_request.commits_sha.include?(pipeline.sha)
......
......@@ -89,9 +89,9 @@ module Ci
# ref can't be HEAD or SHA, can only be branch/tag name
scope :latest, ->(ref = nil) do
max_id = unscope(:select)
.select("max(#{quoted_table_name}.id)")
.group(:ref, :sha)
max_id = unscope(:select).
select("max(#{quoted_table_name}.id)").
group(:ref, :sha)
if ref
where(ref: ref, id: max_id.where(ref: ref))
......@@ -133,16 +133,16 @@ module Ci
def stages
# TODO, this needs refactoring, see gitlab-ce#26481.
stages_query = statuses
.group('stage').select(:stage).order('max(stage_idx)')
stages_query = statuses.
group('stage').select(:stage).order('max(stage_idx)')
status_sql = statuses.latest.where('stage=sg.stage').status_sql
warnings_sql = statuses.latest.select('COUNT(*) > 0')
.where('stage=sg.stage').failed_but_allowed.to_sql
warnings_sql = statuses.latest.select('COUNT(*) > 0').
where('stage=sg.stage').failed_but_allowed.to_sql
stages_with_statuses = CommitStatus.from(stages_query, :sg)
.pluck('sg.stage', status_sql, "(#{warnings_sql})")
stages_with_statuses = CommitStatus.from(stages_query, :sg).
pluck('sg.stage', status_sql, "(#{warnings_sql})")
stages_with_statuses.map do |stage|
Ci::Stage.new(self, Hash[%i[name status warnings].zip(stage)])
......@@ -222,8 +222,8 @@ module Ci
end
def retry_failed(current_user)
Ci::RetryPipelineService.new(project, current_user)
.execute(self)
Ci::RetryPipelineService.new(project, current_user).
execute(self)
end
def mark_as_processable_after_stage(stage_idx)
......@@ -355,15 +355,15 @@ module Ci
# Merge requests for which the current pipeline is running against
# the merge request's latest commit.
def merge_requests
@merge_requests ||= project.merge_requests
.where(source_branch: self.ref)
.select { |merge_request| merge_request.head_pipeline.try(:id) == self.id }
@merge_requests ||= project.merge_requests.
where(source_branch: self.ref).
select { |merge_request| merge_request.head_pipeline.try(:id) == self.id }
end
def detailed_status(current_user)
Gitlab::Ci::Status::Pipeline::Factory
.new(self, current_user)
.fabricate!
Gitlab::Ci::Status::Pipeline::Factory.
new(self, current_user).
fabricate!
end
private
......
......@@ -23,8 +23,8 @@ module Ci
scope :ordered, ->() { order(id: :desc) }
scope :owned_or_shared, ->(project_id) do
joins('LEFT JOIN ci_runner_projects ON ci_runner_projects.runner_id = ci_runners.id')
.where("ci_runner_projects.gl_project_id = :project_id OR ci_runners.is_shared = true", project_id: project_id)
joins('LEFT JOIN ci_runner_projects ON ci_runner_projects.runner_id = ci_runners.id').
where("ci_runner_projects.gl_project_id = :project_id OR ci_runners.is_shared = true", project_id: project_id)
end
scope :assignable_for, ->(project) do
......
......@@ -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
......
......@@ -96,8 +96,8 @@ class CommitStatus < ActiveRecord::Base
after_transition any => :failed do |commit_status|
commit_status.run_after_commit do
MergeRequests::AddTodoWhenBuildFailsService
.new(pipeline.project, nil).execute(self)
MergeRequests::AddTodoWhenBuildFailsService.
new(pipeline.project, nil).execute(self)
end
end
end
......@@ -133,9 +133,9 @@ class CommitStatus < ActiveRecord::Base
end
def detailed_status(current_user)
Gitlab::Ci::Status::Factory
.new(self, current_user)
.fabricate!
Gitlab::Ci::Status::Factory.
new(self, current_user).
fabricate!
end
def sortable_name
......
......@@ -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
......
module Presentable
def present(**attributes)
Gitlab::View::Presenter::Factory
.new(self, attributes)
.fabricate!
Gitlab::View::Presenter::Factory.
new(self, attributes).
fabricate!
end
end
......@@ -42,15 +42,15 @@ module Subscribable
def subscribe(user, project = nil)
unsubscribe_from_other_levels(user, project)
find_or_initialize_subscription(user, project)
.update(subscribed: true)
find_or_initialize_subscription(user, project).
update(subscribed: true)
end
def unsubscribe(user, project = nil)
unsubscribe_from_other_levels(user, project)
find_or_initialize_subscription(user, project)
.update(subscribed: false)
find_or_initialize_subscription(user, project).
update(subscribed: false)
end
private
......
......@@ -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
......@@ -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
......
......@@ -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
......
......@@ -34,9 +34,9 @@ class Label < ActiveRecord::Base
scope :with_title, ->(title) { where(title: title) }
def self.prioritized(project)
joins(:priorities)
.where(label_priorities: { project_id: project })
.reorder('label_priorities.priority ASC, labels.title ASC')
joins(:priorities).
where(label_priorities: { project_id: project }).
reorder('label_priorities.priority ASC, labels.title ASC')
end
def self.unprioritized(project)
......
......@@ -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
......@@ -39,9 +39,9 @@ class Member < ActiveRecord::Base
is_external_invite = arel_table[:user_id].eq(nil).and(arel_table[:invite_token].not_eq(nil))
user_is_active = User.arel_table[:state].eq(:active)
includes(:user).references(:users)
.where(is_external_invite.or(user_is_active))
.where(requested_at: nil)
includes(:user).references(:users).
where(is_external_invite.or(user_is_active)).
where(requested_at: nil)
end
scope :invite, -> { where.not(invite_token: nil) }
......
......@@ -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
......
......@@ -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
......
......@@ -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',
......
......@@ -28,8 +28,8 @@ module Network
if map.include?(p.id)
map[p.id]
end
end
.compact
end.
compact
end
end
end
......@@ -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
......
......@@ -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)
......
......@@ -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
......
......@@ -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
......@@ -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
......
......@@ -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)
......
......@@ -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)
......
......@@ -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!)
......
......@@ -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
......@@ -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
......
......@@ -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
......
......@@ -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]}"
......
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
......
......@@ -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
......
......@@ -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
......
......@@ -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)
......
......@@ -60,9 +60,9 @@ module MergeRequests
by_source_or_target_branch(@branch_name).to_a
# Fork merge requests
merge_requests += MergeRequest.opened
.where(source_branch: @branch_name, source_project: @project)
.where.not(target_project: @project).to_a
merge_requests += MergeRequest.opened.
where(source_branch: @branch_name, source_project: @project).
where.not(target_project: @project).to_a
filter_merge_requests(merge_requests).each do |merge_request|
if merge_request.source_branch == @branch_name || force_push?
......
......@@ -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
......@@ -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
......@@ -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
......
......@@ -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)
......
......@@ -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
......@@ -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
......@@ -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
......@@ -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
......@@ -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
......
......@@ -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
......
......@@ -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
......
......@@ -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
......
......@@ -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
......@@ -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 }
......
......@@ -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
......
......@@ -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
......
......@@ -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
......
......@@ -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
......
......@@ -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
......
......@@ -46,9 +46,9 @@ module Gitlab
private
def compose_jobs!
factory = Entry::Factory.new(Entry::Jobs)
.value(@config.except(*self.class.nodes.keys))
.with(key: :jobs, parent: self,
factory = Entry::Factory.new(Entry::Jobs).
value(@config.except(*self.class.nodes.keys)).
with(key: :jobs, parent: self,
description: 'Jobs definition for this pipeline')
@entries[:jobs] = factory.create!
......
......@@ -31,10 +31,10 @@ module Gitlab
@config.each do |name, config|
node = hidden?(name) ? Entry::Hidden : Entry::Job
factory = Entry::Factory.new(node)
.value(config || {})
.metadata(name: name)
.with(key: name, parent: self,
factory = Entry::Factory.new(node).
value(config || {}).
metadata(name: name).
with(key: name, parent: self,
description: "#{name} job definition.")
@entries[name] = factory.create!
......
......@@ -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
......
......@@ -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
......
......@@ -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
......
......@@ -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
......
......@@ -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
......
......@@ -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
......
......@@ -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
......
......@@ -334,9 +334,9 @@ describe Projects::MergeRequestsController do
it 'sets the MR to merge when the build succeeds' do
service = double(:merge_when_build_succeeds_service)
expect(MergeRequests::MergeWhenPipelineSucceedsService)
.to receive(:new).with(project, anything, anything)
.and_return(service)
expect(MergeRequests::MergeWhenPipelineSucceedsService).
to receive(:new).with(project, anything, anything).
and_return(service)
expect(service).to receive(:execute).with(merge_request)
merge_when_build_succeeds
......
......@@ -11,8 +11,8 @@ describe SessionsController do
it 'does not authenticate user' do
post(:create, user: { login: 'invalid', password: 'invalid' })
expect(response)
.to set_flash.now[:alert].to /Invalid Login or password/
expect(response).
to set_flash.now[:alert].to /Invalid Login or password/
end
end
......@@ -102,8 +102,8 @@ describe SessionsController do
end
it 'warns about invalid OTP code' do
expect(response).to set_flash.now[:alert]
.to /Invalid two-factor code/
expect(response).to set_flash.now[:alert].
to /Invalid two-factor code/
end
end
end
......@@ -129,8 +129,8 @@ describe SessionsController do
end
it 'warns about invalid login' do
expect(response).to set_flash.now[:alert]
.to /Invalid Login or password/
expect(response).to set_flash.now[:alert].
to /Invalid Login or password/
end
it 'locks the user' do
......@@ -140,8 +140,8 @@ describe SessionsController do
it 'keeps the user locked on future login attempts' do
post(:create, user: { login: user.username, password: user.password })
expect(response)
.to set_flash.now[:alert].to /Invalid Login or password/
expect(response).
to set_flash.now[:alert].to /Invalid Login or password/
end
end
end
......@@ -153,8 +153,8 @@ describe SessionsController do
authenticate_2fa(login: another_user.username,
otp_attempt: 'invalid')
expect(response).to set_flash.now[:alert]
.to /Invalid two-factor code/
expect(response).to set_flash.now[:alert].
to /Invalid two-factor code/
end
end
end
......
......@@ -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
......
......@@ -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
......
......@@ -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
......
......@@ -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
......
......@@ -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
......
......@@ -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
......
......@@ -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
......
......@@ -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
......@@ -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
......
......@@ -372,8 +372,8 @@ describe Banzai::Filter::LabelReferenceFilter, lib: true do
let!(:result) { reference_filter("See #{reference}") }
it 'links to a valid reference' do
expect(result.css('a').first.attr('href'))
.to eq urls.namespace_project_issues_url(project2.namespace,
expect(result.css('a').first.attr('href')).
to eq urls.namespace_project_issues_url(project2.namespace,
project2,
label_name: label.name)
end
......@@ -406,8 +406,8 @@ describe Banzai::Filter::LabelReferenceFilter, lib: true do
let!(:result) { reference_filter("See #{reference}") }
it 'links to a valid reference' do
expect(result.css('a').first.attr('href'))
.to eq urls.namespace_project_issues_url(project2.namespace,
expect(result.css('a').first.attr('href')).
to eq urls.namespace_project_issues_url(project2.namespace,
project2,
label_name: label.name)
end
......@@ -440,8 +440,8 @@ describe Banzai::Filter::LabelReferenceFilter, lib: true do
let!(:result) { reference_filter("See #{reference}") }
it 'links to a valid reference' do
expect(result.css('a').first.attr('href'))
.to eq urls.namespace_project_issues_url(project2.namespace,
expect(result.css('a').first.attr('href')).
to eq urls.namespace_project_issues_url(project2.namespace,
project2,
label_name: label.name)
end
......@@ -476,8 +476,8 @@ describe Banzai::Filter::LabelReferenceFilter, lib: true do
let!(:result) { reference_filter("See #{reference}", project: project) }
it 'points to referenced project issues page' do
expect(result.css('a').first.attr('href'))
.to eq urls.namespace_project_issues_url(another_project.namespace,
expect(result.css('a').first.attr('href')).
to eq urls.namespace_project_issues_url(another_project.namespace,
another_project,
label_name: group_label.name)
end
......@@ -549,15 +549,15 @@ describe Banzai::Filter::LabelReferenceFilter, lib: true do
let!(:result) { reference_filter("See #{reference}", project: project) }
it 'points to referenced project issues page' do
expect(result.css('a').first.attr('href'))
.to eq urls.namespace_project_issues_url(project.namespace,
expect(result.css('a').first.attr('href')).
to eq urls.namespace_project_issues_url(project.namespace,
project,
label_name: group_label.name)
end
it 'has valid color' do
expect(result.css('a span').first.attr('style'))
.to match /background-color: #00ff00/
expect(result.css('a span').first.attr('style')).
to match /background-color: #00ff00/
end
it 'has valid link text' do
......@@ -583,8 +583,8 @@ describe Banzai::Filter::LabelReferenceFilter, lib: true do
let!(:result) { reference_filter("See #{reference}", project: project) }
it 'points to referenced project issues page' do
expect(result.css('a').first.attr('href'))
.to eq urls.namespace_project_issues_url(project.namespace,
expect(result.css('a').first.attr('href')).
to eq urls.namespace_project_issues_url(project.namespace,
project,
label_name: group_label.name)
end
......
......@@ -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
......
......@@ -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
......
......@@ -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
......
......@@ -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
......
......@@ -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
......
......@@ -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
......
......@@ -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
......
......@@ -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
......
......@@ -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
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment