draper 1.1.0 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (40) hide show
  1. checksums.yaml +7 -0
  2. data/.travis.yml +7 -0
  3. data/CHANGELOG.md +140 -120
  4. data/Gemfile +5 -3
  5. data/Guardfile +22 -1
  6. data/README.md +4 -3
  7. data/draper.gemspec +3 -1
  8. data/lib/draper.rb +6 -0
  9. data/lib/draper/automatic_delegation.rb +8 -2
  10. data/lib/draper/collection_decorator.rb +17 -28
  11. data/lib/draper/decoratable.rb +6 -3
  12. data/lib/draper/decoratable/equality.rb +15 -3
  13. data/lib/draper/decorated_association.rb +11 -50
  14. data/lib/draper/decorates_assigned.rb +44 -0
  15. data/lib/draper/decorator.rb +19 -6
  16. data/lib/draper/factory.rb +87 -0
  17. data/lib/draper/helper_proxy.rb +2 -0
  18. data/lib/draper/railtie.rb +8 -2
  19. data/lib/draper/version.rb +1 -1
  20. data/lib/generators/decorator/decorator_generator.rb +9 -9
  21. data/spec/draper/collection_decorator_spec.rb +48 -28
  22. data/spec/draper/decoratable_spec.rb +13 -4
  23. data/spec/draper/decorated_association_spec.rb +53 -114
  24. data/spec/draper/decorates_assigned_spec.rb +71 -0
  25. data/spec/draper/decorator_spec.rb +58 -8
  26. data/spec/draper/factory_spec.rb +238 -0
  27. data/spec/draper/helper_proxy_spec.rb +11 -0
  28. data/spec/draper/lazy_helpers_spec.rb +21 -0
  29. data/spec/dummy/app/controllers/posts_controller.rb +3 -1
  30. data/spec/dummy/app/decorators/mongoid_post_decorator.rb +2 -0
  31. data/spec/dummy/app/views/posts/show.html.erb +1 -1
  32. data/spec/dummy/config/application.rb +1 -0
  33. data/spec/dummy/spec/decorators/active_model_serializers_spec.rb +11 -0
  34. data/spec/dummy/spec/decorators/post_decorator_spec.rb +12 -0
  35. data/spec/dummy/spec/models/mongoid_post_spec.rb +2 -4
  36. data/spec/dummy/spec/models/post_spec.rb +2 -10
  37. data/spec/dummy/spec/shared_examples/decoratable.rb +24 -0
  38. data/spec/generators/decorator/decorator_generator_spec.rb +83 -91
  39. data/spec/spec_helper.rb +1 -0
  40. metadata +50 -43
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 6999024e08aa85abe3f852f42feb88106ac36526
4
+ data.tar.gz: 17506815fb0541ee7cdb93edf9c276341ebcc6a9
5
+ SHA512:
6
+ metadata.gz: 8f0a6c592cf8855a39842d4d158497f27d600bc42bd6e4fcab2ebd0989dfed5d9ba813dcc6830f19955fce994decca51a6acb336669332704c2c6fbdff287bc9
7
+ data.tar.gz: 737723f0cf15ebf8badc8279359e559f03214a0ab88157f67fcd7ec1365fc79e8e66a29f5bff436474615c3c02e48b57f254d1c858f15925b542093b8c5250cb
@@ -1,14 +1,21 @@
1
1
  language: ruby
2
+
3
+ services:
4
+ - mongodb
5
+
2
6
  rvm:
3
7
  - 1.9.3
8
+ - 2.0.0
4
9
  - rbx-19mode
5
10
  - jruby-19mode
6
11
  - ruby-head
12
+
7
13
  env:
8
14
  - "RAILS_VERSION=3.2"
9
15
  - "RAILS_VERSION=3.1"
10
16
  - "RAILS_VERSION=3.0"
11
17
  - "RAILS_VERSION=master"
18
+
12
19
  matrix:
13
20
  allow_failures:
14
21
  - rvm: ruby-head
@@ -1,164 +1,184 @@
1
1
  # Draper Changelog
2
2
 
3
- ## 1.0.0
4
-
5
- Major changes from 0.18.0 to 1.0.0 are outlined [in the wiki](https://github.com/drapergem/draper/wiki/Upgrading-to-1.0).
6
-
7
-
8
- * Infer collection decorators. [https://github.com/drapergem/draper/commit/e8253df7dc6c90a542444c0f4ef289909fce4f90](https://github.com/drapergem/draper/commit/e8253df7dc6c90a542444c0f4ef289909fce4f90)
9
-
10
- * Prevent calls to `scoped` on decorated associations. [https://github.com/drapergem/draper/commit/5dcc6c31ecf408753158d15fed9fb23fbfdc3734](https://github.com/drapergem/draper/commit/5dcc6c31ecf408753158d15fed9fb23fbfdc3734)
11
-
12
- * Add `helper` method to tests. [https://github.com/drapergem/draper/commit/551961e72ee92355bc9c848bedfcc573856d12b0](https://github.com/drapergem/draper/commit/551961e72ee92355bc9c848bedfcc573856d12b0)
13
-
14
- * Inherit method security. [https://github.com/drapergem/draper/commit/1865ed3e3b2b34853689a60b59b8ce9145674d1d](https://github.com/drapergem/draper/commit/1865ed3e3b2b34853689a60b59b8ce9145674d1d)
15
-
16
- * Test against all versions of Rails 3. [https://github.com/drapergem/draper/commit/1865ed3e3b2b34853689a60b59b8ce9145674d1d](https://github.com/drapergem/draper/commit/1865ed3e3b2b34853689a60b59b8ce9145674d1d)
17
-
18
- * Pretend to be `instance_of?(source.class)` [https://github.com/drapergem/draper/commit/30d209f990847e84b221ac798e84b976f5775cc0](https://github.com/drapergem/draper/commit/30d209f990847e84b221ac798e84b976f5775cc0)
3
+ ## 1.2.0
19
4
 
20
- * Remove security from `Decorator`. Do manual delegation with `:delegate`. [https://github.com/drapergem/draper/commit/c6f8aaa2b2bd4679738050aede2503aa8e9db130](https://github.com/drapergem/draper/commit/c6f8aaa2b2bd4679738050aede2503aa8e9db130)
5
+ [78 commits by 14 authors](https://github.com/drapergem/draper/compare/v1.1.0...v1.2.0)
21
6
 
22
- * Add generators for MiniTest. [https://github.com/drapergem/draper/commit/1fac02b65b15e32f06e8292cb858c97cb1c1da2c](https://github.com/drapergem/draper/commit/1fac02b65b15e32f06e8292cb858c97cb1c1da2c)
7
+ * [Added license to the gemspec](https://github.com/drapergem/draper/commit/731fa85f7744a12da1364a3aa94cdf6994efa9e2)
23
8
 
24
- * Test against edge rails. [https://github.com/drapergem/draper/commit/e9b71e3cf55a800b48c083ff257a7c1cbe1b601b](https://github.com/drapergem/draper/commit/e9b71e3cf55a800b48c083ff257a7c1cbe1b601b)
9
+ * [Improvements in serialization](https://github.com/drapergem/draper/pull/448)
25
10
 
26
- ## 1.0.0.beta6
11
+ * [Fix support for Guard in development](https://github.com/drapergem/draper/commit/93c95200277fd3922e30e74c7a7e05563747e896)
27
12
 
28
- * Fix up README to include changes made. [https://github.com/drapergem/draper/commit/5e6e4d11b1e0c07c12b6b1e87053bc3f50ef2ab6](https://github.com/drapergem/draper/commit/5e6e4d11b1e0c07c12b6b1e87053bc3f50ef2ab6)
13
+ * [Improved support for #capture](https://github.com/drapergem/draper/commit/efb934a6f59b9d8afe4a7fe29e9a94aae983b05c)
29
14
 
30
- * `CollectionDecorator` no longer freezes its collection: direct access is discouraged by making access private [https://github.com/drapergem/draper/commit/c6d60e6577ed396385f3f1151c3f188fe47e9a57](https://github.com/drapergem/draper/commit/c6d60e6577ed396385f3f1151c3f188fe47e9a57)
15
+ * [CollectionDecorator now has #decorated?](https://github.com/drapergem/draper/commit/65e3c4e4573173b510440b7e80f95a87109a1d15)
31
16
 
32
- * A fix for `Decoratable#==` [https://github.com/drapergem/draper/commit/e4fa239d84e8e9d6a490d785abb3953acc28fa65](https://github.com/drapergem/draper/commit/e4fa239d84e8e9d6a490d785abb3953acc28fa65)
17
+ * [Added #respond_to_missing?](https://github.com/drapergem/draper/commit/11bb59bcf89f8e0be4ba2851eb78634caf783ecd)
33
18
 
34
- * Ensure we coerce to an array in the right place. [https://github.com/drapergem/draper/commit/9eb9fc909c372ea1c2392d05594fa75a5c08b095](https://github.com/drapergem/draper/commit/9eb9fc909c372ea1c2392d05594fa75a5c08b095)
19
+ * [Add proper STI support](https://github.com/drapergem/draper/commit/7802d97446cf6ea130a66c2781f5a7a087d28c0a)
35
20
 
36
- ## 1.0.0.beta5
21
+ * [Added before_remove_const callback for ActiveSupport](https://github.com/drapergem/draper/commit/9efda27c6a4f8680df4fad8f67ecb58e3f91703f)
37
22
 
38
- * Change CollectionDecorator to freeze its collection [https://github.com/drapergem/draper/commit/04d779615c43580409083a71661489e1bbf91ad4](https://github.com/drapergem/draper/commit/04d779615c43580409083a71661489e1bbf91ad4)
23
+ * [Accept a lambda for context](https://github.com/drapergem/draper/commit/3ab3b35e875b8b2bd99a57e4add388313e765230)
39
24
 
40
- * Bugfix on `CollectionDecorator#to_s` [https://github.com/drapergem/draper/commit/eefd7d09cac97d531b9235246378c3746d153f08](https://github.com/drapergem/draper/commit/eefd7d09cac97d531b9235246378c3746d153f08)
25
+ * [Start testing against Ruby 2.0.0](https://github.com/drapergem/draper/commit/dbd1cbceedb0ddb3f060196cd31eb967db8a370b)
41
26
 
42
- * Upgrade `request_store` dependency to take advantage of a bugfix [https://github.com/drapergem/draper/commit/9f17212fd1fb656ef1314327d60fe45e0acf60a2](https://github.com/drapergem/draper/commit/9f17212fd1fb656ef1314327d60fe45e0acf60a2)
27
+ * [Fix our use of #scoped per Rails 4 deprecation](https://github.com/haines/draper/commit/47ee29c3b739eee3fc28a561432ad2363c14813c)
43
28
 
44
- ## 1.0.0.beta4
29
+ * [Properly swallow NameErrors](https://github.com/haines/draper/commit/09ad84fb712a30dd4302b9daa03d11281ac7d169)
45
30
 
46
- * Fixed a race condition with capybara integration. [https://github.com/drapergem/draper/commit/e79464931e7b98c85ed5d78ed9ca38d51f43006e](https://github.com/drapergem/draper/commit/e79464931e7b98c85ed5d78ed9ca38d51f43006e)
31
+ * [Delegate CollectionDecorator#kind_of? to the underlying collection](https://github.com/drapergem/draper/commit/d5975f2c5b810306a96d9485fd39d550896dc2a1)
47
32
 
48
- * `[]` can be decorated again. [https://github.com/drapergem/draper/commit/597fbdf0c80583f5ea6df9f7350fefeaa0cca989](https://github.com/drapergem/draper/commit/597fbdf0c80583f5ea6df9f7350fefeaa0cca989)
33
+ * [Make CollectionDecorators respond to #decorated_with?](https://github.com/drapergem/draper/commit/dc430b3e82de0d9cae86f7297f816e5b69d9ca58)
49
34
 
50
- * `model == decorator` as well as `decorator == model`. [https://github.com/drapergem/draper/commit/46f8a6823c50c13e5c9ab3c07723f335c4e291bc](https://github.com/drapergem/draper/commit/46f8a6823c50c13e5c9ab3c07723f335c4e291bc)
35
+ * [Avoid using #extend in Decorator#== for performance reasons](https://github.com/drapergem/draper/commit/205a0d43b4141f7b1756fe2b44b877545eb37517)
51
36
 
52
- * Preliminary Mongoid integration. [https://github.com/drapergem/draper/commit/892d1954202c61fd082a07213c8d4a23560687bc](https://github.com/drapergem/draper/commit/892d1954202c61fd082a07213c8d4a23560687bc)
37
+ ## 1.1.0
53
38
 
54
- * Add a helper method `sign_in` for devise in decorator specs. [https://github.com/drapergem/draper/commit/66a30093ed4207d02d8fa60bda4df2da091d85a3](https://github.com/drapergem/draper/commit/66a30093ed4207d02d8fa60bda4df2da091d85a3)
39
+ [44 commits by 6 authors](https://github.com/drapergem/draper/compare/v1.0.0...v1.1.0)
55
40
 
56
- * Brought back `context`. [https://github.com/drapergem/draper/commit/9609156b997b3a469386eef3a5f043b24d8a2fba](https://github.com/drapergem/draper/commit/9609156b997b3a469386eef3a5f043b24d8a2fba)
41
+ * README improvements.
42
+ * Rails 4 compatibility.
43
+ [b2401c7](https://github.com/drapergem/draper/commit/b2401c71e092470e3b912b5da475115c22b55734)
44
+ * Added support for testing decorators without loading `ApplicationController`.
45
+ See the [README](https://github.com/drapergem/draper/blob/v1.1.0/README.md#isolated-tests) for details.
46
+ [4d0181f](https://github.com/drapergem/draper/commit/4d0181fb9c65dc769b05ed19bfcec2119d6e88f7)
47
+ * Improved the `==` method to check for `decorated?` before attempting to
48
+ compare with `source`.
49
+ [6c31617](https://github.com/drapergem/draper/commit/6c316176f5039a5861491fbcaa81f64ac4b36768)
50
+ * Changed the way helpers are accessed, so that helper methods may be stubbed
51
+ in tests.
52
+ [7a04619](https://github.com/drapergem/draper/commit/7a04619a06f832801bd4aedaaf5985d6e3e5e1af)
53
+ * Made the Devise test helper `sign_in` method independent of mocking
54
+ framework.
55
+ [b0902ab](https://github.com/drapergem/draper/commit/b0902ab0fe01916b7fddb0a3d97aa0c7cca09482)
56
+ * Stopped attempting to call `to_a` on decorated objects (a now-redundant lazy
57
+ query workaround).
58
+ [34c6390](https://github.com/drapergem/draper/commit/34c6390583f7fc7704d04e38bc974b65fc92517c)
59
+ * Fixed a minor bug where view contexts could be accidentally shared between
60
+ tests.
61
+ [3d07cb3](https://github.com/drapergem/draper/commit/3d07cb387b1cae6f97897dfb85512e30f5e888e9)
62
+ * Improved helper method performance.
63
+ [e6f88a5](https://github.com/drapergem/draper/commit/e6f88a5e7dada3f9db480e13e16d1acc964ba098)
64
+ * Our specs now use the new RSpec `expect( ).to` syntax.
65
+ [9a3b319](https://github.com/drapergem/draper/commit/9a3b319d6d54cd78fb2654a94bbe893e36359754)
57
66
 
58
- * Fixed issue where classes were incorrectly being looked up. [https://github.com/drapergem/draper/commit/ee2a015514ff87dfd2158926457e988c2fc3fd79](https://github.com/drapergem/draper/commit/ee2a015514ff87dfd2158926457e988c2fc3fd79)
59
-
60
- * Integrate RequestStore for per-request storage. [https://github.com/drapergem/draper/commit/fde1cde9adfb856750c1f616d8b62d221ef97fc6](https://github.com/drapergem/draper/commit/fde1cde9adfb856750c1f616d8b62d221ef97fc6)
67
+ ## 1.0.0
61
68
 
62
- ## 1.0.0.beta3
69
+ [249 commits by 19 authors](https://github.com/drapergem/draper/compare/v0.18.0...v1.0.0)
70
+
71
+ Major changes are described [in the upgrade guide](https://github.com/drapergem/draper/wiki/Upgrading-to-1.0).
72
+
73
+ * Infer collection decorators.
74
+ [e8253df](https://github.com/drapergem/draper/commit/e8253df7dc6c90a542444c0f4ef289909fce4f90)
75
+ * Prevent calls to `scoped` on decorated associations.
76
+ [5dcc6c3](https://github.com/drapergem/draper/commit/5dcc6c31ecf408753158d15fed9fb23fbfdc3734)
77
+ * Add `helper` method to tests.
78
+ [551961e](https://github.com/drapergem/draper/commit/551961e72ee92355bc9c848bedfcc573856d12b0)
79
+ * Inherit method security.
80
+ [1865ed3](https://github.com/drapergem/draper/commit/1865ed3e3b2b34853689a60b59b8ce9145674d1d)
81
+ * Test against all versions of Rails 3.
82
+ [1865ed3](https://github.com/drapergem/draper/commit/1865ed3e3b2b34853689a60b59b8ce9145674d1d)
83
+ * Pretend to be `instance_of?(source.class)`.
84
+ [30d209f](https://github.com/drapergem/draper/commit/30d209f990847e84b221ac798e84b976f5775cc0)
85
+ * Remove security from `Decorator`. Do manual delegation with `:delegate`.
86
+ [c6f8aaa](https://github.com/drapergem/draper/commit/c6f8aaa2b2bd4679738050aede2503aa8e9db130)
87
+ * Add generators for MiniTest.
88
+ [1fac02b](https://github.com/drapergem/draper/commit/1fac02b65b15e32f06e8292cb858c97cb1c1da2c)
89
+ * Test against edge rails.
90
+ [e9b71e3](https://github.com/drapergem/draper/commit/e9b71e3cf55a800b48c083ff257a7c1cbe1b601b)
91
+
92
+ ### 1.0.0.beta6
93
+
94
+ * Fix up README to include changes made.
95
+ [5e6e4d1](https://github.com/drapergem/draper/commit/5e6e4d11b1e0c07c12b6b1e87053bc3f50ef2ab6)
96
+ * `CollectionDecorator` no longer freezes its collection: direct access is
97
+ discouraged by making access private.
98
+ [c6d60e6](https://github.com/drapergem/draper/commit/c6d60e6577ed396385f3f1151c3f188fe47e9a57)
99
+ * A fix for `Decoratable#==`.
100
+ [e4fa239](https://github.com/drapergem/draper/commit/e4fa239d84e8e9d6a490d785abb3953acc28fa65)
101
+ * Ensure we coerce to an array in the right place.
102
+ [9eb9fc9](https://github.com/drapergem/draper/commit/9eb9fc909c372ea1c2392d05594fa75a5c08b095)
103
+
104
+ ### 1.0.0.beta5
105
+
106
+ * Change CollectionDecorator to freeze its collection.
107
+ [04d7796](https://github.com/drapergem/draper/commit/04d779615c43580409083a71661489e1bbf91ad4)
108
+ * Bugfix on `CollectionDecorator#to_s`.
109
+ [eefd7d0](https://github.com/drapergem/draper/commit/eefd7d09cac97d531b9235246378c3746d153f08)
110
+ * Upgrade `request_store` dependency to take advantage of a bugfix.
111
+ [9f17212](https://github.com/drapergem/draper/commit/9f17212fd1fb656ef1314327d60fe45e0acf60a2)
112
+
113
+ ### 1.0.0.beta4
114
+
115
+ * Fixed a race condition with capybara integration.
116
+ [e794649](https://github.com/drapergem/draper/commit/e79464931e7b98c85ed5d78ed9ca38d51f43006e)
117
+ * `[]` can be decorated again.
118
+ [597fbdf](https://github.com/drapergem/draper/commit/597fbdf0c80583f5ea6df9f7350fefeaa0cca989)
119
+ * `model == decorator` as well as `decorator == model`.
120
+ [46f8a68](https://github.com/drapergem/draper/commit/46f8a6823c50c13e5c9ab3c07723f335c4e291bc)
121
+ * Preliminary Mongoid integration.
122
+ [892d195](https://github.com/drapergem/draper/commit/892d1954202c61fd082a07213c8d4a23560687bc)
123
+ * Add a helper method `sign_in` for devise in decorator specs.
124
+ [66a3009](https://github.com/drapergem/draper/commit/66a30093ed4207d02d8fa60bda4df2da091d85a3)
125
+ * Brought back `context`.
126
+ [9609156](https://github.com/drapergem/draper/commit/9609156b997b3a469386eef3a5f043b24d8a2fba)
127
+ * Fixed issue where classes were incorrectly being looked up.
128
+ [ee2a015](https://github.com/drapergem/draper/commit/ee2a015514ff87dfd2158926457e988c2fc3fd79)
129
+ * Integrate RequestStore for per-request storage.
130
+ [fde1cde](https://github.com/drapergem/draper/commit/fde1cde9adfb856750c1f616d8b62d221ef97fc6)
131
+
132
+ ### 1.0.0.beta3
63
133
 
64
134
  * Relaxed Rails version requirement to 3.0. Support for < 3.2 should be
65
135
  considered experimental. Please file bug reports.
66
136
 
67
- ## 1.0.0.beta2
68
-
69
- * `has_finders` is now `decorates_finders`. [https://github.com/drapergem/draper/commit/33f18aa062e0d3848443dbd81047f20d5665579f](https://github.com/drapergem/draper/commit/33f18aa062e0d3848443dbd81047f20d5665579f)
70
-
71
- * If a finder method is used, and the source class is not set and cannot be inferred, an `UninferrableSourceError` is raised. [https://github.com/drapergem/draper/commit/8ef5bf2f02f7033e3cd4f1f5de7397b02c984fe3](https://github.com/drapergem/draper/commit/8ef5bf2f02f7033e3cd4f1f5de7397b02c984fe3)
72
-
73
- * Class methods are now properly delegated again. [https://github.com/drapergem/draper/commit/731995a5feac4cd06cf9328d2892c0eca9992db6](https://github.com/drapergem/draper/commit/731995a5feac4cd06cf9328d2892c0eca9992db6)
137
+ ### 1.0.0.beta2
74
138
 
75
- * We no longer `respond_to?` private methods on the source. [https://github.com/drapergem/draper/commit/18ebac81533a6413aa20a3c26f23e91d0b12b031](https://github.com/drapergem/draper/commit/18ebac81533a6413aa20a3c26f23e91d0b12b031)
139
+ * `has_finders` is now `decorates_finders`.
140
+ [33f18aa](https://github.com/drapergem/draper/commit/33f18aa062e0d3848443dbd81047f20d5665579f)
141
+ * If a finder method is used, and the source class is not set and cannot be
142
+ inferred, an `UninferrableSourceError` is raised.
143
+ [8ef5bf2](https://github.com/drapergem/draper/commit/8ef5bf2f02f7033e3cd4f1f5de7397b02c984fe3)
144
+ * Class methods are now properly delegated again.
145
+ [731995a](https://github.com/drapergem/draper/commit/731995a5feac4cd06cf9328d2892c0eca9992db6)
146
+ * We no longer `respond_to?` private methods on the source.
147
+ [18ebac8](https://github.com/drapergem/draper/commit/18ebac81533a6413aa20a3c26f23e91d0b12b031)
148
+ * Rails versioning relaxed to support Rails 4.
149
+ [8bfd393](https://github.com/drapergem/draper/commit/8bfd393b5baa7aa1488076a5e2cb88648efaa815)
76
150
 
77
- * Rails versioning relaxed to support Rails 4 [https://github.com/drapergem/draper/commit/8bfd393b5baa7aa1488076a5e2cb88648efaa815](https://github.com/drapergem/draper/commit/8bfd393b5baa7aa1488076a5e2cb88648efaa815)
78
-
79
- ## 1.0.0.beta1
151
+ ### 1.0.0.beta1
80
152
 
81
153
  * Renaming `Draper::Base` to `Draper::Decorator`. This is the most significant
82
- change you'll need to upgrade your application. [https://github.com/drapergem/draper/commit/025742cb3b295d259cf0ecf3669c24817d6f2df1](https://github.com/drapergem/draper/commit/025742cb3b295d259cf0ecf3669c24817d6f2df1)
154
+ change you'll need to upgrade your application.
155
+ [025742c](https://github.com/drapergem/draper/commit/025742cb3b295d259cf0ecf3669c24817d6f2df1)
83
156
  * Added an internal Rails application for integration tests. This won't affect
84
157
  your application, but we're now running a set of Cucumber tests inside of a
85
158
  Rails app in both development and production mode to help ensure that we
86
- don't make changes that break Draper. [https://github.com/drapergem/draper/commit/90a4859085cab158658d23d77cd3108b6037e36f](https://github.com/drapergem/draper/commit/90a4859085cab158658d23d77cd3108b6037e36f)
159
+ don't make changes that break Draper.
160
+ [90a4859](https://github.com/drapergem/draper/commit/90a4859085cab158658d23d77cd3108b6037e36f)
87
161
  * Add `#decorated?` method. This gives us a free RSpec matcher,
88
- `be_decorated`. [https://github.com/drapergem/draper/commit/834a6fd1f24b5646c333a04a99fe9846a58965d6](https://github.com/drapergem/draper/commit/834a6fd1f24b5646c333a04a99fe9846a58965d6)
162
+ `be_decorated`.
163
+ [834a6fd](https://github.com/drapergem/draper/commit/834a6fd1f24b5646c333a04a99fe9846a58965d6)
89
164
  * `#decorates` is no longer needed inside your models, and should be removed.
90
- Decorators automatically infer the class they decorate. [https://github.com/drapergem/draper/commit/e1214d97b62f2cab45227cc650029734160dcdfe](https://github.com/drapergem/draper/commit/e1214d97b62f2cab45227cc650029734160dcdfe)
165
+ Decorators automatically infer the class they decorate.
166
+ [e1214d9](https://github.com/drapergem/draper/commit/e1214d97b62f2cab45227cc650029734160dcdfe)
91
167
  * Decorators do not automatically come with 'finders' by default. If you'd like
92
168
  to use `SomeDecorator.find(1)`, for example, simply add `#has_finders` to
93
- the decorator to include them. [https://github.com/drapergem/draper/commit/42b6f78fda4f51845dab4d35da68880f1989d178](https://github.com/drapergem/draper/commit/42b6f78fda4f51845dab4d35da68880f1989d178)
169
+ the decorator to include them.
170
+ [42b6f78](https://github.com/drapergem/draper/commit/42b6f78fda4f51845dab4d35da68880f1989d178)
94
171
  * To refer to the object being decorated, `#source` is now the preferred
95
- method. [https://github.com/drapergem/draper/commit/1e84fcb4a0eab0d12f5feda6886ce1caa239cb16](https://github.com/drapergem/draper/commit/1e84fcb4a0eab0d12f5feda6886ce1caa239cb16)
172
+ method.
173
+ [1e84fcb](https://github.com/drapergem/draper/commit/1e84fcb4a0eab0d12f5feda6886ce1caa239cb16)
96
174
  * `ActiveModel::Serialization` is included in Decorators if you've requred
97
- `ActiveModel::Serializers`, so that decorators can be serialized. [https://github.com/drapergem/draper/commit/c4b352799067506849abcbf14963ea36abda301c](https://github.com/drapergem/draper/commit/c4b352799067506849abcbf14963ea36abda301c)
98
- * Properly support Test::Unit [https://github.com/drapergem/draper/commit/087e134ed0885ec11325ffabe8ab2bebef77a33a](https://github.com/drapergem/draper/commit/087e134ed0885ec11325ffabe8ab2bebef77a33a)
175
+ `ActiveModel::Serializers`, so that decorators can be serialized.
176
+ [c4b3527](https://github.com/drapergem/draper/commit/c4b352799067506849abcbf14963ea36abda301c)
177
+ * Properly support Test::Unit.
178
+ [087e134](https://github.com/drapergem/draper/commit/087e134ed0885ec11325ffabe8ab2bebef77a33a)
99
179
 
100
180
  And many small bug fixes and refactorings.
101
181
 
102
- ## 0.18.0
103
-
104
- * [Adds the ability to decorate an enumerable proxy](https://github.com/drapergem/draper/commit/67c7125192740a7586a3a635acd735ae01b97837)
105
-
106
- * Many bug fixes.
107
-
108
- * Last version of Draper in the 0.x series.
109
-
110
- ## 0.17.0
111
-
112
- * [Fix earlier fix of `view_context` priming](https://github.com/drapergem/draper/commit/5da44336)
113
- * [Add `denies_all`](https://github.com/drapergem/draper/commit/148e732)
114
- * [Properly proxy associations with regard to `find`](https://github.com/drapergem/draper/commit/d46d19205e)
115
-
116
- ## 0.16.0
117
-
118
- * [Automatically prime `view_context`](https://github.com/drapergem/draper/commit/057ab4e8)
119
- * [Fixed bug where rspec eq matchers didn't work]((https://github.com/drapergem/draper/commit/57617b)
120
- * [Sequel ORM support](https://github.com/drapergem/draper/commit/7d4942)
121
- * Fixed issues with newer minitest
122
- * [Changed the way the `view_context` gets set](https://github.com/drapergem/draper/commit/0b03d9c)
123
-
124
- ## 0.15.0
125
-
126
- * Proper minitest integration
127
- * [We can properly decorate scoped associations](https://github.com/drapergem/draper/issues/223)
128
- * [Fixed awkward eager loading](https://github.com/drapergem/draper/commit/7dc3510b)
129
-
130
- ## 0.14.0
131
-
132
- * [Properly prime the view context in Rails Console](https://github.com/drapergem/draper/commit/738074f)
133
- * Make more gems development requirements only
134
-
135
- ## 0.13.0
136
-
137
- * Upgraded all dependencies
138
- * Dropped support for Rubies < 1.9.3
139
- * `#to_model` has been renamed to `#wrapped_object`
140
- * Allow proper overriding of special `ActiveModel` methods
141
-
142
- ## 0.12.3
143
-
144
- * [Fix i18n issue](https://github.com/drapergem/draper/issues/202)
145
-
146
- ## 0.12.2
147
-
148
- * Fix bug with initializing ammeter
149
- * Some gems are now development only in the gemspec
150
- * Fix bug where generated models were still inheriting from `ApplicationDecorator`
151
-
152
- ## 0.12.0
153
-
154
- * Added Changelog
155
- * [Prevented double decoration](https://github.com/drapergem/draper/issues/173)
156
- * [`ActiveModel::Errors` support](https://github.com/drapergem/draper/commit/19496f0c)
157
- * [Fixed autoloading issue](https://github.com/drapergem/draper/issues/188)
158
- * [Re-did generators](https://github.com/drapergem/draper/commit/9155e58f)
159
- * [Added capybara integration](https://github.com/drapergem/draper/commit/57c8678e)
160
- * Fixed a few bugs with the `DecoratedEnumerableProxy`
161
-
162
- ## 0.11.1
182
+ ## 0.x
163
183
 
164
- * [Fixed regression, we don't want to introduce a hard dependency on Rails](https://github.com/drapergem/draper/issues/107)
184
+ See changes prior to version 1.0 [here](https://github.com/drapergem/draper/blob/16140fed55f57d18f8b10a0789dd1fa5b3115a8d/CHANGELOG.markdown).
data/Gemfile CHANGED
@@ -1,4 +1,4 @@
1
- source :rubygems
1
+ source "https://rubygems.org"
2
2
 
3
3
  gemspec
4
4
 
@@ -22,8 +22,10 @@ end
22
22
 
23
23
  mongoid = case version
24
24
  when "master"
25
- {github: "mongoid/mongoid", branch: "4.0.0-dev"}
26
- when "3.1", "3.2"
25
+ {github: "mongoid/mongoid"}
26
+ when "3.2"
27
+ "~> 3.1.0"
28
+ when "3.1"
27
29
  "~> 3.0.0"
28
30
  end
29
31
 
data/Guardfile CHANGED
@@ -1,4 +1,25 @@
1
- guard 'rspec', :version => 2, :notification => false do
1
+ def rspec_guard(options = {}, &block)
2
+ options = {
3
+ :version => 2,
4
+ :notification => false
5
+ }.merge(options)
6
+
7
+ guard 'rspec', options, &block
8
+ end
9
+
10
+ rspec_guard :spec_paths => %w{spec/draper spec/generators} do
11
+ watch(%r{^spec/.+_spec\.rb$})
12
+ watch(%r{^lib/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
13
+ watch('spec/spec_helper.rb') { "spec" }
14
+ end
15
+
16
+ rspec_guard :spec_paths => 'spec/integration', :env => {'RAILS_ENV' => 'development'} do
17
+ watch(%r{^spec/.+_spec\.rb$})
18
+ watch(%r{^lib/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
19
+ watch('spec/spec_helper.rb') { "spec" }
20
+ end
21
+
22
+ rspec_guard :spec_paths => 'spec/integration', :env => {'RAILS_ENV' => 'production'} do
2
23
  watch(%r{^spec/.+_spec\.rb$})
3
24
  watch(%r{^lib/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
4
25
  watch('spec/spec_helper.rb') { "spec" }
data/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  # Draper: View Models for Rails
2
2
 
3
3
  [![TravisCI Build Status](https://secure.travis-ci.org/drapergem/draper.png?branch=master)](http://travis-ci.org/drapergem/draper)
4
- [![Code Climate](https://codeclimate.com/badge.png)](https://codeclimate.com/github/drapergem/draper)
4
+ [![Code Climate](https://codeclimate.com/github/drapergem/draper.png)](https://codeclimate.com/github/drapergem/draper)
5
5
 
6
6
  Draper adds an object-oriented layer of presentation logic to your Rails application.
7
7
 
@@ -117,7 +117,7 @@ rails generate decorator Article
117
117
 
118
118
  ### Accessing Helpers
119
119
 
120
- Normal Rails helpers are still useful for lots tasks. Both Rails' provided helper and those defined in your app can be accessed via the `h` method:
120
+ Normal Rails helpers are still useful for lots of tasks. Both Rails' provided helper and those defined in your app can be accessed via the `h` method:
121
121
 
122
122
  ```ruby
123
123
  class ArticleDecorator < Draper::Decorator
@@ -134,6 +134,7 @@ include Draper::LazyHelpers
134
134
  ```
135
135
 
136
136
  ...at the top of your decorator class - you'll mix in a bazillion methods and never have to type `h.` again.
137
+ (Note: the `capture` method is only available through `h` or `helpers`)
137
138
 
138
139
  ### Accessing the model
139
140
 
@@ -197,7 +198,7 @@ end
197
198
  @articles = ArticlesDecorator.decorate(Article.all)
198
199
  ```
199
200
 
200
- Draper infers the decorator used for each item from the name of the collection decorator (`ArticlesDecorator` implies `ArticleDecorator`). If that fails, it falls back to using each item's `decorate` method. Alternatively, you can specify a decorator by overriding the collection decorator's `decorator_class` method.
201
+ Draper decorates each item using its `decorate` method. Alternatively, you can specify a decorator by overriding the collection decorator's `decorator_class` method, or by passing the `:with` option to the constructor.
201
202
 
202
203
  #### Using pagination
203
204
 
@@ -10,7 +10,8 @@ Gem::Specification.new do |s|
10
10
  s.homepage = "http://github.com/drapergem/draper"
11
11
  s.summary = "View Models for Rails"
12
12
  s.description = "Draper adds an object-oriented layer of presentation logic to your Rails apps."
13
- s.rubyforge_project = "draper"
13
+ s.license = "MIT"
14
+
14
15
  s.files = `git ls-files`.split("\n")
15
16
  s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
16
17
  s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
@@ -27,4 +28,5 @@ Gem::Specification.new do |s|
27
28
  s.add_development_dependency 'rspec-rails', '~> 2.12'
28
29
  s.add_development_dependency 'minitest-rails', '~> 0.2'
29
30
  s.add_development_dependency 'capybara'
31
+ s.add_development_dependency 'active_model_serializers'
30
32
  end
@@ -1,5 +1,8 @@
1
1
  require 'action_view'
2
+ require 'active_model/naming'
2
3
  require 'active_model/serialization'
4
+ require 'active_model/serializers/json'
5
+ require 'active_model/serializers/xml'
3
6
  require 'active_support/inflector'
4
7
  require 'active_support/core_ext/hash/keys'
5
8
  require 'active_support/core_ext/hash/reverse_merge'
@@ -13,10 +16,12 @@ require 'draper/decorator'
13
16
  require 'draper/helper_proxy'
14
17
  require 'draper/lazy_helpers'
15
18
  require 'draper/decoratable'
19
+ require 'draper/factory'
16
20
  require 'draper/decorated_association'
17
21
  require 'draper/helper_support'
18
22
  require 'draper/view_context'
19
23
  require 'draper/collection_decorator'
24
+ require 'draper/decorates_assigned'
20
25
  require 'draper/railtie' if defined?(Rails)
21
26
 
22
27
  module Draper
@@ -24,6 +29,7 @@ module Draper
24
29
  base.class_eval do
25
30
  include Draper::ViewContext
26
31
  extend Draper::HelperSupport
32
+ extend Draper::DecoratesAssigned
27
33
 
28
34
  before_filter do |controller|
29
35
  Draper::ViewContext.clear!