Skip to content

Commit

Permalink
Fix nil checks in the client error and supporter finder
Browse files Browse the repository at this point in the history
  • Loading branch information
octopusinvitro committed Dec 7, 2017
1 parent 532bbda commit 6fac9be
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
8 changes: 6 additions & 2 deletions lib/donation_system/salesforce/client_error.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,12 @@ def errors
private

def error_collection
return [] unless client_error&.response
client_error.response.fetch(:body, [])
response.fetch(:body, [])
end

def response
return {} unless client_error
client_error.response || {}
end

def symbolize(error_code)
Expand Down
6 changes: 3 additions & 3 deletions lib/donation_system/salesforce/supporter_finder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,16 @@ def supporter
end

def first_entered
sorted = search.sort_by { |item| item[SORT_FIELD] } if search
sorted&.first
sorted = search.sort_by { |item| item[SORT_FIELD] }
sorted.first
end

def expression
"select #{ID}, #{SORT_FIELD} from #{table} where #{field}='#{value}'"
end

def search
@search ||= client.search(expression)
@search ||= client.search(expression) || []
end

def fetch(id)
Expand Down

0 comments on commit 6fac9be

Please sign in to comment.