wallaby-active_record 0.2.5 → 0.2.6

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: 3326a29a32d97399d5d5e5381ca283b5fefc1601bbe212250c2753deb26d9509
4
- data.tar.gz: e61f519c75994ffce103baee81a573941869487dec966e6060299ec24fe73e12
3
+ metadata.gz: 480cda01ad06246374e842aab7e5198ce1075ff28b953c976bf4bf501e0934df
4
+ data.tar.gz: d1e484f6ce3624c729054e04d6d85ef5d861a400e4c9a33c83d8aa28fa41438a
5
5
  SHA512:
6
- metadata.gz: 05003c11197eeab16a351e202b3f7ee97a593abb0b7bf99505d516acb924950522805e6a0198fa274a635d737f1a4a9b69a8591f961304a0e4085706de86800a
7
- data.tar.gz: 8f34233e937848899b6d16a7143a990cd584ccaf23b9c29700ac1cc8837214f1184b34e0fd0fd1f93eaeef15fcaab0898276d63e5529aac4da2a9aac064a378d
6
+ metadata.gz: 41972bd67b243d06f5c397e0cc2e65412b0d991e382c8584dd594c024fb2b6166b45d1a60174e2d1c35216726727c989228c152b996030560a309d3bfb4c5ac7
7
+ data.tar.gz: e5ecbe81c66fe5f1b886e67c1a68164089340ab2edd89bf9135f6fcaa3cbc89f930c23db1d20e434d22328e1e9242beeaa50de7a798bd35fe6c8fa6798f29910
@@ -43,14 +43,14 @@ module Wallaby
43
43
  # NOTE: Need to check the database and table's existence before building up the metadata
44
44
  # so that the database creation and migration related task can be executed.
45
45
  @fields ||= ::ActiveSupport::HashWithIndifferentAccess.new.tap do |hash|
46
- next unless @model_class.table_exists?
46
+ next hash.default = {} unless @model_class.table_exists?
47
47
 
48
48
  hash.merge! general_fields
49
49
  hash.merge! association_fields
50
50
  hash.except!(*foreign_keys_from_associations)
51
51
  end.freeze
52
52
  rescue ::ActiveRecord::NoDatabaseError
53
- Hash.new({})
53
+ Hash.new({}).with_indifferent_access
54
54
  end
55
55
 
56
56
  # A copy of {#fields} for index page
@@ -15,18 +15,29 @@ module Wallaby
15
15
  defined?(::ApplicationRecord) && model_class == ::ApplicationRecord ||
16
16
  model_class.abstract_class? ||
17
17
  anonymous?(model_class) ||
18
- model_class.name.index('HABTM')
18
+ model_class.name.index('HABTM') ||
19
+ invalid_class_name?(model_class)
19
20
  end.sort_by(&:to_s)
20
21
  end
21
22
 
22
23
  protected
23
24
 
25
+ # @param model_class [Class]
24
26
  # @see Wallaby::ModuleUtils.anonymous_class?
25
27
  def anonymous?(model_class)
26
28
  ModuleUtils.anonymous_class?(model_class).tap do |result|
27
29
  Logger.warn "Anonymous class is detected for table #{model_class.try :table_name}" if result
28
30
  end
29
31
  end
32
+
33
+ # To exclude classes that have invalid class name, e.g. **primary::SchemaMigration** from Rails test
34
+ # @param model_class [Class]
35
+ def invalid_class_name?(model_class)
36
+ model_class.name.constantize
37
+ false
38
+ rescue NameError
39
+ true
40
+ end
30
41
  end
31
42
  end
32
43
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Wallaby
4
4
  module ActiveRecordGem
5
- VERSION = '0.2.5' # :nodoc:
5
+ VERSION = '0.2.6' # :nodoc:
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wallaby-active_record
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.5
4
+ version: 0.2.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tian Chen
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-04-12 00:00:00.000000000 Z
11
+ date: 2020-04-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -147,7 +147,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
147
147
  - !ruby/object:Gem::Version
148
148
  version: '0'
149
149
  requirements: []
150
- rubygems_version: 3.0.3
150
+ rubygems_version: 3.1.2
151
151
  signing_key:
152
152
  specification_version: 4
153
153
  summary: Wallaby's ActiveRecord ORM adapter