Skip to content

Commit

Permalink
'Fix' rubocop
Browse files Browse the repository at this point in the history
  • Loading branch information
carlobeltrame committed Oct 11, 2023
1 parent 82d3dc6 commit 55bf0a2
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 9 deletions.
23 changes: 16 additions & 7 deletions app/controllers/youth/people_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,6 @@ def set_manager_flash
end

def set_manager_notice
new_managers = entry.people_managers.select { |pm| pm.new_record? }.map(&:manager)
destroyed_managers = entry.people_managers
.select { |pm| pm.marked_for_destruction? }.map(&:manager)
new_manageds = entry.people_manageds.select { |pm| pm.new_record? }.map(&:managed)
destroyed_manageds = entry.people_manageds
.select { |pm| pm.marked_for_destruction? }.map(&:managed)

@manager_notice = [['new_managers', new_managers],
['destroyed_managers', destroyed_managers],
['new_manageds', new_manageds],
Expand Down Expand Up @@ -63,4 +56,20 @@ def extract_managed(attrs)
return PeopleManager.find_by(id: attrs[:id]).managed if attrs[:id].present?
nil
end

def new_managers
entry.people_managers.select { |pm| pm.new_record? }.map(&:manager)
end

def destroyed_managers
entry.people_managers.select { |pm| pm.marked_for_destruction? }.map(&:manager)
end

def new_manageds
entry.people_manageds.select { |pm| pm.new_record? }.map(&:managed)
end

def destroyed_manageds
entry.people_manageds.select { |pm| pm.marked_for_destruction? }.map(&:managed)
end
end
4 changes: 2 additions & 2 deletions app/helpers/youth/dropdown/event/participant_add.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def user_participates_in_with_tentative?(user, event)
end
end

# rubocop:disable Metrics/MethodLength
# rubocop:disable Metrics/MethodLength, Metrics/AbcSize
def init_items_with_manageds(url_options)
return init_items_without_manageds(url_options) if url_options[:for_someone_else]
return init_items_without_manageds(url_options) unless FeatureGate.enabled?('people.people_managers') # rubocop:disable Metrics/LineLength
Expand Down Expand Up @@ -75,7 +75,7 @@ def init_items_with_manageds(url_options)
template.contact_data_managed_group_event_participations_path(group, event, opts)
)
end
# rubocop:enable Metrics/MethodLength
# rubocop:enable Metrics/MethodLength, Metrics/AbcSize

def disabled_message_for_person(person)
if ::Event::Participation.exists?(person: person, event: event)
Expand Down
2 changes: 2 additions & 0 deletions app/models/youth/person.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ def validate_ahv_number
end
end

# rubocop:disable Metrics/CyclomaticComplexity
def assert_either_only_managers_or_manageds
existent_managers = people_managers.reject { |pm| pm.marked_for_destruction? }
existent_manageds = people_manageds.reject { |pm| pm.marked_for_destruction? }
Expand All @@ -59,6 +60,7 @@ def assert_either_only_managers_or_manageds
errors.add(:base, :managed_already_manager)
end
end
# rubocop:enable Metrics/CyclomaticComplexity

def and_manageds
return [self] unless FeatureGate.enabled?('people.people_managers')
Expand Down

0 comments on commit 55bf0a2

Please sign in to comment.