WIP
This commit is contained in:
parent
fc6aad0b44
commit
f8b681f6e9
|
@ -23,14 +23,12 @@ module BoardsResponses
|
||||||
return render_403 unless can?(current_user, ability, resource)
|
return render_403 unless can?(current_user, ability, resource)
|
||||||
end
|
end
|
||||||
|
|
||||||
# rubocop:disable Cop/ModuleWithInstanceVariables
|
|
||||||
def respond_with_boards
|
def respond_with_boards
|
||||||
respond_with(@boards)
|
respond_with(@boards) # rubocop:disable Cop/ModuleWithInstanceVariables
|
||||||
end
|
end
|
||||||
|
|
||||||
# rubocop:disable Cop/ModuleWithInstanceVariables
|
|
||||||
def respond_with_board
|
def respond_with_board
|
||||||
respond_with(@board)
|
respond_with(@board) # rubocop:disable Cop/ModuleWithInstanceVariables
|
||||||
end
|
end
|
||||||
|
|
||||||
def respond_with(resource)
|
def respond_with(resource)
|
||||||
|
|
|
@ -46,6 +46,7 @@ module CreatesCommit
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
# rubocop:enable Cop/ModuleWithInstanceVariables
|
||||||
|
|
||||||
def authorize_edit_tree!
|
def authorize_edit_tree!
|
||||||
return if can_collaborate_with_project?
|
return if can_collaborate_with_project?
|
||||||
|
@ -90,6 +91,7 @@ module CreatesCommit
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
# rubocop:enable Cop/ModuleWithInstanceVariables
|
||||||
|
|
||||||
def existing_merge_request_path
|
def existing_merge_request_path
|
||||||
project_merge_request_path(@project, @merge_request)
|
project_merge_request_path(@project, @merge_request)
|
||||||
|
@ -102,18 +104,17 @@ module CreatesCommit
|
||||||
@merge_request = MergeRequestsFinder.new(current_user, project_id: @project.id).execute.opened
|
@merge_request = MergeRequestsFinder.new(current_user, project_id: @project.id).execute.opened
|
||||||
.find_by(source_project_id: @project_to_commit_into, source_branch: @branch_name, target_branch: @start_branch)
|
.find_by(source_project_id: @project_to_commit_into, source_branch: @branch_name, target_branch: @start_branch)
|
||||||
end
|
end
|
||||||
|
# rubocop:enable Cop/ModuleWithInstanceVariables
|
||||||
|
|
||||||
# rubocop:disable Cop/ModuleWithInstanceVariables
|
|
||||||
def different_project?
|
def different_project?
|
||||||
@project_to_commit_into != @project
|
@project_to_commit_into != @project # rubocop:disable Cop/ModuleWithInstanceVariables
|
||||||
end
|
end
|
||||||
|
|
||||||
# rubocop:disable Cop/ModuleWithInstanceVariables
|
|
||||||
def create_merge_request?
|
def create_merge_request?
|
||||||
# Even if the field is set, if we're checking the same branch
|
# Even if the field is set, if we're checking the same branch
|
||||||
# as the target branch in the same project,
|
# as the target branch in the same project,
|
||||||
# we don't want to create a merge request.
|
# we don't want to create a merge request.
|
||||||
params[:create_merge_request].present? &&
|
params[:create_merge_request].present? &&
|
||||||
(different_project? || @start_branch != @branch_name)
|
(different_project? || @start_branch != @branch_name) # rubocop:disable Cop/ModuleWithInstanceVariables
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -99,9 +99,8 @@ module IssuableActions
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# rubocop:disable Cop/ModuleWithInstanceVariables
|
|
||||||
def labels
|
def labels
|
||||||
@labels ||= LabelsFinder.new(current_user, project_id: @project.id).execute
|
@labels ||= LabelsFinder.new(current_user, project_id: @project.id).execute # rubocop:disable Cop/ModuleWithInstanceVariables
|
||||||
end
|
end
|
||||||
|
|
||||||
def authorize_destroy_issuable!
|
def authorize_destroy_issuable!
|
||||||
|
@ -110,9 +109,8 @@ module IssuableActions
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# rubocop:disable Cop/ModuleWithInstanceVariables
|
|
||||||
def authorize_admin_issuable!
|
def authorize_admin_issuable!
|
||||||
unless can?(current_user, :"admin_#{resource_name}", @project)
|
unless can?(current_user, :"admin_#{resource_name}", @project) # rubocop:disable Cop/ModuleWithInstanceVariables
|
||||||
return access_denied!
|
return access_denied!
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -26,6 +26,7 @@ module IssuableCollections
|
||||||
|
|
||||||
@users = []
|
@users = []
|
||||||
end
|
end
|
||||||
|
# rubocop:enable Cop/ModuleWithInstanceVariables
|
||||||
|
|
||||||
def issues_collection
|
def issues_collection
|
||||||
issues_finder.execute.preload(:project, :author, :assignees, :labels, :milestone, project: :namespace)
|
issues_finder.execute.preload(:project, :author, :assignees, :labels, :milestone, project: :namespace)
|
||||||
|
@ -110,6 +111,7 @@ module IssuableCollections
|
||||||
|
|
||||||
@filter_params.permit(IssuableFinder::VALID_PARAMS)
|
@filter_params.permit(IssuableFinder::VALID_PARAMS)
|
||||||
end
|
end
|
||||||
|
# rubocop:enable Cop/ModuleWithInstanceVariables
|
||||||
|
|
||||||
def set_default_state
|
def set_default_state
|
||||||
params[:state] = 'opened' if params[:state].blank?
|
params[:state] = 'opened' if params[:state].blank?
|
||||||
|
|
|
@ -18,4 +18,5 @@ module IssuesAction
|
||||||
format.atom { render layout: 'xml.atom' }
|
format.atom { render layout: 'xml.atom' }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
# rubocop:enable Cop/ModuleWithInstanceVariables
|
||||||
end
|
end
|
||||||
|
|
|
@ -12,6 +12,7 @@ module MergeRequestsAction
|
||||||
@collection_type = "MergeRequest"
|
@collection_type = "MergeRequest"
|
||||||
@issuable_meta_data = issuable_meta_data(@merge_requests, @collection_type)
|
@issuable_meta_data = issuable_meta_data(@merge_requests, @collection_type)
|
||||||
end
|
end
|
||||||
|
# rubocop:enable Cop/ModuleWithInstanceVariables
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
# rubocop:disable Cop/ModuleWithInstanceVariables
|
|
||||||
module MilestoneActions
|
module MilestoneActions
|
||||||
extend ActiveSupport::Concern
|
extend ActiveSupport::Concern
|
||||||
|
|
||||||
|
@ -7,7 +6,7 @@ module MilestoneActions
|
||||||
format.html { redirect_to milestone_redirect_path }
|
format.html { redirect_to milestone_redirect_path }
|
||||||
format.json do
|
format.json do
|
||||||
render json: tabs_json("shared/milestones/_merge_requests_tab", {
|
render json: tabs_json("shared/milestones/_merge_requests_tab", {
|
||||||
merge_requests: @milestone.sorted_merge_requests,
|
merge_requests: @milestone.sorted_merge_requests, # rubocop:disable Cop/ModuleWithInstanceVariables
|
||||||
show_project_name: true
|
show_project_name: true
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
@ -19,7 +18,7 @@ module MilestoneActions
|
||||||
format.html { redirect_to milestone_redirect_path }
|
format.html { redirect_to milestone_redirect_path }
|
||||||
format.json do
|
format.json do
|
||||||
render json: tabs_json("shared/milestones/_participants_tab", {
|
render json: tabs_json("shared/milestones/_participants_tab", {
|
||||||
users: @milestone.participants
|
users: @milestone.participants # rubocop:disable Cop/ModuleWithInstanceVariables
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -30,7 +29,8 @@ module MilestoneActions
|
||||||
format.html { redirect_to milestone_redirect_path }
|
format.html { redirect_to milestone_redirect_path }
|
||||||
format.json do
|
format.json do
|
||||||
render json: tabs_json("shared/milestones/_labels_tab", {
|
render json: tabs_json("shared/milestones/_labels_tab", {
|
||||||
labels: @milestone.labels
|
labels: @milestone.labels # rubocop:disable Cop/ModuleWithInstanceVariables
|
||||||
|
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -44,6 +44,7 @@ module MilestoneActions
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# rubocop:disable Cop/ModuleWithInstanceVariables
|
||||||
def milestone_redirect_path
|
def milestone_redirect_path
|
||||||
if @project
|
if @project
|
||||||
project_milestone_path(@project, @milestone)
|
project_milestone_path(@project, @milestone)
|
||||||
|
@ -53,4 +54,5 @@ module MilestoneActions
|
||||||
dashboard_milestone_path(@milestone.safe_title, title: @milestone.title)
|
dashboard_milestone_path(@milestone.safe_title, title: @milestone.title)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
# rubocop:enable Cop/ModuleWithInstanceVariables
|
||||||
end
|
end
|
||||||
|
|
|
@ -30,36 +30,28 @@ module ResolvableDiscussion
|
||||||
allow_nil: true
|
allow_nil: true
|
||||||
end
|
end
|
||||||
|
|
||||||
# rubocop:disable Cop/ModuleWithInstanceVariables
|
|
||||||
def resolvable?
|
def resolvable?
|
||||||
return @resolvable if @resolvable.present?
|
@resolvable ||= potentially_resolvable? && notes.any?(&:resolvable?)
|
||||||
|
|
||||||
@resolvable = potentially_resolvable? && notes.any?(&:resolvable?)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# rubocop:disable Cop/ModuleWithInstanceVariables
|
|
||||||
def resolved?
|
def resolved?
|
||||||
return @resolved if @resolved.present?
|
@resolved ||= resolvable? && notes.none?(&:to_be_resolved?)
|
||||||
|
|
||||||
@resolved = resolvable? && notes.none?(&:to_be_resolved?)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def first_note
|
def first_note
|
||||||
@first_note ||= notes.first
|
@first_note ||= notes.first
|
||||||
end
|
end
|
||||||
|
|
||||||
# rubocop:disable Cop/ModuleWithInstanceVariables
|
|
||||||
def first_note_to_resolve
|
def first_note_to_resolve
|
||||||
return unless resolvable?
|
return unless resolvable?
|
||||||
|
|
||||||
@first_note_to_resolve ||= notes.find(&:to_be_resolved?)
|
@first_note_to_resolve ||= notes.find(&:to_be_resolved?) # rubocop:disable Cop/ModuleWithInstanceVariables
|
||||||
end
|
end
|
||||||
|
|
||||||
# rubocop:disable Cop/ModuleWithInstanceVariables
|
|
||||||
def last_resolved_note
|
def last_resolved_note
|
||||||
return unless resolved?
|
return unless resolved?
|
||||||
|
|
||||||
@last_resolved_note ||= resolved_notes.sort_by(&:resolved_at).last
|
@last_resolved_note ||= resolved_notes.sort_by(&:resolved_at).last # rubocop:disable Cop/ModuleWithInstanceVariables
|
||||||
end
|
end
|
||||||
|
|
||||||
def resolved_notes
|
def resolved_notes
|
||||||
|
@ -100,7 +92,7 @@ module ResolvableDiscussion
|
||||||
yield(notes_relation)
|
yield(notes_relation)
|
||||||
|
|
||||||
# Set the notes array to the updated notes
|
# Set the notes array to the updated notes
|
||||||
@notes = notes_relation.fresh.to_a
|
@notes = notes_relation.fresh.to_a # rubocop:disable Cop/ModuleWithInstanceVariables
|
||||||
|
|
||||||
self.class.memoized_values.each do |var|
|
self.class.memoized_values.each do |var|
|
||||||
instance_variable_set(:"@#{var}", nil)
|
instance_variable_set(:"@#{var}", nil)
|
||||||
|
|
|
@ -3,17 +3,21 @@ module Gitlab
|
||||||
module Pipeline
|
module Pipeline
|
||||||
module Chain
|
module Chain
|
||||||
module Helpers
|
module Helpers
|
||||||
|
# rubocop:disable Cop/ModuleWithInstanceVariables
|
||||||
def branch_exists?
|
def branch_exists?
|
||||||
return @is_branch if defined?(@is_branch)
|
return @is_branch if defined?(@is_branch)
|
||||||
|
|
||||||
@is_branch = project.repository.branch_exists?(pipeline.ref)
|
@is_branch = project.repository.branch_exists?(pipeline.ref)
|
||||||
end
|
end
|
||||||
|
# rubocop:enable Cop/ModuleWithInstanceVariables
|
||||||
|
|
||||||
|
# rubocop:disable Cop/ModuleWithInstanceVariables
|
||||||
def tag_exists?
|
def tag_exists?
|
||||||
return @is_tag if defined?(@is_tag)
|
return @is_tag if defined?(@is_tag)
|
||||||
|
|
||||||
@is_tag = project.repository.tag_exists?(pipeline.ref)
|
@is_tag = project.repository.tag_exists?(pipeline.ref)
|
||||||
end
|
end
|
||||||
|
# rubocop:enable Cop/ModuleWithInstanceVariables
|
||||||
|
|
||||||
def error(message)
|
def error(message)
|
||||||
pipeline.errors.add(:base, message)
|
pipeline.errors.add(:base, message)
|
||||||
|
|
Loading…
Reference in New Issue