From f289d049882c9fd7455464a048b1786a49170197 Mon Sep 17 00:00:00 2001 From: Joel Turkel Date: Mon, 5 Nov 2018 11:17:14 -0500 Subject: [PATCH] Fix eager loading associations on destroyed models --- CHANGELOG.md | 3 +++ lib/goldiloader/compatibility.rb | 2 +- lib/goldiloader/version.rb | 2 +- spec/goldiloader/goldiloader_spec.rb | 10 ++-------- 4 files changed, 7 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5b64f41..31bc917 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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. diff --git a/lib/goldiloader/compatibility.rb b/lib/goldiloader/compatibility.rb index c970fd8..ff893ef 100644 --- a/lib/goldiloader/compatibility.rb +++ b/lib/goldiloader/compatibility.rb @@ -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? diff --git a/lib/goldiloader/version.rb b/lib/goldiloader/version.rb index a33b99b..99bd367 100644 --- a/lib/goldiloader/version.rb +++ b/lib/goldiloader/version.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true module Goldiloader - VERSION = '3.0.1' + VERSION = '3.0.2' end diff --git a/spec/goldiloader/goldiloader_spec.rb b/spec/goldiloader/goldiloader_spec.rb index 719ad5f..fb416a5 100644 --- a/spec/goldiloader/goldiloader_spec.rb +++ b/spec/goldiloader/goldiloader_spec.rb @@ -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