Skip to content

Commit

Permalink
More Rails 5 cleanup.
Browse files Browse the repository at this point in the history
  • Loading branch information
jturkel committed Feb 25, 2016
1 parent de4d378 commit 012b444
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ env:
- RAILS_VERSION="~> 4.0.13" JRUBY_OPTS="$JRUBY_OPTS --debug"
- RAILS_VERSION="~> 4.1.14" JRUBY_OPTS="$JRUBY_OPTS --debug"
- RAILS_VERSION="~> 4.2.5" JRUBY_OPTS="$JRUBY_OPTS --debug"
- RAILS_VERSION="~> 5.0.0.beta2" JRUBY_OPTS="$JRUBY_OPTS --debug"
- RAILS_VERSION="~> 5.0.0.beta3" JRUBY_OPTS="$JRUBY_OPTS --debug"
rvm:
- 1.9.3
- 2.0.0
Expand Down
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
in Rails 4.1.9+ now that the underlying Rails bug has been fixed.
* Fix [issue 11](https://github.com/salsify/goldiloader/issues/11) - Eager load associations with joins in
Rails 4.2+ now that the underlying Rails bug has been fixed.
* Initial support for Rails 5. There are no known issues but see
[issue 27](https://github.com/salsify/goldiloader/issues/27) for remaining tasks.

### 0.0.9
* Merge [pull request](https://github.com/salsify/goldiloader/pull/24) - Optimization: Cache compatibility
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ Goldiloader detects associations with any of these options and disables automati

## Status

This gem is tested with Rails 3.2, 4.0, 4.1, and 4.2 using MRI 1.9.3, 2.0, 2.1, 2.2 and JRuby in 1.9 mode.
This gem is tested with Rails 3.2, 4.0, 4.1, 4.2, and 5.0 using MRI 1.9.3, 2.0, 2.1, 2.2 and JRuby in 1.9 mode.

Let us know if you find any issues or have any other feedback.

Expand Down
8 changes: 7 additions & 1 deletion lib/goldiloader/association_info.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,14 @@ def group?
end

def joins?
return false unless association_scope

num_joins = association_scope.joins_values.size
if ActiveRecord::VERSION::MAJOR >= 5
num_joins += association_scope.left_joins_values.size + association_scope.left_outer_joins.size
end
# Yuck - Through associations will always have a join for *each* 'through' table
association_scope && (association_scope.joins_values.size - num_through_joins) > 0
num_joins - num_through_joins > 0
end

def uniq?
Expand Down
2 changes: 1 addition & 1 deletion lib/goldiloader/association_options.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ module AssociationOptions
# This is only used in Rails 5+
module AssociationBuilderExtension
def self.build(model, reflection)
# TODO: Should we do anything here?
# We have no callbacks to register
end

def self.valid_options
Expand Down
1 change: 0 additions & 1 deletion spec/goldiloader/goldiloader_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,6 @@
end

if ActiveRecord::VERSION::MAJOR >= 4
# TODO: This is broken in Rails 5
context "associations with an overridden from" do
before do
blogs.first.from_posts.to_a
Expand Down

0 comments on commit 012b444

Please sign in to comment.