active_record_inherit_assoc 2.0.0 → 2.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- metadata +103 -21
- data/.gitignore +0 -6
- data/.travis.yml +0 -8
- data/Appraisals +0 -7
- data/Gemfile +0 -19
- data/LICENSE +0 -176
- data/README.md +0 -37
- data/Rakefile +0 -15
- data/active_record_inherit_assoc.gemspec +0 -13
- data/gemfiles/rails3.2.gemfile +0 -21
- data/gemfiles/rails3.2.gemfile.lock +0 -175
- data/gemfiles/rails4.gemfile +0 -21
- data/gemfiles/rails4.gemfile.lock +0 -174
- data/test/helper.rb +0 -20
- data/test/schema.rb +0 -28
- data/test/test_belongs_to_association.rb +0 -48
- data/test/test_inherit_assoc.rb +0 -115
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 77ea721747d4e223730691211f101cd1bd83c53d
|
4
|
+
data.tar.gz: 59271989efc5aa1330e9bf44a1e640edbb863c99
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fd0db24a952b2e1f4caca0387c2300bf0e3882ad81c415cfe460e5340067467ad88c59e59521cb788eea6644f3e4e14f93b2dd5d715f384ebbde62c432f70450
|
7
|
+
data.tar.gz: 10447f71206299c03f568f2ffbac7525c6d108b89074dc0c13f565fd965036f3c2976c4807370f213f531181b61fcb7b8190817d3f06f6a0d3bb90efb9a578c3
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: active_record_inherit_assoc
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ben Osheroff
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-02-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -19,7 +19,7 @@ dependencies:
|
|
19
19
|
version: 3.2.0
|
20
20
|
- - "<"
|
21
21
|
- !ruby/object:Gem::Version
|
22
|
-
version: '
|
22
|
+
version: '4.2'
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
25
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -29,7 +29,105 @@ dependencies:
|
|
29
29
|
version: 3.2.0
|
30
30
|
- - "<"
|
31
31
|
- !ruby/object:Gem::Version
|
32
|
-
version: '
|
32
|
+
version: '4.2'
|
33
|
+
- !ruby/object:Gem::Dependency
|
34
|
+
name: minitest
|
35
|
+
requirement: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - ">="
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: '0'
|
40
|
+
type: :development
|
41
|
+
prerelease: false
|
42
|
+
version_requirements: !ruby/object:Gem::Requirement
|
43
|
+
requirements:
|
44
|
+
- - ">="
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: '0'
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: minitest-rg
|
49
|
+
requirement: !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - ">="
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
type: :development
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
requirements:
|
58
|
+
- - ">="
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: '0'
|
61
|
+
- !ruby/object:Gem::Dependency
|
62
|
+
name: rake
|
63
|
+
requirement: !ruby/object:Gem::Requirement
|
64
|
+
requirements:
|
65
|
+
- - ">="
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: '0'
|
68
|
+
type: :development
|
69
|
+
prerelease: false
|
70
|
+
version_requirements: !ruby/object:Gem::Requirement
|
71
|
+
requirements:
|
72
|
+
- - ">="
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: '0'
|
75
|
+
- !ruby/object:Gem::Dependency
|
76
|
+
name: rails
|
77
|
+
requirement: !ruby/object:Gem::Requirement
|
78
|
+
requirements:
|
79
|
+
- - ">="
|
80
|
+
- !ruby/object:Gem::Version
|
81
|
+
version: '0'
|
82
|
+
type: :development
|
83
|
+
prerelease: false
|
84
|
+
version_requirements: !ruby/object:Gem::Requirement
|
85
|
+
requirements:
|
86
|
+
- - ">="
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
version: '0'
|
89
|
+
- !ruby/object:Gem::Dependency
|
90
|
+
name: bump
|
91
|
+
requirement: !ruby/object:Gem::Requirement
|
92
|
+
requirements:
|
93
|
+
- - ">="
|
94
|
+
- !ruby/object:Gem::Version
|
95
|
+
version: '0'
|
96
|
+
type: :development
|
97
|
+
prerelease: false
|
98
|
+
version_requirements: !ruby/object:Gem::Requirement
|
99
|
+
requirements:
|
100
|
+
- - ">="
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: '0'
|
103
|
+
- !ruby/object:Gem::Dependency
|
104
|
+
name: wwtd
|
105
|
+
requirement: !ruby/object:Gem::Requirement
|
106
|
+
requirements:
|
107
|
+
- - ">="
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '0'
|
110
|
+
type: :development
|
111
|
+
prerelease: false
|
112
|
+
version_requirements: !ruby/object:Gem::Requirement
|
113
|
+
requirements:
|
114
|
+
- - ">="
|
115
|
+
- !ruby/object:Gem::Version
|
116
|
+
version: '0'
|
117
|
+
- !ruby/object:Gem::Dependency
|
118
|
+
name: sqlite3
|
119
|
+
requirement: !ruby/object:Gem::Requirement
|
120
|
+
requirements:
|
121
|
+
- - ">="
|
122
|
+
- !ruby/object:Gem::Version
|
123
|
+
version: '0'
|
124
|
+
type: :development
|
125
|
+
prerelease: false
|
126
|
+
version_requirements: !ruby/object:Gem::Requirement
|
127
|
+
requirements:
|
128
|
+
- - ">="
|
129
|
+
- !ruby/object:Gem::Version
|
130
|
+
version: '0'
|
33
131
|
description:
|
34
132
|
email:
|
35
133
|
- ben@gimbo.net
|
@@ -37,24 +135,8 @@ executables: []
|
|
37
135
|
extensions: []
|
38
136
|
extra_rdoc_files: []
|
39
137
|
files:
|
40
|
-
- ".gitignore"
|
41
|
-
- ".travis.yml"
|
42
|
-
- Appraisals
|
43
|
-
- Gemfile
|
44
|
-
- LICENSE
|
45
|
-
- README.md
|
46
|
-
- Rakefile
|
47
|
-
- active_record_inherit_assoc.gemspec
|
48
|
-
- gemfiles/rails3.2.gemfile
|
49
|
-
- gemfiles/rails3.2.gemfile.lock
|
50
|
-
- gemfiles/rails4.gemfile
|
51
|
-
- gemfiles/rails4.gemfile.lock
|
52
138
|
- lib/active_record_inherit_assoc.rb
|
53
|
-
|
54
|
-
- test/schema.rb
|
55
|
-
- test/test_belongs_to_association.rb
|
56
|
-
- test/test_inherit_assoc.rb
|
57
|
-
homepage: http://github.com/zendesk/active_record_inherit_assoc
|
139
|
+
homepage: https://github.com/zendesk/active_record_inherit_assoc
|
58
140
|
licenses:
|
59
141
|
- Apache License Version 2.0
|
60
142
|
metadata: {}
|
data/.gitignore
DELETED
data/.travis.yml
DELETED
data/Appraisals
DELETED
data/Gemfile
DELETED
@@ -1,19 +0,0 @@
|
|
1
|
-
source 'https://rubygems.org'
|
2
|
-
|
3
|
-
gemspec
|
4
|
-
|
5
|
-
gem 'minitest'
|
6
|
-
gem 'appraisal', '< 1'
|
7
|
-
gem 'rake'
|
8
|
-
gem 'rails'
|
9
|
-
gem 'bundler'
|
10
|
-
gem 'bump'
|
11
|
-
gem 'sqlite3'
|
12
|
-
gem 'shoulda'
|
13
|
-
gem 'jeweler'
|
14
|
-
gem 'ruby-debug', :platforms => :ruby_18
|
15
|
-
gem 'debugger', :platforms => :ruby_19
|
16
|
-
gem 'byebug', :platforms => [:ruby_20, :ruby_21]
|
17
|
-
gem 'test-unit', '>=2.5.1'
|
18
|
-
gem 'activerecord', :require => 'active_record'
|
19
|
-
gem "activesupport"
|
data/LICENSE
DELETED
@@ -1,176 +0,0 @@
|
|
1
|
-
Apache License
|
2
|
-
Version 2.0, January 2004
|
3
|
-
http://www.apache.org/licenses/
|
4
|
-
|
5
|
-
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
6
|
-
|
7
|
-
1. Definitions.
|
8
|
-
|
9
|
-
"License" shall mean the terms and conditions for use, reproduction,
|
10
|
-
and distribution as defined by Sections 1 through 9 of this document.
|
11
|
-
|
12
|
-
"Licensor" shall mean the copyright owner or entity authorized by
|
13
|
-
the copyright owner that is granting the License.
|
14
|
-
|
15
|
-
"Legal Entity" shall mean the union of the acting entity and all
|
16
|
-
other entities that control, are controlled by, or are under common
|
17
|
-
control with that entity. For the purposes of this definition,
|
18
|
-
"control" means (i) the power, direct or indirect, to cause the
|
19
|
-
direction or management of such entity, whether by contract or
|
20
|
-
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
21
|
-
outstanding shares, or (iii) beneficial ownership of such entity.
|
22
|
-
|
23
|
-
"You" (or "Your") shall mean an individual or Legal Entity
|
24
|
-
exercising permissions granted by this License.
|
25
|
-
|
26
|
-
"Source" form shall mean the preferred form for making modifications,
|
27
|
-
including but not limited to software source code, documentation
|
28
|
-
source, and configuration files.
|
29
|
-
|
30
|
-
"Object" form shall mean any form resulting from mechanical
|
31
|
-
transformation or translation of a Source form, including but
|
32
|
-
not limited to compiled object code, generated documentation,
|
33
|
-
and conversions to other media types.
|
34
|
-
|
35
|
-
"Work" shall mean the work of authorship, whether in Source or
|
36
|
-
Object form, made available under the License, as indicated by a
|
37
|
-
copyright notice that is included in or attached to the work
|
38
|
-
(an example is provided in the Appendix below).
|
39
|
-
|
40
|
-
"Derivative Works" shall mean any work, whether in Source or Object
|
41
|
-
form, that is based on (or derived from) the Work and for which the
|
42
|
-
editorial revisions, annotations, elaborations, or other modifications
|
43
|
-
represent, as a whole, an original work of authorship. For the purposes
|
44
|
-
of this License, Derivative Works shall not include works that remain
|
45
|
-
separable from, or merely link (or bind by name) to the interfaces of,
|
46
|
-
the Work and Derivative Works thereof.
|
47
|
-
|
48
|
-
"Contribution" shall mean any work of authorship, including
|
49
|
-
the original version of the Work and any modifications or additions
|
50
|
-
to that Work or Derivative Works thereof, that is intentionally
|
51
|
-
submitted to Licensor for inclusion in the Work by the copyright owner
|
52
|
-
or by an individual or Legal Entity authorized to submit on behalf of
|
53
|
-
the copyright owner. For the purposes of this definition, "submitted"
|
54
|
-
means any form of electronic, verbal, or written communication sent
|
55
|
-
to the Licensor or its representatives, including but not limited to
|
56
|
-
communication on electronic mailing lists, source code control systems,
|
57
|
-
and issue tracking systems that are managed by, or on behalf of, the
|
58
|
-
Licensor for the purpose of discussing and improving the Work, but
|
59
|
-
excluding communication that is conspicuously marked or otherwise
|
60
|
-
designated in writing by the copyright owner as "Not a Contribution."
|
61
|
-
|
62
|
-
"Contributor" shall mean Licensor and any individual or Legal Entity
|
63
|
-
on behalf of whom a Contribution has been received by Licensor and
|
64
|
-
subsequently incorporated within the Work.
|
65
|
-
|
66
|
-
2. Grant of Copyright License. Subject to the terms and conditions of
|
67
|
-
this License, each Contributor hereby grants to You a perpetual,
|
68
|
-
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
69
|
-
copyright license to reproduce, prepare Derivative Works of,
|
70
|
-
publicly display, publicly perform, sublicense, and distribute the
|
71
|
-
Work and such Derivative Works in Source or Object form.
|
72
|
-
|
73
|
-
3. Grant of Patent License. Subject to the terms and conditions of
|
74
|
-
this License, each Contributor hereby grants to You a perpetual,
|
75
|
-
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
76
|
-
(except as stated in this section) patent license to make, have made,
|
77
|
-
use, offer to sell, sell, import, and otherwise transfer the Work,
|
78
|
-
where such license applies only to those patent claims licensable
|
79
|
-
by such Contributor that are necessarily infringed by their
|
80
|
-
Contribution(s) alone or by combination of their Contribution(s)
|
81
|
-
with the Work to which such Contribution(s) was submitted. If You
|
82
|
-
institute patent litigation against any entity (including a
|
83
|
-
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
84
|
-
or a Contribution incorporated within the Work constitutes direct
|
85
|
-
or contributory patent infringement, then any patent licenses
|
86
|
-
granted to You under this License for that Work shall terminate
|
87
|
-
as of the date such litigation is filed.
|
88
|
-
|
89
|
-
4. Redistribution. You may reproduce and distribute copies of the
|
90
|
-
Work or Derivative Works thereof in any medium, with or without
|
91
|
-
modifications, and in Source or Object form, provided that You
|
92
|
-
meet the following conditions:
|
93
|
-
|
94
|
-
(a) You must give any other recipients of the Work or
|
95
|
-
Derivative Works a copy of this License; and
|
96
|
-
|
97
|
-
(b) You must cause any modified files to carry prominent notices
|
98
|
-
stating that You changed the files; and
|
99
|
-
|
100
|
-
(c) You must retain, in the Source form of any Derivative Works
|
101
|
-
that You distribute, all copyright, patent, trademark, and
|
102
|
-
attribution notices from the Source form of the Work,
|
103
|
-
excluding those notices that do not pertain to any part of
|
104
|
-
the Derivative Works; and
|
105
|
-
|
106
|
-
(d) If the Work includes a "NOTICE" text file as part of its
|
107
|
-
distribution, then any Derivative Works that You distribute must
|
108
|
-
include a readable copy of the attribution notices contained
|
109
|
-
within such NOTICE file, excluding those notices that do not
|
110
|
-
pertain to any part of the Derivative Works, in at least one
|
111
|
-
of the following places: within a NOTICE text file distributed
|
112
|
-
as part of the Derivative Works; within the Source form or
|
113
|
-
documentation, if provided along with the Derivative Works; or,
|
114
|
-
within a display generated by the Derivative Works, if and
|
115
|
-
wherever such third-party notices normally appear. The contents
|
116
|
-
of the NOTICE file are for informational purposes only and
|
117
|
-
do not modify the License. You may add Your own attribution
|
118
|
-
notices within Derivative Works that You distribute, alongside
|
119
|
-
or as an addendum to the NOTICE text from the Work, provided
|
120
|
-
that such additional attribution notices cannot be construed
|
121
|
-
as modifying the License.
|
122
|
-
|
123
|
-
You may add Your own copyright statement to Your modifications and
|
124
|
-
may provide additional or different license terms and conditions
|
125
|
-
for use, reproduction, or distribution of Your modifications, or
|
126
|
-
for any such Derivative Works as a whole, provided Your use,
|
127
|
-
reproduction, and distribution of the Work otherwise complies with
|
128
|
-
the conditions stated in this License.
|
129
|
-
|
130
|
-
5. Submission of Contributions. Unless You explicitly state otherwise,
|
131
|
-
any Contribution intentionally submitted for inclusion in the Work
|
132
|
-
by You to the Licensor shall be under the terms and conditions of
|
133
|
-
this License, without any additional terms or conditions.
|
134
|
-
Notwithstanding the above, nothing herein shall supersede or modify
|
135
|
-
the terms of any separate license agreement you may have executed
|
136
|
-
with Licensor regarding such Contributions.
|
137
|
-
|
138
|
-
6. Trademarks. This License does not grant permission to use the trade
|
139
|
-
names, trademarks, service marks, or product names of the Licensor,
|
140
|
-
except as required for reasonable and customary use in describing the
|
141
|
-
origin of the Work and reproducing the content of the NOTICE file.
|
142
|
-
|
143
|
-
7. Disclaimer of Warranty. Unless required by applicable law or
|
144
|
-
agreed to in writing, Licensor provides the Work (and each
|
145
|
-
Contributor provides its Contributions) on an "AS IS" BASIS,
|
146
|
-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
147
|
-
implied, including, without limitation, any warranties or conditions
|
148
|
-
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
149
|
-
PARTICULAR PURPOSE. You are solely responsible for determining the
|
150
|
-
appropriateness of using or redistributing the Work and assume any
|
151
|
-
risks associated with Your exercise of permissions under this License.
|
152
|
-
|
153
|
-
8. Limitation of Liability. In no event and under no legal theory,
|
154
|
-
whether in tort (including negligence), contract, or otherwise,
|
155
|
-
unless required by applicable law (such as deliberate and grossly
|
156
|
-
negligent acts) or agreed to in writing, shall any Contributor be
|
157
|
-
liable to You for damages, including any direct, indirect, special,
|
158
|
-
incidental, or consequential damages of any character arising as a
|
159
|
-
result of this License or out of the use or inability to use the
|
160
|
-
Work (including but not limited to damages for loss of goodwill,
|
161
|
-
work stoppage, computer failure or malfunction, or any and all
|
162
|
-
other commercial damages or losses), even if such Contributor
|
163
|
-
has been advised of the possibility of such damages.
|
164
|
-
|
165
|
-
9. Accepting Warranty or Additional Liability. While redistributing
|
166
|
-
the Work or Derivative Works thereof, You may choose to offer,
|
167
|
-
and charge a fee for, acceptance of support, warranty, indemnity,
|
168
|
-
or other liability obligations and/or rights consistent with this
|
169
|
-
License. However, in accepting such obligations, You may act only
|
170
|
-
on Your own behalf and on Your sole responsibility, not on behalf
|
171
|
-
of any other Contributor, and only if You agree to indemnify,
|
172
|
-
defend, and hold each Contributor harmless for any liability
|
173
|
-
incurred by, or claims asserted against, such Contributor by reason
|
174
|
-
of your accepting any such warranty or additional liability.
|
175
|
-
|
176
|
-
END OF TERMS AND CONDITIONS
|
data/README.md
DELETED
@@ -1,37 +0,0 @@
|
|
1
|
-
# ActiveRecord association inheritance
|
2
|
-
|
3
|
-
Makes the model inherit the specified attribute from a named association.
|
4
|
-
|
5
|
-
Supports ActiveRecord 2.3, 3.0, 3.1, and 3.2.
|
6
|
-
|
7
|
-
## Install
|
8
|
-
|
9
|
-
gem install active_record_inherit_assoc
|
10
|
-
|
11
|
-
## Usage
|
12
|
-
|
13
|
-
# parent_name - The Symbol name of the parent association.
|
14
|
-
# options - The Hash options to use:
|
15
|
-
# :attr - A Symbol or an Array of Symbol names of the attributes
|
16
|
-
# that should be inherited from the parent association.
|
17
|
-
#
|
18
|
-
class Post < ActiveRecord::Base
|
19
|
-
belongs_to :category
|
20
|
-
inherits_from :category, :attr => :account
|
21
|
-
end
|
22
|
-
|
23
|
-
## Copyright and license
|
24
|
-
|
25
|
-
Copyright 2013 Zendesk
|
26
|
-
|
27
|
-
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License.
|
28
|
-
You may obtain a copy of the License at
|
29
|
-
|
30
|
-
http://www.apache.org/licenses/LICENSE-2.0
|
31
|
-
|
32
|
-
Unless required by applicable law or agreed to in writing, software distributed under the
|
33
|
-
License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
34
|
-
See the License for the specific language governing permissions and limitations under the License.
|
35
|
-
|
36
|
-
## Author
|
37
|
-
Ben Osheroff <ben@gimbo.net>
|
data/Rakefile
DELETED
@@ -1,15 +0,0 @@
|
|
1
|
-
require 'bundler/setup'
|
2
|
-
require 'bundler/gem_tasks'
|
3
|
-
require 'rake/testtask'
|
4
|
-
require 'appraisal'
|
5
|
-
require 'bump/tasks'
|
6
|
-
|
7
|
-
Rake::TestTask.new(:test) do |test|
|
8
|
-
test.libs << 'lib' << 'test'
|
9
|
-
test.pattern = 'test/test*.rb'
|
10
|
-
test.verbose = true
|
11
|
-
end
|
12
|
-
|
13
|
-
task :default do
|
14
|
-
sh "bundle exec rake appraisal:install && bundle exec rake appraisal test"
|
15
|
-
end
|
@@ -1,13 +0,0 @@
|
|
1
|
-
$LOAD_PATH.unshift File.expand_path("../lib", __FILE__)
|
2
|
-
name = "active_record_inherit_assoc"
|
3
|
-
|
4
|
-
Gem::Specification.new name, "2.0.0" do |s|
|
5
|
-
s.summary = "Attribute inheritance for AR associations"
|
6
|
-
s.authors = ["Ben Osheroff"]
|
7
|
-
s.email = ["ben@gimbo.net"]
|
8
|
-
s.files = `git ls-files`.split("\n")
|
9
|
-
s.license = "Apache License Version 2.0"
|
10
|
-
s.homepage = "http://github.com/zendesk/#{name}"
|
11
|
-
s.add_runtime_dependency "activerecord", ">=3.2.0", "< 5"
|
12
|
-
end
|
13
|
-
|
data/gemfiles/rails3.2.gemfile
DELETED
@@ -1,21 +0,0 @@
|
|
1
|
-
# This file was generated by Appraisal
|
2
|
-
|
3
|
-
source "https://rubygems.org"
|
4
|
-
|
5
|
-
gem "minitest"
|
6
|
-
gem "appraisal", "< 1"
|
7
|
-
gem "rake"
|
8
|
-
gem "rails"
|
9
|
-
gem "bundler"
|
10
|
-
gem "bump"
|
11
|
-
gem "sqlite3"
|
12
|
-
gem "shoulda"
|
13
|
-
gem "jeweler"
|
14
|
-
gem "ruby-debug", :platforms=>:ruby_18
|
15
|
-
gem "debugger", :platforms=>:ruby_19
|
16
|
-
gem "byebug", :platforms=>[:ruby_20, :ruby_21]
|
17
|
-
gem "test-unit", ">=2.5.1"
|
18
|
-
gem "activesupport"
|
19
|
-
gem "activerecord", "~> 3.2.0", :require=>"active_record"
|
20
|
-
|
21
|
-
gemspec :path=>"../"
|
@@ -1,175 +0,0 @@
|
|
1
|
-
PATH
|
2
|
-
remote: ../
|
3
|
-
specs:
|
4
|
-
active_record_inherit_assoc (2.0.0)
|
5
|
-
activerecord (>= 3.2.0, < 5)
|
6
|
-
|
7
|
-
GEM
|
8
|
-
remote: https://rubygems.org/
|
9
|
-
specs:
|
10
|
-
actionmailer (3.2.18)
|
11
|
-
actionpack (= 3.2.18)
|
12
|
-
mail (~> 2.5.4)
|
13
|
-
actionpack (3.2.18)
|
14
|
-
activemodel (= 3.2.18)
|
15
|
-
activesupport (= 3.2.18)
|
16
|
-
builder (~> 3.0.0)
|
17
|
-
erubis (~> 2.7.0)
|
18
|
-
journey (~> 1.0.4)
|
19
|
-
rack (~> 1.4.5)
|
20
|
-
rack-cache (~> 1.2)
|
21
|
-
rack-test (~> 0.6.1)
|
22
|
-
sprockets (~> 2.2.1)
|
23
|
-
activemodel (3.2.18)
|
24
|
-
activesupport (= 3.2.18)
|
25
|
-
builder (~> 3.0.0)
|
26
|
-
activerecord (3.2.18)
|
27
|
-
activemodel (= 3.2.18)
|
28
|
-
activesupport (= 3.2.18)
|
29
|
-
arel (~> 3.0.2)
|
30
|
-
tzinfo (~> 0.3.29)
|
31
|
-
activeresource (3.2.18)
|
32
|
-
activemodel (= 3.2.18)
|
33
|
-
activesupport (= 3.2.18)
|
34
|
-
activesupport (3.2.18)
|
35
|
-
i18n (~> 0.6, >= 0.6.4)
|
36
|
-
multi_json (~> 1.0)
|
37
|
-
addressable (2.3.6)
|
38
|
-
appraisal (0.5.2)
|
39
|
-
bundler
|
40
|
-
rake
|
41
|
-
arel (3.0.3)
|
42
|
-
builder (3.0.4)
|
43
|
-
bump (0.5.0)
|
44
|
-
byebug (3.1.2)
|
45
|
-
columnize (~> 0.8)
|
46
|
-
debugger-linecache (~> 1.2)
|
47
|
-
columnize (0.8.9)
|
48
|
-
debugger (1.6.8)
|
49
|
-
columnize (>= 0.3.1)
|
50
|
-
debugger-linecache (~> 1.2.0)
|
51
|
-
debugger-ruby_core_source (~> 1.3.5)
|
52
|
-
debugger-linecache (1.2.0)
|
53
|
-
debugger-ruby_core_source (1.3.5)
|
54
|
-
descendants_tracker (0.0.4)
|
55
|
-
thread_safe (~> 0.3, >= 0.3.1)
|
56
|
-
erubis (2.7.0)
|
57
|
-
faraday (0.9.0)
|
58
|
-
multipart-post (>= 1.2, < 3)
|
59
|
-
git (1.2.7)
|
60
|
-
github_api (0.11.3)
|
61
|
-
addressable (~> 2.3)
|
62
|
-
descendants_tracker (~> 0.0.1)
|
63
|
-
faraday (~> 0.8, < 0.10)
|
64
|
-
hashie (>= 1.2)
|
65
|
-
multi_json (>= 1.7.5, < 2.0)
|
66
|
-
nokogiri (~> 1.6.0)
|
67
|
-
oauth2
|
68
|
-
hashie (3.1.0)
|
69
|
-
highline (1.6.21)
|
70
|
-
hike (1.2.3)
|
71
|
-
i18n (0.6.9)
|
72
|
-
jeweler (2.0.1)
|
73
|
-
builder
|
74
|
-
bundler (>= 1.0)
|
75
|
-
git (>= 1.2.5)
|
76
|
-
github_api
|
77
|
-
highline (>= 1.6.15)
|
78
|
-
nokogiri (>= 1.5.10)
|
79
|
-
rake
|
80
|
-
rdoc
|
81
|
-
journey (1.0.4)
|
82
|
-
json (1.8.1)
|
83
|
-
jwt (1.0.0)
|
84
|
-
linecache (0.46)
|
85
|
-
rbx-require-relative (> 0.0.4)
|
86
|
-
mail (2.5.4)
|
87
|
-
mime-types (~> 1.16)
|
88
|
-
treetop (~> 1.4.8)
|
89
|
-
mime-types (1.25.1)
|
90
|
-
mini_portile (0.6.0)
|
91
|
-
minitest (5.3.5)
|
92
|
-
multi_json (1.10.1)
|
93
|
-
multi_xml (0.5.5)
|
94
|
-
multipart-post (2.0.0)
|
95
|
-
nokogiri (1.6.2.1)
|
96
|
-
mini_portile (= 0.6.0)
|
97
|
-
oauth2 (0.9.4)
|
98
|
-
faraday (>= 0.8, < 0.10)
|
99
|
-
jwt (~> 1.0)
|
100
|
-
multi_json (~> 1.3)
|
101
|
-
multi_xml (~> 0.5)
|
102
|
-
rack (~> 1.2)
|
103
|
-
polyglot (0.3.5)
|
104
|
-
rack (1.4.5)
|
105
|
-
rack-cache (1.2)
|
106
|
-
rack (>= 0.4)
|
107
|
-
rack-ssl (1.3.4)
|
108
|
-
rack
|
109
|
-
rack-test (0.6.2)
|
110
|
-
rack (>= 1.0)
|
111
|
-
rails (3.2.18)
|
112
|
-
actionmailer (= 3.2.18)
|
113
|
-
actionpack (= 3.2.18)
|
114
|
-
activerecord (= 3.2.18)
|
115
|
-
activeresource (= 3.2.18)
|
116
|
-
activesupport (= 3.2.18)
|
117
|
-
bundler (~> 1.0)
|
118
|
-
railties (= 3.2.18)
|
119
|
-
railties (3.2.18)
|
120
|
-
actionpack (= 3.2.18)
|
121
|
-
activesupport (= 3.2.18)
|
122
|
-
rack-ssl (~> 1.3.2)
|
123
|
-
rake (>= 0.8.7)
|
124
|
-
rdoc (~> 3.4)
|
125
|
-
thor (>= 0.14.6, < 2.0)
|
126
|
-
rake (10.3.2)
|
127
|
-
rbx-require-relative (0.0.9)
|
128
|
-
rdoc (3.12.2)
|
129
|
-
json (~> 1.4)
|
130
|
-
ruby-debug (0.10.4)
|
131
|
-
columnize (>= 0.1)
|
132
|
-
ruby-debug-base (~> 0.10.4.0)
|
133
|
-
ruby-debug-base (0.10.4)
|
134
|
-
linecache (>= 0.3)
|
135
|
-
shoulda (3.5.0)
|
136
|
-
shoulda-context (~> 1.0, >= 1.0.1)
|
137
|
-
shoulda-matchers (>= 1.4.1, < 3.0)
|
138
|
-
shoulda-context (1.2.1)
|
139
|
-
shoulda-matchers (2.6.1)
|
140
|
-
activesupport (>= 3.0.0)
|
141
|
-
sprockets (2.2.2)
|
142
|
-
hike (~> 1.2)
|
143
|
-
multi_json (~> 1.0)
|
144
|
-
rack (~> 1.0)
|
145
|
-
tilt (~> 1.1, != 1.3.0)
|
146
|
-
sqlite3 (1.3.9)
|
147
|
-
test-unit (2.5.5)
|
148
|
-
thor (0.19.1)
|
149
|
-
thread_safe (0.3.4)
|
150
|
-
tilt (1.4.1)
|
151
|
-
treetop (1.4.15)
|
152
|
-
polyglot
|
153
|
-
polyglot (>= 0.3.1)
|
154
|
-
tzinfo (0.3.39)
|
155
|
-
|
156
|
-
PLATFORMS
|
157
|
-
ruby
|
158
|
-
|
159
|
-
DEPENDENCIES
|
160
|
-
active_record_inherit_assoc!
|
161
|
-
activerecord (~> 3.2.0)
|
162
|
-
activesupport
|
163
|
-
appraisal (< 1)
|
164
|
-
bump
|
165
|
-
bundler
|
166
|
-
byebug
|
167
|
-
debugger
|
168
|
-
jeweler
|
169
|
-
minitest
|
170
|
-
rails
|
171
|
-
rake
|
172
|
-
ruby-debug
|
173
|
-
shoulda
|
174
|
-
sqlite3
|
175
|
-
test-unit (>= 2.5.1)
|
data/gemfiles/rails4.gemfile
DELETED
@@ -1,21 +0,0 @@
|
|
1
|
-
# This file was generated by Appraisal
|
2
|
-
|
3
|
-
source "https://rubygems.org"
|
4
|
-
|
5
|
-
gem "minitest"
|
6
|
-
gem "appraisal", "< 1"
|
7
|
-
gem "rake"
|
8
|
-
gem "rails"
|
9
|
-
gem "bundler"
|
10
|
-
gem "bump"
|
11
|
-
gem "sqlite3"
|
12
|
-
gem "shoulda"
|
13
|
-
gem "jeweler"
|
14
|
-
gem "ruby-debug", :platforms=>:ruby_18
|
15
|
-
gem "debugger", :platforms=>:ruby_19
|
16
|
-
gem "byebug", :platforms=>[:ruby_20, :ruby_21]
|
17
|
-
gem "test-unit", ">=2.5.1"
|
18
|
-
gem "activesupport"
|
19
|
-
gem "activerecord", "~> 4.0", :require=>"active_record"
|
20
|
-
|
21
|
-
gemspec :path=>"../"
|
@@ -1,174 +0,0 @@
|
|
1
|
-
PATH
|
2
|
-
remote: ../
|
3
|
-
specs:
|
4
|
-
active_record_inherit_assoc (2.0.0)
|
5
|
-
activerecord (>= 3.2.0, < 5)
|
6
|
-
|
7
|
-
GEM
|
8
|
-
remote: https://rubygems.org/
|
9
|
-
specs:
|
10
|
-
actionmailer (4.1.2)
|
11
|
-
actionpack (= 4.1.2)
|
12
|
-
actionview (= 4.1.2)
|
13
|
-
mail (~> 2.5.4)
|
14
|
-
actionpack (4.1.2)
|
15
|
-
actionview (= 4.1.2)
|
16
|
-
activesupport (= 4.1.2)
|
17
|
-
rack (~> 1.5.2)
|
18
|
-
rack-test (~> 0.6.2)
|
19
|
-
actionview (4.1.2)
|
20
|
-
activesupport (= 4.1.2)
|
21
|
-
builder (~> 3.1)
|
22
|
-
erubis (~> 2.7.0)
|
23
|
-
activemodel (4.1.2)
|
24
|
-
activesupport (= 4.1.2)
|
25
|
-
builder (~> 3.1)
|
26
|
-
activerecord (4.1.2)
|
27
|
-
activemodel (= 4.1.2)
|
28
|
-
activesupport (= 4.1.2)
|
29
|
-
arel (~> 5.0.0)
|
30
|
-
activesupport (4.1.2)
|
31
|
-
i18n (~> 0.6, >= 0.6.9)
|
32
|
-
json (~> 1.7, >= 1.7.7)
|
33
|
-
minitest (~> 5.1)
|
34
|
-
thread_safe (~> 0.1)
|
35
|
-
tzinfo (~> 1.1)
|
36
|
-
addressable (2.3.6)
|
37
|
-
appraisal (0.5.2)
|
38
|
-
bundler
|
39
|
-
rake
|
40
|
-
arel (5.0.1.20140414130214)
|
41
|
-
builder (3.2.2)
|
42
|
-
bump (0.5.0)
|
43
|
-
byebug (3.1.2)
|
44
|
-
columnize (~> 0.8)
|
45
|
-
debugger-linecache (~> 1.2)
|
46
|
-
columnize (0.8.9)
|
47
|
-
debugger (1.6.8)
|
48
|
-
columnize (>= 0.3.1)
|
49
|
-
debugger-linecache (~> 1.2.0)
|
50
|
-
debugger-ruby_core_source (~> 1.3.5)
|
51
|
-
debugger-linecache (1.2.0)
|
52
|
-
debugger-ruby_core_source (1.3.5)
|
53
|
-
descendants_tracker (0.0.4)
|
54
|
-
thread_safe (~> 0.3, >= 0.3.1)
|
55
|
-
erubis (2.7.0)
|
56
|
-
faraday (0.9.0)
|
57
|
-
multipart-post (>= 1.2, < 3)
|
58
|
-
git (1.2.7)
|
59
|
-
github_api (0.11.3)
|
60
|
-
addressable (~> 2.3)
|
61
|
-
descendants_tracker (~> 0.0.1)
|
62
|
-
faraday (~> 0.8, < 0.10)
|
63
|
-
hashie (>= 1.2)
|
64
|
-
multi_json (>= 1.7.5, < 2.0)
|
65
|
-
nokogiri (~> 1.6.0)
|
66
|
-
oauth2
|
67
|
-
hashie (3.1.0)
|
68
|
-
highline (1.6.21)
|
69
|
-
hike (1.2.3)
|
70
|
-
i18n (0.6.9)
|
71
|
-
jeweler (2.0.1)
|
72
|
-
builder
|
73
|
-
bundler (>= 1.0)
|
74
|
-
git (>= 1.2.5)
|
75
|
-
github_api
|
76
|
-
highline (>= 1.6.15)
|
77
|
-
nokogiri (>= 1.5.10)
|
78
|
-
rake
|
79
|
-
rdoc
|
80
|
-
json (1.8.1)
|
81
|
-
jwt (1.0.0)
|
82
|
-
linecache (0.46)
|
83
|
-
rbx-require-relative (> 0.0.4)
|
84
|
-
mail (2.5.4)
|
85
|
-
mime-types (~> 1.16)
|
86
|
-
treetop (~> 1.4.8)
|
87
|
-
mime-types (1.25.1)
|
88
|
-
mini_portile (0.6.0)
|
89
|
-
minitest (5.3.5)
|
90
|
-
multi_json (1.10.1)
|
91
|
-
multi_xml (0.5.5)
|
92
|
-
multipart-post (2.0.0)
|
93
|
-
nokogiri (1.6.2.1)
|
94
|
-
mini_portile (= 0.6.0)
|
95
|
-
oauth2 (0.9.4)
|
96
|
-
faraday (>= 0.8, < 0.10)
|
97
|
-
jwt (~> 1.0)
|
98
|
-
multi_json (~> 1.3)
|
99
|
-
multi_xml (~> 0.5)
|
100
|
-
rack (~> 1.2)
|
101
|
-
polyglot (0.3.5)
|
102
|
-
rack (1.5.2)
|
103
|
-
rack-test (0.6.2)
|
104
|
-
rack (>= 1.0)
|
105
|
-
rails (4.1.2)
|
106
|
-
actionmailer (= 4.1.2)
|
107
|
-
actionpack (= 4.1.2)
|
108
|
-
actionview (= 4.1.2)
|
109
|
-
activemodel (= 4.1.2)
|
110
|
-
activerecord (= 4.1.2)
|
111
|
-
activesupport (= 4.1.2)
|
112
|
-
bundler (>= 1.3.0, < 2.0)
|
113
|
-
railties (= 4.1.2)
|
114
|
-
sprockets-rails (~> 2.0)
|
115
|
-
railties (4.1.2)
|
116
|
-
actionpack (= 4.1.2)
|
117
|
-
activesupport (= 4.1.2)
|
118
|
-
rake (>= 0.8.7)
|
119
|
-
thor (>= 0.18.1, < 2.0)
|
120
|
-
rake (10.3.2)
|
121
|
-
rbx-require-relative (0.0.9)
|
122
|
-
rdoc (4.1.1)
|
123
|
-
json (~> 1.4)
|
124
|
-
ruby-debug (0.10.4)
|
125
|
-
columnize (>= 0.1)
|
126
|
-
ruby-debug-base (~> 0.10.4.0)
|
127
|
-
ruby-debug-base (0.10.4)
|
128
|
-
linecache (>= 0.3)
|
129
|
-
shoulda (3.5.0)
|
130
|
-
shoulda-context (~> 1.0, >= 1.0.1)
|
131
|
-
shoulda-matchers (>= 1.4.1, < 3.0)
|
132
|
-
shoulda-context (1.2.1)
|
133
|
-
shoulda-matchers (2.6.1)
|
134
|
-
activesupport (>= 3.0.0)
|
135
|
-
sprockets (2.12.1)
|
136
|
-
hike (~> 1.2)
|
137
|
-
multi_json (~> 1.0)
|
138
|
-
rack (~> 1.0)
|
139
|
-
tilt (~> 1.1, != 1.3.0)
|
140
|
-
sprockets-rails (2.1.3)
|
141
|
-
actionpack (>= 3.0)
|
142
|
-
activesupport (>= 3.0)
|
143
|
-
sprockets (~> 2.8)
|
144
|
-
sqlite3 (1.3.9)
|
145
|
-
test-unit (2.5.5)
|
146
|
-
thor (0.19.1)
|
147
|
-
thread_safe (0.3.4)
|
148
|
-
tilt (1.4.1)
|
149
|
-
treetop (1.4.15)
|
150
|
-
polyglot
|
151
|
-
polyglot (>= 0.3.1)
|
152
|
-
tzinfo (1.2.1)
|
153
|
-
thread_safe (~> 0.1)
|
154
|
-
|
155
|
-
PLATFORMS
|
156
|
-
ruby
|
157
|
-
|
158
|
-
DEPENDENCIES
|
159
|
-
active_record_inherit_assoc!
|
160
|
-
activerecord (~> 4.0)
|
161
|
-
activesupport
|
162
|
-
appraisal (< 1)
|
163
|
-
bump
|
164
|
-
bundler
|
165
|
-
byebug
|
166
|
-
debugger
|
167
|
-
jeweler
|
168
|
-
minitest
|
169
|
-
rails
|
170
|
-
rake
|
171
|
-
ruby-debug
|
172
|
-
shoulda
|
173
|
-
sqlite3
|
174
|
-
test-unit (>= 2.5.1)
|
data/test/helper.rb
DELETED
@@ -1,20 +0,0 @@
|
|
1
|
-
require 'bundler'
|
2
|
-
Bundler.setup
|
3
|
-
Bundler.require
|
4
|
-
|
5
|
-
if ActiveRecord::VERSION::MAJOR == 4
|
6
|
-
# voodoo!
|
7
|
-
require 'minitest/autorun'
|
8
|
-
end
|
9
|
-
|
10
|
-
require 'active_support/test_case'
|
11
|
-
|
12
|
-
|
13
|
-
ActiveRecord::Base.establish_connection(
|
14
|
-
:adapter => "sqlite3",
|
15
|
-
:database => ":memory:"
|
16
|
-
)
|
17
|
-
require File.expand_path("../schema", __FILE__)
|
18
|
-
|
19
|
-
$LOAD_PATH.unshift File.expand_path("../../lib", __FILE__)
|
20
|
-
require 'active_record_inherit_assoc'
|
data/test/schema.rb
DELETED
@@ -1,28 +0,0 @@
|
|
1
|
-
ActiveRecord::Schema.define(:version => 1) do
|
2
|
-
drop_table(:mains) rescue nil
|
3
|
-
create_table "mains" do |t|
|
4
|
-
t.integer :account_id
|
5
|
-
t.integer :blah_id
|
6
|
-
t.string "val"
|
7
|
-
end
|
8
|
-
|
9
|
-
drop_table(:others) rescue nil
|
10
|
-
create_table "others" do |t|
|
11
|
-
t.integer :main_id
|
12
|
-
t.integer :account_id
|
13
|
-
t.string :val
|
14
|
-
end
|
15
|
-
|
16
|
-
drop_table(:thirds) rescue nil
|
17
|
-
create_table "thirds" do |t|
|
18
|
-
t.integer :main_id
|
19
|
-
t.integer :account_id
|
20
|
-
end
|
21
|
-
|
22
|
-
drop_table(:fourths) rescue nil
|
23
|
-
create_table "fourths" do |t|
|
24
|
-
t.integer :main_id
|
25
|
-
t.integer :account_id
|
26
|
-
t.integer :blah_id
|
27
|
-
end
|
28
|
-
end
|
@@ -1,48 +0,0 @@
|
|
1
|
-
require File.expand_path '../helper', __FILE__
|
2
|
-
|
3
|
-
class TestBelongsToAssociation < ActiveSupport::TestCase
|
4
|
-
class Main < ActiveRecord::Base
|
5
|
-
end
|
6
|
-
|
7
|
-
class Other < ActiveRecord::Base
|
8
|
-
belongs_to :main
|
9
|
-
inherits_from :main, :attr => [:account_id, :val]
|
10
|
-
end
|
11
|
-
|
12
|
-
def test_value_is_inherited_from_parent
|
13
|
-
@main = Main.create!(:account_id => 42)
|
14
|
-
@other = Other.create!(:main => @main)
|
15
|
-
|
16
|
-
assert_equal 42, @other.account_id
|
17
|
-
end
|
18
|
-
|
19
|
-
def test_multiple_values_are_inherited_from_parent
|
20
|
-
@main = Main.create!(:account_id => 42, :val => "The Answer")
|
21
|
-
@other = Other.create!(:main => @main)
|
22
|
-
|
23
|
-
assert_equal 42, @other.account_id
|
24
|
-
assert_equal "The Answer", @other.val
|
25
|
-
end
|
26
|
-
|
27
|
-
def test_does_not_inherit_when_parent_not_present
|
28
|
-
@other = Other.create!
|
29
|
-
assert_nil @other.account_id
|
30
|
-
end
|
31
|
-
|
32
|
-
def test_overwrites_value_on_child
|
33
|
-
@main = Main.create!(:account_id => 42)
|
34
|
-
@other = Other.create!(:main => @main, :account_id => 1337)
|
35
|
-
|
36
|
-
assert_equal 42, @other.account_id
|
37
|
-
end
|
38
|
-
|
39
|
-
def test_allows_setting_the_value_after_instantiation
|
40
|
-
@main = Main.create!
|
41
|
-
@other = Other.new(:main => @main, :account_id => 1337)
|
42
|
-
|
43
|
-
@main.account_id = 42
|
44
|
-
@other.save
|
45
|
-
|
46
|
-
assert_equal 42, @other.account_id
|
47
|
-
end
|
48
|
-
end
|
data/test/test_inherit_assoc.rb
DELETED
@@ -1,115 +0,0 @@
|
|
1
|
-
require File.expand_path '../helper', __FILE__
|
2
|
-
|
3
|
-
class TestInheritAssoc < ActiveSupport::TestCase
|
4
|
-
class Main < ActiveRecord::Base
|
5
|
-
has_many :others, :inherit => :account_id
|
6
|
-
has_one :third, :inherit => :account_id
|
7
|
-
has_many :fourths, :inherit => [:account_id, :blah_id]
|
8
|
-
if ActiveRecord::VERSION::MAJOR < 4
|
9
|
-
has_many :conditional_others, :inherit => :account_id, :conditions => {:val => "foo"}, :class_name => "Other"
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
|
-
class Other < ActiveRecord::Base
|
14
|
-
belongs_to :main
|
15
|
-
end
|
16
|
-
|
17
|
-
class Third < ActiveRecord::Base
|
18
|
-
belongs_to :main
|
19
|
-
end
|
20
|
-
|
21
|
-
class Fourth < ActiveRecord::Base
|
22
|
-
belongs_to :main
|
23
|
-
end
|
24
|
-
|
25
|
-
context "Main, with some others, scoped by account_id" do
|
26
|
-
setup do
|
27
|
-
@main = Main.create! :account_id => 1
|
28
|
-
Other.create! :main_id => @main.id, :account_id => 1
|
29
|
-
Other.create! :main_id => @main.id, :account_id => 2
|
30
|
-
Other.create! :main_id => @main.id, :account_id => 1, :val => "foo"
|
31
|
-
end
|
32
|
-
|
33
|
-
should "set conditions on simple access" do
|
34
|
-
assert_equal 2, @main.others.size
|
35
|
-
end
|
36
|
-
|
37
|
-
if ActiveRecord::VERSION::MAJOR < 4
|
38
|
-
should "set conditions on find" do
|
39
|
-
assert_equal 2, @main.others.find(:all).size
|
40
|
-
end
|
41
|
-
|
42
|
-
should "merge conditions on find" do
|
43
|
-
assert_equal 1, @main.others.all(:conditions => "val = 'foo'").size
|
44
|
-
end
|
45
|
-
|
46
|
-
should "merge conditions" do
|
47
|
-
assert_equal 1, @main.conditional_others.size
|
48
|
-
end
|
49
|
-
else
|
50
|
-
should "set conditions on find" do
|
51
|
-
assert_equal 2, @main.others.all.size
|
52
|
-
end
|
53
|
-
|
54
|
-
should "merge conditions on find" do
|
55
|
-
assert_equal 1, @main.others.all.where("val = 'foo'").size
|
56
|
-
end
|
57
|
-
|
58
|
-
should_eventually "merge conditions" do
|
59
|
-
assert_equal 1, @main.conditional_others.size
|
60
|
-
end
|
61
|
-
|
62
|
-
end
|
63
|
-
end
|
64
|
-
|
65
|
-
def test_has_one_should_set_conditions_on_fetch
|
66
|
-
main = Main.create! :account_id => 1
|
67
|
-
third_1 = Third.create! :main_id => main.id, :account_id => 2
|
68
|
-
third_2 = Third.create! :main_id => main.id, :account_id => 1
|
69
|
-
assert_equal third_2, main.third
|
70
|
-
end
|
71
|
-
|
72
|
-
def test_has_many_should_set_conditions_for_multiple_inherits
|
73
|
-
main = Main.create! :account_id => 1, :blah_id => 10
|
74
|
-
# these two should match
|
75
|
-
Fourth.create! :main_id => main.id, :account_id => 1, :blah_id => 10
|
76
|
-
Fourth.create! :main_id => main.id, :account_id => 1, :blah_id => 10
|
77
|
-
|
78
|
-
# nope.
|
79
|
-
Fourth.create! :main_id => main.id, :account_id => 1, :blah_id => 5
|
80
|
-
Fourth.create! :main_id => main.id, :account_id => 1, :blah_id => 12
|
81
|
-
Fourth.create! :main_id => 99999, :account_id => 1, :blah_id => 12
|
82
|
-
|
83
|
-
assert_equal(2, main.fourths.size)
|
84
|
-
end
|
85
|
-
|
86
|
-
def test_has_many_should_setup_attributes_when_building
|
87
|
-
main = Main.create! :account_id => 1, :blah_id => 10
|
88
|
-
|
89
|
-
other = main.others.build
|
90
|
-
assert_equal main.id, other.main_id
|
91
|
-
assert_equal main.account_id, other.account_id
|
92
|
-
end
|
93
|
-
|
94
|
-
def test_has_many_should_setup_attributes_when_creating
|
95
|
-
main = Main.create! :account_id => 1, :blah_id => 10
|
96
|
-
|
97
|
-
other = main.others.create!
|
98
|
-
assert_equal main.id, other.main_id
|
99
|
-
assert_equal main.account_id, other.account_id
|
100
|
-
|
101
|
-
other = main.others.create
|
102
|
-
assert_equal main.id, other.main_id
|
103
|
-
assert_equal main.account_id, other.account_id
|
104
|
-
end
|
105
|
-
|
106
|
-
def test_has_one_should_setup_attributes_when_building
|
107
|
-
main = Main.create! :account_id => 1, :blah_id => 10
|
108
|
-
|
109
|
-
other = main.build_third
|
110
|
-
assert_equal main.account_id, other.account_id
|
111
|
-
|
112
|
-
other = main.create_third
|
113
|
-
assert_equal main.account_id, other.account_id
|
114
|
-
end
|
115
|
-
end
|