Commit Graph

852 Commits

Author SHA1 Message Date
Benjamin Fleischer
23aae928d5 [RFC][WIP] Resource Routing 2016-01-28 13:44:56 -06:00
Benjamin Fleischer
65093055d6 Merge pull request #1310 from maurogeorge/patch-12
RFC: Primary namespace: ActiveModel::Serializer, ActiveModel::Serializers, vs. ActiveModelSerializers
2016-01-28 12:54:52 -06:00
João M. D. Moura
58ff7535b7 releaseing new version RC4 2016-01-27 10:03:01 -05:00
Lucas Hosseini
790efee9c3 Merge pull request #1467 from dgynn/pr_configure_generators
Ensure that generators get configured correctly
2016-01-26 18:16:13 +01:00
Alexandre de Oliveira
dfd22ad860 Merge pull request #1444 from bf4/serializer_prehistory
Why rails renderers are only sentinels for a method; not lookups [ci skip]
2016-01-25 19:57:41 -02:00
Alexandre de Oliveira
ef58efdf73 Merge pull request #1418 from brigade/collection-pluralize
Don't pluralize the CollectionSerializer#root for #json_key
2016-01-25 19:46:47 -02:00
Dave Gynn
b1b3e9fb6a ensure that generators get configured correctly 2016-01-25 09:01:25 -08:00
Lucas Hosseini
2df8804047 Merge pull request #1459 from joyvuu-dave/update_readme
Update Readme to reflect AMS is no longer default in Rails 5
2016-01-24 22:02:02 +01:00
Lucas Hosseini
b34d53287e Merge pull request #1462 from nate00/attribute-overriding--update-docs
Update attribute/association overriding docs
2016-01-24 22:00:31 +01:00
Nate Sullivan
0a937a0fba Use new block-based attribute override in docs 2016-01-23 18:59:18 -08:00
Nate Sullivan
da85d944d4 Remove unrelated code from attribute override examples 2016-01-23 18:50:18 -08:00
Dave Riddle
40553258af updates Readme to reflect AMS is no longer included by default in Rails 5 2016-01-22 23:18:15 -08:00
Benjamin Fleischer
f056ef34e2 Why rails renderers are only sentinels for a method; not lookups 2016-01-18 23:38:12 -05:00
Benjamin Fleischer
8981683b9f Merge pull request #1352 from bf4/railties
Fix generators (@dgynn); load Railtie only with Rails, ensures caching configured
2016-01-18 23:24:40 -05:00
Lucas Hosseini
f2d59b20ca Update rendering.md 2016-01-17 16:58:35 +01:00
Dave Gynn
6713864b64 combine config initializers and update comments
this also changes the action_controller load hook to not trigger loading of the ActionController::Base
2016-01-16 14:08:32 -08:00
Lucas Hosseini
b9f4720cbd Merge pull request #1406 from beauby/dynamic-jsonapi-string-links
Add support for custom dynamic valued links in JsonApi adapter.
2016-01-15 14:57:12 +01:00
Lucas Hosseini
30d8414cce Add support for dynamic string-links in JsonApi adapter. 2016-01-15 14:36:42 +01:00
Benjamin Fleischer
d3bdc9be57 Replace load hook :active_model_serializers with :action_controller 2016-01-15 01:58:14 -06:00
Dave Gynn
ea8d463555 use action_controller configuration options in initializers
this uses the configuration settings rather than calling ActionController::Base to get the configured values.
after the "action_controller.set_configs" initializer has run, the configuration option holds the value Base will get when it loads.
2016-01-15 01:58:14 -06:00
Benjamin Fleischer
58a74d064e Add CHANGELOG 2016-01-15 01:58:14 -06:00
Benjamin Fleischer
509221c1e0 Only call railtie when Rails is defined; assume controller loaded
Isolated Testing

- Rake test inspired by https://github.com/rails/rails/blob/v5.0.0.beta1/activejob/Rakefile
- Isolated unit inspired by
  - https://github.com/rails/rails/blob/v5.0.0.beta1/railties/test/isolation/abstract_unit.rb
  - https://github.com/rails/rails/blob/v5.0.0.beta1/activemodel/test/cases/railtie_test.rb

Misc

- Turns out `mattr_accessor(:logger) {
  ActiveSupport::TaggedLogging.new(ActiveSupport::Logger.new(STDOUT)) }`
  was always nil until the Railtie was loaded, since mattr_accessor
  block defaults don't really work on modules, but on the classes that
  include them.
- Commented on important on Rails being required first for caching to
  work.
- In isolated tests, `active_support/core_ext/object/with_options` is required.
2016-01-15 01:54:07 -06:00
Benjamin Fleischer
fe015d17f2 Fix load-order issues 2016-01-15 01:54:07 -06:00
Dave Gynn
94db22c1e0 Only load generators when needed
- use hook_for to hook in the serializer and remove load_generators
- move generators so they can be found by rails
- move to_prepare block to railtie config

This commit improves the way the generators are loaded and how
they extend the resource generator.

* The initializer block has been changed to a `generator` block which is only executed when generators are needed.
* The call to `app.load_generators` has been removed. There is no need to load *all* generators.
* The `resource_override.rb` has been changed to use `hook_for` to extend the resource generator.
* The directory for the generators has been moved to match the way Rails looks to load generators.

With `hook_for` it would now be possible for a user to pass `--no-serializer` to skip that option.
The `--serialize` option also now shows up in the generator help with `rails g resource --help`.

These changes follow the way the Draper gem extends the `controller` generator.
2016-01-15 01:52:27 -06:00
Benjamin Fleischer
0c2153ac5e Collect more Rails initialization code in the Railtie 2016-01-15 01:52:27 -06:00
Benjamin Fleischer
316026e9ce Merge branch 'CorainChicago-changelog' 2016-01-15 01:05:37 -06:00
Benjamin Fleischer
47f6db203c Touchup Changelog 2016-01-15 01:05:31 -06:00
CorainChicago
8ffcdc7668 update CHANGELOG 2016-01-15 01:05:31 -06:00
Benjamin Fleischer
87ca408ead Merge pull request #1425 from beauby/extract-serializer-modules
[CLEANUP] Extract links and type-related methods to their own module.
2016-01-15 00:56:40 -06:00
Benjamin Fleischer
92e8a0a246 Merge pull request #1417 from koryteg/custom_root_docs
[DOCS] added documentation for adding custom root
2016-01-15 00:52:56 -06:00
Benjamin Fleischer
ac13053790 Merge branch 'maurogeorge-patch-09'
Rebased from cb3afa93ffa75a65b080c764547020bee2f2f191 to 9aed6ac63
and resolved conflicts by Benjamin Fleischer (bf4)
2016-01-15 00:47:06 -06:00
Mauro George
5058694f4a Create assert_response_schema test helper
It is a common pattern to use JSON Schema to validate a API response[1], [2]
and [3].

This patch creates the `assert_response_schema` test helper that helps people do
this kind of validation easily on the controller tests.

[1]: https://robots.thoughtbot.com/validating-json-schemas-with-an-rspec-matcher
[2]: https://github.com/sharethrough/json-schema-rspec
[3]: https://github.com/rails-api/active_model_serializers/issues/1011#issuecomment-127608121
2016-01-15 00:45:56 -06:00
Benjamin Fleischer
9aed6ac634 Merge pull request #1390 from bf4/maurogeorge-patch-02
Bring back assert_serializer for controller testing
2016-01-14 17:54:31 -06:00
Mauro George
2f8c430a09 Update the RFC to use ActiveModelSerializers
After some internal discussion was decided to use the ActiveModelSerializers
namespace.

This patch update the content following this idea.

Ref:
https://github.com/rails-api/active_model_serializers/pull/1310/files#r45947587
https://github.com/rails-api/active_model_serializers/pull/1310/files#r47144210
2016-01-14 19:21:33 -02:00
Benjamin Fleischer
f5e2b991bf Remove outdated regression test
Per https://github.com/rails-api/active_model_serializers/pull/1390#discussion_r48322329
2016-01-13 21:47:08 -06:00
Benjamin Fleischer
9779185d57 Restore test-local subscriber teardown
This commit revises 0ce4ad35a12ffd858f6a5d7bbeb48fc1e2cfac92
`Remove unused/unusable unsubscribe since we don't want to unsubscribe`

Looking at Rails implementation of assert_template
which was likely the inspiration for assert_serializer:

f756b33c13/lib/rails/controller/testing/template_assertions.rb

Ref:

- https://github.com/rails-api/active_model_serializers/pull/596
- https://github.com/rails-api/active_model_serializers/pull/620
- https://github.com/rails-api/active_model_serializers/issues/616
2016-01-13 21:47:08 -06:00
Benjamin Fleischer
e60937bc2f Remove duplicate documentation 2016-01-13 21:47:08 -06:00
Benjamin Fleischer
28f314aef2 Surface logging event name for re-use 2016-01-13 21:47:08 -06:00
Benjamin Fleischer
a43cff4ae3 Remove assert_template from Test::SerializerTest
Rails 5 removed this assertion after considering it not
a good testing practice. https://github.com/rails/rails/issues/18950

Rather that add a gem to our Rails 5 matrix to support it,
the assertion is made that the template is rendering using
active support notifications.

Also, to clarify that the action 'render_template' is unrelated to the
event name '!render_template.action_view', I renamed the actions
so that would not look like event names.
2016-01-13 21:47:08 -06:00
Benjamin Fleischer
f59431439d Remove unused/unusable unsubscribe since we don't want to unsubscribe
In 0.9 (which this implementation is based on), the instrumentation
was `!serialize.active_model_serializers`.

https://github.com/rails-api/active_model_serializers/pull/596/

The '!' in the event name meant the event wasn't meant for
production.

https://github.com/rails/rails/pull/10446/files#r4075679

Since we intend the event for production and have a log subscriber,
if we unsubscribe from `render.active_model_serializers`, we'll
break other tests that are relying on that event being subscribed.
2016-01-13 20:54:22 -06:00
Benjamin Fleischer
ef09c9043f Small perf, readability refactor to Test::Serializer 2016-01-13 20:54:22 -06:00
Benjamin Fleischer
37a6d2b245 Be consisent in usage of ActiveSupport::Autoload 2016-01-13 20:54:22 -06:00
Mauro George
c0b99c980c Bring back assert_serializer for controller testing
The `assert_serializer` test helper was added in 0.9.0.apha1[1],
and was not included in 0.10.

This patch brings back the `assert_serializer` test helper. This is the last
revision[2] that has the helper. The original helper was used as base.

[1]: https://github.com/rails-api/active_model_serializers/pull/596
[2]: 610aeb2e92

- Create the AssertSerializer

- Use the Test namespace

- Make the tests pass on the Rails master
  - Rails 5 does not include `assert_template` but we need this on the tests of
the helper.
  - This add the `rails-controller-testing` to keep support on `assert_template`.

- Only load test helpers in the test environment
2016-01-13 20:54:22 -06:00
Benjamin Fleischer
d448481b6b Merge pull request #1386 from bf4/warnings_fix_again
Remove capture_warnings testing. Is fickle and Rubocop linting is good enough
2016-01-13 20:17:24 -06:00
Benjamin Fleischer
dde843d162 Add serialization docs PR request note for conditional attributes 2016-01-13 10:19:07 -06:00
Benjamin Fleischer
2f74dd9682 Merge pull request #1432 from biow0lf/patch-1
Fix link in ARCHITECTURE.md [ci skip]
2016-01-13 10:00:12 -06:00
Igor Zubkov
aa8e306782 Fix ARCHITECTURE.md 2016-01-13 17:45:18 +02:00
Lucas Hosseini
53c59a1510 Merge pull request #1403 from beauby/conditional-attributes
Conditional attributes/associations (if/unless).
2016-01-13 07:50:59 +01:00
Lucas Hosseini
2696557650 Replace Field#included? with Field#excluded?. 2016-01-13 06:20:05 +01:00
Lucas Hosseini
7af198653d Add tests for conditional attributes/associations. 2016-01-13 06:20:05 +01:00