hide_ancestry 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (27) hide show
  1. checksums.yaml +4 -4
  2. data/lib/generators/hide_ancestry_migration/hide_ancestry_migration_generator.rb +2 -2
  3. data/lib/generators/hide_ancestry_migration/templates/hide_ancestry_migration.rb +1 -1
  4. data/lib/hide_ancestry/has_hide_ancestry.rb +8 -8
  5. data/lib/hide_ancestry/instance_methods.rb +28 -28
  6. data/lib/hide_ancestry/model_manage/base.rb +3 -3
  7. data/lib/hide_ancestry/model_manage/custom_ancestry_updater.rb +23 -23
  8. data/lib/hide_ancestry/model_manage/hide.rb +2 -2
  9. data/lib/hide_ancestry/model_manage/restore.rb +2 -2
  10. data/lib/hide_ancestry/validators.rb +1 -1
  11. data/lib/hide_ancestry/version.rb +1 -1
  12. data/spec/dummy/db/development.sqlite3 +0 -0
  13. data/spec/dummy/db/migrate/20161217174321_add_hide_ancestry_cols_to_monkeys.rb +1 -1
  14. data/spec/dummy/db/schema.rb +1 -1
  15. data/spec/dummy/db/test.sqlite3 +0 -0
  16. data/spec/dummy/log/development.log +414 -0
  17. data/spec/dummy/log/test.log +12651 -0
  18. data/spec/factories/monkey.rb +1 -1
  19. data/spec/lib/hide_ancestry/instance_methods_spec.rb +29 -29
  20. data/spec/lib/hide_ancestry/model_manage/custom_ancestry_updater/cases/{hided_nodes_cases_spec.rb → hidden_nodes_cases_spec.rb} +12 -12
  21. data/spec/lib/hide_ancestry/model_manage/hide_spec.rb +6 -6
  22. data/spec/lib/hide_ancestry/model_manage/restore_spec.rb +6 -6
  23. data/spec/lib/hide_ancestry/model_manage/validators_spec.rb +5 -5
  24. data/spec/models/bonobo_spec.rb +1 -1
  25. data/spec/support/shared_examples/has_hide_ancestry_examples.rb +4 -4
  26. data/spec/support/shared_examples/instance_methods_examples.rb +9 -9
  27. metadata +3 -3
@@ -2,7 +2,7 @@ FactoryGirl.define do
2
2
  factory :monkey do
3
3
  end
4
4
 
5
- factory :hiden_monkey, class: Monkey do
5
+ factory :hidden_monkey, class: Monkey do
6
6
  after(:create) { |monkey| monkey.hide }
7
7
  end
8
8
  end
@@ -18,23 +18,23 @@ describe HideAncestry::InstanceMethods do
18
18
  end
19
19
 
20
20
  context '#restore' do
21
- let(:hiden) { create :hiden_monkey }
21
+ let(:hidden) { create :hidden_monkey }
22
22
 
23
23
  it 'return #not_valid_error unless #valid?' do
24
- allow(hiden).to receive(:valid?).and_return false
25
- hiden.restore
26
- expect(hiden.errors[:base].first).to include 'not valid'
24
+ allow(hidden).to receive(:valid?).and_return false
25
+ hidden.restore
26
+ expect(hidden.errors[:base].first).to include 'not valid'
27
27
  end
28
28
 
29
- it 'return #already_restored_error unless hiden' do
29
+ it 'return #already_restored_error unless hidden' do
30
30
  parent.restore
31
31
  expect(parent.errors[:base].first).to include 'Already restored'
32
32
  end
33
33
 
34
34
  it do
35
35
  expect(HideAncestry::ModelManage::Restore)
36
- .to receive(:call).with(hiden)
37
- hiden.restore
36
+ .to receive(:call).with(hidden)
37
+ hidden.restore
38
38
  end
39
39
  end
40
40
 
@@ -61,49 +61,49 @@ describe HideAncestry::InstanceMethods do
61
61
  end
62
62
  end
63
63
 
64
- context '#hiden_parent_changed?' do
65
- subject { child.reload.hiden_parent_changed? }
64
+ context '#hidden_parent_changed?' do
65
+ subject { child.reload.hidden_parent_changed? }
66
66
 
67
- it 'true if node grandparent != hiden parent old parent' do
67
+ it 'true if node grandparent != hidden parent old parent' do
68
68
  HideAncestry::ModelManage::Hide.call(parent)
69
69
  allow(child).to receive(:parent_id).and_return 111
70
70
  is_expected.to be_truthy
71
71
  end
72
72
 
73
- it 'false if node grandparent == hiden parent old parent' do
73
+ it 'false if node grandparent == hidden parent old parent' do
74
74
  HideAncestry::ModelManage::Hide.call(parent)
75
75
  is_expected.to be_falsey
76
76
  end
77
77
 
78
- it 'false if no hiden parent' do
79
- allow(child).to receive(:hiden_parent).and_return nil
78
+ it 'false if no hidden parent' do
79
+ allow(child).to receive(:hidden_parent).and_return nil
80
80
  is_expected.to be_falsey
81
81
  end
82
82
  end
83
83
 
84
- context '#hiden_parent' do
84
+ context '#hidden_parent' do
85
85
  before { HideAncestry::ModelManage::Hide.call(grandparent) }
86
86
 
87
- it 'return record#hiden? which ' \
87
+ it 'return record#hidden? which ' \
88
88
  'includes node#id in #old_child_ids' do
89
- expect(parent.hiden_parent).to eq grandparent
89
+ expect(parent.hidden_parent).to eq grandparent
90
90
  expect(parent.reload.parent).to be_nil
91
91
  end
92
92
 
93
- it 'return nil if no record#hiden? ' \
93
+ it 'return nil if no record#hidden? ' \
94
94
  'with node#id in #old_child_ids' do
95
- expect(child.hiden_parent).to be_nil
95
+ expect(child.hidden_parent).to be_nil
96
96
  end
97
97
  end
98
98
 
99
- context '#hiden_descendants_ids' do
99
+ context '#hidden_descendants_ids' do
100
100
  before { HideAncestry::ModelManage::Hide.call(parent) }
101
101
 
102
- it 'return ids nodes#hiden?, ' \
102
+ it 'return ids nodes#hidden?, ' \
103
103
  'which #old_parent_id eql to descendants ids' do
104
104
 
105
- expect(grandparent.hiden_descendants_ids).to include parent.id
106
- expect(child.hiden_descendants_ids).to be_blank
105
+ expect(grandparent.hidden_descendants_ids).to include parent.id
106
+ expect(child.hidden_descendants_ids).to be_blank
107
107
  end
108
108
  end
109
109
 
@@ -122,18 +122,18 @@ describe HideAncestry::InstanceMethods do
122
122
  expect(grandparent.find_first_real_parent).to be_nil
123
123
  end
124
124
 
125
- it 'call itself to finded if record#hiden?' do
125
+ it 'call itself to finded if record#hidden?' do
126
126
  HideAncestry::ModelManage::Hide.call(parent)
127
127
  HideAncestry::ModelManage::Hide.call(child)
128
128
  expect(child.find_first_real_parent).to eq grandparent
129
129
  end
130
130
  end
131
131
 
132
- context '#depth_with_hiden' do
132
+ context '#depth_with_hidden' do
133
133
  it 'return #size of #hide_ancestry_ids' do
134
134
  ids = [1, 2, 3]
135
135
  allow(parent).to receive(:hide_ancestry_ids).and_return(ids)
136
- expect(parent.depth_with_hiden).to eq 3
136
+ expect(parent.depth_with_hidden).to eq 3
137
137
  end
138
138
  end
139
139
 
@@ -146,17 +146,17 @@ describe HideAncestry::InstanceMethods do
146
146
  end
147
147
  end
148
148
 
149
- context '#subtree_with_hiden' do
149
+ context '#subtree_with_hidden' do
150
150
  it 'calls subtree ids as array' do
151
151
  expect(parent).to receive_message_chain('subtree.pluck')
152
152
  .with(:id)
153
153
  .and_return []
154
154
 
155
- parent.subtree_with_hiden
155
+ parent.subtree_with_hidden
156
156
  end
157
157
 
158
158
  context 'return ordered relation' do
159
- let(:relation) { grandparent.subtree_with_hiden }
159
+ let(:relation) { grandparent.subtree_with_hidden }
160
160
 
161
161
  after do
162
162
  expect(relation.first.id).to eq grandparent.id
@@ -168,7 +168,7 @@ describe HideAncestry::InstanceMethods do
168
168
  relation
169
169
  end
170
170
 
171
- it 'return ordered relation even node is hiden' do
171
+ it 'return ordered relation even node is hidden' do
172
172
  parent.hide
173
173
  relation
174
174
  end
@@ -5,7 +5,7 @@ describe HideAncestry::ModelManage::CustomAncestryUpdater do
5
5
 
6
6
  let(:root_monkey) { create :monkey }
7
7
 
8
- describe 'when #hiden_status' do
8
+ describe 'when #hidden_status' do
9
9
  context 'does not change custom ancestry cols' do
10
10
  context 'of called node' do
11
11
  let!(:before_hide_ancestry) { parent.hide_ancestry }
@@ -34,8 +34,8 @@ describe HideAncestry::ModelManage::CustomAncestryUpdater do
34
34
  end
35
35
  end
36
36
 
37
- context 'and parent of hiden node changes its parent' do
38
- let!(:old_hiden_path) { parent.hide_ancestry_ids }
37
+ context 'and parent of hidden node changes its parent' do
38
+ let!(:old_hidden_path) { parent.hide_ancestry_ids }
39
39
 
40
40
  let(:new_parent) { create :monkey }
41
41
 
@@ -46,13 +46,13 @@ describe HideAncestry::ModelManage::CustomAncestryUpdater do
46
46
 
47
47
  it 'node#hide_ancestry changes' do
48
48
  expect(parent.reload.hide_ancestry_ids).to include new_parent.id
49
- expect(parent.hide_ancestry_ids).not_to eq old_hiden_path
49
+ expect(parent.hide_ancestry_ids).not_to eq old_hidden_path
50
50
  end
51
51
  end
52
52
  end
53
53
 
54
- describe 'and parent of hiden node changes its parent' do
55
- let!(:old_hiden_path) { parent.hide_ancestry_ids }
54
+ describe 'and parent of hidden node changes its parent' do
55
+ let!(:old_hidden_path) { parent.hide_ancestry_ids }
56
56
 
57
57
  let(:new_parent) { create :monkey }
58
58
 
@@ -63,12 +63,12 @@ describe HideAncestry::ModelManage::CustomAncestryUpdater do
63
63
 
64
64
  it 'node#hide_ancestry changes' do
65
65
  expect(parent.reload.hide_ancestry_ids).to include new_parent.id
66
- expect(parent.hide_ancestry_ids).not_to eq old_hiden_path
66
+ expect(parent.hide_ancestry_ids).not_to eq old_hidden_path
67
67
  end
68
68
  end
69
69
 
70
70
  describe do
71
- context 'hiden parent, child changes path' do
71
+ context 'hidden parent, child changes path' do
72
72
  before do
73
73
  parent.hide
74
74
  child.update parent: root_monkey
@@ -81,7 +81,7 @@ describe HideAncestry::ModelManage::CustomAncestryUpdater do
81
81
  it { expect(subject).not_to include grandparent.id }
82
82
  end
83
83
 
84
- context 'hiden parent, child does not changes path' do
84
+ context 'hidden parent, child does not changes path' do
85
85
  before { parent.hide }
86
86
 
87
87
  subject { child.reload.hide_ancestry_ids }
@@ -91,15 +91,15 @@ describe HideAncestry::ModelManage::CustomAncestryUpdater do
91
91
  end
92
92
  end
93
93
 
94
- describe 'hiden parent, changed subtree' do
95
- let!(:some_hiden_monkey) { create :hiden_monkey }
94
+ describe 'hidden parent, changed subtree' do
95
+ let!(:some_hidden_monkey) { create :hidden_monkey }
96
96
 
97
97
  before do
98
98
  parent.hide
99
99
  grandparent.update parent: root_monkey
100
100
  end
101
101
 
102
- it 'changes #hide_ancestry of subtree hiden monkeys' do
102
+ it 'changes #hide_ancestry of subtree hidden monkeys' do
103
103
  expect(parent.reload.hide_ancestry_ids).to include root_monkey.id
104
104
  end
105
105
  end
@@ -8,7 +8,7 @@ describe HideAncestry::ModelManage::Hide do
8
8
  subject { described_class.new(parent) }
9
9
  after { subject.call }
10
10
 
11
- it { is_expected.to receive(:change_hiden_status).with(true) }
11
+ it { is_expected.to receive(:change_hidden_status).with(true) }
12
12
  it { is_expected.to receive :save_parent_id }
13
13
  it { is_expected.to receive :save_child_ids }
14
14
 
@@ -19,8 +19,8 @@ describe HideAncestry::ModelManage::Hide do
19
19
  describe 'set' do
20
20
  before { described_class.call(parent) }
21
21
 
22
- it '#hiden_status to true' do
23
- expect(parent.hiden_status).to eq true
22
+ it '#hidden_status to true' do
23
+ expect(parent.hidden_status).to eq true
24
24
  end
25
25
 
26
26
  it '#ancestry to nil' do
@@ -36,7 +36,7 @@ describe HideAncestry::ModelManage::Hide do
36
36
  is_expected.to eq grandparent.id
37
37
  end
38
38
 
39
- it 'first real parent if actual parent #hiden?' do
39
+ it 'first real parent if actual parent #hidden?' do
40
40
  grandparent.update(parent: some_monkey)
41
41
  described_class.call(grandparent)
42
42
 
@@ -65,7 +65,7 @@ describe HideAncestry::ModelManage::Hide do
65
65
  is_expected.to include child.id
66
66
  end
67
67
 
68
- it 'of previously hiden children' do
68
+ it 'of previously hidden children' do
69
69
  some_monkey.update parent_id: parent.id
70
70
  parent.reload
71
71
 
@@ -85,7 +85,7 @@ describe HideAncestry::ModelManage::Hide do
85
85
  is_expected.to eq grandparent.id
86
86
  end
87
87
 
88
- it 'of hiden parent if present' do
88
+ it 'of hidden parent if present' do
89
89
  grandparent.update parent: some_monkey
90
90
  described_class.call(grandparent)
91
91
 
@@ -12,7 +12,7 @@ describe HideAncestry::ModelManage::Restore do
12
12
  it { is_expected.to receive :restore_children }
13
13
 
14
14
  it do
15
- is_expected.to receive(:change_hiden_status).with false
15
+ is_expected.to receive(:change_hidden_status).with false
16
16
  end
17
17
  end
18
18
 
@@ -33,8 +33,8 @@ describe HideAncestry::ModelManage::Restore do
33
33
  end
34
34
 
35
35
  context 'restore children' do
36
- it 'doesn`t restore hiden children' do
37
- allow(child).to receive(:hiden?).and_return true
36
+ it 'doesn`t restore hidden children' do
37
+ allow(child).to receive(:hidden?).and_return true
38
38
  described_class.call(grandparent)
39
39
  expect(grandparent.reload.child_ids).not_to include child.id
40
40
  end
@@ -62,12 +62,12 @@ describe HideAncestry::ModelManage::Restore do
62
62
  end
63
63
  end
64
64
 
65
- context 'change #hiden_status' do
66
- before { parent.update_attribute :hiden_status, true }
65
+ context 'change #hidden_status' do
66
+ before { parent.update_attribute :hidden_status, true }
67
67
 
68
68
  it 'to false' do
69
69
  described_class.call(parent)
70
- expect(parent.hiden_status).to be_falsey
70
+ expect(parent.hidden_status).to be_falsey
71
71
  end
72
72
  end
73
73
 
@@ -2,15 +2,15 @@ require 'spec_helper'
2
2
 
3
3
  describe HideAncestry::Validators do
4
4
  let(:monkey) { build :monkey }
5
- let(:hiden_monkey) { create :hiden_monkey }
5
+ let(:hidden_monkey) { create :hidden_monkey }
6
6
 
7
7
  context '#can_not_has_parent_or_children' do
8
8
  it 'when ancestry changed' do
9
- error_message = 'hiden node can`t has any real parent or children'
10
- hiden_monkey.ancestry = '1/2/3'
9
+ error_message = 'hidden node can`t has any real parent or children'
10
+ hidden_monkey.ancestry = '1/2/3'
11
11
 
12
- hiden_monkey.valid?
13
- expect(hiden_monkey.errors[:base]).to include error_message
12
+ hidden_monkey.valid?
13
+ expect(hidden_monkey.errors[:base]).to include error_message
14
14
  end
15
15
  end
16
16
  end
@@ -1,7 +1,7 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Bonobo, type: :model do
4
- it { is_expected.not_to have_db_column :hiden_status }
4
+ it { is_expected.not_to have_db_column :hidden_status }
5
5
 
6
6
  it_behaves_like '.has_hide_ancestry owner'
7
7
  it_behaves_like 'hide_ancestry instance methods owner'
@@ -15,10 +15,10 @@ shared_examples '.has_hide_ancestry owner' do |false_expectation|
15
15
  context 'scopes' do
16
16
  subject { described_class }
17
17
 
18
- it { is_expected.public_send predicate_matcher, respond_to(:hiden) }
19
- it { is_expected.public_send predicate_matcher, respond_to(:unhiden) }
20
- it { is_expected.public_send predicate_matcher, respond_to(:hiden_nodes) }
21
- it { is_expected.public_send predicate_matcher, respond_to(:hiden_childs) }
18
+ it { is_expected.public_send predicate_matcher, respond_to(:hidden) }
19
+ it { is_expected.public_send predicate_matcher, respond_to(:unhidden) }
20
+ it { is_expected.public_send predicate_matcher, respond_to(:hidden_nodes) }
21
+ it { is_expected.public_send predicate_matcher, respond_to(:hidden_childs) }
22
22
  end
23
23
  end
24
24
  end
@@ -7,19 +7,19 @@ shared_examples 'hide_ancestry instance methods owner' do |false_expectation|
7
7
  it { is_expected.public_send predicate_matcher, respond_to(:restore) }
8
8
  it { is_expected.public_send predicate_matcher, respond_to(:first_hiding?) }
9
9
 
10
- it { is_expected.public_send predicate_matcher, respond_to(:hiden?) }
10
+ it { is_expected.public_send predicate_matcher, respond_to(:hidden?) }
11
11
  it { is_expected.public_send predicate_matcher, respond_to(:hide_ancestry_ids) }
12
- it { is_expected.public_send predicate_matcher, respond_to(:children_of_hiden) }
12
+ it { is_expected.public_send predicate_matcher, respond_to(:children_of_hidden) }
13
13
 
14
- it { is_expected.public_send predicate_matcher, respond_to(:hiden_children) }
15
- it { is_expected.public_send predicate_matcher, respond_to(:hiden_parent_changed?) }
16
- it { is_expected.public_send predicate_matcher, respond_to(:subtree_with_hiden) }
14
+ it { is_expected.public_send predicate_matcher, respond_to(:hidden_children) }
15
+ it { is_expected.public_send predicate_matcher, respond_to(:hidden_parent_changed?) }
16
+ it { is_expected.public_send predicate_matcher, respond_to(:subtree_with_hidden) }
17
17
 
18
- it { is_expected.public_send predicate_matcher, respond_to(:hiden_parent) }
19
- it { is_expected.public_send predicate_matcher, respond_to(:hiden_children_present?) }
20
- it { is_expected.public_send predicate_matcher, respond_to(:hiden_descendants_ids) }
18
+ it { is_expected.public_send predicate_matcher, respond_to(:hidden_parent) }
19
+ it { is_expected.public_send predicate_matcher, respond_to(:hidden_children_present?) }
20
+ it { is_expected.public_send predicate_matcher, respond_to(:hidden_descendants_ids) }
21
21
 
22
- it { is_expected.public_send predicate_matcher, respond_to(:hiden_ids) }
22
+ it { is_expected.public_send predicate_matcher, respond_to(:hidden_ids) }
23
23
  it { is_expected.public_send predicate_matcher, respond_to(:find_first_real_parent) }
24
24
 
25
25
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hide_ancestry
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dimkarodinz
@@ -197,7 +197,7 @@ files:
197
197
  - spec/dummy/public/favicon.ico
198
198
  - spec/factories/monkey.rb
199
199
  - spec/lib/hide_ancestry/instance_methods_spec.rb
200
- - spec/lib/hide_ancestry/model_manage/custom_ancestry_updater/cases/hided_nodes_cases_spec.rb
200
+ - spec/lib/hide_ancestry/model_manage/custom_ancestry_updater/cases/hidden_nodes_cases_spec.rb
201
201
  - spec/lib/hide_ancestry/model_manage/custom_ancestry_updater/cases/mixed_cases_spec.rb
202
202
  - spec/lib/hide_ancestry/model_manage/custom_ancestry_updater/cases/updating_parent_cases_spec.rb
203
203
  - spec/lib/hide_ancestry/model_manage/custom_ancestry_updater/custom_ancestry_updater_spec.rb
@@ -298,7 +298,7 @@ test_files:
298
298
  - spec/lib/hide_ancestry/model_manage/restore_spec.rb
299
299
  - spec/lib/hide_ancestry/model_manage/custom_ancestry_updater/cases/updating_parent_cases_spec.rb
300
300
  - spec/lib/hide_ancestry/model_manage/custom_ancestry_updater/cases/mixed_cases_spec.rb
301
- - spec/lib/hide_ancestry/model_manage/custom_ancestry_updater/cases/hided_nodes_cases_spec.rb
301
+ - spec/lib/hide_ancestry/model_manage/custom_ancestry_updater/cases/hidden_nodes_cases_spec.rb
302
302
  - spec/lib/hide_ancestry/model_manage/custom_ancestry_updater/custom_ancestry_updater_spec.rb
303
303
  - spec/lib/hide_ancestry/model_manage/hide_spec.rb
304
304
  - spec/lib/hide_ancestry/instance_methods_spec.rb