forked from JackDanger/permanent_records
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request JackDanger#103 from emjot/update-to-rails-5
Update to rails 5
- Loading branch information
Showing
14 changed files
with
118 additions
and
77 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,7 @@ | ||
# This configuration was generated by | ||
# `rubocop --auto-gen-config` | ||
# on 2019-10-09 11:48:30 +0200 using RuboCop version 0.50.0. | ||
# on 2019-10-15 13:32:11 +0200 using RuboCop version 0.68.1. | ||
# The point is for the user to remove these configuration records | ||
# one by one as the offenses are removed from the code base. | ||
# Note that changes in the inspected code, or installation of new | ||
# versions of RuboCop, may require this file to be generated again. | ||
|
||
# Offense count: 15 | ||
Lint/AmbiguousBlockAssociation: | ||
Exclude: | ||
- 'spec/permanent_records_spec.rb' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,11 @@ | ||
language: ruby | ||
rvm: | ||
- 2.0.0-p648 | ||
- 2.2.10 | ||
- 2.3.8 | ||
- 2.4.9 | ||
- 2.5.7 | ||
- 2.6.5 | ||
env: | ||
- AR_TEST_VERSION: 4.2.0 | ||
- AR_TEST_VERSION: 4.2.11.1 | ||
- AR_TEST_VERSION: 5.0.7.2 | ||
- AR_TEST_VERSION: 5.1.7 | ||
- AR_TEST_VERSION: 5.2.3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# rubocop:disable Metrics/AbcSize | ||
# Support destroy for rails belongs_to assocations. | ||
module HandlePermanentRecordsDestroyedInBelongsToAssociation | ||
def handle_dependency | ||
return unless load_target | ||
|
||
case options[:dependent] | ||
when :destroy | ||
target.destroy | ||
raise ActiveRecord::Rollback if target.respond_to?(:deleted?) && !target.deleted? | ||
else | ||
target.send(options[:dependent]) | ||
end | ||
end | ||
end | ||
|
||
# rubocop:disable Metrics/MethodLength | ||
# rubocop:disable Metrics/CyclomaticComplexity | ||
# Support destroy for rails 5.2. has_on associations. | ||
module HandlePermanentRecordsDestroyedInHasOneAssociation | ||
def delete(method = options[:dependent]) | ||
return unless load_target | ||
|
||
case method | ||
when :delete | ||
target.delete | ||
when :destroy | ||
target.destroyed_by_association = reflection | ||
target.destroy | ||
throw(:abort) if target.respond_to?(:deleted?) && !target.deleted? | ||
when :nullify | ||
target.update_columns(reflection.foreign_key => nil) if target.persisted? | ||
end | ||
end | ||
end | ||
# rubocop:enable Metrics/CyclomaticComplexity | ||
# rubocop:enable Metrics/MethodLength | ||
# rubocop:enable Metrics/AbcSize | ||
ActiveRecord::Associations::BelongsToAssociation.prepend(HandlePermanentRecordsDestroyedInBelongsToAssociation) | ||
ActiveRecord::Associations::HasOneAssociation.prepend(HandlePermanentRecordsDestroyedInHasOneAssociation) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,7 +10,7 @@ Gem::Specification.new do |s| | |
s.description = <<-DESCRIPTION | ||
Never Lose Data. Rather than deleting rows this sets Record#deleted_at and | ||
gives you all the scopes you need to work with your data. | ||
DESCRIPTION | ||
DESCRIPTION | ||
s.email = '[email protected]' | ||
s.extra_rdoc_files = [ | ||
'LICENSE', | ||
|
@@ -26,12 +26,13 @@ DESCRIPTION | |
ver = ENV['AR_TEST_VERSION'] | ||
ver = ver.dup.chomp if ver | ||
|
||
s.add_runtime_dependency 'activerecord', ver || '>= 4.2.0' | ||
s.add_runtime_dependency 'activesupport', ver || '>= 4.2.0' | ||
s.add_runtime_dependency 'activerecord', ver || '>= 5.0.0' | ||
s.add_runtime_dependency 'activesupport', ver || '>= 5.0.0' | ||
s.add_development_dependency 'database_cleaner', '>= 1.5.1' | ||
s.add_development_dependency 'pry-byebug' | ||
s.add_development_dependency 'rake' # For Travis-ci | ||
s.add_development_dependency 'rspec', '>= 3.5.0' | ||
s.add_development_dependency 'rubocop', '~> 0.50.0' # freeze to ensure ruby 2.0 compatibility | ||
s.add_development_dependency 'sqlite3', '~> 1.3.6' # freeze to ensure specs are working | ||
s.add_development_dependency 'rubocop', '~> 0.68.0' # freeze to ensure ruby 2.2 compatibility | ||
s.add_development_dependency 'rubocop-performance' | ||
s.add_development_dependency 'sqlite3', '~> 1.3.13' # freeze to ensure specs are working | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.