poly_belongs_to 0.1.4 → 0.1.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +9 -6
- data/lib/poly_belongs_to/dup.rb +16 -5
- data/lib/poly_belongs_to/poly_belongs_to.rb +4 -12
- data/lib/poly_belongs_to/version.rb +1 -1
- data/lib/poly_belongs_to.rb +0 -1
- data/test/dummy/app/models/address.rb +2 -0
- data/test/dummy/app/models/geo_location.rb +4 -0
- data/test/dummy/app/models/squishy.rb +3 -0
- data/test/dummy/db/migrate/20150220213422_create_geo_locations.rb +11 -0
- data/test/dummy/db/migrate/20150220230146_create_squishies.rb +10 -0
- data/test/dummy/db/schema.rb +20 -1
- data/test/dummy/db/test.sqlite3 +0 -0
- data/test/dummy/log/development.log +116 -0
- data/test/dummy/log/test.log +17191 -0
- data/test/dup_test.rb +7 -6
- data/test/fixtures/geo_locations.yml +14 -0
- data/test/fixtures/squishies.yml +26 -0
- data/test/test_helper.rb +2 -3
- metadata +14 -11
- data/lib/poly_belongs_to/hierarchy.rb +0 -23
- data/test/dummy/db/development.sqlite3 +0 -0
- data/test/dummy/public/404.html +0 -67
- data/test/dummy/public/422.html +0 -67
- data/test/dummy/public/500.html +0 -66
data/test/dup_test.rb
CHANGED
@@ -29,11 +29,12 @@ class DupTest < ActiveSupport::TestCase
|
|
29
29
|
bob_prof = profiles(:bob_prof)
|
30
30
|
contact = user1.contacts.new
|
31
31
|
contact.pbt_deep_dup_build(bob_prof)
|
32
|
-
CleanAttrs[contact.profile].must_equal
|
33
|
-
CleanAttrs[contact.profile.addresses.first].must_equal
|
34
|
-
CleanAttrs[contact.profile.addresses.
|
35
|
-
CleanAttrs[contact.profile.
|
36
|
-
CleanAttrs[contact.profile.phones.
|
37
|
-
CleanAttrs[contact.profile.
|
32
|
+
CleanAttrs[contact.profile].must_equal CleanAttrs[bob_prof]
|
33
|
+
CleanAttrs[contact.profile.addresses.first].must_equal CleanAttrs[bob_prof.addresses.first]
|
34
|
+
CleanAttrs[contact.profile.addresses.first.geo_location].must_equal CleanAttrs[bob_prof.addresses.first.geo_location]
|
35
|
+
CleanAttrs[contact.profile.addresses.last].must_equal CleanAttrs[bob_prof.addresses.last]
|
36
|
+
CleanAttrs[contact.profile.phones.first].must_equal CleanAttrs[bob_prof.phones.first]
|
37
|
+
CleanAttrs[contact.profile.phones.last].must_equal CleanAttrs[bob_prof.phones.last]
|
38
|
+
CleanAttrs[contact.profile.photo].must_equal CleanAttrs[bob_prof.photo]
|
38
39
|
end
|
39
40
|
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# Read about fixtures at
|
2
|
+
# http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html
|
3
|
+
|
4
|
+
bob_geo_loc:
|
5
|
+
address_id: <%= ActiveRecord::FixtureSet.identify(:bob_address) %>
|
6
|
+
content: <%= SecureRandom.hex %>
|
7
|
+
|
8
|
+
steve_geo_loc:
|
9
|
+
address_id: <%= ActiveRecord::FixtureSet.identify(:steve_address) %>
|
10
|
+
content: <%= SecureRandom.hex %>
|
11
|
+
|
12
|
+
susan_geo_loc:
|
13
|
+
address_id: <%= ActiveRecord::FixtureSet.identify(:susan_address) %>
|
14
|
+
content: <%= SecureRandom.hex %>
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# Read about fixtures at
|
2
|
+
# http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html
|
3
|
+
|
4
|
+
bob_squishy_address:
|
5
|
+
content: Squishy
|
6
|
+
squishable: bob_address (Address)
|
7
|
+
|
8
|
+
bob_squishy_geo_loc:
|
9
|
+
content: Squishy
|
10
|
+
squishable: bob_geo_loc (GeoLocation)
|
11
|
+
|
12
|
+
steve_squishy_address:
|
13
|
+
content: Squishy
|
14
|
+
squishable: steve_address (Address)
|
15
|
+
|
16
|
+
steve_squishy_geo_loc:
|
17
|
+
content: Squishy
|
18
|
+
squishable: steve_geo_loc (GeoLocation)
|
19
|
+
|
20
|
+
susan_squishy_address:
|
21
|
+
content: Squishy
|
22
|
+
squishable: susan_address (Address)
|
23
|
+
|
24
|
+
susan_squishy_geo_loc:
|
25
|
+
content: Squishy
|
26
|
+
squishable: susan_geo_loc (GeoLocation)
|
data/test/test_helper.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
ENV["RAILS_ENV"] = "test"
|
2
|
-
|
2
|
+
require "codeclimate-test-reporter"
|
3
|
+
CodeClimate::TestReporter.start
|
3
4
|
require File.expand_path("../../test/dummy/config/environment.rb", __FILE__)
|
4
|
-
# require File.expand_path("../dummy/config/environment.rb", __FILE__)
|
5
5
|
|
6
6
|
ActiveRecord::Migrator.migrations_paths = [File.expand_path("../../test/dummy/db/migrate", __FILE__)]
|
7
7
|
require 'rails/test_help'
|
@@ -20,7 +20,6 @@ if ActiveSupport::TestCase.respond_to?(:fixture_path=)
|
|
20
20
|
ActiveSupport::TestCase.fixture_path = File.expand_path("../fixtures", __FILE__)
|
21
21
|
end
|
22
22
|
|
23
|
-
#reporter_options = { color: true }
|
24
23
|
Minitest::Reporters.use! [Minitest::Reporters::SpecReporter.new]
|
25
24
|
|
26
25
|
class ActiveSupport::TestCase
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: poly_belongs_to
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Daniel P. Clark
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-02-
|
11
|
+
date: 2015-02-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -96,7 +96,6 @@ files:
|
|
96
96
|
- Rakefile
|
97
97
|
- lib/poly_belongs_to.rb
|
98
98
|
- lib/poly_belongs_to/dup.rb
|
99
|
-
- lib/poly_belongs_to/hierarchy.rb
|
100
99
|
- lib/poly_belongs_to/poly_belongs_to.rb
|
101
100
|
- lib/poly_belongs_to/version.rb
|
102
101
|
- lib/tasks/poly_belongs_to_tasks.rake
|
@@ -105,9 +104,11 @@ files:
|
|
105
104
|
- test/dummy/app/helpers/application_helper.rb
|
106
105
|
- test/dummy/app/models/address.rb
|
107
106
|
- test/dummy/app/models/contact.rb
|
107
|
+
- test/dummy/app/models/geo_location.rb
|
108
108
|
- test/dummy/app/models/phone.rb
|
109
109
|
- test/dummy/app/models/photo.rb
|
110
110
|
- test/dummy/app/models/profile.rb
|
111
|
+
- test/dummy/app/models/squishy.rb
|
111
112
|
- test/dummy/app/models/ssn.rb
|
112
113
|
- test/dummy/app/models/tag.rb
|
113
114
|
- test/dummy/app/models/user.rb
|
@@ -135,7 +136,6 @@ files:
|
|
135
136
|
- test/dummy/config/locales/en.yml
|
136
137
|
- test/dummy/config/routes.rb
|
137
138
|
- test/dummy/config/secrets.yml
|
138
|
-
- test/dummy/db/development.sqlite3
|
139
139
|
- test/dummy/db/migrate/20150211224139_create_users.rb
|
140
140
|
- test/dummy/db/migrate/20150211224157_create_tags.rb
|
141
141
|
- test/dummy/db/migrate/20150211224225_create_phones.rb
|
@@ -144,19 +144,20 @@ files:
|
|
144
144
|
- test/dummy/db/migrate/20150216092411_create_photos.rb
|
145
145
|
- test/dummy/db/migrate/20150216092449_create_contacts.rb
|
146
146
|
- test/dummy/db/migrate/20150216092519_create_ssns.rb
|
147
|
+
- test/dummy/db/migrate/20150220213422_create_geo_locations.rb
|
148
|
+
- test/dummy/db/migrate/20150220230146_create_squishies.rb
|
147
149
|
- test/dummy/db/schema.rb
|
148
150
|
- test/dummy/db/test.sqlite3
|
149
151
|
- test/dummy/log/development.log
|
150
152
|
- test/dummy/log/test.log
|
151
|
-
- test/dummy/public/404.html
|
152
|
-
- test/dummy/public/422.html
|
153
|
-
- test/dummy/public/500.html
|
154
153
|
- test/dummy/public/favicon.ico
|
155
154
|
- test/dup_test.rb
|
156
155
|
- test/fixtures/addresses.yml
|
156
|
+
- test/fixtures/geo_locations.yml
|
157
157
|
- test/fixtures/phones.yml
|
158
158
|
- test/fixtures/photos.yml
|
159
159
|
- test/fixtures/profiles.yml
|
160
|
+
- test/fixtures/squishies.yml
|
160
161
|
- test/fixtures/ssns.yml
|
161
162
|
- test/fixtures/tags.yml
|
162
163
|
- test/fixtures/users.yml
|
@@ -190,20 +191,23 @@ summary: Shorthand belongs_to testing and universal identifiers.
|
|
190
191
|
test_files:
|
191
192
|
- test/poly_belongs_to_test.rb
|
192
193
|
- test/dup_test.rb
|
194
|
+
- test/fixtures/squishies.yml
|
193
195
|
- test/fixtures/addresses.yml
|
194
196
|
- test/fixtures/photos.yml
|
195
197
|
- test/fixtures/profiles.yml
|
198
|
+
- test/fixtures/geo_locations.yml
|
196
199
|
- test/fixtures/phones.yml
|
197
200
|
- test/fixtures/users.yml
|
198
201
|
- test/fixtures/tags.yml
|
199
202
|
- test/fixtures/ssns.yml
|
200
203
|
- test/test_helper.rb
|
201
204
|
- test/dummy/db/test.sqlite3
|
202
|
-
- test/dummy/db/development.sqlite3
|
203
205
|
- test/dummy/db/schema.rb
|
206
|
+
- test/dummy/db/migrate/20150220230146_create_squishies.rb
|
204
207
|
- test/dummy/db/migrate/20150216092449_create_contacts.rb
|
205
208
|
- test/dummy/db/migrate/20150216092218_create_addresses.rb
|
206
209
|
- test/dummy/db/migrate/20150211224225_create_phones.rb
|
210
|
+
- test/dummy/db/migrate/20150220213422_create_geo_locations.rb
|
207
211
|
- test/dummy/db/migrate/20150216092519_create_ssns.rb
|
208
212
|
- test/dummy/db/migrate/20150211224157_create_tags.rb
|
209
213
|
- test/dummy/db/migrate/20150211224139_create_users.rb
|
@@ -232,16 +236,15 @@ test_files:
|
|
232
236
|
- test/dummy/app/models/ssn.rb
|
233
237
|
- test/dummy/app/models/contact.rb
|
234
238
|
- test/dummy/app/models/user.rb
|
239
|
+
- test/dummy/app/models/geo_location.rb
|
235
240
|
- test/dummy/app/models/address.rb
|
236
241
|
- test/dummy/app/models/phone.rb
|
237
242
|
- test/dummy/app/models/profile.rb
|
243
|
+
- test/dummy/app/models/squishy.rb
|
238
244
|
- test/dummy/app/models/tag.rb
|
239
245
|
- test/dummy/app/models/photo.rb
|
240
246
|
- test/dummy/app/views/layouts/application.html.erb
|
241
|
-
- test/dummy/public/422.html
|
242
247
|
- test/dummy/public/favicon.ico
|
243
|
-
- test/dummy/public/404.html
|
244
|
-
- test/dummy/public/500.html
|
245
248
|
- test/dummy/Rakefile
|
246
249
|
- test/dummy/config.ru
|
247
250
|
- test/dummy/log/test.log
|
@@ -1,23 +0,0 @@
|
|
1
|
-
module PolyBelongsTo
|
2
|
-
module Hierarchy
|
3
|
-
extend ActiveSupport::Concern
|
4
|
-
|
5
|
-
included do
|
6
|
-
def self.pbt_offspring(obj)
|
7
|
-
# planning phase
|
8
|
-
end
|
9
|
-
|
10
|
-
def self.pbt_children(obj, kind)
|
11
|
-
# planning phase
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
def pbt_offspring
|
16
|
-
self.class.pbt_offspring(self)
|
17
|
-
end
|
18
|
-
|
19
|
-
def pbt_children(kind)
|
20
|
-
self.class.pbt_children(self, kind)
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
File without changes
|
data/test/dummy/public/404.html
DELETED
@@ -1,67 +0,0 @@
|
|
1
|
-
<!DOCTYPE html>
|
2
|
-
<html>
|
3
|
-
<head>
|
4
|
-
<title>The page you were looking for doesn't exist (404)</title>
|
5
|
-
<meta name="viewport" content="width=device-width,initial-scale=1">
|
6
|
-
<style>
|
7
|
-
body {
|
8
|
-
background-color: #EFEFEF;
|
9
|
-
color: #2E2F30;
|
10
|
-
text-align: center;
|
11
|
-
font-family: arial, sans-serif;
|
12
|
-
margin: 0;
|
13
|
-
}
|
14
|
-
|
15
|
-
div.dialog {
|
16
|
-
width: 95%;
|
17
|
-
max-width: 33em;
|
18
|
-
margin: 4em auto 0;
|
19
|
-
}
|
20
|
-
|
21
|
-
div.dialog > div {
|
22
|
-
border: 1px solid #CCC;
|
23
|
-
border-right-color: #999;
|
24
|
-
border-left-color: #999;
|
25
|
-
border-bottom-color: #BBB;
|
26
|
-
border-top: #B00100 solid 4px;
|
27
|
-
border-top-left-radius: 9px;
|
28
|
-
border-top-right-radius: 9px;
|
29
|
-
background-color: white;
|
30
|
-
padding: 7px 12% 0;
|
31
|
-
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
|
32
|
-
}
|
33
|
-
|
34
|
-
h1 {
|
35
|
-
font-size: 100%;
|
36
|
-
color: #730E15;
|
37
|
-
line-height: 1.5em;
|
38
|
-
}
|
39
|
-
|
40
|
-
div.dialog > p {
|
41
|
-
margin: 0 0 1em;
|
42
|
-
padding: 1em;
|
43
|
-
background-color: #F7F7F7;
|
44
|
-
border: 1px solid #CCC;
|
45
|
-
border-right-color: #999;
|
46
|
-
border-left-color: #999;
|
47
|
-
border-bottom-color: #999;
|
48
|
-
border-bottom-left-radius: 4px;
|
49
|
-
border-bottom-right-radius: 4px;
|
50
|
-
border-top-color: #DADADA;
|
51
|
-
color: #666;
|
52
|
-
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
|
53
|
-
}
|
54
|
-
</style>
|
55
|
-
</head>
|
56
|
-
|
57
|
-
<body>
|
58
|
-
<!-- This file lives in public/404.html -->
|
59
|
-
<div class="dialog">
|
60
|
-
<div>
|
61
|
-
<h1>The page you were looking for doesn't exist.</h1>
|
62
|
-
<p>You may have mistyped the address or the page may have moved.</p>
|
63
|
-
</div>
|
64
|
-
<p>If you are the application owner check the logs for more information.</p>
|
65
|
-
</div>
|
66
|
-
</body>
|
67
|
-
</html>
|
data/test/dummy/public/422.html
DELETED
@@ -1,67 +0,0 @@
|
|
1
|
-
<!DOCTYPE html>
|
2
|
-
<html>
|
3
|
-
<head>
|
4
|
-
<title>The change you wanted was rejected (422)</title>
|
5
|
-
<meta name="viewport" content="width=device-width,initial-scale=1">
|
6
|
-
<style>
|
7
|
-
body {
|
8
|
-
background-color: #EFEFEF;
|
9
|
-
color: #2E2F30;
|
10
|
-
text-align: center;
|
11
|
-
font-family: arial, sans-serif;
|
12
|
-
margin: 0;
|
13
|
-
}
|
14
|
-
|
15
|
-
div.dialog {
|
16
|
-
width: 95%;
|
17
|
-
max-width: 33em;
|
18
|
-
margin: 4em auto 0;
|
19
|
-
}
|
20
|
-
|
21
|
-
div.dialog > div {
|
22
|
-
border: 1px solid #CCC;
|
23
|
-
border-right-color: #999;
|
24
|
-
border-left-color: #999;
|
25
|
-
border-bottom-color: #BBB;
|
26
|
-
border-top: #B00100 solid 4px;
|
27
|
-
border-top-left-radius: 9px;
|
28
|
-
border-top-right-radius: 9px;
|
29
|
-
background-color: white;
|
30
|
-
padding: 7px 12% 0;
|
31
|
-
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
|
32
|
-
}
|
33
|
-
|
34
|
-
h1 {
|
35
|
-
font-size: 100%;
|
36
|
-
color: #730E15;
|
37
|
-
line-height: 1.5em;
|
38
|
-
}
|
39
|
-
|
40
|
-
div.dialog > p {
|
41
|
-
margin: 0 0 1em;
|
42
|
-
padding: 1em;
|
43
|
-
background-color: #F7F7F7;
|
44
|
-
border: 1px solid #CCC;
|
45
|
-
border-right-color: #999;
|
46
|
-
border-left-color: #999;
|
47
|
-
border-bottom-color: #999;
|
48
|
-
border-bottom-left-radius: 4px;
|
49
|
-
border-bottom-right-radius: 4px;
|
50
|
-
border-top-color: #DADADA;
|
51
|
-
color: #666;
|
52
|
-
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
|
53
|
-
}
|
54
|
-
</style>
|
55
|
-
</head>
|
56
|
-
|
57
|
-
<body>
|
58
|
-
<!-- This file lives in public/422.html -->
|
59
|
-
<div class="dialog">
|
60
|
-
<div>
|
61
|
-
<h1>The change you wanted was rejected.</h1>
|
62
|
-
<p>Maybe you tried to change something you didn't have access to.</p>
|
63
|
-
</div>
|
64
|
-
<p>If you are the application owner check the logs for more information.</p>
|
65
|
-
</div>
|
66
|
-
</body>
|
67
|
-
</html>
|
data/test/dummy/public/500.html
DELETED
@@ -1,66 +0,0 @@
|
|
1
|
-
<!DOCTYPE html>
|
2
|
-
<html>
|
3
|
-
<head>
|
4
|
-
<title>We're sorry, but something went wrong (500)</title>
|
5
|
-
<meta name="viewport" content="width=device-width,initial-scale=1">
|
6
|
-
<style>
|
7
|
-
body {
|
8
|
-
background-color: #EFEFEF;
|
9
|
-
color: #2E2F30;
|
10
|
-
text-align: center;
|
11
|
-
font-family: arial, sans-serif;
|
12
|
-
margin: 0;
|
13
|
-
}
|
14
|
-
|
15
|
-
div.dialog {
|
16
|
-
width: 95%;
|
17
|
-
max-width: 33em;
|
18
|
-
margin: 4em auto 0;
|
19
|
-
}
|
20
|
-
|
21
|
-
div.dialog > div {
|
22
|
-
border: 1px solid #CCC;
|
23
|
-
border-right-color: #999;
|
24
|
-
border-left-color: #999;
|
25
|
-
border-bottom-color: #BBB;
|
26
|
-
border-top: #B00100 solid 4px;
|
27
|
-
border-top-left-radius: 9px;
|
28
|
-
border-top-right-radius: 9px;
|
29
|
-
background-color: white;
|
30
|
-
padding: 7px 12% 0;
|
31
|
-
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
|
32
|
-
}
|
33
|
-
|
34
|
-
h1 {
|
35
|
-
font-size: 100%;
|
36
|
-
color: #730E15;
|
37
|
-
line-height: 1.5em;
|
38
|
-
}
|
39
|
-
|
40
|
-
div.dialog > p {
|
41
|
-
margin: 0 0 1em;
|
42
|
-
padding: 1em;
|
43
|
-
background-color: #F7F7F7;
|
44
|
-
border: 1px solid #CCC;
|
45
|
-
border-right-color: #999;
|
46
|
-
border-left-color: #999;
|
47
|
-
border-bottom-color: #999;
|
48
|
-
border-bottom-left-radius: 4px;
|
49
|
-
border-bottom-right-radius: 4px;
|
50
|
-
border-top-color: #DADADA;
|
51
|
-
color: #666;
|
52
|
-
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
|
53
|
-
}
|
54
|
-
</style>
|
55
|
-
</head>
|
56
|
-
|
57
|
-
<body>
|
58
|
-
<!-- This file lives in public/500.html -->
|
59
|
-
<div class="dialog">
|
60
|
-
<div>
|
61
|
-
<h1>We're sorry, but something went wrong.</h1>
|
62
|
-
</div>
|
63
|
-
<p>If you are the application owner check the logs for more information.</p>
|
64
|
-
</div>
|
65
|
-
</body>
|
66
|
-
</html>
|