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.
Files changed (62) hide show
  1. checksums.yaml +5 -5
  2. data/.gitignore +2 -0
  3. data/.travis.yml +92 -25
  4. data/CHANGELOG.md +52 -0
  5. data/Gemfile +1 -6
  6. data/README.md +68 -49
  7. data/Rakefile +5 -1
  8. data/active_decorator.gemspec +15 -4
  9. data/gemfiles/Gemfile-rails.4.2.x +4 -5
  10. data/gemfiles/Gemfile-rails.5.0.x +3 -5
  11. data/gemfiles/Gemfile-rails.5.1.x +6 -0
  12. data/gemfiles/Gemfile-rails.5.2.x +7 -0
  13. data/gemfiles/Gemfile-rails.6.0.x +7 -0
  14. data/gemfiles/Gemfile-rails.6.1.x +8 -0
  15. data/gemfiles/Gemfile-rails.edge +18 -0
  16. data/lib/active_decorator/config.rb +8 -1
  17. data/lib/active_decorator/decorated.rb +5 -0
  18. data/lib/active_decorator/decorator.rb +52 -20
  19. data/lib/active_decorator/helpers.rb +21 -7
  20. data/lib/active_decorator/monkey/abstract_controller/rendering.rb +3 -0
  21. data/lib/active_decorator/monkey/action_controller/base/rescue_from.rb +5 -2
  22. data/lib/active_decorator/monkey/action_view/collection_renderer.rb +12 -0
  23. data/lib/active_decorator/monkey/action_view/object_renderer.rb +12 -0
  24. data/lib/active_decorator/monkey/action_view/partial_renderer.rb +22 -8
  25. data/lib/active_decorator/monkey/active_record/associations.rb +61 -0
  26. data/lib/active_decorator/railtie.rb +36 -2
  27. data/lib/active_decorator/version.rb +2 -1
  28. data/lib/active_decorator/view_context.rb +19 -21
  29. data/lib/active_decorator.rb +6 -1
  30. data/lib/generators/rails/USAGE +8 -0
  31. data/lib/generators/rails/decorator_generator.rb +4 -13
  32. data/lib/generators/rails/templates/decorator.rb +2 -0
  33. data/lib/generators/rspec/decorator_generator.rb +7 -4
  34. data/lib/generators/rspec/templates/decorator_spec.rb +4 -2
  35. data/lib/generators/test_unit/decorator_generator.rb +8 -4
  36. data/lib/generators/test_unit/templates/decorator_test.rb +4 -2
  37. metadata +133 -57
  38. data/gemfiles/Gemfile-rails.3.2.x +0 -11
  39. data/gemfiles/Gemfile-rails.4.0.x +0 -9
  40. data/gemfiles/Gemfile-rails.4.1.x +0 -9
  41. data/test/configuration_test.rb +0 -27
  42. data/test/controllers/fake_detection_test.rb +0 -9
  43. data/test/fake_app/app/views/authors/index.html.erb +0 -16
  44. data/test/fake_app/app/views/authors/show.html.erb +0 -2
  45. data/test/fake_app/app/views/authors/show.json.jbuilder +0 -3
  46. data/test/fake_app/app/views/book_mailer/thanks.text.erb +0 -1
  47. data/test/fake_app/app/views/books/_book.html.erb +0 -2
  48. data/test/fake_app/app/views/books/_book.json.jbuilder +0 -3
  49. data/test/fake_app/app/views/books/_book_locals.html.erb +0 -2
  50. data/test/fake_app/app/views/books/errata.html.erb +0 -1
  51. data/test/fake_app/app/views/books/error.html.erb +0 -1
  52. data/test/fake_app/app/views/books/index.html.erb +0 -4
  53. data/test/fake_app/app/views/books/purchase.html.erb +0 -1
  54. data/test/fake_app/app/views/books/show.html.erb +0 -4
  55. data/test/fake_app/app/views/movies/show.html.erb +0 -1
  56. data/test/fake_app/fake_app.rb +0 -198
  57. data/test/features/action_view_helpers_test.rb +0 -37
  58. data/test/features/controller_ivar_test.rb +0 -40
  59. data/test/features/jbuilder_test.rb +0 -15
  60. data/test/features/name_error_handling_test.rb +0 -17
  61. data/test/features/partial_test.rb +0 -28
  62. 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'