poly_belongs_to 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +11 -12
- data/lib/poly_belongs_to/version.rb +1 -1
- data/lib/poly_belongs_to.rb +4 -4
- data/test/dummy/app/models/phone.rb +3 -0
- data/test/dummy/app/models/tag.rb +3 -0
- data/test/dummy/app/models/user.rb +4 -0
- data/test/dummy/db/migrate/20150211224139_create_users.rb +8 -0
- data/test/dummy/db/migrate/20150211224157_create_tags.rb +10 -0
- data/test/dummy/db/migrate/20150211224225_create_phones.rb +9 -0
- data/test/dummy/db/schema.rb +38 -0
- data/test/dummy/db/test.sqlite3 +0 -0
- data/test/dummy/log/development.log +56 -0
- data/test/dummy/log/test.log +2522 -0
- data/test/dummy/test/models/phone_test.rb +7 -0
- data/test/dummy/test/models/tag_test.rb +7 -0
- data/test/dummy/test/models/user_test.rb +7 -0
- data/test/fixtures/phones.yml +5 -0
- data/test/fixtures/tags.yml +4 -0
- data/test/fixtures/users.yml +7 -0
- data/test/poly_belongs_to_test.rb +136 -2
- data/test/test_helper.rb +6 -1
- metadata +88 -7
- data/test/dummy/README.rdoc +0 -28
@@ -0,0 +1,7 @@
|
|
1
|
+
# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
|
2
|
+
|
3
|
+
# This model initially had no columns defined. If you add columns to the
|
4
|
+
# model remove the '{}' from the fixture names and add the columns immediately
|
5
|
+
# below each fixture, per the syntax in the comments below
|
6
|
+
#
|
7
|
+
one: {}
|
@@ -1,7 +1,141 @@
|
|
1
1
|
require 'test_helper'
|
2
2
|
|
3
3
|
class PolyBelongsToTest < ActiveSupport::TestCase
|
4
|
-
|
5
|
-
|
4
|
+
fixtures :all
|
5
|
+
|
6
|
+
it "is a module" do
|
7
|
+
PolyBelongsTo.must_be_kind_of Module
|
8
|
+
end
|
9
|
+
|
10
|
+
it "reports User as not polymorphic" do
|
11
|
+
user = users(:one)
|
12
|
+
user.poly?.must_be_same_as false
|
13
|
+
User.poly?.must_be_same_as false
|
14
|
+
end
|
15
|
+
|
16
|
+
it "reports Tag as not polymorphic" do
|
17
|
+
tag = tags(:one)
|
18
|
+
tag.poly?.must_be_same_as false
|
19
|
+
Tag.poly?.must_be_same_as false
|
20
|
+
end
|
21
|
+
|
22
|
+
it "reports Phone as polymorphic" do
|
23
|
+
phone = phones(:one)
|
24
|
+
phone.poly?.must_be_same_as true
|
25
|
+
Phone.poly?.must_be_same_as true
|
26
|
+
end
|
27
|
+
|
28
|
+
it "reports User belongs to relation table as nil" do
|
29
|
+
user = users(:one)
|
30
|
+
user.pbt.must_be_nil
|
31
|
+
User.pbt.must_be_nil
|
32
|
+
end
|
33
|
+
|
34
|
+
it "reports Tag belongs to relation table as :user" do
|
35
|
+
tag = tags(:one)
|
36
|
+
tag.pbt.must_be_same_as :user
|
37
|
+
Tag.pbt.must_be_same_as :user
|
38
|
+
end
|
39
|
+
|
40
|
+
it "reports Phone belongs to relation table as :phoneable" do
|
41
|
+
phone = phones(:one)
|
42
|
+
phone.pbt.must_be_same_as :phoneable
|
43
|
+
Phone.pbt.must_be_same_as :phoneable
|
44
|
+
end
|
45
|
+
|
46
|
+
it "reports User params name as :user" do
|
47
|
+
user = users(:one)
|
48
|
+
user.pbt_params_name.must_be_same_as :user
|
49
|
+
User.pbt_params_name.must_be_same_as :user
|
50
|
+
User.pbt_params_name(true).must_be_same_as :user
|
51
|
+
User.pbt_params_name(false).must_be_same_as :user
|
52
|
+
end
|
53
|
+
|
54
|
+
it "reports Tag params name as :tag" do
|
55
|
+
tag = tags(:one)
|
56
|
+
tag.pbt_params_name.must_be_same_as :tag
|
57
|
+
Tag.pbt_params_name.must_be_same_as :tag
|
58
|
+
Tag.pbt_params_name(true).must_be_same_as :tag
|
59
|
+
Tag.pbt_params_name(false).must_be_same_as :tag
|
60
|
+
end
|
61
|
+
|
62
|
+
it "reports Phone params name as :phones_attributes" do
|
63
|
+
phone = phones(:one)
|
64
|
+
phone.pbt_params_name.must_be_same_as :phones_attributes
|
65
|
+
Phone.pbt_params_name.must_be_same_as :phones_attributes
|
66
|
+
Phone.pbt_params_name(true).must_be_same_as :phones_attributes
|
67
|
+
end
|
68
|
+
|
69
|
+
it "reports Phone params name with false as :phone" do
|
70
|
+
phone = phones(:one)
|
71
|
+
phone.pbt_params_name(false).must_be_same_as :phone
|
72
|
+
Phone.pbt_params_name(false).must_be_same_as :phone
|
6
73
|
end
|
74
|
+
|
75
|
+
it "reports User belongs to field id symbol as nil" do
|
76
|
+
user = users(:one)
|
77
|
+
user.pbt_id_sym.must_be_nil
|
78
|
+
User.pbt_id_sym.must_be_nil
|
79
|
+
end
|
80
|
+
|
81
|
+
it "reports Tag belongs to field id symbol as :tag_id" do
|
82
|
+
tag = tags(:one)
|
83
|
+
tag.pbt_id_sym.must_be_same_as :user_id
|
84
|
+
Tag.pbt_id_sym.must_be_same_as :user_id
|
85
|
+
end
|
86
|
+
|
87
|
+
it "reports Phone belongs to field id symbol as :phoneable_id" do
|
88
|
+
phone = phones(:one)
|
89
|
+
phone.pbt_id_sym.must_be_same_as :phoneable_id
|
90
|
+
Phone.pbt_id_sym.must_be_same_as :phoneable_id
|
91
|
+
end
|
92
|
+
|
93
|
+
it "reports User belongs to field type symbol as nil" do
|
94
|
+
user = users(:one)
|
95
|
+
user.pbt_type_sym.must_be_nil
|
96
|
+
User.pbt_type_sym.must_be_nil
|
97
|
+
end
|
98
|
+
|
99
|
+
it "reports Tag belongs to field type symbol as nil" do
|
100
|
+
tag = tags(:one)
|
101
|
+
tag.pbt_type_sym.must_be_nil
|
102
|
+
Tag.pbt_type_sym.must_be_nil
|
103
|
+
end
|
104
|
+
|
105
|
+
it "reports Phone belongs to field type symbol as :phoneable_type" do
|
106
|
+
phone = phones(:one)
|
107
|
+
phone.pbt_type_sym.must_be_same_as :phoneable_type
|
108
|
+
Phone.pbt_type_sym.must_be_same_as :phoneable_type
|
109
|
+
end
|
110
|
+
|
111
|
+
it "reports User belongs to relation id as nil" do
|
112
|
+
user = users(:one)
|
113
|
+
user.pbt_id.must_be_nil
|
114
|
+
end
|
115
|
+
|
116
|
+
it "reports Tag belongs to relation id as 1" do
|
117
|
+
tag = tags(:one)
|
118
|
+
tag.pbt_id.must_be_same_as 1
|
119
|
+
end
|
120
|
+
|
121
|
+
it "reports Phone belongs to relation id as 1" do
|
122
|
+
phone = phones(:one)
|
123
|
+
phone.pbt_id.must_be_same_as 1
|
124
|
+
end
|
125
|
+
|
126
|
+
it "reports User belongs to relation type as nil" do
|
127
|
+
user = users(:one)
|
128
|
+
user.pbt_type.must_be_nil
|
129
|
+
end
|
130
|
+
|
131
|
+
it "reports Tag belongs to relation type as nil" do
|
132
|
+
tag = tags(:one)
|
133
|
+
tag.pbt_type.must_be_nil
|
134
|
+
end
|
135
|
+
|
136
|
+
it "reports Phone belongs to relation type as 'User'" do
|
137
|
+
phone = phones(:one)
|
138
|
+
phone.pbt_type.must_equal "User"
|
139
|
+
end
|
140
|
+
|
7
141
|
end
|
data/test/test_helper.rb
CHANGED
@@ -3,7 +3,9 @@ ENV["RAILS_ENV"] = "test"
|
|
3
3
|
|
4
4
|
require File.expand_path("../../test/dummy/config/environment.rb", __FILE__)
|
5
5
|
ActiveRecord::Migrator.migrations_paths = [File.expand_path("../../test/dummy/db/migrate", __FILE__)]
|
6
|
-
require
|
6
|
+
require 'rails/test_help'
|
7
|
+
require 'minitest/rails'
|
8
|
+
require 'minitest/reporters'
|
7
9
|
|
8
10
|
# Filter out Minitest backtrace while allowing backtrace from other libraries
|
9
11
|
# to be shown.
|
@@ -16,3 +18,6 @@ Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
|
|
16
18
|
if ActiveSupport::TestCase.respond_to?(:fixture_path=)
|
17
19
|
ActiveSupport::TestCase.fixture_path = File.expand_path("../fixtures", __FILE__)
|
18
20
|
end
|
21
|
+
|
22
|
+
reporter_options = { color: true }
|
23
|
+
Minitest::Reporters.use! [Minitest::Reporters::DefaultReporter.new(reporter_options)]
|
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.3
|
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-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -44,8 +44,63 @@ dependencies:
|
|
44
44
|
- - "~>"
|
45
45
|
- !ruby/object:Gem::Version
|
46
46
|
version: '1.3'
|
47
|
-
|
48
|
-
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: minitest
|
49
|
+
requirement: !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - "~>"
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '5.5'
|
54
|
+
type: :development
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
requirements:
|
58
|
+
- - "~>"
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: '5.5'
|
61
|
+
- !ruby/object:Gem::Dependency
|
62
|
+
name: minitest-reporters
|
63
|
+
requirement: !ruby/object:Gem::Requirement
|
64
|
+
requirements:
|
65
|
+
- - "~>"
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: '1.0'
|
68
|
+
type: :development
|
69
|
+
prerelease: false
|
70
|
+
version_requirements: !ruby/object:Gem::Requirement
|
71
|
+
requirements:
|
72
|
+
- - "~>"
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: '1.0'
|
75
|
+
- !ruby/object:Gem::Dependency
|
76
|
+
name: minitest-rails
|
77
|
+
requirement: !ruby/object:Gem::Requirement
|
78
|
+
requirements:
|
79
|
+
- - "~>"
|
80
|
+
- !ruby/object:Gem::Version
|
81
|
+
version: '2.1'
|
82
|
+
type: :development
|
83
|
+
prerelease: false
|
84
|
+
version_requirements: !ruby/object:Gem::Requirement
|
85
|
+
requirements:
|
86
|
+
- - "~>"
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
version: '2.1'
|
89
|
+
- !ruby/object:Gem::Dependency
|
90
|
+
name: minitest-spec-rails
|
91
|
+
requirement: !ruby/object:Gem::Requirement
|
92
|
+
requirements:
|
93
|
+
- - "~>"
|
94
|
+
- !ruby/object:Gem::Version
|
95
|
+
version: '5.2'
|
96
|
+
type: :development
|
97
|
+
prerelease: false
|
98
|
+
version_requirements: !ruby/object:Gem::Requirement
|
99
|
+
requirements:
|
100
|
+
- - "~>"
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: '5.2'
|
103
|
+
description: A standard way to check belongs_to relations on any belongs_to Object
|
49
104
|
email:
|
50
105
|
- 6ftdan@gmail.com
|
51
106
|
executables: []
|
@@ -58,12 +113,14 @@ files:
|
|
58
113
|
- lib/poly_belongs_to.rb
|
59
114
|
- lib/poly_belongs_to/version.rb
|
60
115
|
- lib/tasks/poly_belongs_to_tasks.rake
|
61
|
-
- test/dummy/README.rdoc
|
62
116
|
- test/dummy/Rakefile
|
63
117
|
- test/dummy/app/assets/javascripts/application.js
|
64
118
|
- test/dummy/app/assets/stylesheets/application.css
|
65
119
|
- test/dummy/app/controllers/application_controller.rb
|
66
120
|
- test/dummy/app/helpers/application_helper.rb
|
121
|
+
- test/dummy/app/models/phone.rb
|
122
|
+
- test/dummy/app/models/tag.rb
|
123
|
+
- test/dummy/app/models/user.rb
|
67
124
|
- test/dummy/app/views/layouts/application.html.erb
|
68
125
|
- test/dummy/bin/bundle
|
69
126
|
- test/dummy/bin/rails
|
@@ -88,12 +145,23 @@ files:
|
|
88
145
|
- test/dummy/config/locales/en.yml
|
89
146
|
- test/dummy/config/routes.rb
|
90
147
|
- test/dummy/config/secrets.yml
|
148
|
+
- test/dummy/db/migrate/20150211224139_create_users.rb
|
149
|
+
- test/dummy/db/migrate/20150211224157_create_tags.rb
|
150
|
+
- test/dummy/db/migrate/20150211224225_create_phones.rb
|
151
|
+
- test/dummy/db/schema.rb
|
91
152
|
- test/dummy/db/test.sqlite3
|
153
|
+
- test/dummy/log/development.log
|
92
154
|
- test/dummy/log/test.log
|
93
155
|
- test/dummy/public/404.html
|
94
156
|
- test/dummy/public/422.html
|
95
157
|
- test/dummy/public/500.html
|
96
158
|
- test/dummy/public/favicon.ico
|
159
|
+
- test/dummy/test/models/phone_test.rb
|
160
|
+
- test/dummy/test/models/tag_test.rb
|
161
|
+
- test/dummy/test/models/user_test.rb
|
162
|
+
- test/fixtures/phones.yml
|
163
|
+
- test/fixtures/tags.yml
|
164
|
+
- test/fixtures/users.yml
|
97
165
|
- test/poly_belongs_to_test.rb
|
98
166
|
- test/test_helper.rb
|
99
167
|
homepage: https://github.com/danielpclark/PolyBelongsTo
|
@@ -119,11 +187,18 @@ rubyforge_project:
|
|
119
187
|
rubygems_version: 2.4.5
|
120
188
|
signing_key:
|
121
189
|
specification_version: 4
|
122
|
-
summary: Shorthand
|
190
|
+
summary: Shorthand belongs_to testing and universal identifiers.
|
123
191
|
test_files:
|
124
192
|
- test/poly_belongs_to_test.rb
|
193
|
+
- test/fixtures/phones.yml
|
194
|
+
- test/fixtures/users.yml
|
195
|
+
- test/fixtures/tags.yml
|
125
196
|
- test/test_helper.rb
|
126
197
|
- test/dummy/db/test.sqlite3
|
198
|
+
- test/dummy/db/schema.rb
|
199
|
+
- test/dummy/db/migrate/20150211224225_create_phones.rb
|
200
|
+
- test/dummy/db/migrate/20150211224157_create_tags.rb
|
201
|
+
- test/dummy/db/migrate/20150211224139_create_users.rb
|
127
202
|
- test/dummy/config/initializers/mime_types.rb
|
128
203
|
- test/dummy/config/initializers/session_store.rb
|
129
204
|
- test/dummy/config/initializers/assets.rb
|
@@ -142,9 +217,11 @@ test_files:
|
|
142
217
|
- test/dummy/config/locales/en.yml
|
143
218
|
- test/dummy/config/environment.rb
|
144
219
|
- test/dummy/config/database.yml
|
145
|
-
- test/dummy/README.rdoc
|
146
220
|
- test/dummy/app/controllers/application_controller.rb
|
147
221
|
- test/dummy/app/helpers/application_helper.rb
|
222
|
+
- test/dummy/app/models/user.rb
|
223
|
+
- test/dummy/app/models/phone.rb
|
224
|
+
- test/dummy/app/models/tag.rb
|
148
225
|
- test/dummy/app/views/layouts/application.html.erb
|
149
226
|
- test/dummy/app/assets/stylesheets/application.css
|
150
227
|
- test/dummy/app/assets/javascripts/application.js
|
@@ -155,7 +232,11 @@ test_files:
|
|
155
232
|
- test/dummy/Rakefile
|
156
233
|
- test/dummy/config.ru
|
157
234
|
- test/dummy/log/test.log
|
235
|
+
- test/dummy/log/development.log
|
158
236
|
- test/dummy/bin/rake
|
159
237
|
- test/dummy/bin/rails
|
160
238
|
- test/dummy/bin/bundle
|
161
239
|
- test/dummy/bin/setup
|
240
|
+
- test/dummy/test/models/tag_test.rb
|
241
|
+
- test/dummy/test/models/user_test.rb
|
242
|
+
- test/dummy/test/models/phone_test.rb
|
data/test/dummy/README.rdoc
DELETED
@@ -1,28 +0,0 @@
|
|
1
|
-
== README
|
2
|
-
|
3
|
-
This README would normally document whatever steps are necessary to get the
|
4
|
-
application up and running.
|
5
|
-
|
6
|
-
Things you may want to cover:
|
7
|
-
|
8
|
-
* Ruby version
|
9
|
-
|
10
|
-
* System dependencies
|
11
|
-
|
12
|
-
* Configuration
|
13
|
-
|
14
|
-
* Database creation
|
15
|
-
|
16
|
-
* Database initialization
|
17
|
-
|
18
|
-
* How to run the test suite
|
19
|
-
|
20
|
-
* Services (job queues, cache servers, search engines, etc.)
|
21
|
-
|
22
|
-
* Deployment instructions
|
23
|
-
|
24
|
-
* ...
|
25
|
-
|
26
|
-
|
27
|
-
Please feel free to use a different markup language if you do not plan to run
|
28
|
-
<tt>rake doc:app</tt>.
|