• Mehmet Emin INAC's avatar
    Return an instance of Feedback from Occurrence#_feedback methods · 962f7748
    Mehmet Emin INAC authored
    Currently Occurrence#_feedback methods return an instance of
    BatchLoader which mimics almost all the behaviour of proxied object
    but it's not perfect.
    We can't use safe navigation operator on these return objects because
    they are not actually `nil` since the Ruby VM just checks the object to
    see if it's `NIL_P` before sending the message.
    This causes getting NoMethodError on nil:NilClass which causes tears
    on developers' eye.
    
    Here we are explicitly returning an instance of Feedback model and also
    loading all the feedback of all occurrences which solves the hidden
    N+1 query issue.
    962f7748
feedback_spec.rb 7.37 KB