kakurenbo 0.1.3 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.travis.yml +2 -3
- data/Gemfile +4 -0
- data/README.md +24 -12
- data/kakurenbo.gemspec +2 -2
- data/lib/kakurenbo.rb +8 -1
- data/lib/kakurenbo/{soft_delete_core.rb → core.rb} +76 -53
- data/lib/kakurenbo/mixin_ar_base.rb +38 -15
- data/lib/kakurenbo/mixin_ar_relation.rb +82 -0
- data/lib/kakurenbo/version.rb +1 -1
- data/spec/kakurenbo/cores/associations_spec.rb +178 -0
- data/spec/kakurenbo/cores/callbacks_spec.rb +102 -0
- data/spec/kakurenbo/cores/core_spec.rb +186 -0
- data/spec/kakurenbo/cores/scopes_spec.rb +96 -0
- data/spec/kakurenbo/mixin_ar_base_spec.rb +65 -46
- data/spec/kakurenbo/mixin_ar_relation_spec.rb +117 -0
- data/spec/spec_helper.rb +15 -2
- metadata +19 -16
- data/spec/kakurenbo/soft_delete_cores/associations_spec.rb +0 -270
- data/spec/kakurenbo/soft_delete_cores/callbacks_spec.rb +0 -38
- data/spec/kakurenbo/soft_delete_cores/core_spec.rb +0 -229
- data/spec/kakurenbo/soft_delete_cores/scopes_spec.rb +0 -60
@@ -1,60 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Kakurenbo::SoftDeleteCore::Scopes do
|
4
|
-
create_temp_table(:paranoid_models){ |t| t.datetime :deleted_at }
|
5
|
-
|
6
|
-
before :each do
|
7
|
-
class ParanoidModel < ActiveRecord::Base; end
|
8
|
-
end
|
9
|
-
|
10
|
-
after :each do
|
11
|
-
Object.class_eval{ remove_const :ParanoidModel }
|
12
|
-
end
|
13
|
-
|
14
|
-
context 'when call scope of' do
|
15
|
-
before :each do
|
16
|
-
@existing_model = ParanoidModel.create!
|
17
|
-
@deleted_model = ParanoidModel.create!(deleted_at: Time.now)
|
18
|
-
end
|
19
|
-
|
20
|
-
context 'default_scope' do
|
21
|
-
it 'show existing model.' do
|
22
|
-
expect(ParanoidModel.find_by(id: @existing_model.id)).not_to be_nil
|
23
|
-
end
|
24
|
-
|
25
|
-
it 'hide deleted model.' do
|
26
|
-
expect(ParanoidModel.find_by(id: @deleted_model.id)).to be_nil
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
context 'only_deleted' do
|
31
|
-
it 'hide existing model.' do
|
32
|
-
expect(ParanoidModel.only_deleted.find_by(id: @existing_model.id)).to be_nil
|
33
|
-
end
|
34
|
-
|
35
|
-
it 'show deleted model.' do
|
36
|
-
expect(ParanoidModel.only_deleted.find_by(@deleted_model.id)).not_to be_nil
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
context 'with_deleted' do
|
41
|
-
it 'show existing model.' do
|
42
|
-
expect(ParanoidModel.with_deleted.find_by(id: @existing_model.id)).not_to be_nil
|
43
|
-
end
|
44
|
-
|
45
|
-
it 'show deleted model.' do
|
46
|
-
expect(ParanoidModel.with_deleted.find_by(@deleted_model.id)).not_to be_nil
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
|
-
context 'without_deleted' do
|
51
|
-
it 'show existing model.' do
|
52
|
-
expect(ParanoidModel.without_deleted.find_by(id: @existing_model.id)).not_to be_nil
|
53
|
-
end
|
54
|
-
|
55
|
-
it 'hide deleted model.' do
|
56
|
-
expect(ParanoidModel.without_deleted.find_by(id: @deleted_model.id)).to be_nil
|
57
|
-
end
|
58
|
-
end
|
59
|
-
end
|
60
|
-
end
|