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

Rails 5 support #77

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
.config
.yardoc
Gemfile.lock
gemfiles/*.lock
vendor/
InstalledFiles
_yardoc
coverage
Expand Down
11 changes: 10 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,19 @@
rvm:
- 2.0.0
- 2.1.0
- 2.2.2

before_install:
- gem install bundler -v '= 1.5.1'

gemfile:
- gemfiles/Gemfile.4.2
- gemfiles/Gemfile.5.0

matrix:
exclude:
- rvm: 2.1.0
gemfile: gemfiles/Gemfile.5.0

notifications:
hipchat:
rooms:
Expand Down
4 changes: 2 additions & 2 deletions destroyed_at.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ Gem::Specification.new do |spec|

spec.required_ruby_version = '~> 2.0'

spec.add_runtime_dependency "activerecord", '~> 4.1'
spec.add_runtime_dependency 'actionpack', '~> 4.1'
spec.add_runtime_dependency "activerecord", '>= 4.1'
spec.add_runtime_dependency 'actionpack', '>= 4.1'

spec.add_development_dependency "bundler", "~> 1.3"
spec.add_development_dependency "rake"
Expand Down
6 changes: 6 additions & 0 deletions gemfiles/Gemfile.4.2
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
source 'https://rubygems.org'

# Specify your gem's dependencies in destroyed_at.gemspec
gemspec :path => "../"
gem 'm', github: 'unmanbearpig/m'
gem "activerecord", "~> 4.2.0"
6 changes: 6 additions & 0 deletions gemfiles/Gemfile.5.0
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
source 'https://rubygems.org'

# Specify your gem's dependencies in destroyed_at.gemspec
gemspec :path => "../"
gem 'm', github: 'unmanbearpig/m'
gem "activerecord", "~> 5.0.0"
3 changes: 2 additions & 1 deletion lib/destroyed_at.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ def self.has_destroy_at?(object)
module ClassMethods
def destroyed(time = nil)
query = where.not(destroyed_at: nil)
query.where_values.reject! do |node|
values = query.respond_to?(:where_clause) ? query.where_clause.send(:predicates) : query.where_values
values.reject! do |node|
Arel::Nodes::Equality === node && node.left.name == 'destroyed_at' && node.right.nil?
end
time ? query.where(destroyed_at: time) : query.where.not(destroyed_at: nil)
Expand Down
3 changes: 2 additions & 1 deletion lib/destroyed_at/has_many_association.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ def delete_records(records, method)
r.destroy
end
end
update_counter(-records.length) unless inverse_updates_counter_cache?
iucc = ActiveRecord::VERSION::MAJOR >= 5 ? reflection.inverse_updates_counter_cache? : inverse_updates_counter_cache?
update_counter(-records.length) unless iucc
else
super
end
Expand Down