active-record-ex 0.2.1 → 0.2.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: 37b890b128f7b72b6de19f2c1b7f08d7bb6927a0
4
- data.tar.gz: 70d54c75898522aa2f00662dc9d915f4d0dbcabd
3
+ metadata.gz: 003406b4939618a1f44328e1bf84155ea6de693b
4
+ data.tar.gz: 1bee5be3e16844522ec53f91ab2a05721d231fa8
5
5
  SHA512:
6
- metadata.gz: f23c5a2c7143fe57912763b45a6be54662f691ab7e378226cddd56f20ba0255ffc293c745bc40f13a76f0b71cc79b9263b6a2999d45a27c9aa9a5ed87bcd5f54
7
- data.tar.gz: fb304cfeba050827048fb0ed6eef698eaa719d60af026a0ce49c7d12c194f911f6bff7a47473f8d754c3b0964e82729c84e7d22c977595b5e494d74952232173
6
+ metadata.gz: c6e1aa0159785dff066465d8d5ae242c373f922313a3d282daa2311638267e094ee0a72f68f77faf6d4a1b02461c82cea2901b07ccbbb1167487c9d1dd2a3d42
7
+ data.tar.gz: b49112112339eb49f429af039e2baa2e5c15eb8ce2bafe483e79332ed146244409544931e0b46abd4b76b75821b6f8454afb12acd1e78ae6456bb9e88b31d0d2
data/.gitignore CHANGED
@@ -27,9 +27,9 @@
27
27
 
28
28
  # for a library or gem, you might want to ignore these files since the code is
29
29
  # intended to run in multiple environments; otherwise, check them in:
30
- Gemfile.lock
31
- .ruby-version
32
- .ruby-gemset
30
+ Gemfile.lock
31
+ .ruby-version
32
+ .ruby-gemset
33
33
 
34
34
  # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
35
35
  .rvmrc
@@ -5,8 +5,15 @@ rvm:
5
5
  - 2.0.0
6
6
  - 2.1.2
7
7
  - 2.2.3
8
+ env:
9
+ - "RAILS_VERSION=3.2.22.5"
10
+ - "RAILS_VERSION=4.2.8"
8
11
  cache:
9
12
  bundler: true
13
+ install:
14
+ - gem update --system
15
+ - gem install bundler
16
+ - bundle install --jobs=3 --retry=3
10
17
  branches:
11
18
  only:
12
19
  - master
@@ -1,3 +1,7 @@
1
+ #### 0.2.2
2
+
3
+ - Compatibility with Rails 4.x
4
+
1
5
  #### 0.2.1
2
6
 
3
7
  - Compatibility with more Ruby versions:
data/Gemfile CHANGED
@@ -2,3 +2,12 @@ source 'https://rubygems.org'
2
2
 
3
3
  # Specify your gem's dependencies in active-record-ex.gemspec
4
4
  gemspec
5
+
6
+ rails_version = ENV["RAILS_VERSION"] || '4.2.8'
7
+
8
+ gem 'activerecord', rails_version
9
+ gem 'activesupport', rails_version
10
+
11
+ group :test do
12
+ gem 'testrbl'
13
+ end
data/Rakefile CHANGED
@@ -2,8 +2,9 @@ require 'bundler/gem_tasks'
2
2
  require 'rake/testtask'
3
3
 
4
4
  Rake::TestTask.new do |t|
5
- t.libs.push 'test'
6
- t.test_files = FileList['test/**/*_test.rb']
5
+ t.libs << 'test'
6
+ t.pattern = 'test/**/*_test.rb'
7
+ t.verbose = true
7
8
  end
8
9
 
9
10
  desc 'Run tests'
@@ -20,10 +20,13 @@ Gem::Specification.new do |spec|
20
20
 
21
21
  spec.add_development_dependency 'bundler'
22
22
  spec.add_development_dependency 'rake'
23
- spec.add_development_dependency 'test-unit'
24
23
  spec.add_development_dependency 'shoulda'
25
24
  spec.add_development_dependency 'mocha'
25
+ spec.add_development_dependency 'sqlite3'
26
+ spec.add_development_dependency 'database_cleaner'
27
+ spec.add_development_dependency 'minitest-rails'
28
+ spec.add_development_dependency 'test-unit'
26
29
 
27
- spec.add_runtime_dependency 'activesupport', '~> 3.2'
28
- spec.add_runtime_dependency 'activerecord', '~> 3.2'
30
+ spec.add_runtime_dependency 'activesupport', '>= 3.2'
31
+ spec.add_runtime_dependency 'activerecord', '>= 3.2'
29
32
  end
@@ -7,9 +7,14 @@ module ActiveRecordEx
7
7
  end
8
8
 
9
9
  module ClassMethods
10
- def has_many(assoc_name, options = {}, &extension)
11
- order_field = options.delete(:order_on)
12
- super
10
+ def has_many(assoc_name, scope = nil, options = {}, &extension)
11
+ order_field = scope.is_a?(Hash) ? scope.delete(:order_on) : options.delete(:order_on)
12
+ if ActiveRecord::VERSION::MAJOR < 4
13
+ super(assoc_name, scope || {}, &extension)
14
+ else
15
+ super
16
+ end
17
+ opts = (scope.is_a?(Hash) ? scope : options)
13
18
  return unless order_field
14
19
 
15
20
  define_model_setter(assoc_name, order_field)
@@ -1,7 +1,7 @@
1
1
  # extends accepts_nested_attributes_for
2
2
  # by default, accepts_nested_attributes_for "allow_destroy"s,
3
3
  # ie, will destroy associations if explicitly marked by _destroy: true
4
- # this flips that, causing an association to be destroyed
4
+ # this flips that, causing an association to be destroyed
5
5
  # if it's not included in the updating attrs
6
6
  module ActiveRecordEx
7
7
  module AssumeDestroy
@@ -18,6 +18,7 @@ module ActiveRecordEx
18
18
  super assoc_name, options
19
19
 
20
20
  return unless assume_destroy
21
+
21
22
  attrs_name = ("#{assoc_name.to_s}_attributes").to_sym
22
23
  setter_name = ("#{attrs_name.to_s}=").to_sym
23
24
  unassuming_setter_name = ("#{attrs_name.to_s}_without_assume=").to_sym
@@ -26,7 +27,6 @@ module ActiveRecordEx
26
27
  define_method(assuming_setter_name) do |attrs|
27
28
  ids = attrs.map { |a| a['id'] || a[:id] }.compact
28
29
  assocs = self.send(assoc_name)
29
-
30
30
  dead_assocs = []
31
31
  # the ternary's 'cause Arel doesn't do the right thing with an empty array
32
32
  dead_assocs = assocs.where('id NOT IN (?)', ids.any? ? ids : '') unless self.new_record?
@@ -35,7 +35,8 @@ module ActiveRecordEx
35
35
  attrs = attrs.concat(dead_attrs)
36
36
  self.send(unassuming_setter_name, attrs)
37
37
  end
38
- alias_method_chain setter_name, :assume
38
+ alias_method unassuming_setter_name, setter_name
39
+ alias_method setter_name, assuming_setter_name
39
40
  end
40
41
  end
41
42
  end
@@ -26,19 +26,42 @@ module ActiveRecordEx
26
26
  end
27
27
 
28
28
  module ClassMethods
29
- def belongs_to(name, options={})
29
+ def set_scope_and_options(scope, options)
30
+ if scope.is_a?(Hash)
31
+ options = scope
32
+ scope = nil
33
+ end
34
+ [scope, options]
35
+ end
36
+
37
+ def belongs_to(name, scope = nil, options = {})
38
+ scope, options = set_scope_and_options(scope, options)
30
39
  subtypes = options.delete(:subtypes)
31
- super
40
+ if ActiveRecord::VERSION::MAJOR < 4
41
+ super(name, options)
42
+ else
43
+ super
44
+ end
32
45
  define_belongs_assoc(name, options.merge(subtypes: subtypes))
33
46
  end
34
47
 
35
- def has_many(name, options = {}, &extension)
36
- super
48
+ def has_many(name, scope = nil, options = {}, &extension)
49
+ scope, options = set_scope_and_options(scope, options)
50
+ if ActiveRecord::VERSION::MAJOR < 4
51
+ super(name, options, &extension)
52
+ else
53
+ super
54
+ end
37
55
  define_has_assoc(name.to_s.singularize, options)
38
56
  end
39
57
 
40
- def has_one(name, options = {}, &extension)
41
- super
58
+ def has_one(name, scope = nil, options = {}, &extension)
59
+ scope, options = set_scope_and_options(scope, options)
60
+ if ActiveRecord::VERSION::MAJOR < 4
61
+ super(name, options, &extension)
62
+ else
63
+ super
64
+ end
42
65
  define_has_assoc(name.to_s, options)
43
66
  end
44
67
 
@@ -74,7 +97,7 @@ module ActiveRecordEx
74
97
  method_name = name.pluralize.to_sym
75
98
  define_singleton_method(method_name) do
76
99
  klass = klass_name.constantize
77
- foreign_key = self.arel_table[key_name]
100
+ foreign_key = ActiveRecord::VERSION::MAJOR < 4 ? self.arel_table[key_name] : self.arel_table[key_name].name
78
101
  primary_keys = self.pluck(foreign_key).uniq
79
102
  # eg, Account.where(id: ids)
80
103
  klass.where(klass.primary_key => primary_keys)
@@ -89,7 +112,7 @@ module ActiveRecordEx
89
112
 
90
113
  method_name = subtype_klass.to_s.demodulize.underscore.pluralize.to_sym
91
114
  define_singleton_method(method_name) do
92
- foreign_key = self.arel_table[key_name]
115
+ foreign_key = ActiveRecord::VERSION::MAJOR < 4 ? self.arel_table[key_name] : self.arel_table[key_name].name
93
116
  primary_keys = self.where(type_key => type_val).pluck(foreign_key).uniq
94
117
  # eg, Account.where(id: ids)
95
118
  subtype_klass.where(subtype_klass.primary_key => primary_keys)
@@ -111,7 +134,7 @@ module ActiveRecordEx
111
134
 
112
135
  method_name = name.pluralize.to_sym
113
136
  define_singleton_method(method_name) do
114
- primary_key = self.arel_table[self.primary_key]
137
+ primary_key = ActiveRecord::VERSION::MAJOR < 4 ? self.arel_table[self.primary_key] : self.arel_table[self.primary_key].name
115
138
  foreign_keys = self.pluck(primary_key).uniq
116
139
 
117
140
  other_klass = klass_name.constantize
@@ -7,7 +7,7 @@ module ActiveRecordEx
7
7
  def self.included(base)
8
8
  base.extend(ClassMethods)
9
9
  base.instance_eval do
10
- attr_accessible :type
10
+ attr_accessible :type if respond_to?(:attr_accessible)
11
11
 
12
12
  class << self
13
13
  alias_method_chain :new, :typing
@@ -29,7 +29,10 @@ module ActiveRecord
29
29
 
30
30
  def collapsed_where
31
31
  values = self.where_values
32
- values = [true] if values.empty?
32
+ # You must pass in 1 instead of True Arel no longer
33
+ # supports TrueClass
34
+ # https://github.com/rails/rails/issues/20473
35
+ values = [1] if values.empty?
33
36
  # FIXME: Needs to wrap string literal conditions (e.g., where("id > 1"))
34
37
  Arel::Nodes::And.new(values)
35
38
  end
@@ -1,3 +1,3 @@
1
1
  module ActiveRecordEx
2
- VERSION = '0.2.1'
2
+ VERSION = '0.2.2'
3
3
  end
@@ -0,0 +1,63 @@
1
+ ActiveRecord::Schema.define do
2
+ execute('PRAGMA foreign_keys = ON;')
3
+ create_table 'assumes_destroys' do |t|
4
+ end
5
+
6
+ create_table "destroyees" do |t|
7
+ t.integer :assumes_destroy_id
8
+ t.string :name
9
+ end
10
+
11
+ create_table 'parents' do |t|
12
+ end
13
+
14
+ create_table "children" do |t|
15
+ t.integer :parent_id
16
+ t.string :foo
17
+ end
18
+
19
+ create_table 'has_manieds' do |t|
20
+ end
21
+
22
+ create_table 'has_ordered_assocs' do |t|
23
+ end
24
+
25
+ create_table 'ordered_assocs' do |t|
26
+ end
27
+
28
+ create_table 'simple_belongs_tos' do |t|
29
+ t.integer :has_manied_id
30
+ end
31
+
32
+ create_table 'belongs_to_throughs' do |t|
33
+ t.integer :simple_belongs_to_id
34
+ end
35
+
36
+ create_table 'some_class_names' do |t|
37
+ t.integer :some_name_id
38
+ t.integer :has_manied_id
39
+ end
40
+
41
+ create_table 'foreign_keyeds' do |t|
42
+ t.integer :has_manied
43
+ end
44
+ # https://stackoverflow.com/questions/1884818/how-do-i-add-a-foreign-key-to-an-existing-sqlite-3-6-21-table
45
+ execute("ALTER TABLE foreign_keyeds ADD COLUMN some_foreign_key_id INTEGER REFERENCES has_manieds(id)")
46
+
47
+ create_table 'ones' do |t|
48
+ t.integer :has_manied_id
49
+ end
50
+
51
+ create_table 'aseds' do |t|
52
+ t.string :some_as_type
53
+ t.integer :some_as_id
54
+ end
55
+
56
+ create_table 'belongs_tos' do |t|
57
+ t.integer :has_manied_id
58
+ end
59
+
60
+ create_table 'poly_bases' do |t|
61
+ t.string :type
62
+ end
63
+ end
@@ -1,85 +1,30 @@
1
1
  require 'active_record'
2
- require 'test/unit'
2
+ require 'minitest/autorun'
3
3
  require 'shoulda'
4
- require 'mocha'
5
-
4
+ require 'mocha/mini_test'
6
5
  require 'active-record-ex/relation_extensions'
6
+ require 'database_cleaner'
7
7
 
8
- class ActiveSupport::TestCase
9
- def db_expects(arel, query, response = nil)
10
- response_columns = response.try(:first).try(:keys).try(:map, &:to_s) || []
11
- response_rows = response.try(:map, &:values) || []
12
- response = ActiveRecord::Result.new(response_columns, response_rows)
13
-
14
- case query.first
15
- when /^SELECT/
16
- arel.connection.expects(:exec_query).with(*query).returns(response)
17
- when /^DELETE/
18
- arel.connection.expects(:exec_delete).with(*query).returns(response)
19
- end
20
- end
21
- end
22
-
23
- # Used as a "dummy" model in tests to avoid using a database connection
24
- class StubModel < ActiveRecord::Base
25
- self.abstract_class = true
26
-
27
- conn = Class.new(ActiveRecord::ConnectionAdapters::AbstractAdapter) do
28
- def quote_column_name(name)
29
- "`#{name.to_s.gsub('`', '``')}`"
30
- end
31
-
32
- def quote_table_name(name)
33
- quote_column_name(name).gsub('.', '`.`')
34
- end
35
-
36
- def select(sql, name = nil, _ = [])
37
- exec_query(sql, name).to_a
38
- end
39
- end
40
-
41
- visitor = Class.new(Arel::Visitors::ToSql) do
42
- def table_exists?(*_)
43
- true
44
- end
45
-
46
- def column_for(attr)
47
- pk = attr == 'id'
48
- column = ActiveRecord::ConnectionAdapters::Column.new(attr, nil, pk ? :integer : :string)
49
- column.primary = pk
50
- column
51
- end
52
- end
53
-
54
- @@connection = conn.new({})
55
- @@connection.visitor = visitor.new(@@connection)
56
-
57
- class << self
58
- def connection
59
- @@connection
60
- end
61
-
62
- def columns; []; end
63
-
64
- def get_primary_key(*_); 'id'; end
65
- end
8
+ DatabaseCleaner.strategy = :truncation
66
9
 
67
- # prevent AR from hitting the DB to get the schema
68
- def get_primary_key(*_); 'id'; end
10
+ ActiveRecord::Base.establish_connection adapter: "sqlite3", database: ":memory:"
11
+ puts File.dirname(__FILE__) + '/schema.rb'
12
+ load File.dirname(__FILE__) + '/schema.rb'
69
13
 
70
- def with_transaction_returning_status; yield; end
71
- end
14
+ require 'logger'
15
+ ActiveRecord::Base.logger = Logger.new(STDOUT)
16
+ ActiveRecord::Base.logger.level = Logger::ERROR
72
17
 
73
18
  # SQLCounter is part of ActiveRecord but is not distributed with the gem (used for internal tests only)
74
19
  # see https://github.com/rails/rails/blob/3-2-stable/activerecord/test/cases/helper.rb#L59
75
20
  module ActiveRecord
76
21
  class SQLCounter
77
22
  cattr_accessor :ignored_sql
78
- self.ignored_sql = [/^PRAGMA (?!(table_info))/, /^SELECT currval/, /^SELECT CAST/, /^SELECT @@IDENTITY/, /^SELECT @@ROWCOUNT/, /^SAVEPOINT/, /^ROLLBACK TO SAVEPOINT/, /^RELEASE SAVEPOINT/, /^SHOW max_identifier_length/, /^BEGIN/, /^COMMIT/]
23
+ self.ignored_sql = [/^PRAGMA/, /^SELECT currval/, /^SELECT CAST/, /^SELECT @@IDENTITY/, /^SELECT @@ROWCOUNT/, /^SAVEPOINT/, /^ROLLBACK TO SAVEPOINT/, /^RELEASE SAVEPOINT/, /^SHOW max_identifier_length/, /^BEGIN/i, /^COMMIT/i, /FROM sqlite_master/]
79
24
 
80
25
  # FIXME: this needs to be refactored so specific database can add their own
81
26
  # ignored SQL. This ignored SQL is for Oracle.
82
- ignored_sql.concat [/^select .*nextval/i, /^SAVEPOINT/, /^ROLLBACK TO/, /^\s*select .* from all_triggers/im]
27
+ self.ignored_sql.concat [/^select .*nextval/i, /^SAVEPOINT/, /^ROLLBACK TO/, /^\s*select .* from all_triggers/im, /^INSERT/]
83
28
 
84
29
  cattr_accessor :log
85
30
  self.log = []
@@ -90,6 +35,10 @@ module ActiveRecord
90
35
  @ignore = ignore
91
36
  end
92
37
 
38
+ def self.clear_log
39
+ self.log = []
40
+ end
41
+
93
42
  def call(name, start, finish, message_id, values)
94
43
  sql = values[:sql]
95
44
 
@@ -102,3 +51,32 @@ module ActiveRecord
102
51
 
103
52
  ActiveSupport::Notifications.subscribe('sql.active_record', SQLCounter.new)
104
53
  end
54
+
55
+ class ActiveSupport::TestCase
56
+ setup do
57
+ DatabaseCleaner.strategy = :transaction
58
+ DatabaseCleaner.clean_with :truncation
59
+ DatabaseCleaner.start
60
+ end
61
+
62
+ teardown do
63
+ DatabaseCleaner.clean
64
+ end
65
+
66
+ def assert_no_queries(&block)
67
+ assert_queries(0, :ignore_none => true, &block)
68
+ end
69
+ def assert_queries(num = 1, options = {})
70
+ ignore_none = options.fetch(:ignore_none) { num == :any }
71
+ ActiveRecord::SQLCounter.clear_log
72
+ yield
73
+ ensure
74
+ the_log = ActiveRecord::SQLCounter.log
75
+ if num == :any
76
+ assert_operator the_log.size, :>=, 1, "1 or more queries expected, but none were executed."
77
+ else
78
+ mesg = "#{the_log.size} instead of #{num} queries were executed.#{the_log.size == 0 ? '' : "\nQueries:\n#{the_log.join("\n")}"}"
79
+ assert_equal num, the_log.size, mesg
80
+ end
81
+ end
82
+ end
@@ -1,19 +1,19 @@
1
1
  require 'test_helper'
2
2
  require 'active-record-ex/assoc_ordering'
3
3
 
4
- class OrderedAssoc < StubModel
4
+ class OrderedAssoc < ActiveRecord::Base
5
5
  attr_accessor :name
6
6
  attr_accessor :order
7
7
  attr_accessor :has_orderd_assoc_id
8
8
  end
9
9
 
10
- class DestroyableAssoc < StubModel
10
+ class DestroyableAssoc < ActiveRecord::Base
11
11
  attr_accessor :name
12
12
  attr_accessor :order
13
13
  attr_accessor :has_orderd_assoc_id
14
14
  end
15
15
 
16
- class HasOrderedAssoc < StubModel
16
+ class HasOrderedAssoc < ActiveRecord::Base
17
17
  include ActiveRecordEx::AssocOrdering
18
18
 
19
19
  has_many :ordered_assocs, order_on: :order
@@ -1,32 +1,29 @@
1
1
  require 'test_helper'
2
2
  require 'active-record-ex/assume_destroy'
3
3
 
4
- class AssumeDestroyTest < ActiveRecord::TestCase
5
- class AssumesDestroy < StubModel
4
+ class AssumeDestroyTest < ActiveSupport::TestCase
5
+ class AssumesDestroy < ActiveRecord::Base
6
6
  include ActiveRecordEx::AssumeDestroy
7
7
 
8
8
  has_many :destroyees
9
9
  accepts_nested_attributes_for :destroyees, assume_destroy: true
10
10
  end
11
11
 
12
- class Destroyee < StubModel
12
+ class Destroyee < ActiveRecord::Base
13
13
  end
14
14
 
15
15
  context 'ActiveRecordEx::AssumeDestroy' do
16
- setup do
17
- @subject = AssumesDestroy.new
18
- @subject.stubs(:new_record?).returns(false)
16
+ setup do
17
+ @subject = AssumesDestroy.create
18
+ 2.times { @subject.destroyees.create }
19
19
  end
20
20
 
21
21
  context 'preconditions in ActiveRecord' do
22
22
  should 'DELETE records marked for destruction' do
23
23
  attrs = []
24
- stub_association_query(@subject, '\'\'', [{'id' => 1}, {'id' => 2}])
25
- db_expects(@subject, ['SELECT `destroyees`.* FROM `destroyees` WHERE `destroyees`.`assumes_destroy_id` IS NULL AND `destroyees`.`id` IN (1, 2)', 'AssumeDestroyTest::Destroyee Load'], [{'id' => 1}, {'id' => 2}])
26
- db_expects(@subject.destroyees, ['DELETE FROM `destroyees` WHERE `destroyees`.`id` = ?', 'SQL', [[nil, 1]]])
27
- db_expects(@subject.destroyees, ['DELETE FROM `destroyees` WHERE `destroyees`.`id` = ?', 'SQL', [[nil, 2]]])
28
-
24
+ assert_equal @subject.destroyees.count, 2
29
25
  @subject.update_attributes(destroyees_attributes: attrs)
26
+ assert_equal Destroyee.all, []
30
27
  end
31
28
  end
32
29
 
@@ -34,50 +31,37 @@ class AssumeDestroyTest < ActiveRecord::TestCase
34
31
  @subject.stubs(:new_record?).returns(true)
35
32
  attrs = [{name: 'one'}]
36
33
  expected_attrs = [{name: 'one'}]
37
- @subject.expects(:destroyees_attributes_without_assume=).with(expected_attrs)
38
-
39
- # shouldn't even hit the DB
40
34
  assert_no_queries { @subject.destroyees_attributes = attrs }
41
35
  end
42
36
 
43
37
  should 'mark all associations for destruction when passed an empty array' do
44
38
  attrs = []
45
- stub_association_query(@subject, '\'\'', [{'id' => 1}, {'id' => 2}])
46
-
47
- expected_attrs = [{id: 1, _destroy: true}, {id: 2, _destroy: true}]
39
+ expected_attrs = []
40
+ @subject.destroyees.each {|d| expected_attrs << {id: d.id, _destroy: true} }
48
41
  @subject.expects(:destroyees_attributes_without_assume=).with(expected_attrs)
49
42
  @subject.destroyees_attributes = attrs
50
43
  end
51
44
 
52
45
  should 'mark all existing associations for destruction when passed an array of just new' do
53
46
  attrs = [{name: 'one'}]
54
- stub_association_query(@subject, '\'\'', [{'id' => 1}, {'id' => 2}])
55
-
56
- expected_attrs = [{name: 'one'}, {id: 1, _destroy: true}, {id: 2, _destroy: true}]
47
+ expected_attrs = attrs.dup
48
+ @subject.destroyees.each {|d| expected_attrs << {id: d.id, _destroy: true} }
57
49
  @subject.expects(:destroyees_attributes_without_assume=).with(expected_attrs)
58
50
  @subject.destroyees_attributes = attrs
59
51
  end
60
52
 
61
53
  should 'not mark explicitly passed in associations for destruction' do
62
54
  attrs = [{name: 'one'}, {id: 1}]
63
- stub_association_query(@subject, '1', [{id: 2}])
64
-
65
55
  expected_attrs = [{name: 'one'}, {id: 1}, {id: 2, _destroy: true}]
66
56
  @subject.expects(:destroyees_attributes_without_assume=).with(expected_attrs)
67
57
  @subject.destroyees_attributes = attrs
68
58
  end
69
59
 
70
- should 'preserve existing marks for destruction' do
60
+ should 'preserve existing marks for destruction' do
71
61
  attrs = [{name: 'one'}, {id: 1, _destroy: true}]
72
- stub_association_query(@subject, '1', [{id: 2}])
73
-
74
62
  expected_attrs = [{name: 'one'}, {id: 1, _destroy: true}, {id: 2, _destroy: true}]
75
63
  @subject.expects(:destroyees_attributes_without_assume=).with(expected_attrs)
76
64
  @subject.destroyees_attributes = attrs
77
65
  end
78
66
  end
79
-
80
- def stub_association_query(subject, id_string, id_response)
81
- db_expects(subject, ["SELECT `destroyees`.* FROM `destroyees` WHERE `destroyees`.`assumes_destroy_id` IS NULL AND (id NOT IN (#{id_string}))", 'AssumeDestroyTest::Destroyee Load'], id_response)
82
- end
83
67
  end
@@ -2,7 +2,7 @@ require 'test_helper'
2
2
  require 'active-record-ex/many_to_many'
3
3
 
4
4
  class ManyToManyTest < ActiveSupport::TestCase
5
- class HasManied < StubModel
5
+ class HasManied < ActiveRecord::Base
6
6
  include ActiveRecordEx::ManyToMany
7
7
 
8
8
  has_one :one
@@ -14,7 +14,7 @@ class ManyToManyTest < ActiveSupport::TestCase
14
14
 
15
15
  singularize :ones
16
16
  end
17
- class SimpleBelongsTo < StubModel
17
+ class SimpleBelongsTo < ActiveRecord::Base
18
18
  include ActiveRecordEx::ManyToMany
19
19
 
20
20
  belongs_to :has_manied
@@ -22,122 +22,112 @@ class ManyToManyTest < ActiveSupport::TestCase
22
22
 
23
23
  singularize :has_manieds
24
24
  end
25
- class BelongsToThrough < StubModel
25
+ class BelongsToThrough < ActiveRecord::Base
26
26
  include ActiveRecordEx::ManyToMany
27
27
 
28
28
  belongs_to :has_manied
29
29
  end
30
- class SomeClassName < StubModel
30
+ class SomeClassName < ActiveRecord::Base
31
31
  include ActiveRecordEx::ManyToMany
32
32
 
33
33
  belongs_to :some_name, class_name: 'ManyToManyTest::HasManied'
34
34
  end
35
- class ForeignKeyed < StubModel
35
+ class ForeignKeyed < ActiveRecord::Base
36
36
  include ActiveRecordEx::ManyToMany
37
37
 
38
38
  belongs_to :has_manied, foreign_key: :some_foreign_key_id
39
39
  end
40
- class Ased < StubModel
40
+ class Ased < ActiveRecord::Base
41
41
  include ActiveRecordEx::ManyToMany
42
42
 
43
43
  belongs_to :some_as, polymorphic: true, subtypes: [HasManied]
44
44
  end
45
- class One < StubModel
45
+ class One < ActiveRecord::Base
46
46
  end
47
47
 
48
48
  context 'ActiveRecord::ManyToMany' do
49
49
  context '#has_one' do
50
- setup { @arel = HasManied.scoped }
50
+ setup do
51
+ @has_manied = HasManied.create
52
+ @one = @has_manied.create_one
53
+ end
54
+
51
55
  should 'handle the simple case correctly' do
52
- db_expects(@arel, ['SELECT `has_manieds`.`id` FROM `has_manieds` '], [{id: 1}])
53
- db_expects(@arel, ['SELECT `ones`.* FROM `ones` WHERE `ones`.`has_manied_id` IN (1)', 'ManyToManyTest::One Load'])
54
- @arel.ones.to_a
56
+ assert_equal HasManied.where('1=1').ones.to_a, [@one]
55
57
  end
56
58
  end
57
59
 
58
60
  context '#has_many' do
59
- setup { @arel = HasManied.scoped }
61
+ setup do
62
+ @has_manied = HasManied.create
63
+ @simple_belongs_to = @has_manied.simple_belongs_tos.create
64
+ end
60
65
 
61
66
  should 'handle the simple case correctly' do
62
- db_expects(@arel, ['SELECT `has_manieds`.`id` FROM `has_manieds` '], [id: 1])
63
- db_expects(@arel, ['SELECT `simple_belongs_tos`.* FROM `simple_belongs_tos` WHERE `simple_belongs_tos`.`has_manied_id` IN (1)', 'ManyToManyTest::SimpleBelongsTo Load'])
64
- @arel.simple_belongs_tos.to_a
67
+ assert_equal HasManied.where('1=1').simple_belongs_tos.to_a, [@simple_belongs_to]
65
68
  end
66
69
 
67
70
  should 'handle the empty base case correctly' do
68
- db_expects(@arel, ['SELECT `has_manieds`.`id` FROM `has_manieds` WHERE (1=0)'], [])
69
- db_expects(@arel, ['SELECT `simple_belongs_tos`.* FROM `simple_belongs_tos` WHERE 1=0', 'ManyToManyTest::SimpleBelongsTo Load'])
70
- @arel.none.simple_belongs_tos.to_a
71
+ assert_equal HasManied.where('1=1').none.simple_belongs_tos.to_a, []
71
72
  end
72
73
 
73
74
  should 'handle the multiple base ids case correctly' do
74
- db_expects(@arel, ['SELECT `has_manieds`.`id` FROM `has_manieds` '], [{id: 1}, {id: 2}])
75
- db_expects(@arel, ['SELECT `simple_belongs_tos`.* FROM `simple_belongs_tos` WHERE `simple_belongs_tos`.`has_manied_id` IN (1, 2)', 'ManyToManyTest::SimpleBelongsTo Load'])
76
- @arel.simple_belongs_tos.to_a
75
+ second_has_manied = HasManied.create
76
+ simple_belongs_to = second_has_manied.simple_belongs_tos.create
77
+ assert_equal HasManied.where('1=1').simple_belongs_tos.to_a, [@simple_belongs_to, simple_belongs_to]
77
78
  end
78
79
 
79
80
  should 'chain queries for has_many through:' do
80
- db_expects(@arel, ['SELECT `has_manieds`.`id` FROM `has_manieds` '], [{id: 1}])
81
- db_expects(@arel, ['SELECT `simple_belongs_tos`.`id` FROM `simple_belongs_tos` WHERE `simple_belongs_tos`.`has_manied_id` IN (1)'], [{id: 1}])
82
- db_expects(@arel, ['SELECT `belongs_to_throughs`.* FROM `belongs_to_throughs` WHERE `belongs_to_throughs`.`simple_belongs_to_id` IN (1)', 'ManyToManyTest::BelongsToThrough Load'])
81
+ belongs_to_through = @simple_belongs_to.belongs_to_throughs.create
83
82
 
84
- @arel.belongs_to_throughs.to_a
83
+ assert_equal HasManied.belongs_to_throughs.to_a, [belongs_to_through]
85
84
  end
86
85
 
87
86
  should 'not N+1 has_many through:' do
88
- db_expects(@arel, ['SELECT `has_manieds`.`id` FROM `has_manieds` '], [{id: 1}, {id: 2}])
89
- db_expects(@arel, ['SELECT `simple_belongs_tos`.`id` FROM `simple_belongs_tos` WHERE `simple_belongs_tos`.`has_manied_id` IN (1, 2)'], [{id: 1}, {id: 2}])
90
- db_expects(@arel, ['SELECT `belongs_to_throughs`.* FROM `belongs_to_throughs` WHERE `belongs_to_throughs`.`simple_belongs_to_id` IN (1, 2)', 'ManyToManyTest::BelongsToThrough Load'])
91
-
92
- @arel.belongs_to_throughs.to_a
87
+ assert_queries(3) do
88
+ HasManied.where('1=1').belongs_to_throughs.to_a
89
+ end
93
90
  end
94
91
 
95
92
  should 'use the class name passed in' do
96
- db_expects(@arel, ['SELECT `has_manieds`.`id` FROM `has_manieds` '], [id: 1])
97
- db_expects(@arel, ['SELECT `some_class_names`.* FROM `some_class_names` WHERE `some_class_names`.`has_manied_id` IN (1)', 'ManyToManyTest::SomeClassName Load'])
98
- @arel.class_nameds.to_a
93
+ @has_manied.class_nameds.create
94
+ assert_equal HasManied.where('1=1').class_nameds.first.class, ManyToManyTest::SomeClassName
99
95
  end
100
96
 
101
97
  should 'use the foreign key passed in' do
102
- db_expects(@arel, ['SELECT `has_manieds`.`id` FROM `has_manieds` '], [id: 1])
103
- db_expects(@arel, ['SELECT `foreign_keyeds`.* FROM `foreign_keyeds` WHERE `foreign_keyeds`.`some_foreign_key_id` IN (1)', 'ManyToManyTest::ForeignKeyed Load'])
104
- @arel.foreign_keyeds.to_a
98
+ foreign_keyed = @has_manied.foreign_keyeds.create
99
+ assert_equal HasManied.where('1=1').foreign_keyeds.to_a, [foreign_keyed]
105
100
  end
106
101
 
107
102
  should 'use the as passed in' do
108
- db_expects(@arel, ['SELECT `has_manieds`.`id` FROM `has_manieds` '], [id: 1])
109
- db_expects(@arel, ['SELECT `aseds`.* FROM `aseds` WHERE `aseds`.`some_as_type` = \'ManyToManyTest::HasManied\' AND `aseds`.`some_as_id` IN (1)', 'ManyToManyTest::Ased Load'])
110
- @arel.aseds.to_a
103
+ ased = @has_manied.aseds.create
104
+ assert_equal HasManied.where('1=1').aseds.to_a, [ased]
111
105
  end
112
106
  end
113
107
 
114
108
  context '#belongs_to' do
115
109
  should 'handle the simple case correctly' do
116
- @arel = SimpleBelongsTo.scoped
117
- db_expects(@arel, ['SELECT `simple_belongs_tos`.`has_manied_id` FROM `simple_belongs_tos` '], [has_manied_id: 1])
118
- db_expects(@arel, ['SELECT `has_manieds`.* FROM `has_manieds` WHERE `has_manieds`.`id` IN (1)', 'ManyToManyTest::HasManied Load'])
119
- @arel.has_manieds.to_a
110
+ has_manied = HasManied.create
111
+ sbt = has_manied.simple_belongs_tos.create
112
+ assert_equal SimpleBelongsTo.where('1=1').has_manieds.to_a, [has_manied]
120
113
  end
121
114
 
122
115
  should 'use the class name passed in' do
123
- @arel = SomeClassName.scoped
124
- db_expects(@arel, ['SELECT `some_class_names`.`some_name_id` FROM `some_class_names` '], [some_name_id: 1])
125
- db_expects(@arel, ['SELECT `has_manieds`.* FROM `has_manieds` WHERE `has_manieds`.`id` IN (1)', 'ManyToManyTest::HasManied Load'])
126
- @arel.some_names.to_a
116
+ has_manied = HasManied.create
117
+ scn = SomeClassName.create(some_name_id: has_manied.id)
118
+ assert_equal SomeClassName.where('1=1').some_names.to_a, [has_manied]
127
119
  end
128
-
120
+
129
121
  should 'use the foreign key passed in' do
130
- @arel = ForeignKeyed.scoped
131
- db_expects(@arel, ['SELECT `foreign_keyeds`.`some_foreign_key_id` FROM `foreign_keyeds` '], [some_foreign_key_id: 1])
132
- db_expects(@arel, ['SELECT `has_manieds`.* FROM `has_manieds` WHERE `has_manieds`.`id` IN (1)', 'ManyToManyTest::HasManied Load'])
133
- @arel.has_manieds.to_a
122
+ has_manied = HasManied.create
123
+ foreign_keyed = ForeignKeyed.create(has_manied: has_manied)
124
+ assert_equal ForeignKeyed.where('1=1').has_manieds.to_a, [has_manied]
134
125
  end
135
126
 
136
127
  should 'handle polymorphic belongs_to' do
137
- @arel = Ased.scoped
138
- db_expects(@arel, ['SELECT `aseds`.`some_as_id` FROM `aseds` WHERE `aseds`.`some_as_type` = \'ManyToManyTest::HasManied\''], [some_as_id: 1])
139
- db_expects(@arel, ['SELECT `has_manieds`.* FROM `has_manieds` WHERE `has_manieds`.`id` IN (1)', 'ManyToManyTest::HasManied Load'])
140
- @arel.has_manieds.to_a
128
+ has_manied = HasManied.create
129
+ ased = Ased.create(some_as: has_manied)
130
+ assert_equal Ased.where('1=1').has_manieds.to_a, [has_manied]
141
131
  end
142
132
  end
143
133
 
@@ -145,17 +135,15 @@ class ManyToManyTest < ActiveSupport::TestCase
145
135
  should 'work for belongs_tos without triggering an extra query' do
146
136
  @model = SimpleBelongsTo.new
147
137
  @model.stubs(:has_manied_id).returns(42)
148
- @arel = HasManied.scoped
149
- db_expects(@arel, ['SELECT `has_manieds`.* FROM `has_manieds` WHERE `has_manieds`.`id` IN (42)', 'ManyToManyTest::HasManied Load'])
150
- @model.has_manieds.to_a
138
+ @arel = HasManied.all
139
+ assert_queries(1) { @model.has_manieds.to_a }
151
140
  end
152
141
 
153
142
  should 'work for has_ones without triggering an extra query' do
154
143
  @model = HasManied.new
155
144
  @model.stubs(:id).returns(42)
156
- @arel = One.scoped
157
- db_expects(@arel, ['SELECT `ones`.* FROM `ones` WHERE `ones`.`has_manied_id` IN (42)', 'ManyToManyTest::One Load'])
158
- @model.ones.to_a
145
+ @arel = One.all
146
+ assert_queries(1) {@model.ones.to_a}
159
147
  end
160
148
  end
161
149
  end
@@ -3,54 +3,47 @@ require 'active-record-ex/many_to_many'
3
3
  require 'active-record-ex/nillable_find'
4
4
 
5
5
  class NillableFindTest < ActiveSupport::TestCase
6
- class Parent < StubModel
6
+ class Parent < ActiveRecord::Base
7
7
  include ActiveRecordEx::ManyToMany
8
8
  include ActiveRecordEx::NillableFind
9
9
 
10
10
  has_many :children
11
11
  end
12
12
 
13
- class Child < StubModel
13
+ class Child < ActiveRecord::Base
14
14
  end
15
15
 
16
16
  context 'ActiveRecordEx::NillableFind' do
17
17
  context '#nillable_find' do
18
- setup { @arel = Parent.scoped }
18
+ setup do
19
+ @parent = Parent.where('1=1')
20
+ end
19
21
  # RC == relative complement
20
22
  should 'request the RC of the base scope in the parent scope when just passed nil' do
21
- # fetch IDs
22
- db_expects(@arel, ['SELECT `parents`.`id` FROM `parents` WHERE `parents`.`id` IS NULL'], [])
23
- # fetch outside set
24
- db_expects(@arel, ['SELECT `parents`.`id` FROM `parents` '], [{id: 1}, {id: 2}])
25
- # disjunct
26
- db_expects(@arel, ['SELECT `children`.* FROM `children` WHERE ((1=0 OR NOT (`children`.`parent_id` IN (1, 2)) AND `children`.`foo` = \'bar\'))', 'NillableFindTest::Child Load'], [])
27
-
28
- Parent.nillable_find([nil], Child.where(foo: 'bar')).children.all
23
+ 2.times { Parent.create }
24
+ child = @parent.children.create
25
+ foo_child = @parent.children.create(foo: 'bar')
26
+ assert_equal Parent.nillable_find([nil], Child.where(foo: 'bar')).children.all, []
29
27
  end
30
28
 
31
29
  should 'request the disjunct of the RC of base scope in parent scope and all children of non-nil ids' do
32
30
  # fetch IDs
33
- db_expects(@arel, ['SELECT `parents`.`id` FROM `parents` WHERE ((`parents`.`id` IN (1) OR `parents`.`id` IS NULL))'], [{id: 1}])
34
- # fetch outside set
35
- db_expects(@arel, ['SELECT `parents`.`id` FROM `parents` '], [{id: 1}, {id: 2}])
36
- # disjunct
37
- db_expects(@arel, ['SELECT `children`.* FROM `children` WHERE ((`children`.`parent_id` IN (1) OR NOT (`children`.`parent_id` IN (1, 2)) AND `children`.`foo` = \'bar\'))', 'NillableFindTest::Child Load'], [])
38
-
39
- Parent.nillable_find([1, nil], Child.where(foo: 'bar')).children.all
31
+ 2.times { Parent.create }
32
+ parent = Parent.first
33
+ child = parent.children.create
34
+ assert_equal Parent.nillable_find([parent.id, nil], Child.where(foo: 'bar')).children.all.to_a, [child]
40
35
  end
41
36
 
42
37
  should 'request nothing when passed no an empty set of ids' do
43
- db_expects(@arel, ['SELECT `parents`.`id` FROM `parents` WHERE 1=0'], [])
44
- db_expects(@arel, ['SELECT `children`.* FROM `children` WHERE 1=0', 'NillableFindTest::Child Load'], [])
45
-
46
- Parent.nillable_find([], Child.where(foo: 'bar')).children.all
38
+ child = Child.create(foo: 'bar')
39
+ assert_equal Parent.nillable_find([], Child.where(foo: 'bar')).children.all.to_a, []
47
40
  end
48
41
 
49
42
  should 'request as a normal many-to-many when passed only normal ids' do
50
- db_expects(@arel, ['SELECT `parents`.`id` FROM `parents` WHERE `parents`.`id` IN (1)'], [{id: 1}])
51
- db_expects(@arel, ['SELECT `children`.* FROM `children` WHERE `children`.`parent_id` IN (1)', 'NillableFindTest::Child Load'], [])
52
-
53
- Parent.nillable_find([1], Child.where(foo: 'bar')).children.all
43
+ parent = Parent.create
44
+ child = parent.children.create
45
+ foo_child = Child.create(foo: 'bar')
46
+ assert_equal Parent.nillable_find([parent.id], Child.where(foo: 'bar')).children.all.to_a, [child]
54
47
  end
55
48
  end
56
49
  end
@@ -2,7 +2,7 @@ require 'test_helper'
2
2
  require 'active-record-ex/polymorphic_build'
3
3
 
4
4
  class PolymorphicBuildTest < ActiveSupport::TestCase
5
- class PolyBase < StubModel
5
+ class PolyBase < ActiveRecord::Base
6
6
  include ActiveRecordEx::PolymorphicBuild
7
7
  attr_accessor :type
8
8
  end
@@ -22,7 +22,7 @@ class PolymorphicBuildTest < ActiveSupport::TestCase
22
22
 
23
23
  should 'throw an error if the passed in class is not a subclass' do
24
24
  assert_raise(ArgumentError) do
25
- PolyBase.new(type: StubModel.to_s)
25
+ PolyBase.new(type: ActiveRecord::Base.to_s)
26
26
  end
27
27
  end
28
28
  end
@@ -1,11 +1,11 @@
1
1
  require 'test_helper'
2
2
 
3
3
  class RelationExtensionsTest < ActiveSupport::TestCase
4
- class HasManied < StubModel
4
+ class HasManied < ActiveRecord::Base
5
5
  has_many :belongs_tos
6
6
  end
7
7
 
8
- class BelongsTo < StubModel
8
+ class BelongsTo < ActiveRecord::Base
9
9
  belongs_to :has_manied
10
10
  attr_accessor :has_manied_id
11
11
  end
@@ -49,13 +49,13 @@ class RelationExtensionsTest < ActiveSupport::TestCase
49
49
 
50
50
  context 'by unconditional' do
51
51
  should 'return nothing' do
52
- assert_empty BelongsTo.scoped.relative_complement(@hm1.belongs_tos)
52
+ assert_equal true, BelongsTo.unscoped.relative_complement(@hm1.belongs_tos).empty?
53
53
  end
54
54
  end
55
55
 
56
56
  context 'of unconditional' do
57
57
  should 'return all belongs_tos' do
58
- assert_equal @hm2.belongs_tos.all, @hm1.belongs_tos.relative_complement(BelongsTo.scoped)
58
+ assert_equal @hm2.belongs_tos.all, @hm1.belongs_tos.relative_complement(BelongsTo.where('1=1'))
59
59
  end
60
60
  end
61
61
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active-record-ex
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Arjun Kavi
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-11-02 00:00:00.000000000 Z
12
+ date: 2017-09-13 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
@@ -40,7 +40,7 @@ dependencies:
40
40
  - !ruby/object:Gem::Version
41
41
  version: '0'
42
42
  - !ruby/object:Gem::Dependency
43
- name: test-unit
43
+ name: shoulda
44
44
  requirement: !ruby/object:Gem::Requirement
45
45
  requirements:
46
46
  - - ">="
@@ -54,7 +54,7 @@ dependencies:
54
54
  - !ruby/object:Gem::Version
55
55
  version: '0'
56
56
  - !ruby/object:Gem::Dependency
57
- name: shoulda
57
+ name: mocha
58
58
  requirement: !ruby/object:Gem::Requirement
59
59
  requirements:
60
60
  - - ">="
@@ -68,7 +68,49 @@ dependencies:
68
68
  - !ruby/object:Gem::Version
69
69
  version: '0'
70
70
  - !ruby/object:Gem::Dependency
71
- name: mocha
71
+ name: sqlite3
72
+ requirement: !ruby/object:Gem::Requirement
73
+ requirements:
74
+ - - ">="
75
+ - !ruby/object:Gem::Version
76
+ version: '0'
77
+ type: :development
78
+ prerelease: false
79
+ version_requirements: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - ">="
82
+ - !ruby/object:Gem::Version
83
+ version: '0'
84
+ - !ruby/object:Gem::Dependency
85
+ name: database_cleaner
86
+ requirement: !ruby/object:Gem::Requirement
87
+ requirements:
88
+ - - ">="
89
+ - !ruby/object:Gem::Version
90
+ version: '0'
91
+ type: :development
92
+ prerelease: false
93
+ version_requirements: !ruby/object:Gem::Requirement
94
+ requirements:
95
+ - - ">="
96
+ - !ruby/object:Gem::Version
97
+ version: '0'
98
+ - !ruby/object:Gem::Dependency
99
+ name: minitest-rails
100
+ requirement: !ruby/object:Gem::Requirement
101
+ requirements:
102
+ - - ">="
103
+ - !ruby/object:Gem::Version
104
+ version: '0'
105
+ type: :development
106
+ prerelease: false
107
+ version_requirements: !ruby/object:Gem::Requirement
108
+ requirements:
109
+ - - ">="
110
+ - !ruby/object:Gem::Version
111
+ version: '0'
112
+ - !ruby/object:Gem::Dependency
113
+ name: test-unit
72
114
  requirement: !ruby/object:Gem::Requirement
73
115
  requirements:
74
116
  - - ">="
@@ -85,28 +127,28 @@ dependencies:
85
127
  name: activesupport
86
128
  requirement: !ruby/object:Gem::Requirement
87
129
  requirements:
88
- - - "~>"
130
+ - - ">="
89
131
  - !ruby/object:Gem::Version
90
132
  version: '3.2'
91
133
  type: :runtime
92
134
  prerelease: false
93
135
  version_requirements: !ruby/object:Gem::Requirement
94
136
  requirements:
95
- - - "~>"
137
+ - - ">="
96
138
  - !ruby/object:Gem::Version
97
139
  version: '3.2'
98
140
  - !ruby/object:Gem::Dependency
99
141
  name: activerecord
100
142
  requirement: !ruby/object:Gem::Requirement
101
143
  requirements:
102
- - - "~>"
144
+ - - ">="
103
145
  - !ruby/object:Gem::Version
104
146
  version: '3.2'
105
147
  type: :runtime
106
148
  prerelease: false
107
149
  version_requirements: !ruby/object:Gem::Requirement
108
150
  requirements:
109
- - - "~>"
151
+ - - ">="
110
152
  - !ruby/object:Gem::Version
111
153
  version: '3.2'
112
154
  description: A library to make ActiveRecord::Relations even more awesome
@@ -133,6 +175,7 @@ files:
133
175
  - lib/active-record-ex/polymorphic_build.rb
134
176
  - lib/active-record-ex/relation_extensions.rb
135
177
  - lib/active-record-ex/version.rb
178
+ - test/schema.rb
136
179
  - test/test_helper.rb
137
180
  - test/unit/assoc_ordering_test.rb
138
181
  - test/unit/assume_destroy_test.rb
@@ -160,11 +203,12 @@ required_rubygems_version: !ruby/object:Gem::Requirement
160
203
  version: '0'
161
204
  requirements: []
162
205
  rubyforge_project:
163
- rubygems_version: 2.2.2
206
+ rubygems_version: 2.5.1
164
207
  signing_key:
165
208
  specification_version: 4
166
209
  summary: Relation -> Relation methods
167
210
  test_files:
211
+ - test/schema.rb
168
212
  - test/test_helper.rb
169
213
  - test/unit/assoc_ordering_test.rb
170
214
  - test/unit/assume_destroy_test.rb