Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not observe the same model more than once. Fixes #35. #36

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

anthonyjsmith
Copy link

  • This was happening when a subclass of an observed class was created.
  • The subclass was being observed twice.
  • I've changed one of the tests to catch this.

* This was happening when a subclass of an observed class was created.
* The subclass was being observed twice.
* I've changed one of the tests to catch this.
…ails#35.

* Subclasses were being observed (via add_observer) but not added to
  observed_classes
* Added call to observe() in initialize to update observed_classes
* Moved searching of descendants to initialize, so the comment "Start observing
  the declared classes and their subclasses." will be correct for all subclasses
  of ActiveModel::Observer (not just ActiveRecord::Observer)
* Removed ActiveRecord::Observer#observed_classes, as descendants are now
  searched on initialize (this was the main cause of rails#35)
* No need for models.uniq! in #observe (undoing previous commit)
* Improved tests to better cover uniqueness of observed_classes
* Tests don't work with minitest 5.8.0; require < 5
@DesertSnow
Copy link

Any updates on this issue?

@cfis
Copy link

cfis commented Jan 26, 2017

Agreed, would be nice to have this fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants