partial_ks 0.4.1 → 0.4.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 38febb0d43538e1c658e595dfa1b690669e9366b
4
- data.tar.gz: f518ef601cb41bf1fc480e75269fdb2d7723c45e
3
+ metadata.gz: ad9df615166ffb1addb9feff9c7a0db7cc73c841
4
+ data.tar.gz: 9781d32d0230aa6e376822cd9803cfbea2938084
5
5
  SHA512:
6
- metadata.gz: 8dba5fdfc838d88f1bac8900d1e7e119da31868acbbe54103753a4c8cf9d6f5181bc1358c66ba7c66cdb993dd483519c8cb63a1d041a91b602373d7887be4985
7
- data.tar.gz: 5eb5e046f03bf8fc15b31ca96d50966a591d5496d95d24ce47a00df83427e9d39f620709cbe7f2ec415310fe67291a4347ed0c4e7e0d8518f1c5ea41e66c5dda
6
+ metadata.gz: 7445c9ebc62962e3ee09bd7650d79545a3af9477c89fdfdf0d81b530713ebe012e90c3abe007cbfeec24df28c1624bfe94935c1794929363ccbc75759d80d7ca
7
+ data.tar.gz: c5ea6e4a4d723d8e6f86e748bd7f969974bff2775bb18f38ca33c5d5f1a015a15b2df1ceb26e079337541381e8686a3cf5abc6d38c53d95962116007c640c974
data/CHANGES.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Changelog
2
2
 
3
+ # 0.4.2
4
+
5
+ Fix an issue where we did not support the new ApplicationRecord convention
6
+
3
7
  # 0.4.1
4
8
 
5
9
  Fix issue where models which are missing their table would error out the whole process.
@@ -4,6 +4,12 @@ module PartialKs
4
4
  ::Rails.application.eager_load!
5
5
  ::Rails::Engine.subclasses.map(&:eager_load!)
6
6
  end
7
- ActiveRecord::Base.direct_descendants
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
@@ -1,3 +1,3 @@
1
1
  module PartialKs
2
- VERSION = '0.4.1'
2
+ VERSION = '0.4.2'
3
3
  end
@@ -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 infer models with different table_name" do
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 User < ActiveRecord::Base
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.1
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-04-08 00:00:00.000000000 Z
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