active_decorator 1.3.0 → 1.3.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 39935554e752b75933ebf759c5173fc67b451c077c6cb3d18c48af54f9b4192c
4
- data.tar.gz: 6917e250174825e7ead1ffaa69ad4614ba6aa1070bd53d6e84aa2b2c15faef47
3
+ metadata.gz: 9312dab89b8f57877eac8447beff11151b7399640c9a457aa51d9251a0779792
4
+ data.tar.gz: d09cceaf7f064a6536d983fdb577bdbca11aba51046faaee021887ca112b1bed
5
5
  SHA512:
6
- metadata.gz: 1acb7ae8ea1a3a263d59611d3819036eb6aa303a3dfc3b55b0a6eb9eaef4b26412ed6c74aea6580ef1435aaab4a62360b7464e75130004f3da1d563f49a321c3
7
- data.tar.gz: 69b9d07798170f1944cdd98a396b880232ed44278167ae0db3760aebdfc83a86f8f9fcf9846ec8008594bbb28e6285b9537fef3c19805ebbe3d17b47dd3e589d
6
+ metadata.gz: f1d98fea1b67c618239dc865b913a8f1ccf32097ca19b7e2adc2679bb3668ce57a981ddcc5940aa3b5388d85ac7fe01eb4cd51bd8005944253016112d53e5c1c
7
+ data.tar.gz: 9314835959902259af91f0909abd3b299dc7b7a30730323b235e51a231d8d9ce644145c457cfeae526b18a600dbf3561dcbf9072219ad17a9d980a1ec3c0595a
@@ -1,3 +1,7 @@
1
+ ## 1.3.1
2
+
3
+ * Switched back from Ruby's `const_get` to Active Support `constantize` for fetching decorator modules, due to inability to properly detect namespaced decorator [@sinsoku]
4
+
1
5
  ## 1.3.0
2
6
 
3
7
  * Switched from Active Support `constantize` to Ruby's `const_get` when fetching decorator modules
@@ -18,6 +18,8 @@ Gem::Specification.new do |s|
18
18
  s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
19
19
  s.require_paths = ["lib"]
20
20
 
21
+ s.add_dependency 'activesupport'
22
+
21
23
  s.add_development_dependency 'test-unit-rails'
22
24
  s.add_development_dependency 'selenium-webdriver'
23
25
  s.add_development_dependency 'puma'
@@ -2,4 +2,4 @@ source 'https://rubygems.org'
2
2
 
3
3
  gemspec path: '..'
4
4
 
5
- gem 'rails', '~> 6.0.0.rc1'
5
+ gem 'rails', '~> 6.0.0.rc2'
@@ -69,7 +69,7 @@ module ActiveDecorator
69
69
  return @@decorators[model_class] if @@decorators.key? model_class
70
70
 
71
71
  decorator_name = "#{model_class.name}#{ActiveDecorator.config.decorator_suffix}"
72
- d = Object.const_get decorator_name, false
72
+ d = decorator_name.constantize
73
73
  unless Class === d
74
74
  d.send :include, ActiveDecorator::Helpers
75
75
  @@decorators[model_class] = d
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ActiveDecorator
4
- VERSION = '1.3.0'
4
+ VERSION = '1.3.1'
5
5
  end
@@ -1,2 +1,4 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module <%= class_name %>Decorator
2
4
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require '<%= File.exists?('spec/rails_helper.rb') ? 'rails_helper' : 'spec_helper' %>'
2
4
 
3
5
  RSpec.describe <%= class_name %>Decorator do
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'test_helper'
2
4
 
3
5
  class <%= class_name %>DecoratorTest < ActiveSupport::TestCase
@@ -48,4 +48,11 @@ class DecoratorTest < Test::Unit::TestCase
48
48
  assert value.is_a?(BookDecorator)
49
49
  end
50
50
  end
51
+
52
+ test "Don't use the wrong decorator for nested classes" do
53
+ comic = Foo::Comic.new
54
+
55
+ assert_equal comic, ActiveDecorator::Decorator.instance.decorate(comic)
56
+ assert !comic.is_a?(ComicDecorator)
57
+ end
51
58
  end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ # decorator to test auto-loading behavior
4
+ # this module is intended not to be loaded.
5
+ module ComicDecorator; end
@@ -277,3 +277,7 @@ class RelationProxy < BasicObject
277
277
  @ar_relation.public_send(method, *args, &block)
278
278
  end
279
279
  end
280
+
281
+ module Foo
282
+ class Comic; end
283
+ end
metadata CHANGED
@@ -1,15 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_decorator
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.0
4
+ version: 1.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Akira Matsuda
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-06-28 00:00:00.000000000 Z
11
+ date: 2019-08-16 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: activesupport
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
13
27
  - !ruby/object:Gem::Dependency
14
28
  name: test-unit-rails
15
29
  requirement: !ruby/object:Gem::Requirement
@@ -165,6 +179,7 @@ files:
165
179
  - test/configuration_test.rb
166
180
  - test/controllers/fake_detection_test.rb
167
181
  - test/decorator_test.rb
182
+ - test/fake_app/app/decorators/comic_decorator.rb
168
183
  - test/fake_app/app/views/api/bookstores/show.json.jbuilder
169
184
  - test/fake_app/app/views/authors/index.html.erb
170
185
  - test/fake_app/app/views/authors/show.html.erb
@@ -218,6 +233,7 @@ test_files:
218
233
  - test/configuration_test.rb
219
234
  - test/controllers/fake_detection_test.rb
220
235
  - test/decorator_test.rb
236
+ - test/fake_app/app/decorators/comic_decorator.rb
221
237
  - test/fake_app/app/views/api/bookstores/show.json.jbuilder
222
238
  - test/fake_app/app/views/authors/index.html.erb
223
239
  - test/fake_app/app/views/authors/show.html.erb