Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorblackst0ne <blackst0ne.ru@gmail.com>2018-04-11 14:16:59 +0300
committerblackst0ne <blackst0ne.ru@gmail.com>2018-04-11 14:16:59 +0300
commitc57cddf5b9bce8eeb700b59b964cad6e304d94c8 (patch)
tree0b5357256bec160f7aaa87885e9c8bfaf39f2d13 /app/models
parentfc7d76ae58cfd314867d69f2eaabb8ced31009b4 (diff)
[Rails5] Update Event#subclass_from_attributes method
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.
Diffstat (limited to 'app/models')
-rw-r--r--app/models/event.rb3
1 files changed, 3 insertions, 0 deletions
diff --git a/app/models/event.rb b/app/models/event.rb
index 3805f6cf857..741a84194e2 100644
--- a/app/models/event.rb
+++ b/app/models/event.rb
@@ -110,7 +110,10 @@ class Event < ActiveRecord::Base
end
end
+ # Remove this method when removing Gitlab.rails5? code.
def subclass_from_attributes(attrs)
+ return super if Gitlab.rails5?
+
# Without this Rails will keep calling this method on the returned class,
# resulting in an infinite loop.
return unless self == Event