has_many_polymorphic 2.0.5 → 3.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (62) hide show
  1. checksums.yaml +4 -4
  2. data/lib/has_many_polymorphic/has_many_polymorphic.rb +14 -25
  3. data/lib/has_many_polymorphic/version.rb +7 -1
  4. data/spec/dummy/Rakefile +6 -0
  5. data/spec/dummy/app/assets/config/manifest.js +5 -0
  6. data/spec/dummy/app/assets/javascripts/application.js +13 -0
  7. data/spec/dummy/app/assets/javascripts/cable.js +13 -0
  8. data/spec/dummy/app/assets/stylesheets/application.css +15 -0
  9. data/spec/dummy/app/channels/application_cable/channel.rb +4 -0
  10. data/spec/dummy/app/channels/application_cable/connection.rb +4 -0
  11. data/spec/dummy/app/controllers/application_controller.rb +3 -0
  12. data/spec/dummy/app/helpers/application_helper.rb +2 -0
  13. data/spec/dummy/app/jobs/application_job.rb +2 -0
  14. data/spec/dummy/app/mailers/application_mailer.rb +4 -0
  15. data/spec/dummy/app/models/application_record.rb +3 -0
  16. data/spec/dummy/app/views/layouts/application.html.erb +14 -0
  17. data/spec/dummy/app/views/layouts/mailer.html.erb +13 -0
  18. data/spec/dummy/app/views/layouts/mailer.text.erb +1 -0
  19. data/spec/dummy/bin/bundle +3 -0
  20. data/spec/dummy/bin/rails +4 -0
  21. data/spec/dummy/bin/rake +4 -0
  22. data/spec/dummy/bin/setup +38 -0
  23. data/spec/dummy/bin/update +29 -0
  24. data/spec/dummy/bin/yarn +11 -0
  25. data/spec/dummy/config.ru +5 -0
  26. data/spec/dummy/config/application.rb +17 -0
  27. data/spec/dummy/config/boot.rb +5 -0
  28. data/spec/dummy/config/cable.yml +10 -0
  29. data/spec/dummy/config/database.yml +12 -0
  30. data/spec/dummy/config/environment.rb +5 -0
  31. data/spec/dummy/config/environments/development.rb +54 -0
  32. data/spec/dummy/config/environments/production.rb +91 -0
  33. data/spec/dummy/config/environments/spec.rb +42 -0
  34. data/spec/dummy/config/initializers/application_controller_renderer.rb +8 -0
  35. data/spec/dummy/config/initializers/assets.rb +14 -0
  36. data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
  37. data/spec/dummy/config/initializers/cookies_serializer.rb +5 -0
  38. data/spec/dummy/config/initializers/filter_parameter_logging.rb +4 -0
  39. data/spec/dummy/config/initializers/inflections.rb +16 -0
  40. data/spec/dummy/config/initializers/mime_types.rb +4 -0
  41. data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
  42. data/spec/dummy/config/locales/en.yml +33 -0
  43. data/spec/dummy/config/puma.rb +56 -0
  44. data/spec/dummy/config/routes.rb +2 -0
  45. data/spec/dummy/config/secrets.yml +32 -0
  46. data/spec/dummy/config/spring.rb +6 -0
  47. data/spec/{db → dummy/db}/schema.rb +6 -6
  48. data/spec/dummy/db/spec.sqlite3 +0 -0
  49. data/spec/dummy/log/spec.log +40658 -0
  50. data/spec/dummy/package.json +5 -0
  51. data/spec/dummy/public/404.html +67 -0
  52. data/spec/dummy/public/422.html +67 -0
  53. data/spec/dummy/public/500.html +66 -0
  54. data/spec/dummy/public/apple-touch-icon-precomposed.png +0 -0
  55. data/spec/dummy/public/apple-touch-icon.png +0 -0
  56. data/spec/dummy/public/favicon.ico +0 -0
  57. data/spec/{has_many_polymorphic_spec.rb → lib/has_many_polymorphic_spec.rb} +5 -4
  58. data/spec/spec_helper.rb +22 -7
  59. data/spec/support/models.rb +13 -10
  60. metadata +66 -30
  61. data/spec/db/database.yml +0 -3
  62. data/spec/debug.log +0 -48
@@ -0,0 +1,5 @@
1
+ {
2
+ "name": "dummy",
3
+ "private": true,
4
+ "dependencies": {}
5
+ }
@@ -0,0 +1,67 @@
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
+ .rails-default-error-page {
8
+ background-color: #EFEFEF;
9
+ color: #2E2F30;
10
+ text-align: center;
11
+ font-family: arial, sans-serif;
12
+ margin: 0;
13
+ }
14
+
15
+ .rails-default-error-page div.dialog {
16
+ width: 95%;
17
+ max-width: 33em;
18
+ margin: 4em auto 0;
19
+ }
20
+
21
+ .rails-default-error-page 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
+ .rails-default-error-page h1 {
35
+ font-size: 100%;
36
+ color: #730E15;
37
+ line-height: 1.5em;
38
+ }
39
+
40
+ .rails-default-error-page 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 class="rails-default-error-page">
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>
@@ -0,0 +1,67 @@
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
+ .rails-default-error-page {
8
+ background-color: #EFEFEF;
9
+ color: #2E2F30;
10
+ text-align: center;
11
+ font-family: arial, sans-serif;
12
+ margin: 0;
13
+ }
14
+
15
+ .rails-default-error-page div.dialog {
16
+ width: 95%;
17
+ max-width: 33em;
18
+ margin: 4em auto 0;
19
+ }
20
+
21
+ .rails-default-error-page 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
+ .rails-default-error-page h1 {
35
+ font-size: 100%;
36
+ color: #730E15;
37
+ line-height: 1.5em;
38
+ }
39
+
40
+ .rails-default-error-page 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 class="rails-default-error-page">
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>
@@ -0,0 +1,66 @@
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
+ .rails-default-error-page {
8
+ background-color: #EFEFEF;
9
+ color: #2E2F30;
10
+ text-align: center;
11
+ font-family: arial, sans-serif;
12
+ margin: 0;
13
+ }
14
+
15
+ .rails-default-error-page div.dialog {
16
+ width: 95%;
17
+ max-width: 33em;
18
+ margin: 4em auto 0;
19
+ }
20
+
21
+ .rails-default-error-page 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
+ .rails-default-error-page h1 {
35
+ font-size: 100%;
36
+ color: #730E15;
37
+ line-height: 1.5em;
38
+ }
39
+
40
+ .rails-default-error-page 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 class="rails-default-error-page">
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>
File without changes
File without changes
@@ -8,14 +8,14 @@ describe "HasManyPolymorphic" do
8
8
  Monkey.create(:name => 'George')
9
9
  end
10
10
 
11
- it "have created the animals and zoo" do
11
+ it "has created the animals and zoo" do
12
12
  expect(Zoo.first.name).eql?'Zoo Lander'
13
13
  expect(Monkey.find_by_name('George').name).eql? 'George'
14
14
  expect(Bird.find_by_name('Big Bird').name).eql? 'Big Bird'
15
15
  expect(Bear.find_by_name('Smokey').name).eql? 'Smokey'
16
16
  end
17
17
 
18
- it "allow you to add animals to a zoo" do
18
+ it "allows you to add animals to a zoo" do
19
19
  zoo = Zoo.first
20
20
  expect(zoo.animals.count).eql? 0
21
21
  zoo.monkeys << Monkey.find_by_name('George')
@@ -35,13 +35,14 @@ describe "HasManyPolymorphic" do
35
35
  expect(zoo.animals.count).eql? 3
36
36
  end
37
37
 
38
- it "allow you to get the zoo from an animal" do
38
+ it "allows you to get the zoo from an animal" do
39
39
  zoo = Zoo.first
40
40
 
41
41
  zoo.monkeys << Monkey.find_by_name('George')
42
42
  zoo.birds << Bird.find_by_name('Big Bird')
43
43
  zoo.bears << Bear.find_by_name('Smokey')
44
- zoo.save
44
+
45
+ zoo.save!
45
46
 
46
47
  monkey = Monkey.find_by_name('George')
47
48
  expect(monkey.zoos.first.id).eql? zoo.id
@@ -1,5 +1,4 @@
1
1
  $:.unshift(File.dirname(__FILE__) + '/../lib')
2
- plugin_test_dir = File.dirname(__FILE__)
3
2
 
4
3
  require 'rubygems'
5
4
  require 'bundler/setup'
@@ -9,16 +8,32 @@ require 'active_model'
9
8
  require 'active_record'
10
9
  require 'action_controller'
11
10
  require 'simplecov'
12
- require 'rspec/rails'
11
+
12
+ DUMMY_APP_ROOT=File.join(File.dirname(__FILE__), '/dummy')
13
13
 
14
14
  SimpleCov.start
15
15
 
16
- require 'has_many_polymorphic'
17
- require 'support/models'
16
+ # Configure Rails Envinronment
17
+ ENV["RAILS_ENV"] = "spec"
18
+ require File.expand_path(DUMMY_APP_ROOT + "/config/environment.rb", __FILE__)
18
19
 
19
- ActiveRecord::Base.configurations = YAML::load(ERB.new(IO.read(plugin_test_dir + "/db/database.yml")).result)
20
- ActiveRecord::Base.establish_connection(ENV["DB"] || "spec")
20
+ ActiveRecord::Base.configurations = YAML::load(IO.read(DUMMY_APP_ROOT + "/config/database.yml"))
21
+ #ActiveRecord::Base.establish_connection(ENV["RAILS_ENV"])
21
22
  ActiveRecord::Migration.verbose = false
22
- load(File.join(plugin_test_dir, "db", "schema.rb"))
23
+
24
+ load(File.join(DUMMY_APP_ROOT, "db", "schema.rb"))
25
+
26
+ Rails.backtrace_cleaner.remove_silencers!
27
+
28
+ require 'rspec/rails'
29
+
30
+ RSpec.configure do |config|
31
+ config.infer_spec_type_from_file_location!
32
+ config.mock_with :rspec
33
+ config.use_transactional_fixtures = true
34
+ config.infer_base_class_for_anonymous_controllers = false
35
+ end
36
+
37
+ require 'support/models'
23
38
 
24
39
  RussellEdge::HasManyPolymorphic::Engine.add_models("Zoo")
@@ -1,20 +1,23 @@
1
- class Monkey < ActiveRecord::Base
1
+ class ApplicationRecord < ActiveRecord::Base
2
+ self.abstract_class = true
2
3
  end
3
4
 
4
- class Bird < ActiveRecord::Base
5
+ class Monkey < ApplicationRecord
5
6
  end
6
7
 
7
- class Bear < ActiveRecord::Base
8
+ class Bird < ApplicationRecord
8
9
  end
9
10
 
10
- class ZooAnimal < ActiveRecord::Base
11
- belongs_to :zoo
12
- belongs_to :animal, :polymorphic => true
11
+ class Bear < ApplicationRecord
13
12
  end
14
13
 
15
- class Zoo < ActiveRecord::Base
16
- has_many_polymorphic :animals,
17
- :through => :zoo_animals,
18
- :models => [:monkeys, :birds, :bears]
14
+ class ZooAnimal < ApplicationRecord
15
+ belongs_to :zoo, optional: true
16
+ belongs_to :animal, :polymorphic => true, optional: true
19
17
  end
20
18
 
19
+ class Zoo < ApplicationRecord
20
+ has_many_polymorphic :animals,
21
+ :through => :zoo_animals,
22
+ :models => [:monkeys, :birds, :bears]
23
+ end
metadata CHANGED
@@ -1,71 +1,57 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: has_many_polymorphic
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.5
4
+ version: 3.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Russell Holmes
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-09-06 00:00:00.000000000 Z
11
+ date: 2018-05-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
18
- - !ruby/object:Gem::Version
19
- version: '3.2'
20
- type: :runtime
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - "~>"
17
+ - - "<="
25
18
  - !ruby/object:Gem::Version
26
- version: '3.2'
27
- - !ruby/object:Gem::Dependency
28
- name: test-unit
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - "~>"
32
- - !ruby/object:Gem::Version
33
- version: '3.0'
19
+ version: '5.3'
34
20
  type: :runtime
35
21
  prerelease: false
36
22
  version_requirements: !ruby/object:Gem::Requirement
37
23
  requirements:
38
- - - "~>"
24
+ - - "<="
39
25
  - !ruby/object:Gem::Version
40
- version: '3.0'
26
+ version: '5.3'
41
27
  - !ruby/object:Gem::Dependency
42
28
  name: rspec-rails
43
29
  requirement: !ruby/object:Gem::Requirement
44
30
  requirements:
45
31
  - - "~>"
46
32
  - !ruby/object:Gem::Version
47
- version: '3.6'
33
+ version: 3.7.2
48
34
  type: :runtime
49
35
  prerelease: false
50
36
  version_requirements: !ruby/object:Gem::Requirement
51
37
  requirements:
52
38
  - - "~>"
53
39
  - !ruby/object:Gem::Version
54
- version: '3.6'
40
+ version: 3.7.2
55
41
  - !ruby/object:Gem::Dependency
56
42
  name: simplecov
57
43
  requirement: !ruby/object:Gem::Requirement
58
44
  requirements:
59
45
  - - "~>"
60
46
  - !ruby/object:Gem::Version
61
- version: '0.15'
47
+ version: 0.15.1
62
48
  type: :runtime
63
49
  prerelease: false
64
50
  version_requirements: !ruby/object:Gem::Requirement
65
51
  requirements:
66
52
  - - "~>"
67
53
  - !ruby/object:Gem::Version
68
- version: '0.15'
54
+ version: 0.15.1
69
55
  - !ruby/object:Gem::Dependency
70
56
  name: sqlite3
71
57
  requirement: !ruby/object:Gem::Requirement
@@ -73,7 +59,7 @@ dependencies:
73
59
  - - ">="
74
60
  - !ruby/object:Gem::Version
75
61
  version: '0'
76
- type: :development
62
+ type: :runtime
77
63
  prerelease: false
78
64
  version_requirements: !ruby/object:Gem::Requirement
79
65
  requirements:
@@ -93,10 +79,60 @@ files:
93
79
  - lib/has_many_polymorphic/engine.rb
94
80
  - lib/has_many_polymorphic/has_many_polymorphic.rb
95
81
  - lib/has_many_polymorphic/version.rb
96
- - spec/db/database.yml
97
- - spec/db/schema.rb
98
- - spec/debug.log
99
- - spec/has_many_polymorphic_spec.rb
82
+ - spec/dummy/Rakefile
83
+ - spec/dummy/app/assets/config/manifest.js
84
+ - spec/dummy/app/assets/javascripts/application.js
85
+ - spec/dummy/app/assets/javascripts/cable.js
86
+ - spec/dummy/app/assets/stylesheets/application.css
87
+ - spec/dummy/app/channels/application_cable/channel.rb
88
+ - spec/dummy/app/channels/application_cable/connection.rb
89
+ - spec/dummy/app/controllers/application_controller.rb
90
+ - spec/dummy/app/helpers/application_helper.rb
91
+ - spec/dummy/app/jobs/application_job.rb
92
+ - spec/dummy/app/mailers/application_mailer.rb
93
+ - spec/dummy/app/models/application_record.rb
94
+ - spec/dummy/app/views/layouts/application.html.erb
95
+ - spec/dummy/app/views/layouts/mailer.html.erb
96
+ - spec/dummy/app/views/layouts/mailer.text.erb
97
+ - spec/dummy/bin/bundle
98
+ - spec/dummy/bin/rails
99
+ - spec/dummy/bin/rake
100
+ - spec/dummy/bin/setup
101
+ - spec/dummy/bin/update
102
+ - spec/dummy/bin/yarn
103
+ - spec/dummy/config.ru
104
+ - spec/dummy/config/application.rb
105
+ - spec/dummy/config/boot.rb
106
+ - spec/dummy/config/cable.yml
107
+ - spec/dummy/config/database.yml
108
+ - spec/dummy/config/environment.rb
109
+ - spec/dummy/config/environments/development.rb
110
+ - spec/dummy/config/environments/production.rb
111
+ - spec/dummy/config/environments/spec.rb
112
+ - spec/dummy/config/initializers/application_controller_renderer.rb
113
+ - spec/dummy/config/initializers/assets.rb
114
+ - spec/dummy/config/initializers/backtrace_silencers.rb
115
+ - spec/dummy/config/initializers/cookies_serializer.rb
116
+ - spec/dummy/config/initializers/filter_parameter_logging.rb
117
+ - spec/dummy/config/initializers/inflections.rb
118
+ - spec/dummy/config/initializers/mime_types.rb
119
+ - spec/dummy/config/initializers/wrap_parameters.rb
120
+ - spec/dummy/config/locales/en.yml
121
+ - spec/dummy/config/puma.rb
122
+ - spec/dummy/config/routes.rb
123
+ - spec/dummy/config/secrets.yml
124
+ - spec/dummy/config/spring.rb
125
+ - spec/dummy/db/schema.rb
126
+ - spec/dummy/db/spec.sqlite3
127
+ - spec/dummy/log/spec.log
128
+ - spec/dummy/package.json
129
+ - spec/dummy/public/404.html
130
+ - spec/dummy/public/422.html
131
+ - spec/dummy/public/500.html
132
+ - spec/dummy/public/apple-touch-icon-precomposed.png
133
+ - spec/dummy/public/apple-touch-icon.png
134
+ - spec/dummy/public/favicon.ico
135
+ - spec/lib/has_many_polymorphic_spec.rb
100
136
  - spec/spec_helper.rb
101
137
  - spec/support/models.rb
102
138
  homepage: https://github.com/russ1985/has_many_polymorphic
@@ -118,7 +154,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
118
154
  version: '0'
119
155
  requirements: []
120
156
  rubyforge_project:
121
- rubygems_version: 2.4.8
157
+ rubygems_version: 2.6.13
122
158
  signing_key:
123
159
  specification_version: 4
124
160
  summary: Simple replacement for has_many_polymorphs