Commit Graph

1101 Commits

Author SHA1 Message Date
Yohan Robert
8dfbc4818d Simplify adapter deprecation and delegation
The Adapter module was refactored a bit to use Active Support delegation
and remove duplicated code.
The CHANGELOG was also added.
2016-03-07 15:09:09 +01:00
Benjamin Fleischer
1a312bc2d3 Merge pull request #1545 from CodedBeardedSignedTaylor/1506-document-passing-arbitrary-options-to-serializer
[DOCS] 1506 document passing arbitrary options to serializer
2016-03-07 01:09:50 -06:00
Benjamin Fleischer
b50195fde7 Add a deprecation DSL 2016-03-07 01:07:06 -06:00
Benjamin Fleischer
6b4c8df6fb Clean up test deprecation warnings 2016-03-06 23:35:22 -06:00
Benjamin Fleischer
5d7a1a4889 Remove the last of ApiObjects 2016-03-06 23:24:53 -06:00
Benjamin Fleischer
e30b2a4417 Merge branch 'groyoh-follow_up_1535'
Needs followup
- way we deprecate classes to be generalized
  - initialize old json api https://github.com/rails-api/active_model_serializers/pull/1543#discussion_r54368858
  - consider restoring ensure https://github.com/rails-api/active_model_serializers/pull/1543#discussion_r54368925
2016-03-06 23:15:46 -06:00
Yohan Robert
dd94fe2163 Follow up to #1535
- The removed classes and modules were added back with deprecation
  warning and deprecation test were added for them.
- One test was renamed because it contained `__`.
- Some tests were refactored.
- The ActiveModelSerializers::Deserialization module is now called
  Adapter instead of ActiveModelSerializers::Adapter.
- The changelog was added for #1535
2016-03-06 23:15:39 -06:00
L. Preston Sego III
79e6acbc4a Merge pull request #1004 from bf4/json_api_errors
JSON API Errors (Initial implementation and roadmap for full feature-set)
2016-03-06 22:09:18 -05:00
NullVoxPopuli
d03db81070 add an extra format token to the primary data string so that JRuby doesn't break 2016-03-06 20:05:25 -06:00
Benjamin Fleischer
e6ae34b84c Update documentation with Yard links 2016-03-06 20:05:25 -06:00
Benjamin Fleischer
3d986377b6 Collapse JSON API success/failure documents in one adapter
Idea per remear (Ben Mills) in the slack:
https://amserializers.slack.com/archives/general/p1455140474000171

remear:

    just so i understand, the adapter in `render json: resource, status: 422, adapter: 'json_api/error',
    serializer: ActiveModel::Serializer::ErrorSerializer` is a different one than, say what i’ve
    specified in a base serializer with `ActiveModel::Serializer.config.adapter = :json_api`. correct?

    and a followup question of, why not same adapter but different serializer?

me:

   With the way the code is written now, it might be possible to not require a special jsonapi adapter.
   However, the behavior is pretty different from the jsonapi adapter.

   this first draft of the PR had it automatically set the adapter if there were errors.  since that
   requires more discussion, I took a step back and made it explicit for this PR

   If I were to re-use the json api adapter and remove the error one, it think the serializable hash
   method would look like

   ```
   def serializable_hash(options = nil)
     return { errors: JsonApi::Error.collection_errors } if serializer.is_a?(ErrorsSerializer)
     return { errors: JsonApi::Error.resource_errors(serializer) } if serializer.is_a?(ErrorSerializer)
     options ||= {}
   ```

   I suppose it could be something more duckish like

   ```
   def serializable_hash(options = nil)
     if serializer.errors? # object.errors.any? || object.any? {|o| o.errors.any? }
       JsonApi::Error.new(serializer).serializable_hash
     else
       # etc
   ```
2016-03-06 12:03:17 -06:00
Benjamin Fleischer
96107c56aa Require explicit adapter/serializer to render JSON API errors
- Separate collection errors from resource errors in adapter
- Refactor to ErrorsSerializer; first-class json error methods
- DOCS
- Rails 4.0 requires assert exact exception class, boo
2016-03-06 12:03:17 -06:00
Benjamin Fleischer
dfe162638c Generalize detection of serializable resource with errors 2016-03-06 12:03:17 -06:00
Benjamin Fleischer
0ba944dabf RFC: Json Api Errors (WIP)
- ActiveModelSerializers::JsonPointer
- ActiveModel::Serializer::Adapter::JsonApi::Error
- ActiveModel::Serializer::Adapter::JsonApi::Error.attributes
- Fix rubocop config
2016-03-06 12:03:14 -06:00
Taylor Jones
48f8a892e6 a little bit more trimming 2016-03-04 11:14:43 -05:00
Taylor Jones
60a207bb0d wrong link 2016-03-04 11:12:09 -05:00
Taylor Jones
32c6bccec7 edits and rearranging logic 2016-03-04 11:09:38 -05:00
Benjamin Fleischer
df815c48ba Merge pull request #1544 from groyoh/remove_design
[DOC] Removes DESIGN.textile doc and update ARCHITECTURE.md [ci skip]
2016-03-03 13:31:10 -06:00
Tomasz Korzeniowski
eac5622873 codebeat badge
Is it fine to add codebeat badge to README? 

codebeat is automated code review tool for Swift, Ruby & Go that helps get instant feedback on code quality. 

"Quick wins" suggested by codebeat could be a nice candidate for a pull request and help other developers become contributors.

FYI. To be fully open and honest. I'm co-founder of codebeat.
2016-03-02 11:12:52 +01:00
Taylor Jones
da55cd181c addressing comments / concerns 2016-03-01 08:40:45 -05:00
Taylor Jones
e9f259697a addressing pull request comments 2016-02-29 10:56:14 -05:00
CodedBeardedSignedTaylor
6a8da1f664 adding ruby tag to code blocks 2016-02-28 22:45:45 -05:00
bobba surendranath chowdary
8b5da690fe Removes DESIGN.textile doc and update ARCHITECTURE.md
The old DESIGN.textile was removed and replace by reference to 0.8 and
0.9 READMEs within the ARCHITECTURE.md docs.
2016-02-29 04:41:47 +01:00
CodedBeardedSignedTaylor
558769981e rough draft 2016-02-28 22:41:26 -05:00
Yohan Robert
8a040052af Merge pull request #1535 from bf4/domitian-move-namespace-of-adapter-to-active-model-serializers
Moved the adapter and adapter folder to active_model_serializers folder and changed the module namespace
2016-02-28 12:58:36 +01:00
Benjamin Fleischer
3975e3642a Merge pull request #1542 from bf4/rake_isolated_shellescape
Escape paths in rake isolated for directory with spaces and parens
2016-02-26 14:38:20 -06:00
Benjamin Fleischer
042ec38b40 Escape paths in rake isolated for directory with spaces and parens 2016-02-26 14:14:00 -06:00
Ben Mills
b2314017c6 Fix GitHub template formatting and spelling 2016-02-26 11:24:57 -07:00
Ben Mills
3af7ae2eb4 Merge pull request #1530 from bf4/gh_templates
Simplify contributing.md; move details into GitHub templates
2016-02-26 11:17:37 -07:00
Ben Mills
5d9039e172 Adjust GitHub templates 2016-02-26 10:43:52 -07:00
Benjamin Fleischer
721efffeff Simplify contributing.md; move details into GitHub templates
per https://github.com/blog/2111-issue-and-pull-request-templates
2016-02-26 10:43:52 -07:00
Ben Mills
04e0e7a71b Merge pull request #1485 from karellm/karellm-contributing
Simplify CONTRIBUTING.md for filling an issue
2016-02-26 10:38:33 -07:00
Benjamin Fleischer
fcdb58f67d Remove AS::Testing::Stream in favor of Minitest assert_output 2016-02-25 23:21:44 -06:00
Benjamin Fleischer
e35390623d Improve adapter test coverage per groyoh 2016-02-25 23:08:20 -06:00
Benjamin Fleischer
7f25c580d8 Merge pull request #1497 from CorainChicago/add_JRuby_to_appveyor
[MISC] Add jruby to appveyor
2016-02-24 22:48:17 -06:00
Benjamin Fleischer
25c9df0b97 Merge branch 'master' into domitian-move-namespace-of-adapter-to-active-model-serializers
Conflicts:
	CHANGELOG.md
	lib/active_model/serializer/adapter/attributes.rb
	lib/active_model/serializer/adapter/cached_serializer.rb
	lib/active_model/serializer/adapter/fragment_cache.rb
	lib/active_model/serializer/adapter/json_api.rb
	lib/active_model/serializer/adapter/json_api/link.rb
	test/adapter/fragment_cache_test.rb
	test/adapter/json_api/links_test.rb
	test/adapter/json_api/resource_type_config_test.rb
2016-02-23 23:21:49 -06:00
bobba surendranath chowdary
252f9c4ae9 Moved the adapter and adapter folder to active_model_serializers folder and changed the module namespace
Changed the namespace in adapters and folder to active_model_serializers from active_model::serializer

Changed namespace of adapters in serializers and other folders

Moved adapter_for_test file to active_model_serializers folder and changed namespace of adapter inside the test file

Require ActiveSupport's string/inflections

We depend on string/inflections to define String#underscore.

Refactor JsonApi adapter to avoid redundant computations.

Update readme.md to link to v0.10.0.rc4

changed namespace of adapter folder testcases

Changed all namespaces of adapter under active_moder_serializers

Namespaced IncludeTree which is from serializer module, so needed to namespace it properly

Fixed wrong namsepacing of fieldset

namespace change in deserializer json_api

Fixed the namespace for collection serializer when used inside adapter, changed namespace for adapter to new namespace which I had forgotten previously

Modified logging test and adapter test cases to make the testcases pass

Changed the yardoc links,as old links are not taking to documentation pages,proper links for 0.10,0.9 and 0.8 in rubydoc

Rubocop errors are fixed by underscore naming unused variables

Moved the require of adapter to serializable resource

Remoeved adapter dependency inside serializer and added warning to Serializer::adapter method

Fixed frament cache test which is calling Serializer.adapter

Changed the name of lookup_adapter_from_config to configured_adapter

Changed the docs which will show the new namespace of adapters

Rubocop fix
2016-02-23 21:49:58 -06:00
Benjamin Fleischer
532828b4da Merge pull request #1515 from groyoh/symbol_type
[FEATURE] Add symbol support for Serializer.type method
2016-02-21 10:41:41 -06:00
Yohan Robert
727d7631ae Add symbol support for ActiveModel::Serializer.type method
The ActiveModel::Serializer.type method now accepts symbol as paremeter:
class AuthorSerializer < ActiveModel::Serializer
  type :profile
end
The test file for the type was also refactored.
2016-02-19 17:05:13 +01:00
Benjamin Fleischer
f02f0849b1 Merge pull request #1525 from groyoh/remove_warning_message
Fix deprecation warning
2016-02-19 09:15:42 -06:00
Yohan Robert
c2eace3468 Fix deprecation warning
Fix the "Calling deprecated ArraySerializer... Please use
CollectionSerializer" warning that appeared when running the specs. This
happened because on of the test called ArraySerializer instead of
CollectionSerializer.
2016-02-19 10:13:54 +01:00
Benjamin Fleischer
a6c6979e08 Merge pull request #1516 from groyoh/fix_relationship_href
[FIX] bug displaying nil for relationship link href
2016-02-15 22:08:01 -06:00
Yohan Robert
3cbc0541c1 Fix bug displaying nil for relationship link href
When using the relationship link with a block, calling "meta" without "href", e.g.
has_one :bio do
  link :related do
    meta id: 1
  end
end

results in in a nil "href", e.g.
{ links: { posts: { related: { href: nil, meta: { id: 1 } }  } } }.
According to JSONAPI, we should be able to use meta without href
(http://jsonapi.org/format/#document-links).
2016-02-15 09:26:53 +01:00
Benjamin Fleischer
2b673634d9 Merge branch 'groyoh-association-blocks' 2016-02-12 14:52:21 -06:00
Benjamin Fleischer
344d09d36e Merge pull request #1472 from edwinlunando/master
[DOC] update JSON adapter pagination links how to guide
2016-02-12 14:13:40 -06:00
Benjamin Fleischer
b45f7b4ffe Add changelog for https://github.com/rails-api/active_model_serializers/pull/1372 2016-02-11 00:53:11 -06:00
Benjamin Fleischer
f1b3fe6a37 Fix rubocop config
`undefined method '[]' for nil:NilClass`
2016-02-11 00:51:23 -06:00
Benjamin Fleischer
54aa6aa499 Merge branch 'LcpMarvel-support_read_multi'
Followup:
- Changelog
2016-02-11 00:48:48 -06:00
Yohan Robert
b1fd43303c Fix relationship behavior when using block
When using the relationships DSL with a block e.g.
has_one :bio do
  link :self, "some_link"
end
the "data" field would be rendered with a nil value even though the bio
is not nil. This happened because the block return value was set to nil
but used as a value for the "data" field.
2016-02-10 21:04:37 +01:00
Yohan Robert
2c4193851b Follow up to #1454
PR #1454 was merged with some missing fixes. All these fixes are
addressed by this commit:
- Rename ActiveModel::Serializer::Adapter::JsonApi::Association to
ActiveModel::Serializer::Adapter::JsonApi::Relationship
- Move ActiveModel::Serializer::Adapter:: JsonApi::Relationship and
ActiveModel::Serializer::Adapter::JsonApi::ResourceIdentifier to
ActiveModel::Serializer::Adapter::JsonApi::ApiObjects module
- Add unit test for
ActiveModel::Serializer::Adapter::JsonApi::Relationship
- Add unit test for
ActiveModel::Serializer::Adapter::JsonApi::ResourceIdentifier
2016-02-10 12:57:54 +01:00