Skip to content

Commit

Permalink
✅ Adds a guard clause to fix failing tests
Browse files Browse the repository at this point in the history
This commit adds a guard clause to the `SortTitle` model to fix failing
tests due to a nil value being assigned to `@title` on initialization.

Ref:
- scientist-softserv/adventist_knapsack#185
  • Loading branch information
sjproctor committed Sep 9, 2024
1 parent 2a7de90 commit 2846f44
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions app/models/sort_title.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ def initialize(title)
end

def alphabetical
return if @title.blank?

title = @title.downcase
title = title.gsub(/^an(?:[[:space:]])/, '')
.gsub(/^a(?:[[:space:]])/, '')
Expand Down

0 comments on commit 2846f44

Please sign in to comment.