• blackst0ne's avatar
    [Rails5] Update Event#subclass_from_attributes method · c57cddf5
    blackst0ne authored
    In Rails 5.0 the `ActiveRecord::Inheritance::subclass_from_attributes`
    method was updated.
    Now it calls the `find_sti_class` method [1] which is overriden in the `Event`
    model and returns needed class (`Event` vs `PushEvent`).
    
    [1]: https://github.com/rails/rails/blob/5-0-stable/activerecord/lib/active_record/inheritance.rb#L209
    
    This commit fixes the errors like
    ```
    143) User#contributed_projects doesn't include IDs for unrelated projects
          Failure/Error: action = attrs.with_indifferent_access[inheritance_column].to_i
    
          NoMethodError:
            undefined method `with_indifferent_access' for nil:NilClass
          # ./app/models/event.rb:118:in `subclass_from_attributes'
    ```
    which are raised on the `RAILS5=1 rspec ...` command.
    c57cddf5
event.rb 8.71 KB