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

Fix eager loading associations on destroyed models #76

Merged
merged 1 commit into from
Nov 5, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Changelog

### 3.0.2
- Fix destroyed model eager loading which accidentally broke in [#74](https://github.com/salsify/goldiloader/pull/74).

### 3.0.1
- Enable eager loading of associations on destroyed models in all versions of Rails except 5.2.0 since
Rails issue [32375](https://github.com/rails/rails/pull/32375) has been fixed.
Expand Down
2 changes: 1 addition & 1 deletion lib/goldiloader/compatibility.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def self.rails_5_0?

# See https://github.com/rails/rails/pull/32375
def self.destroyed_model_associations_eager_loadable?
RAILS_5_2_0
!RAILS_5_2_0
end

def self.from_eager_loadable?
Expand Down
2 changes: 1 addition & 1 deletion lib/goldiloader/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# frozen_string_literal: true

module Goldiloader
VERSION = '3.0.1'
VERSION = '3.0.2'
end
10 changes: 2 additions & 8 deletions spec/goldiloader/goldiloader_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -528,14 +528,8 @@
expect(@blog_after_destroy).to eq blog1
end

if ::Goldiloader::Compatibility.destroyed_model_associations_eager_loadable?
it "auto eager loads the associations on other models" do
expect(other_post.association(:blog)).to be_loaded
end
else
it "doesn't auto eager loads associations on other models" do
expect(other_post.association(:blog)).not_to be_loaded
end
it "auto eager loads the associations on other models" do
expect(other_post.association(:blog)).to be_loaded
end
end

Expand Down