Skip to content

Commit

Permalink
fix: undefined method 'zero?' for nil:NilClass (#8689)
Browse files Browse the repository at this point in the history
  • Loading branch information
vishnu-narayanan committed Jan 15, 2024
1 parent 7d6085c commit e7e14f0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
6 changes: 4 additions & 2 deletions app/services/action_service.rb
Expand Up @@ -49,8 +49,10 @@ def remove_label(labels)
end

def assign_team(team_ids = [])
return unassign_team if team_ids[0].zero?
return unless team_belongs_to_account?(team_ids)
return unassign_team if team_ids[0]&.zero?
# check if team belongs to account only if team_id is present
# if team_id is nil, then it means that the team is being unassigned
return unless !team_ids[0].nil? && team_belongs_to_account?(team_ids)

@conversation.update!(team_id: team_ids[0])
end
Expand Down
5 changes: 5 additions & 0 deletions spec/services/action_service_spec.rb
Expand Up @@ -39,5 +39,10 @@
action_service.assign_agent(['nil'])
expect(conversation.reload.assignee).to be_nil
end

it 'unassigns the team if team_id is nil' do
action_service.assign_team([nil])
expect(conversation.reload.team).to be_nil
end
end
end

0 comments on commit e7e14f0

Please sign in to comment.