forest_liana 7.6.4 → 7.6.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1f706a8e009cd73a7493662f62db58e8fa05daccd6c51b3303919354573bbdb6
4
- data.tar.gz: 28c20ebe192a3e9aa366026c1e2f65401cc5627806c6e1348ca6a29297b3889b
3
+ metadata.gz: 707b0b16c61c9b7fcccbe24bd1c751a4cc4329bb70f40b4a4e67507bd5fcecef
4
+ data.tar.gz: c3e41015202d8f246f2328edc4dd013dd7f8d6c26a5a4efc00e00c4eefb10a59
5
5
  SHA512:
6
- metadata.gz: b7119a64a459718a8f65b7c5a85cefcd6e427360ce14a8f5bd0749ef5eb88b30441ea82c1f409e706a60919fc7615f2f2b7b7d21d41e10490d8f9f3f2010205f
7
- data.tar.gz: e85658a00033eccc188f75e59cb15a4b299044e4f7e012f92b07dad854a40b3811b524a3ba7bfedd74f2d00193d01d53424c5da09468947f5c998fd24595380b
6
+ metadata.gz: 95a00b54abf9d30d2dc4d07ac26a70ae17900669fc5646bbb37fcc0a698eb2410b9750110ac2bafab64c56aa0ed0d0076c6eb3f8eec8eec65174408a67ac03f2
7
+ data.tar.gz: 5098267f47503d451160ad421cccfc1a6319331d28625cb25272a3c9882ddf88cd377c656b7bc0e997334a5e8fc7777890f50df957c89369f5c4a101307fbcf6
@@ -114,14 +114,14 @@ module ForestLiana
114
114
  def fetch_model(model)
115
115
  begin
116
116
  if model.abstract_class?
117
- model.descendants.each { |submodel| fetch_model(submodel) }
117
+ model.subclasses.each { |submodel| fetch_model(submodel) }
118
118
  else
119
119
  if is_sti_parent_model?(model)
120
- model.descendants.each { |submodel_sti| fetch_model(submodel_sti) }
120
+ model.subclasses.each { |submodel_sti| fetch_model(submodel_sti) }
121
121
  end
122
122
 
123
123
  if analyze_model?(model)
124
- ForestLiana.models << model
124
+ ForestLiana.models << model unless ForestLiana.models.include?(model)
125
125
  end
126
126
  end
127
127
  rescue => exception
@@ -136,7 +136,7 @@ module ForestLiana
136
136
  end
137
137
 
138
138
  def create_factories
139
- ForestLiana.models.uniq.map do |model|
139
+ ForestLiana.models.map do |model|
140
140
  ForestLiana::SerializerFactory.new.serializer_for(model)
141
141
  ForestLiana::ControllerFactory.new.controller_for(model)
142
142
  end
@@ -1,3 +1,3 @@
1
1
  module ForestLiana
2
- VERSION = "7.6.4"
2
+ VERSION = "7.6.5"
3
3
  end
@@ -0,0 +1,3 @@
1
+ class ApplicationRecord < ActiveRecord::Base
2
+ self.abstract_class = true
3
+ end
@@ -1,3 +1,3 @@
1
- class Product < ActiveRecord::Base
1
+ class Product < ApplicationRecord
2
2
  validates :uri, presence: true, format: { with: URI::DEFAULT_PARSER.make_regexp }
3
3
  end
@@ -1,2 +1,2 @@
1
- class Reference < ActiveRecord::Base
1
+ class Reference < SubApplicationRecord
2
2
  end
@@ -0,0 +1,3 @@
1
+ class SubApplicationRecord < ApplicationRecord
2
+ self.abstract_class = true
3
+ end
@@ -1,5 +1,9 @@
1
1
  module ForestLiana
2
2
  describe Bootstrapper do
3
+ before do
4
+ allow(ForestLiana).to receive(:env_secret).and_return(nil)
5
+ end
6
+
3
7
  describe 'setup_forest_liana_meta' do
4
8
  it "should put statistic data related to user stack on a dedicated object" do
5
9
  expect(ForestLiana.meta[:stack])
@@ -9,6 +13,50 @@ module ForestLiana
9
13
  end
10
14
  end
11
15
 
16
+ describe 'models' do
17
+ let(:expected_models) do
18
+ [
19
+ Island,
20
+ Location,
21
+ Owner,
22
+ Product,
23
+ Reference,
24
+ Tree,
25
+ User
26
+ ]
27
+ end
28
+
29
+ it 'should populate the models correctly' do
30
+ ForestLiana::Bootstrapper.new
31
+ rails_models = [ActiveRecord::InternalMetadata, ActiveRecord::SchemaMigration]
32
+
33
+ expect(ForestLiana.models).to match_array(ForestLiana.models.uniq)
34
+ expect(ForestLiana.models).to match_array(expected_models + rails_models)
35
+ end
36
+
37
+ it 'should generate serializers for all models' do
38
+ factory = instance_double(ForestLiana::SerializerFactory, serializer_for: nil)
39
+ allow(ForestLiana::SerializerFactory).to receive(:new).and_return(factory)
40
+
41
+ ForestLiana::Bootstrapper.new
42
+
43
+ expected_models.each do |model|
44
+ expect(factory).to have_received(:serializer_for).with(model).once
45
+ end
46
+ end
47
+
48
+ it 'should generate controllers for all models' do
49
+ factory = instance_double(ForestLiana::ControllerFactory, controller_for: nil)
50
+ allow(ForestLiana::ControllerFactory).to receive(:new).and_return(factory)
51
+
52
+ ForestLiana::Bootstrapper.new
53
+
54
+ expected_models.each do |model|
55
+ expect(factory).to have_received(:controller_for).with(model).once
56
+ end
57
+ end
58
+ end
59
+
12
60
  describe 'generate_action_hooks' do
13
61
  schema = '{
14
62
  "collections": [
@@ -102,7 +150,6 @@ module ForestLiana
102
150
 
103
151
 
104
152
  it "Should return actions hooks empty for the island collection" do
105
- allow(ForestLiana).to receive(:env_secret).and_return(nil)
106
153
  bootstrapper = Bootstrapper.new
107
154
  content = JSON.parse(schema)
108
155
  bootstrapper.instance_variable_set(:@collections_sent, content['collections'])
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: forest_liana
3
3
  version: !ruby/object:Gem::Version
4
- version: 7.6.4
4
+ version: 7.6.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sandro Munda
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-06-20 00:00:00.000000000 Z
11
+ date: 2022-06-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -328,11 +328,13 @@ files:
328
328
  - spec/dummy/app/controllers/application_controller.rb
329
329
  - spec/dummy/app/controllers/forest/islands_controller.rb
330
330
  - spec/dummy/app/helpers/application_helper.rb
331
+ - spec/dummy/app/models/application_record.rb
331
332
  - spec/dummy/app/models/island.rb
332
333
  - spec/dummy/app/models/location.rb
333
334
  - spec/dummy/app/models/owner.rb
334
335
  - spec/dummy/app/models/product.rb
335
336
  - spec/dummy/app/models/reference.rb
337
+ - spec/dummy/app/models/sub_application_record.rb
336
338
  - spec/dummy/app/models/tree.rb
337
339
  - spec/dummy/app/models/user.rb
338
340
  - spec/dummy/app/views/layouts/application.html.erb
@@ -627,11 +629,13 @@ test_files:
627
629
  - spec/dummy/app/helpers/application_helper.rb
628
630
  - spec/dummy/app/models/reference.rb
629
631
  - spec/dummy/app/models/owner.rb
632
+ - spec/dummy/app/models/application_record.rb
630
633
  - spec/dummy/app/models/location.rb
631
634
  - spec/dummy/app/models/tree.rb
632
635
  - spec/dummy/app/models/product.rb
633
636
  - spec/dummy/app/models/user.rb
634
637
  - spec/dummy/app/models/island.rb
638
+ - spec/dummy/app/models/sub_application_record.rb
635
639
  - spec/dummy/app/views/layouts/application.html.erb
636
640
  - spec/dummy/app/controllers/forest/islands_controller.rb
637
641
  - spec/dummy/app/controllers/application_controller.rb