with_model 2.1.2 → 2.1.3

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
  SHA256:
3
- metadata.gz: 73d3473a8847088dfb50b96f339306c6b853b78d1be908aee3dfbae594df8c5a
4
- data.tar.gz: c3c48245f7ec06041f9c99cac9e72e0e490760451bd936a36bf05f274cc75eef
3
+ metadata.gz: cb3f231c15ce48cb075bcb5fe28ffde183e3432328d7a3797744cef9a9eb27ab
4
+ data.tar.gz: 1a4ef223a3c590833eaa4886bf471dd0b1e5fe5f79b84b2ed011537812e681d6
5
5
  SHA512:
6
- metadata.gz: 1d2dbbf33bb33961595848a2974166610a1afc557a8cbf3e460c53a0793278f2132114fbbb5ac396866ec2e736de9067542daf52aaa4283293e1886c65a3b585
7
- data.tar.gz: 154318219e3adfa3469e60041c1f8559c3912481f278cc01c117856374f1ac5aee1d32b711d2fc5eb44e3946fc374ce48ce8f3d80c750109f0db25c71a2308cd
6
+ metadata.gz: 21640ee3c2312f019aa6c83268c6606c96f3fe03b7c1af2be15e2fd2ea9a48e3ed31f48d0581733a65577843cdf7069523b674137650d50187d933f8cb53ef90
7
+ data.tar.gz: 39aa2e361858be2e75375c02ba272bd39ff2528650b17e6ce197ac92683b3dbf83f0cb968573af37cf60945b847992091e2510f3bde196ba3e7543928f081dc2
@@ -4,3 +4,6 @@ inherit_gem:
4
4
 
5
5
  AllCops:
6
6
  TargetRubyVersion: 2.3
7
+
8
+ Lint/MissingCopEnableDirective:
9
+ Enabled: false
@@ -1,37 +1,33 @@
1
1
  language: ruby
2
- sudo: false
3
2
 
4
3
  rvm:
5
- - "2.5.1"
6
- - "2.4.4"
7
- - "2.3.7"
8
- - jruby-9.2.0.0
4
+ - 2.6.5
5
+ - 2.5.7
6
+ - 2.4.9
7
+ - jruby-9.2.8.0
9
8
 
10
9
  install:
10
+ - gem install bundler
11
11
  - bundle install --retry=3
12
12
 
13
13
  env:
14
14
  - ACTIVE_RECORD_BRANCH="master"
15
- - ACTIVE_RECORD_BRANCH="5-2-stable"
15
+ - ACTIVE_RECORD_VERSION="~> 6.0.0"
16
16
  - ACTIVE_RECORD_VERSION="~> 5.2.0"
17
17
  - ACTIVE_RECORD_VERSION="~> 5.1.0"
18
18
  - ACTIVE_RECORD_VERSION="~> 5.0.0"
19
19
  - ACTIVE_RECORD_VERSION="~> 4.2.0"
20
20
 
21
21
  matrix:
22
+ fast_finish: true
22
23
  allow_failures:
23
24
  - env: ACTIVE_RECORD_BRANCH="master"
24
- - env: ACTIVE_RECORD_BRANCH="5-2-stable"
25
25
  exclude:
26
- - rvm: 2.3.7
26
+ - rvm: 2.4.9
27
27
  env: ACTIVE_RECORD_BRANCH="master"
28
- - rvm: jruby-9.2.0.0
29
- env: ACTIVE_RECORD_BRANCH="master"
30
- - rvm: jruby-9.2.0.0
31
- env: ACTIVE_RECORD_BRANCH="5-2-stable"
32
- - rvm: jruby-9.2.0.0
33
- env: ACTIVE_RECORD_VERSION="~> 5.2.0"
34
- - rvm: jruby-9.2.0.0
28
+ - rvm: 2.4.9
29
+ env: ACTIVE_RECORD_VERSION="~> 6.0.0"
30
+ - rvm: jruby-9.2.8.0
35
31
  env: ACTIVE_RECORD_VERSION="~> 4.2.0"
36
32
 
37
33
  addons:
@@ -1,4 +1,8 @@
1
- ### 2.2.2
1
+ ### 2.1.3
2
+
3
+ - Support ActiveRecord 6.0, working around new dependency tracking API
4
+
5
+ ### 2.1.2
2
6
 
3
7
  - Don't clobber existing rake executable
4
8
 
data/Gemfile CHANGED
@@ -1,5 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ # rubocop:disable Bundler/DuplicatedGem, Bundler/OrderedGems
4
+
3
5
  source 'https://rubygems.org'
4
6
 
5
7
  gemspec
@@ -8,10 +10,25 @@ gem 'lint-config-ruby', git: 'https://github.com/Casecommons/lint-config-ruby.gi
8
10
 
9
11
  ar_branch = ENV['ACTIVE_RECORD_BRANCH']
10
12
  ar_version = ENV['ACTIVE_RECORD_VERSION']
13
+ is_jruby = RUBY_PLATFORM == 'java'
11
14
 
12
15
  if ar_branch
13
16
  gem 'activerecord', git: 'https://github.com/rails/rails.git', branch: ar_branch
14
- gem 'arel', git: 'https://github.com/rails/arel.git' if ar_branch == 'master'
17
+ if ar_branch == 'master'
18
+ gem 'arel', git: 'https://github.com/rails/arel.git'
19
+ gem 'activerecord-jdbcsqlite3-adapter', git: 'https://github.com/jruby/activerecord-jdbc-adapter.git' if is_jruby
20
+ end
15
21
  elsif ar_version
16
22
  gem 'activerecord', ar_version # rubocop:disable Bundler/DuplicatedGem
23
+ if is_jruby && Gem::Requirement.new(ar_version).satisfied_by?(Gem::Version.new('6.0.0'))
24
+ gem 'activerecord-jdbcsqlite3-adapter', git: 'https://github.com/jruby/activerecord-jdbc-adapter.git'
25
+ end
26
+ end
27
+
28
+ unless is_jruby
29
+ if ar_branch == 'master' || Gem::Requirement.new(ar_version).satisfied_by?(Gem::Version.new('6.0.0'))
30
+ gem 'sqlite3', '~> 1.4.1'
31
+ else
32
+ gem 'sqlite3', '~> 1.3.11'
33
+ end
17
34
  end
data/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2010-2018 Case Commons, Inc. <http://casecommons.org>
1
+ Copyright (c) 2010-2019 Casebook, PBC <http://www.casebook.net>
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining a copy
4
4
  of this software and associated documentation files (the "Software"), to deal
data/README.md CHANGED
@@ -181,5 +181,5 @@ In general, `with_model` is not guaranteed to be thread-safe, but is, in certain
181
181
 
182
182
  ## License
183
183
 
184
- Copyright © 2010–2018 [Case Commons, Inc](http://casecommons.org).
184
+ Copyright © 2010–2018 [Casebook PBC](https://www.casebook.net).
185
185
  Licensed under the MIT license, see [LICENSE](/LICENSE) file.
@@ -6,7 +6,7 @@ require 'with_model/table'
6
6
  require 'with_model/version'
7
7
 
8
8
  module WithModel
9
- # @param name The constant name (as a symbol) to assign the model class to.
9
+ # @param [Symbol] name The constant name to assign the model class to.
10
10
  # @param scope Passed to `before`/`after` in the test context.
11
11
  # @param options Passed to {WithModel::Model#initialize}.
12
12
  # @param block Yielded an instance of {WithModel::Model::DSL}.
@@ -24,7 +24,7 @@ module WithModel
24
24
  end
25
25
  end
26
26
 
27
- # @param name The table name (as a symbol) to create.
27
+ # @param [Symbol] name The table name to create.
28
28
  # @param scope Passed to `before`/`after` in the test context.
29
29
  # @param options Passed to {WithModel::Table#initialize}.
30
30
  # @param block Passed to {WithModel::Table#initialize} (like {WithModel::Model::DSL#table}).
@@ -13,8 +13,8 @@ module WithModel
13
13
  class Model
14
14
  attr_writer :model_block, :table_block, :table_options
15
15
 
16
- # @param name The constant name (as a symbol) to assign the model class to.
17
- # @param superclass The superclass for the created class. Should
16
+ # @param [Symbol] name The constant name to assign the model class to.
17
+ # @param [Class] superclass The superclass for the created class. Should
18
18
  # have `ActiveRecord::Base` as an ancestor.
19
19
  def initialize(name, superclass: ActiveRecord::Base)
20
20
  @name = name.to_sym
@@ -35,7 +35,7 @@ module WithModel
35
35
 
36
36
  def destroy
37
37
  stubber.unstub_const
38
- remove_from_superclass_descendants
38
+ cleanup_descendants_tracking
39
39
  reset_dependencies_cache
40
40
  table.destroy
41
41
  @model = nil
@@ -53,9 +53,12 @@ module WithModel
53
53
  @model.reset_column_information
54
54
  end
55
55
 
56
- def remove_from_superclass_descendants
57
- return unless @model.superclass.respond_to?(:direct_descendants)
58
- @model.superclass.direct_descendants.delete(@model)
56
+ def cleanup_descendants_tracking
57
+ if defined?(ActiveSupport::DescendantsTracker)
58
+ ActiveSupport::DescendantsTracker.class_variable_get(:@@direct_descendants).delete(ActiveRecord::Base)
59
+ elsif @model.superclass.respond_to?(:direct_descendants)
60
+ @model.superclass.direct_descendants.delete(@model)
61
+ end
59
62
  end
60
63
 
61
64
  def reset_dependencies_cache
@@ -6,7 +6,7 @@ module WithModel
6
6
  # In general, direct use of this class should be avoided. Instead use
7
7
  # either the {WithModel high-level API} or {WithModel::Model::DSL low-level API}.
8
8
  class Table
9
- # @param name The name of the table to create.
9
+ # @param [Symbol] name The name of the table to create.
10
10
  # @param options Passed to ActiveRecord `create_table`.
11
11
  # @param block Passed to ActiveRecord `create_table`.
12
12
  # @see https://api.rubyonrails.org/classes/ActiveRecord/ConnectionAdapters/SchemaStatements.html#method-i-create_table
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module WithModel
4
- VERSION = '2.1.2'
4
+ VERSION = '2.1.3'
5
5
  end
@@ -305,20 +305,26 @@ describe 'a temporary ActiveRecord model created with with_model' do
305
305
  end
306
306
 
307
307
  context 'with ActiveSupport::DescendantsTracker' do
308
- with_model :BlogPost
308
+ with_model :BlogPost do
309
+ model do
310
+ def self.inspect
311
+ "BlogPost class #{object_id}"
312
+ end
313
+ end
314
+ end
309
315
 
310
- it 'includes the correct model class in descendants on the first test run' do
311
- descendant = ActiveRecord::Base.descendants.detect do |c|
316
+ def blog_post_classes
317
+ ActiveRecord::Base.descendants.select do |c|
312
318
  c.table_name == BlogPost.table_name
313
319
  end
314
- expect(descendant).to eq BlogPost
320
+ end
321
+
322
+ it 'includes the correct model class in descendants on the first test run' do
323
+ expect(blog_post_classes).to eq [BlogPost]
315
324
  end
316
325
 
317
326
  it 'includes the correct model class in descendants on the second test run' do
318
- descendant = ActiveRecord::Base.descendants.detect do |c|
319
- c.table_name == BlogPost.table_name
320
- end
321
- expect(descendant).to eq BlogPost
327
+ expect(blog_post_classes).to eq [BlogPost]
322
328
  end
323
329
  end
324
330
 
@@ -20,12 +20,13 @@ Gem::Specification.new do |spec|
20
20
 
21
21
  spec.required_ruby_version = '>= 2.3'
22
22
 
23
- spec.add_dependency 'activerecord', '>= 4.2', '< 6.0'
23
+ spec.add_dependency 'activerecord', '>= 4.2', '< 6.1'
24
24
 
25
- spec.add_development_dependency 'bundler', '~> 1.0'
25
+ spec.add_development_dependency 'bundler', '~> 2.0'
26
26
  spec.add_development_dependency 'minitest'
27
27
  spec.add_development_dependency 'rake'
28
28
  spec.add_development_dependency 'rspec', '~> 3.0'
29
+ spec.add_development_dependency 'yard'
29
30
 
30
31
  if RUBY_PLATFORM == 'java'
31
32
  spec.add_development_dependency 'activerecord-jdbcsqlite3-adapter'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: with_model
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.2
4
+ version: 2.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Case Commons, LLC
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2018-11-06 00:00:00.000000000 Z
13
+ date: 2019-11-14 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: activerecord
@@ -21,7 +21,7 @@ dependencies:
21
21
  version: '4.2'
22
22
  - - "<"
23
23
  - !ruby/object:Gem::Version
24
- version: '6.0'
24
+ version: '6.1'
25
25
  type: :runtime
26
26
  prerelease: false
27
27
  version_requirements: !ruby/object:Gem::Requirement
@@ -31,21 +31,21 @@ dependencies:
31
31
  version: '4.2'
32
32
  - - "<"
33
33
  - !ruby/object:Gem::Version
34
- version: '6.0'
34
+ version: '6.1'
35
35
  - !ruby/object:Gem::Dependency
36
36
  name: bundler
37
37
  requirement: !ruby/object:Gem::Requirement
38
38
  requirements:
39
39
  - - "~>"
40
40
  - !ruby/object:Gem::Version
41
- version: '1.0'
41
+ version: '2.0'
42
42
  type: :development
43
43
  prerelease: false
44
44
  version_requirements: !ruby/object:Gem::Requirement
45
45
  requirements:
46
46
  - - "~>"
47
47
  - !ruby/object:Gem::Version
48
- version: '1.0'
48
+ version: '2.0'
49
49
  - !ruby/object:Gem::Dependency
50
50
  name: minitest
51
51
  requirement: !ruby/object:Gem::Requirement
@@ -88,6 +88,20 @@ dependencies:
88
88
  - - "~>"
89
89
  - !ruby/object:Gem::Version
90
90
  version: '3.0'
91
+ - !ruby/object:Gem::Dependency
92
+ name: yard
93
+ requirement: !ruby/object:Gem::Requirement
94
+ requirements:
95
+ - - ">="
96
+ - !ruby/object:Gem::Version
97
+ version: '0'
98
+ type: :development
99
+ prerelease: false
100
+ version_requirements: !ruby/object:Gem::Requirement
101
+ requirements:
102
+ - - ">="
103
+ - !ruby/object:Gem::Version
104
+ version: '0'
91
105
  - !ruby/object:Gem::Dependency
92
106
  name: sqlite3
93
107
  requirement: !ruby/object:Gem::Requirement
@@ -153,8 +167,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
153
167
  - !ruby/object:Gem::Version
154
168
  version: '0'
155
169
  requirements: []
156
- rubyforge_project:
157
- rubygems_version: 2.7.6
170
+ rubygems_version: 3.0.6
158
171
  signing_key:
159
172
  specification_version: 4
160
173
  summary: Dynamically build a model within an RSpec context