partial_ks 0.4.1 → 0.4.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGES.md +4 -0
- data/lib/partial_ks/all_rails_models.rb +7 -1
- data/lib/partial_ks/version.rb +1 -1
- data/test/all_rails_models_test.rb +19 -0
- data/test/configuration_generator_test.rb +3 -1
- data/test/setup_models.rb +8 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ad9df615166ffb1addb9feff9c7a0db7cc73c841
|
4
|
+
data.tar.gz: 9781d32d0230aa6e376822cd9803cfbea2938084
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7445c9ebc62962e3ee09bd7650d79545a3af9477c89fdfdf0d81b530713ebe012e90c3abe007cbfeec24df28c1624bfe94935c1794929363ccbc75759d80d7ca
|
7
|
+
data.tar.gz: c5ea6e4a4d723d8e6f86e748bd7f969974bff2775bb18f38ca33c5d5f1a015a15b2df1ceb26e079337541381e8686a3cf5abc6d38c53d95962116007c640c974
|
data/CHANGES.md
CHANGED
@@ -4,6 +4,12 @@ module PartialKs
|
|
4
4
|
::Rails.application.eager_load!
|
5
5
|
::Rails::Engine.subclasses.map(&:eager_load!)
|
6
6
|
end
|
7
|
-
|
7
|
+
|
8
|
+
concrete_classes.map(&:base_class).uniq
|
9
|
+
end
|
10
|
+
|
11
|
+
private
|
12
|
+
def self.concrete_classes
|
13
|
+
ActiveRecord::Base.descendants.reject {|klass| klass.abstract_class? || !klass.table_exists?}
|
8
14
|
end
|
9
15
|
end
|
data/lib/partial_ks/version.rb
CHANGED
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
describe "all rails tables" do
|
4
|
+
it "includes models that descend from ApplicationRecord" do
|
5
|
+
PartialKs.all_rails_models.must_include User
|
6
|
+
end
|
7
|
+
|
8
|
+
it "excludes abstract classes like ApplicationRecord" do
|
9
|
+
PartialKs.all_rails_models.wont_include ApplicationRecord
|
10
|
+
end
|
11
|
+
|
12
|
+
it "excludes subclass" do
|
13
|
+
PartialKs.all_rails_models.wont_include SubTag
|
14
|
+
end
|
15
|
+
|
16
|
+
it "returns the same number of models as the number of tables" do
|
17
|
+
PartialKs.all_rails_models.map(&:table_name).sort.must_equal ActiveRecord::Base.connection.tables.sort
|
18
|
+
end
|
19
|
+
end
|
@@ -12,6 +12,7 @@ describe "generating dependencies" do
|
|
12
12
|
]
|
13
13
|
end
|
14
14
|
|
15
|
+
# TODO remove redundant test (cf parent_inferrer_test)
|
15
16
|
it "auto infers single belongs-to dependencies" do
|
16
17
|
generator(manual_configuration, models: [User, BlogPost]).
|
17
18
|
must_equal [
|
@@ -20,6 +21,7 @@ describe "generating dependencies" do
|
|
20
21
|
]
|
21
22
|
end
|
22
23
|
|
24
|
+
# TODO remove redundant test (cf parent_inferrer_test)
|
23
25
|
it "auto infers top level tables" do
|
24
26
|
generator(manual_configuration, models: [User, Tag]).
|
25
27
|
must_equal [
|
@@ -28,7 +30,7 @@ describe "generating dependencies" do
|
|
28
30
|
]
|
29
31
|
end
|
30
32
|
|
31
|
-
it "can
|
33
|
+
it "can return models with different table_name" do
|
32
34
|
model = OldEntry
|
33
35
|
model.table_name.wont_equal model.name.tableize
|
34
36
|
|
data/test/setup_models.rb
CHANGED
@@ -1,4 +1,8 @@
|
|
1
|
-
class
|
1
|
+
class ApplicationRecord < ActiveRecord::Base
|
2
|
+
self.abstract_class = true
|
3
|
+
end
|
4
|
+
|
5
|
+
class User < ApplicationRecord
|
2
6
|
has_many :blog_posts
|
3
7
|
end
|
4
8
|
|
@@ -28,3 +32,6 @@ class NewModel < ActiveRecord::Base
|
|
28
32
|
# no tables, e.g. migration not run yet
|
29
33
|
belongs_to :user
|
30
34
|
end
|
35
|
+
|
36
|
+
class SubTag < Tag
|
37
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: partial_ks
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Thong Kuah
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-06-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -76,6 +76,7 @@ files:
|
|
76
76
|
- lib/partial_ks/table.rb
|
77
77
|
- lib/partial_ks/version.rb
|
78
78
|
- partial_ks.gemspec
|
79
|
+
- test/all_rails_models_test.rb
|
79
80
|
- test/configuration_generator_test.rb
|
80
81
|
- test/database.yml
|
81
82
|
- test/filtered_table_test.rb
|
@@ -110,6 +111,7 @@ signing_key:
|
|
110
111
|
specification_version: 4
|
111
112
|
summary: Partial KS
|
112
113
|
test_files:
|
114
|
+
- test/all_rails_models_test.rb
|
113
115
|
- test/configuration_generator_test.rb
|
114
116
|
- test/database.yml
|
115
117
|
- test/filtered_table_test.rb
|