paranoia 2.1.0.pre → 2.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +17 -0
- data/lib/paranoia/version.rb +1 -1
- data/test/paranoia_test.rb +24 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f0cb57d2b73781793a6c745fb89bb9d7793fecb3
|
4
|
+
data.tar.gz: f53171d8795a238508541336bbf6e0aa6082959e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 42eab22150eb1e35f7c49b430949905ddf7590695ab6cb8df7cadbd0012ad4038375f859ba63cc200f0b3fe2bde8a0941aeaf51a9daca4a0803ad5d7a3a4841d
|
7
|
+
data.tar.gz: f88c66a92dd499958c14b2c1c4443334522c524270eaab270166ad702db7fa1ae47c4f927a79795fa57f157d8dc7a628f4fce9025e2606e3583dc3b7430c0ba5
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,22 @@
|
|
1
1
|
# paranoia Changelog
|
2
2
|
|
3
|
+
## 2.1.0 (2015-01-23)
|
4
|
+
|
5
|
+
### Major changes
|
6
|
+
|
7
|
+
* `#destroyed?` is no longer overridden. Use `#paranoia_destroyed?` for the existing behaviour. [Washington Luiz](https://github.com/huoxito)
|
8
|
+
* `#persisted?` is no longer overridden.
|
9
|
+
* ActiveRecord 4.0 no longer has `#destroy!` as an alias for `#really_destroy`.
|
10
|
+
* `#destroy` will now raise an exception if called on a readonly record.
|
11
|
+
* `#destroy` on a hard deleted record is now a successful noop.
|
12
|
+
* `#destroy` on a new record will set deleted_at (previously this raised an error)
|
13
|
+
* `#destroy` and `#delete` always return self when successful.
|
14
|
+
|
15
|
+
### Bug Fixes
|
16
|
+
|
17
|
+
* Calling `#destroy` twice will not hard-delete records. Use `#really_destroy` if this is desired.
|
18
|
+
* Fix errors on non-paranoid has_one dependent associations
|
19
|
+
|
3
20
|
## 2.0.5 (2015-01-22)
|
4
21
|
|
5
22
|
### Bug fixes
|
data/lib/paranoia/version.rb
CHANGED
data/test/paranoia_test.rb
CHANGED
@@ -15,9 +15,11 @@ def setup!
|
|
15
15
|
ActiveRecord::Base.connection.execute 'CREATE TABLE parent_models (id INTEGER NOT NULL PRIMARY KEY, deleted_at DATETIME)'
|
16
16
|
ActiveRecord::Base.connection.execute 'CREATE TABLE paranoid_models (id INTEGER NOT NULL PRIMARY KEY, parent_model_id INTEGER, deleted_at DATETIME)'
|
17
17
|
ActiveRecord::Base.connection.execute 'CREATE TABLE paranoid_model_with_belongs (id INTEGER NOT NULL PRIMARY KEY, parent_model_id INTEGER, deleted_at DATETIME, paranoid_model_with_has_one_id INTEGER)'
|
18
|
+
ActiveRecord::Base.connection.execute 'CREATE TABLE paranoid_model_with_build_belongs (id INTEGER NOT NULL PRIMARY KEY, parent_model_id INTEGER, deleted_at DATETIME, paranoid_model_with_has_one_and_build_id INTEGER, name VARCHAR(32))'
|
18
19
|
ActiveRecord::Base.connection.execute 'CREATE TABLE paranoid_model_with_anthor_class_name_belongs (id INTEGER NOT NULL PRIMARY KEY, parent_model_id INTEGER, deleted_at DATETIME, paranoid_model_with_has_one_id INTEGER)'
|
19
20
|
ActiveRecord::Base.connection.execute 'CREATE TABLE paranoid_model_with_foreign_key_belongs (id INTEGER NOT NULL PRIMARY KEY, parent_model_id INTEGER, deleted_at DATETIME, has_one_foreign_key_id INTEGER)'
|
20
21
|
ActiveRecord::Base.connection.execute 'CREATE TABLE not_paranoid_model_with_belongs (id INTEGER NOT NULL PRIMARY KEY, parent_model_id INTEGER, paranoid_model_with_has_one_id INTEGER)'
|
22
|
+
ActiveRecord::Base.connection.execute 'CREATE TABLE paranoid_model_with_has_one_and_builds (id INTEGER NOT NULL PRIMARY KEY, parent_model_id INTEGER, color VARCHAR(32), deleted_at DATETIME, has_one_foreign_key_id INTEGER)'
|
21
23
|
ActiveRecord::Base.connection.execute 'CREATE TABLE featureful_models (id INTEGER NOT NULL PRIMARY KEY, deleted_at DATETIME, name VARCHAR(32))'
|
22
24
|
ActiveRecord::Base.connection.execute 'CREATE TABLE plain_models (id INTEGER NOT NULL PRIMARY KEY, deleted_at DATETIME)'
|
23
25
|
ActiveRecord::Base.connection.execute 'CREATE TABLE callback_models (id INTEGER NOT NULL PRIMARY KEY, deleted_at DATETIME)'
|
@@ -214,6 +216,11 @@ class ParanoiaTest < test_framework
|
|
214
216
|
assert_equal 1, model.class.unscoped.count
|
215
217
|
end
|
216
218
|
|
219
|
+
def test_destroy_behavior_for_has_one_with_build_and_validation_error
|
220
|
+
model = ParanoidModelWithHasOneAndBuild.create
|
221
|
+
model.destroy
|
222
|
+
end
|
223
|
+
|
217
224
|
# Regression test for #24
|
218
225
|
def test_chaining_for_paranoid_models
|
219
226
|
scope = FeaturefulModel.where(:name => "foo").only_deleted
|
@@ -863,6 +870,23 @@ class ParanoidModelWithHasOne < ParanoidModel
|
|
863
870
|
has_one :not_paranoid_model_with_belong, :dependent => :destroy
|
864
871
|
end
|
865
872
|
|
873
|
+
class ParanoidModelWithHasOneAndBuild < ActiveRecord::Base
|
874
|
+
has_one :paranoid_model_with_build_belong, :dependent => :destroy
|
875
|
+
validates :color, :presence => true
|
876
|
+
after_validation :build_paranoid_model_with_build_belong, on: :create
|
877
|
+
|
878
|
+
private
|
879
|
+
def build_paranoid_model_with_build_belong
|
880
|
+
super.tap { |child| child.name = "foo" }
|
881
|
+
end
|
882
|
+
end
|
883
|
+
|
884
|
+
class ParanoidModelWithBuildBelong < ActiveRecord::Base
|
885
|
+
acts_as_paranoid
|
886
|
+
validates :name, :presence => true
|
887
|
+
belongs_to :paranoid_model_with_has_one_and_build
|
888
|
+
end
|
889
|
+
|
866
890
|
class ParanoidModelWithBelong < ActiveRecord::Base
|
867
891
|
acts_as_paranoid
|
868
892
|
belongs_to :paranoid_model_with_has_one
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: paranoia
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.1.0
|
4
|
+
version: 2.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- radarlistener@gmail.com
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-01-
|
11
|
+
date: 2015-01-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -94,7 +94,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
94
94
|
version: 1.3.6
|
95
95
|
requirements: []
|
96
96
|
rubyforge_project: paranoia
|
97
|
-
rubygems_version: 2.
|
97
|
+
rubygems_version: 2.2.2
|
98
98
|
signing_key:
|
99
99
|
specification_version: 4
|
100
100
|
summary: Paranoia is a re-implementation of acts_as_paranoid for Rails 3, using much,
|