active_decorator 0.8.0 → 1.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- data/.gitignore +2 -0
- data/.travis.yml +92 -25
- data/CHANGELOG.md +52 -0
- data/Gemfile +1 -6
- data/README.md +68 -49
- data/Rakefile +5 -1
- data/active_decorator.gemspec +15 -4
- data/gemfiles/Gemfile-rails.4.2.x +4 -5
- data/gemfiles/Gemfile-rails.5.0.x +3 -5
- data/gemfiles/Gemfile-rails.5.1.x +6 -0
- data/gemfiles/Gemfile-rails.5.2.x +7 -0
- data/gemfiles/Gemfile-rails.6.0.x +7 -0
- data/gemfiles/Gemfile-rails.6.1.x +8 -0
- data/gemfiles/Gemfile-rails.edge +18 -0
- data/lib/active_decorator/config.rb +8 -1
- data/lib/active_decorator/decorated.rb +5 -0
- data/lib/active_decorator/decorator.rb +52 -20
- data/lib/active_decorator/helpers.rb +21 -7
- data/lib/active_decorator/monkey/abstract_controller/rendering.rb +3 -0
- data/lib/active_decorator/monkey/action_controller/base/rescue_from.rb +5 -2
- data/lib/active_decorator/monkey/action_view/collection_renderer.rb +12 -0
- data/lib/active_decorator/monkey/action_view/object_renderer.rb +12 -0
- data/lib/active_decorator/monkey/action_view/partial_renderer.rb +22 -8
- data/lib/active_decorator/monkey/active_record/associations.rb +61 -0
- data/lib/active_decorator/railtie.rb +36 -2
- data/lib/active_decorator/version.rb +2 -1
- data/lib/active_decorator/view_context.rb +19 -21
- data/lib/active_decorator.rb +6 -1
- data/lib/generators/rails/USAGE +8 -0
- data/lib/generators/rails/decorator_generator.rb +4 -13
- data/lib/generators/rails/templates/decorator.rb +2 -0
- data/lib/generators/rspec/decorator_generator.rb +7 -4
- data/lib/generators/rspec/templates/decorator_spec.rb +4 -2
- data/lib/generators/test_unit/decorator_generator.rb +8 -4
- data/lib/generators/test_unit/templates/decorator_test.rb +4 -2
- metadata +133 -57
- data/gemfiles/Gemfile-rails.3.2.x +0 -11
- data/gemfiles/Gemfile-rails.4.0.x +0 -9
- data/gemfiles/Gemfile-rails.4.1.x +0 -9
- data/test/configuration_test.rb +0 -27
- data/test/controllers/fake_detection_test.rb +0 -9
- data/test/fake_app/app/views/authors/index.html.erb +0 -16
- data/test/fake_app/app/views/authors/show.html.erb +0 -2
- data/test/fake_app/app/views/authors/show.json.jbuilder +0 -3
- data/test/fake_app/app/views/book_mailer/thanks.text.erb +0 -1
- data/test/fake_app/app/views/books/_book.html.erb +0 -2
- data/test/fake_app/app/views/books/_book.json.jbuilder +0 -3
- data/test/fake_app/app/views/books/_book_locals.html.erb +0 -2
- data/test/fake_app/app/views/books/errata.html.erb +0 -1
- data/test/fake_app/app/views/books/error.html.erb +0 -1
- data/test/fake_app/app/views/books/index.html.erb +0 -4
- data/test/fake_app/app/views/books/purchase.html.erb +0 -1
- data/test/fake_app/app/views/books/show.html.erb +0 -4
- data/test/fake_app/app/views/movies/show.html.erb +0 -1
- data/test/fake_app/fake_app.rb +0 -198
- data/test/features/action_view_helpers_test.rb +0 -37
- data/test/features/controller_ivar_test.rb +0 -40
- data/test/features/jbuilder_test.rb +0 -15
- data/test/features/name_error_handling_test.rb +0 -17
- data/test/features/partial_test.rb +0 -28
- data/test/test_helper.rb +0 -30
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
require 'test_helper'
|
|
3
|
-
|
|
4
|
-
class NameErrorHandlingTest < ActionDispatch::IntegrationTest
|
|
5
|
-
setup do
|
|
6
|
-
aamine = Author.create! name: 'aamine'
|
|
7
|
-
@rhg = aamine.books.create! title: 'RHG'
|
|
8
|
-
end
|
|
9
|
-
|
|
10
|
-
test 'raising NameError in a decorator' do
|
|
11
|
-
err = assert_raises ActionView::Template::Error do
|
|
12
|
-
visit "/authors/#{@rhg.author.id}/books/#{@rhg.id}/errata"
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
assert_match(/undefined method `poof!` for/, err.message)
|
|
16
|
-
end
|
|
17
|
-
end
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
require 'test_helper'
|
|
3
|
-
|
|
4
|
-
class PartialTest < ActionDispatch::IntegrationTest
|
|
5
|
-
setup do
|
|
6
|
-
Author.create! name: 'aamine'
|
|
7
|
-
nari = Author.create! name: 'nari'
|
|
8
|
-
nari.books.create! title: 'the gc book'
|
|
9
|
-
end
|
|
10
|
-
|
|
11
|
-
test 'decorating implicit @object' do
|
|
12
|
-
visit '/authors'
|
|
13
|
-
assert page.has_content? 'the gc book'
|
|
14
|
-
assert page.has_content? 'the gc book'.reverse
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
test 'decorating implicit @collection' do
|
|
18
|
-
visit '/authors?partial=collection'
|
|
19
|
-
assert page.has_content? 'the gc book'
|
|
20
|
-
assert page.has_content? 'the gc book'.reverse
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
test 'decorating objects in @locals' do
|
|
24
|
-
visit '/authors?partial=locals'
|
|
25
|
-
assert page.has_content? 'the gc book'
|
|
26
|
-
assert page.has_content? 'the gc book'.upcase
|
|
27
|
-
end
|
|
28
|
-
end
|
data/test/test_helper.rb
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
|
3
|
-
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
|
4
|
-
# load Rails first
|
|
5
|
-
require 'rails'
|
|
6
|
-
|
|
7
|
-
# load the plugin
|
|
8
|
-
require 'active_decorator'
|
|
9
|
-
|
|
10
|
-
# needs to load the app next
|
|
11
|
-
require 'fake_app/fake_app'
|
|
12
|
-
|
|
13
|
-
require 'test/unit/rails/test_help'
|
|
14
|
-
|
|
15
|
-
class ActionDispatch::IntegrationTest
|
|
16
|
-
include Capybara::DSL
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
module DatabaseDeleter
|
|
20
|
-
def setup
|
|
21
|
-
Book.delete_all
|
|
22
|
-
Author.delete_all
|
|
23
|
-
Movie.delete_all
|
|
24
|
-
super
|
|
25
|
-
end
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
Test::Unit::TestCase.send :prepend, DatabaseDeleter
|
|
29
|
-
|
|
30
|
-
CreateAllTables.up unless ActiveRecord::Base.connection.table_exists? 'authors'
|