active_model_serializers 0.10.0.rc4 → 0.10.0.rc5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/ISSUE_TEMPLATE.md +29 -0
- data/.github/PULL_REQUEST_TEMPLATE.md +15 -0
- data/.gitignore +1 -0
- data/.rubocop.yml +19 -1
- data/.rubocop_todo.yml +30 -103
- data/.simplecov +0 -1
- data/.travis.yml +20 -8
- data/CHANGELOG.md +89 -5
- data/CONTRIBUTING.md +54 -179
- data/Gemfile +7 -2
- data/{LICENSE.txt → MIT-LICENSE} +0 -0
- data/README.md +27 -5
- data/Rakefile +44 -16
- data/active_model_serializers.gemspec +9 -1
- data/appveyor.yml +1 -0
- data/bin/bench +171 -0
- data/bin/bench_regression +316 -0
- data/bin/serve_benchmark +39 -0
- data/docs/ARCHITECTURE.md +13 -7
- data/docs/README.md +5 -1
- data/docs/STYLE.md +58 -0
- data/docs/general/adapters.md +99 -16
- data/docs/general/configuration_options.md +87 -14
- data/docs/general/deserialization.md +100 -0
- data/docs/general/getting_started.md +35 -0
- data/docs/general/instrumentation.md +1 -1
- data/docs/general/key_transforms.md +40 -0
- data/docs/general/rendering.md +115 -13
- data/docs/general/serializers.md +138 -6
- data/docs/howto/add_pagination_links.md +36 -18
- data/docs/howto/outside_controller_use.md +4 -4
- data/docs/howto/passing_arbitrary_options.md +27 -0
- data/docs/jsonapi/errors.md +56 -0
- data/docs/jsonapi/schema.md +29 -18
- data/docs/rfcs/0000-namespace.md +106 -0
- data/docs/rfcs/template.md +15 -0
- data/lib/action_controller/serialization.rb +10 -19
- data/lib/active_model/serializable_resource.rb +4 -65
- data/lib/active_model/serializer.rb +73 -18
- data/lib/active_model/serializer/adapter.rb +15 -82
- data/lib/active_model/serializer/adapter/attributes.rb +5 -56
- data/lib/active_model/serializer/adapter/base.rb +5 -47
- data/lib/active_model/serializer/adapter/json.rb +6 -12
- data/lib/active_model/serializer/adapter/json_api.rb +5 -213
- data/lib/active_model/serializer/adapter/null.rb +7 -3
- data/lib/active_model/serializer/array_serializer.rb +3 -3
- data/lib/active_model/serializer/association.rb +4 -5
- data/lib/active_model/serializer/attributes.rb +1 -1
- data/lib/active_model/serializer/caching.rb +56 -5
- data/lib/active_model/serializer/collection_serializer.rb +30 -13
- data/lib/active_model/serializer/configuration.rb +7 -0
- data/lib/active_model/serializer/error_serializer.rb +10 -0
- data/lib/active_model/serializer/errors_serializer.rb +27 -0
- data/lib/active_model/serializer/links.rb +4 -2
- data/lib/active_model/serializer/lint.rb +14 -0
- data/lib/active_model/serializer/meta.rb +29 -0
- data/lib/active_model/serializer/null.rb +17 -0
- data/lib/active_model/serializer/reflection.rb +57 -1
- data/lib/active_model/serializer/type.rb +1 -1
- data/lib/active_model/serializer/version.rb +1 -1
- data/lib/active_model_serializers.rb +17 -0
- data/lib/active_model_serializers/adapter.rb +92 -0
- data/lib/active_model_serializers/adapter/attributes.rb +94 -0
- data/lib/active_model_serializers/adapter/base.rb +90 -0
- data/lib/active_model_serializers/adapter/json.rb +11 -0
- data/lib/active_model_serializers/adapter/json_api.rb +513 -0
- data/lib/active_model_serializers/adapter/json_api/deserialization.rb +213 -0
- data/lib/active_model_serializers/adapter/json_api/error.rb +96 -0
- data/lib/active_model_serializers/adapter/json_api/jsonapi.rb +49 -0
- data/lib/active_model_serializers/adapter/json_api/link.rb +83 -0
- data/lib/active_model_serializers/adapter/json_api/meta.rb +37 -0
- data/lib/active_model_serializers/adapter/json_api/pagination_links.rb +57 -0
- data/lib/active_model_serializers/adapter/json_api/relationship.rb +52 -0
- data/lib/active_model_serializers/adapter/json_api/resource_identifier.rb +37 -0
- data/lib/active_model_serializers/adapter/null.rb +10 -0
- data/lib/active_model_serializers/cached_serializer.rb +87 -0
- data/lib/active_model_serializers/callbacks.rb +1 -1
- data/lib/active_model_serializers/deprecate.rb +55 -0
- data/lib/active_model_serializers/deserialization.rb +2 -2
- data/lib/active_model_serializers/fragment_cache.rb +118 -0
- data/lib/active_model_serializers/json_pointer.rb +14 -0
- data/lib/active_model_serializers/key_transform.rb +70 -0
- data/lib/active_model_serializers/logging.rb +4 -1
- data/lib/active_model_serializers/model.rb +11 -1
- data/lib/active_model_serializers/railtie.rb +9 -1
- data/lib/active_model_serializers/register_jsonapi_renderer.rb +64 -0
- data/lib/active_model_serializers/serializable_resource.rb +81 -0
- data/lib/active_model_serializers/serialization_context.rb +24 -2
- data/lib/active_model_serializers/test/schema.rb +2 -2
- data/lib/grape/formatters/active_model_serializers.rb +1 -1
- data/test/action_controller/adapter_selector_test.rb +1 -1
- data/test/action_controller/json_api/deserialization_test.rb +56 -3
- data/test/action_controller/json_api/errors_test.rb +41 -0
- data/test/action_controller/json_api/linked_test.rb +10 -9
- data/test/action_controller/json_api/pagination_test.rb +2 -2
- data/test/action_controller/json_api/transform_test.rb +180 -0
- data/test/action_controller/serialization_scope_name_test.rb +201 -35
- data/test/action_controller/serialization_test.rb +39 -7
- data/test/active_model_serializers/adapter_for_test.rb +208 -0
- data/test/active_model_serializers/cached_serializer_test.rb +80 -0
- data/test/active_model_serializers/fragment_cache_test.rb +34 -0
- data/test/active_model_serializers/json_pointer_test.rb +20 -0
- data/test/active_model_serializers/key_transform_test.rb +263 -0
- data/test/active_model_serializers/logging_test.rb +8 -8
- data/test/active_model_serializers/railtie_test_isolated.rb +6 -0
- data/test/active_model_serializers/serialization_context_test_isolated.rb +58 -0
- data/test/adapter/deprecation_test.rb +100 -0
- data/test/adapter/json/belongs_to_test.rb +32 -34
- data/test/adapter/json/collection_test.rb +73 -75
- data/test/adapter/json/has_many_test.rb +36 -38
- data/test/adapter/json/transform_test.rb +93 -0
- data/test/adapter/json_api/belongs_to_test.rb +127 -129
- data/test/adapter/json_api/collection_test.rb +80 -82
- data/test/adapter/json_api/errors_test.rb +78 -0
- data/test/adapter/json_api/fields_test.rb +68 -70
- data/test/adapter/json_api/has_many_embed_ids_test.rb +32 -34
- data/test/adapter/json_api/has_many_explicit_serializer_test.rb +75 -77
- data/test/adapter/json_api/has_many_test.rb +121 -123
- data/test/adapter/json_api/has_one_test.rb +59 -61
- data/test/adapter/json_api/json_api_test.rb +28 -30
- data/test/adapter/json_api/linked_test.rb +319 -321
- data/test/adapter/json_api/links_test.rb +75 -50
- data/test/adapter/json_api/pagination_links_test.rb +115 -82
- data/test/adapter/json_api/parse_test.rb +114 -116
- data/test/adapter/json_api/relationship_test.rb +161 -0
- data/test/adapter/json_api/relationships_test.rb +199 -0
- data/test/adapter/json_api/resource_identifier_test.rb +85 -0
- data/test/adapter/json_api/resource_meta_test.rb +100 -0
- data/test/adapter/json_api/toplevel_jsonapi_test.rb +61 -63
- data/test/adapter/json_api/transform_test.rb +500 -0
- data/test/adapter/json_api/type_test.rb +61 -0
- data/test/adapter/json_test.rb +35 -37
- data/test/adapter/null_test.rb +13 -15
- data/test/adapter/polymorphic_test.rb +72 -0
- data/test/adapter_test.rb +27 -29
- data/test/array_serializer_test.rb +7 -8
- data/test/benchmark/app.rb +65 -0
- data/test/benchmark/benchmarking_support.rb +67 -0
- data/test/benchmark/bm_caching.rb +117 -0
- data/test/benchmark/bm_transform.rb +34 -0
- data/test/benchmark/config.ru +3 -0
- data/test/benchmark/controllers.rb +77 -0
- data/test/benchmark/fixtures.rb +167 -0
- data/test/cache_test.rb +388 -0
- data/test/collection_serializer_test.rb +10 -0
- data/test/fixtures/active_record.rb +12 -0
- data/test/fixtures/poro.rb +28 -3
- data/test/grape_test.rb +5 -5
- data/test/lint_test.rb +9 -0
- data/test/serializable_resource_test.rb +59 -3
- data/test/serializers/associations_test.rb +8 -8
- data/test/serializers/attribute_test.rb +7 -7
- data/test/serializers/caching_configuration_test_isolated.rb +170 -0
- data/test/serializers/meta_test.rb +74 -6
- data/test/serializers/read_attribute_for_serialization_test.rb +79 -0
- data/test/serializers/serialization_test.rb +55 -0
- data/test/support/isolated_unit.rb +3 -0
- data/test/support/rails5_shims.rb +26 -8
- data/test/support/rails_app.rb +38 -18
- data/test/support/serialization_testing.rb +5 -5
- data/test/test_helper.rb +6 -10
- metadata +132 -37
- data/docs/DESIGN.textile +7 -1
- data/lib/active_model/serializer/adapter/cached_serializer.rb +0 -45
- data/lib/active_model/serializer/adapter/fragment_cache.rb +0 -111
- data/lib/active_model/serializer/adapter/json/fragment_cache.rb +0 -13
- data/lib/active_model/serializer/adapter/json_api/deserialization.rb +0 -207
- data/lib/active_model/serializer/adapter/json_api/fragment_cache.rb +0 -21
- data/lib/active_model/serializer/adapter/json_api/link.rb +0 -44
- data/lib/active_model/serializer/adapter/json_api/pagination_links.rb +0 -58
- data/test/active_model_serializers/serialization_context_test.rb +0 -18
- data/test/adapter/fragment_cache_test.rb +0 -38
- data/test/adapter/json_api/resource_type_config_test.rb +0 -71
- data/test/serializers/adapter_for_test.rb +0 -166
- data/test/serializers/cache_test.rb +0 -209
- data/test/support/simplecov.rb +0 -6
- data/test/support/stream_capture.rb +0 -50
- data/test/support/test_case.rb +0 -19
data/CONTRIBUTING.md
CHANGED
@@ -1,187 +1,80 @@
|
|
1
|
-
|
1
|
+
## Have an issue?
|
2
2
|
|
3
|
-
|
4
|
-
http://www.commitstrip.com/en/2014/05/07/the-truth-behind-open-source-apps/](docs/how-open-source-maintained.jpg)
|
3
|
+
Before opening an issue, try the following:
|
5
4
|
|
6
|
-
|
5
|
+
##### Consult the documentation
|
7
6
|
|
8
|
-
|
9
|
-
[issue](https://github.com/rails-api/active_model_serializers/issues/1258).
|
7
|
+
See if your issue can be resolved by information in the documentation.
|
10
8
|
|
11
|
-
|
9
|
+
- [0.10 (master) Documentation](https://github.com/rails-api/active_model_serializers/tree/master/docs)
|
10
|
+
- [![API Docs](http://img.shields.io/badge/yard-docs-blue.svg)](http://www.rubydoc.info/github/rails-api/active_model_serializers/v0.10.0.rc5)
|
11
|
+
- [Guides](docs)
|
12
|
+
- [0.9 (0-9-stable) Documentation](https://github.com/rails-api/active_model_serializers/tree/0-9-stable)
|
13
|
+
- [0.8 (0-8-stable) Documentation](https://github.com/rails-api/active_model_serializers/tree/0-8-stable)
|
12
14
|
|
13
|
-
|
14
|
-
- [Writing code and comments](CONTRIBUTING.md#writing-code-and-comments)
|
15
|
+
##### Check for an existing issue
|
15
16
|
|
16
|
-
|
17
|
+
Take a look at the issues to see if a similar one has already been created. If
|
18
|
+
one exists, please add any additional information that might expedite
|
19
|
+
resolution.
|
17
20
|
|
18
|
-
|
19
|
-
bugs, ideas, documentation (`/docs`), performance problems – everything helps!
|
21
|
+
#### Open an issue
|
20
22
|
|
21
|
-
|
23
|
+
If the documentation wasn't able to help resolve the issue and no issue already
|
24
|
+
exists, please open a new issue with the following in mind:
|
22
25
|
|
23
|
-
|
26
|
+
- Please make sure only to include one issue per report. If you encounter
|
27
|
+
multiple, unrelated issues, please report them as such.
|
28
|
+
- Be detailed. Provide backtraces and example code when possible. Provide
|
29
|
+
information about your environment. e.g., Ruby version, rails version, etc.
|
30
|
+
- Own your issue. Actively participate in the discussion and help drive the
|
31
|
+
issue to closure.
|
32
|
+
- If you resolve your own issue, please share the details on the issue and close
|
33
|
+
it out. Others might have the same issue and sharing solutions is helpful.
|
24
34
|
|
25
|
-
|
26
|
-
- If you find an existing issue report, feel free to add further information to that report.
|
35
|
+
## Contributing
|
27
36
|
|
28
|
-
|
37
|
+
Contributing can be done in many ways and is not exclusive to code. If you have
|
38
|
+
thoughts on a particular issue or feature, we encourage you to open new issues
|
39
|
+
for discussion or add your comments to existing ones.
|
29
40
|
|
30
|
-
|
31
|
-
issue](https://github.com/rails-api/active_model_serializers/issues/new):
|
41
|
+
#### Pull requests
|
32
42
|
|
33
|
-
|
34
|
-
|
35
|
-
- If you are not running the latest version (please check), and you cannot update it,
|
36
|
-
please specify in your report why you can't update to the latest version.
|
37
|
-
- Operating system type + version.
|
38
|
-
- Ruby version with patch level. And whether you're using rvm, rbenv, etc.
|
39
|
-
- Include `ruby -e "puts RUBY_DESCRIPTION"`.
|
40
|
-
- Clearly-written steps to reproduce the issue (i.e. "Show me how to show myself." ), including:
|
41
|
-
- What were you doing? Include code if possible.
|
42
|
-
- Command line parameters used, if any.
|
43
|
-
- RubyGems code in your Gemfile, if any. Gemfile.lock, if possible.
|
44
|
-
- Any configuration you've made.
|
45
|
-
- What did you expect to happen?
|
46
|
-
- What happened? Include as much information as possible.
|
47
|
-
- Nature of reported defect (e.g. user name missing, not "It doesn't work."). Is it intermittent?
|
48
|
-
- The best help here is a failing test. Even better if it's a PR.
|
49
|
-
- Then the steps to reproduce and/or a gist or repository that demonstrates the defect.
|
50
|
-
- Then examples of the code you were using.
|
51
|
-
- Any error messages (including stacktrace, i.e. "Show me the error.")
|
52
|
-
- Things you've tried.
|
53
|
-
- A pull request for your fix would be great. Code should have tests.
|
54
|
-
- Link to source code, if available.
|
43
|
+
We also gladly welcome pull requests. When preparing to work on pull request,
|
44
|
+
please adhere to these standards:
|
55
45
|
|
56
|
-
|
57
|
-
|
46
|
+
- Base work on the master branch unless fixing an issue with
|
47
|
+
[0.9-stable](https://github.com/rails-api/active_model_serializers/tree/0-9-stable)
|
48
|
+
or
|
49
|
+
[0.8-stable](https://github.com/rails-api/active_model_serializers/tree/0-8-stable)
|
50
|
+
- Squash your commits and regularly rebase off master.
|
51
|
+
- Provide a description of the changes contained in the pull request.
|
52
|
+
- Note any specific areas that should be reviewed.
|
53
|
+
- Include tests.
|
54
|
+
- The test suite must pass on [supported Ruby versions](.travis.yml)
|
55
|
+
- Include updates to the [documentation](https://github.com/rails-api/active_model_serializers/tree/master/docs)
|
56
|
+
where applicable.
|
57
|
+
- Update the
|
58
|
+
[CHANGELOG](https://github.com/rails-api/active_model_serializers/blob/master/CHANGELOG.md)
|
59
|
+
to the appropriate sections with a brief description of the changes.
|
60
|
+
- Do not change the VERSION file.
|
58
61
|
|
59
|
-
|
60
|
-
[How to Report Bugs Effectively](http://www.chiark.greenend.org.uk/~sgtatham/bugs.html)
|
61
|
-
which is [well worth reading](http://yourbugreportneedsmore.info/), although it is not specific to ActiveModelSerializers.
|
62
|
+
#### Running tests
|
62
63
|
|
63
|
-
|
64
|
+
Run all tests
|
64
65
|
|
65
|
-
|
66
|
+
`$ rake test`
|
66
67
|
|
67
|
-
|
68
|
+
Run a single test suite
|
68
69
|
|
69
|
-
|
70
|
-
an invitation to make a better case for your issue or be able to reproduce a bug, and
|
71
|
-
its being close is just an opportunity to help out some more, and then re-open.
|
72
|
-
|
73
|
-
#### After
|
74
|
-
|
75
|
-
Thanks to everyone involved!
|
76
|
-
|
77
|
-
If you get help, sharing it back in the form of a pull-request or making an issue to document
|
78
|
-
what you've found is *extremely* helpful.
|
79
|
-
|
80
|
-
If you solve your issue, stop working on it, or realize the problem was something else,
|
81
|
-
please share that in a comment to an issue and close it. That way, everyone can learn and
|
82
|
-
we don't have closed issues without a clear resolution. Even if it's just a stackoverflow link :)
|
83
|
-
And please don't forget to stay involved in the issue until it is closed! Thanks to all!
|
84
|
-
|
85
|
-
### Writing code and comments
|
86
|
-
|
87
|
-
- We are actively working to identify tasks under the label [**Good for New
|
88
|
-
Contributors**](https://github.com/rails-api/active_model_serializers/labels/Good%20for%20New%20Contributors).
|
89
|
-
- [Changelog
|
90
|
-
Missing](https://github.com/rails-api/active_model_serializers/issues?q=label%3A%22Changelog+Missing%22+is%3Aclosed) is
|
91
|
-
an easy way to help out.
|
92
|
-
|
93
|
-
- [Fix a bug](https://github.com/rails-api/active_model_serializers/labels/Ready%20for%20PR).
|
94
|
-
- Ready for PR - A well defined bug, needs someone to PR a fix.
|
95
|
-
- Bug - Anything that is broken.
|
96
|
-
- Regression - A bug that did not exist in previous versions and isn't a new feature (applied in tandem with Bug).
|
97
|
-
- Performance - A performance related issue. We could track this as a bug, but usually these would have slightly lower priority than standard bugs.
|
98
|
-
|
99
|
-
- [Develop new features](https://github.com/rails-api/active_model_serializers/labels/Feature).
|
100
|
-
|
101
|
-
- [Improve code quality](https://codeclimate.com/github/rails-api/active_model_serializers/code?sort=smell_count&sort_direction=desc).
|
102
|
-
|
103
|
-
- [Improve amount of code exercised by tests](https://codeclimate.com/github/rails-api/active_model_serializers/coverage?sort=covered_percent&sort_direction=asc).
|
104
|
-
|
105
|
-
- [Fix RuboCop (Style) TODOS](https://github.com/rails-api/active_model_serializers/blob/master/.rubocop_todo.yml).
|
106
|
-
- Delete and offsense, run `rake rubocop` (or possibly `rake rubocop:auto_correct`),
|
107
|
-
and [submit a PR](CONTRIBUTING.md#submitting-a-pull-request-pr).
|
108
|
-
|
109
|
-
- We are also encouraging comments to substantial changes (larger than bugfixes and simple features) under an
|
110
|
-
"RFC" (Request for Comments) process before we start active development.
|
111
|
-
Look for the [**RFC**](https://github.com/rails-api/active_model_serializers/labels/RFC) label.
|
112
|
-
|
113
|
-
#### Submitting a pull request (PR)
|
114
|
-
|
115
|
-
1. The vast majority of development is happening under the `master` branch.
|
116
|
-
This is where we would suggest you start.
|
117
|
-
1. Fixing bugs is extraordinarily helpful and requires the least familiarity with ActiveModelSerializers.
|
118
|
-
Look for issues labeled [**Needs Bug Verification**](https://github.com/rails-api/active_model_serializers/labels/Needs%20Bug%20Verification) and [**Bug**](https://github.com/rails-api/active_model_serializers/labels/bug).
|
119
|
-
1. Adding or fixing documentation is also fantastic!
|
120
|
-
|
121
|
-
To fetch & test the library for development, do:
|
122
|
-
|
123
|
-
1. Fork the repository ( https://github.com/rails-api/active_model_serializers/fork )
|
124
|
-
1. `git clone https://github.com/{whoami}/active_model_serializers.git`
|
125
|
-
1. `cd active_model_serializers`
|
126
|
-
1. `bundle`
|
127
|
-
- To test against a particular rails version-- 4.0 is usually the most buggy-- set then
|
128
|
-
RAILS_VERSION environment variable as described in the [.travis.yml](.travis.yml).
|
129
|
-
e.g. `export RAILS_VERSION=4.0`.
|
130
|
-
1. Create your PR branch (`git checkout -b my-helpful-pr`)
|
131
|
-
1. Write tests for your feature, or regression tests highlighting a bug.
|
132
|
-
This is important so ActiveModelSerializers doesn't break it in a future version unintentionally.
|
133
|
-
1. Write the feature itself, or fix your bug
|
134
|
-
1. `bundle exec rake`
|
135
|
-
1. Commit your changes (`git commit -am 'Add some feature'`)
|
136
|
-
- Use well-described, small (atomic) commits.
|
137
|
-
1. Push to the branch (`git push origin my-helpful-pr`)
|
138
|
-
1. Create a new Pull Request
|
139
|
-
- Include links to any relevant github issues.
|
140
|
-
- *Don't* change the VERSION file.
|
141
|
-
- Update `/docs` to include, whenever possible, a new, suitable recommendation about how to use
|
142
|
-
the feature.
|
143
|
-
- Extra Credit: [Confirm it runs and tests pass on the rubies specified in the travis
|
144
|
-
config](.travis.yml). A maintainer will otherwise confirm it runs on these.
|
145
|
-
|
146
|
-
1. *Bonus Points* Update [CHANGELOG.md](https://github.com/rails-api/active_model_serializers/blob/master/CHANGELOG.md)
|
147
|
-
with a brief description of any breaking changes, fixes, features, or
|
148
|
-
miscellaneous changes under the proper version section.
|
149
|
-
1. Iterate on feedback given by the community (fix syntax, modify bits of code, add
|
150
|
-
tests), pushing the new commits to the PR each time
|
151
|
-
|
152
|
-
Remember to [squash your commits](CONTRIBUTING.md#about-pull-requests-prs) and rebase off `master`.
|
153
|
-
|
154
|
-
#### How maintainers handle pull requests:
|
155
|
-
|
156
|
-
- If the tests pass and the pull request looks good, a maintainer will merge it.
|
157
|
-
- If the pull request needs to be changed,
|
158
|
-
- you can change it by updating the branch you generated the pull request from
|
159
|
-
- either by adding more commits, or
|
160
|
-
- by force pushing to it
|
161
|
-
- A maintainer can make any changes themselves and manually merge the code in.
|
162
|
-
|
163
|
-
#### Commit Messages
|
164
|
-
|
165
|
-
- [A Note About Git Commit Messages](http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html)
|
166
|
-
- [http://stopwritingramblingcommitmessages.com/](http://stopwritingramblingcommitmessages.com/)
|
167
|
-
- [ThoughtBot style guide](https://github.com/thoughtbot/guides/tree/master/style#git)
|
168
|
-
|
169
|
-
#### About Pull Requests (PR's)
|
70
|
+
`$ rake test TEST=path/to/test.rb`
|
170
71
|
|
171
|
-
|
172
|
-
- [Github pull requests made easy](http://www.element84.com/github-pull-requests-made-easy.html)
|
173
|
-
- [Exercism Git Workflow](http://help.exercism.io/git-workflow.html).
|
174
|
-
- [Level up your Git](http://rakeroutes.com/blog/deliberate-git/)
|
175
|
-
- [All Your Open Source Code Are Belong To Us](http://www.benjaminfleischer.com/2013/07/30/all-your-open-source-code-are-belong-to-us/)
|
72
|
+
Run a single test
|
176
73
|
|
177
|
-
|
178
|
-
|
179
|
-
ActiveModelSerializers uses a subset of [StandardIssueLabels](https://github.com/wagenet/StandardIssueLabels) for Github Issues. You can [see our labels here](https://github.com/rails-api/active_model_serializers/labels).
|
180
|
-
|
181
|
-
## Running tests
|
74
|
+
`$ rake test TEST=path/to/test.rb TESTOPTS="--name=test_something"`
|
182
75
|
|
183
76
|
Run tests against different Rails versions by setting the RAILS_VERSION variable
|
184
|
-
and bundling gems.
|
77
|
+
and bundling gems.
|
185
78
|
|
186
79
|
```bash
|
187
80
|
for version in 4.0 4.1 4.2 master; do
|
@@ -200,21 +93,3 @@ for version in 4.0 4.1 4.2 master; do
|
|
200
93
|
done
|
201
94
|
```
|
202
95
|
|
203
|
-
|
204
|
-
### Running with Rake
|
205
|
-
|
206
|
-
The easiest way to run the unit tests is through Rake. The default task runs
|
207
|
-
the entire test suite for all classes. For more information, checkout the
|
208
|
-
full array of rake tasks with "rake -T"
|
209
|
-
|
210
|
-
Rake can be found at http://docs.seattlerb.org/rake/.
|
211
|
-
|
212
|
-
To run a single test suite
|
213
|
-
|
214
|
-
`$ rake test TEST=path/to/test.rb`
|
215
|
-
|
216
|
-
Which can be further narrowed down to one test:
|
217
|
-
|
218
|
-
`$ rake test TEST=path/to/test.rb TESTOPTS="--name=test_something"`
|
219
|
-
|
220
|
-
:heart: :sparkling_heart: :heart:
|
data/Gemfile
CHANGED
@@ -36,14 +36,19 @@ end
|
|
36
36
|
# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
|
37
37
|
gem 'tzinfo-data', platforms: (@windows_platforms + [:jruby])
|
38
38
|
|
39
|
+
group :bench do
|
40
|
+
# https://github.com/rails-api/active_model_serializers/commit/cb4459580a6f4f37f629bf3185a5224c8624ca76
|
41
|
+
gem 'benchmark-ips', require: false, group: :development
|
42
|
+
end
|
43
|
+
|
39
44
|
group :test do
|
40
45
|
gem 'sqlite3', platform: (@windows_platforms + [:ruby])
|
41
46
|
gem 'activerecord-jdbcsqlite3-adapter', platform: :jruby
|
42
47
|
|
43
48
|
gem 'codeclimate-test-reporter', require: false
|
44
|
-
gem 'simplecov', '~> 0.10', require: false, group: :development
|
45
49
|
end
|
46
50
|
|
47
51
|
group :development, :test do
|
48
|
-
gem 'rubocop', '~> 0.
|
52
|
+
gem 'rubocop', '~> 0.36', require: false
|
53
|
+
gem 'yard', require: false
|
49
54
|
end
|
data/{LICENSE.txt → MIT-LICENSE}
RENAMED
File without changes
|
data/README.md
CHANGED
@@ -1,17 +1,39 @@
|
|
1
1
|
# ActiveModelSerializers
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
3
|
+
<table>
|
4
|
+
<tr>
|
5
|
+
<td>Build Status</td>
|
6
|
+
<td>
|
7
|
+
<a href="https://travis-ci.org/rails-api/active_model_serializers"><img src="https://travis-ci.org/rails-api/active_model_serializers.svg?branch=master" alt="Build Status" ></a>
|
8
|
+
<a href="https://ci.appveyor.com/project/joaomdmoura/active-model-serializers/branch/master"><img src="https://ci.appveyor.com/api/projects/status/x6xdjydutm54gvyt/branch/master?svg=true" alt="Build status"></a>
|
9
|
+
</td>
|
10
|
+
</tr>
|
11
|
+
<tr>
|
12
|
+
<td>Code Quality</td>
|
13
|
+
<td>
|
14
|
+
<a href="https://codeclimate.com/github/rails-api/active_model_serializers"><img src="https://codeclimate.com/github/rails-api/active_model_serializers/badges/gpa.svg" alt="Code Quality"></a>
|
15
|
+
<a href="https://codebeat.co/projects/github-com-rails-api-active_model_serializers"><img src="https://codebeat.co/badges/a9ab35fa-8b5a-4680-9d4e-a81f9a55ebcd" alt="codebeat" ></a>
|
16
|
+
<a href="https://codeclimate.com/github/rails-api/active_model_serializers/coverage"><img src="https://codeclimate.com/github/rails-api/active_model_serializers/badges/coverage.svg" alt="Test Coverage"></a>
|
17
|
+
</td>
|
18
|
+
</tr>
|
19
|
+
<tr>
|
20
|
+
<td>Issue Stats</td>
|
21
|
+
<td>
|
22
|
+
<a href="https://github.com/rails-api/active_model_serializers/pulse/monthly">Pulse</a>
|
23
|
+
</td>
|
24
|
+
</tr>
|
25
|
+
</table>
|
26
|
+
|
7
27
|
|
8
28
|
## Documentation
|
9
29
|
|
10
30
|
- [0.10 (master) Documentation](https://github.com/rails-api/active_model_serializers/tree/master)
|
11
|
-
- [![API Docs](http://img.shields.io/badge/yard-docs-blue.svg)](http://www.rubydoc.info/github/rails-api/active_model_serializers)
|
31
|
+
- [![API Docs](http://img.shields.io/badge/yard-docs-blue.svg)](http://www.rubydoc.info/github/rails-api/active_model_serializers/v0.10.0.rc5)
|
12
32
|
- [Guides](docs)
|
13
33
|
- [0.9 (0-9-stable) Documentation](https://github.com/rails-api/active_model_serializers/tree/0-9-stable)
|
34
|
+
- [![API Docs](http://img.shields.io/badge/yard-docs-blue.svg)](http://www.rubydoc.info/github/rails-api/active_model_serializers/0-9-stable)
|
14
35
|
- [0.8 (0-8-stable) Documentation](https://github.com/rails-api/active_model_serializers/tree/0-8-stable)
|
36
|
+
- [![API Docs](http://img.shields.io/badge/yard-docs-blue.svg)](http://www.rubydoc.info/github/rails-api/active_model_serializers/0-8-stable)
|
15
37
|
|
16
38
|
## About
|
17
39
|
|
data/Rakefile
CHANGED
@@ -1,9 +1,34 @@
|
|
1
|
+
begin
|
2
|
+
require 'bundler/setup'
|
3
|
+
rescue LoadError
|
4
|
+
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
5
|
+
end
|
1
6
|
begin
|
2
7
|
require 'simplecov'
|
3
8
|
rescue LoadError
|
4
9
|
end
|
5
10
|
|
6
|
-
|
11
|
+
Bundler::GemHelper.install_tasks
|
12
|
+
|
13
|
+
require 'yard'
|
14
|
+
|
15
|
+
namespace :yard do
|
16
|
+
YARD::Rake::YardocTask.new(:doc) do |t|
|
17
|
+
t.stats_options = ['--list-undoc']
|
18
|
+
end
|
19
|
+
|
20
|
+
desc 'start a gem server'
|
21
|
+
task :server do
|
22
|
+
sh 'bundle exec yard server --gems'
|
23
|
+
end
|
24
|
+
|
25
|
+
desc 'use Graphviz to generate dot graph'
|
26
|
+
task :graph do
|
27
|
+
output_file = 'doc/erd.dot'
|
28
|
+
sh "bundle exec yard graph --protected --full --dependencies > #{output_file}"
|
29
|
+
puts 'open doc/erd.dot if you have graphviz installed'
|
30
|
+
end
|
31
|
+
end
|
7
32
|
|
8
33
|
begin
|
9
34
|
require 'rubocop'
|
@@ -37,30 +62,33 @@ end
|
|
37
62
|
|
38
63
|
require 'rake/testtask'
|
39
64
|
|
40
|
-
Rake::TestTask.new do |t|
|
65
|
+
Rake::TestTask.new(:test) do |t|
|
66
|
+
t.libs << 'lib'
|
41
67
|
t.libs << 'test'
|
42
|
-
t.
|
68
|
+
t.pattern = 'test/**/*_test.rb'
|
43
69
|
t.ruby_opts = ['-r./test/test_helper.rb']
|
70
|
+
t.ruby_opts << ' -w' unless ENV['NO_WARN'] == 'true'
|
44
71
|
t.verbose = true
|
45
72
|
end
|
46
73
|
|
47
74
|
desc 'Run isolated tests'
|
48
|
-
task isolated: ['test:isolated
|
75
|
+
task isolated: ['test:isolated']
|
49
76
|
namespace :test do
|
50
|
-
|
77
|
+
task :isolated do
|
51
78
|
desc 'Run isolated tests for Railtie'
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
79
|
+
require 'shellwords'
|
80
|
+
dir = File.dirname(__FILE__)
|
81
|
+
dir = Shellwords.shellescape(dir)
|
82
|
+
isolated_test_files = FileList['test/**/*_test_isolated.rb']
|
83
|
+
# https://github.com/rails/rails/blob/3d590add45/railties/lib/rails/generators/app_base.rb#L345-L363
|
84
|
+
_bundle_command = Gem.bin_path('bundler', 'bundle')
|
85
|
+
require 'bundler'
|
86
|
+
Bundler.with_clean_env do
|
87
|
+
isolated_test_files.all? do |test_file|
|
88
|
+
command = "-w -I#{dir}/lib -I#{dir}/test #{Shellwords.shellescape(test_file)}"
|
61
89
|
full_command = %("#{Gem.ruby}" #{command})
|
62
|
-
system(full_command)
|
63
|
-
end
|
90
|
+
system(full_command)
|
91
|
+
end or fail 'Failures' # rubocop:disable Style/AndOr
|
64
92
|
end
|
65
93
|
end
|
66
94
|
end
|
@@ -17,6 +17,7 @@ Gem::Specification.new do |spec|
|
|
17
17
|
spec.files = `git ls-files -z`.split("\x0")
|
18
18
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
19
|
spec.require_paths = ['lib']
|
20
|
+
spec.executables = []
|
20
21
|
|
21
22
|
spec.required_ruby_version = '>= 2.0.0'
|
22
23
|
|
@@ -51,8 +52,15 @@ Gem::Specification.new do |spec|
|
|
51
52
|
spec.add_development_dependency 'will_paginate', '~> 3.0', '>= 3.0.7'
|
52
53
|
|
53
54
|
spec.add_development_dependency 'bundler', '~> 1.6'
|
55
|
+
spec.add_development_dependency 'simplecov', '~> 0.11'
|
54
56
|
spec.add_development_dependency 'timecop', '~> 0.7'
|
55
|
-
spec.add_development_dependency 'minitest-reporters'
|
56
57
|
spec.add_development_dependency 'grape', ['>= 0.13', '< 1.0']
|
57
58
|
spec.add_development_dependency 'json_schema'
|
59
|
+
spec.add_development_dependency 'rake', ['>= 10.0', '< 12.0']
|
60
|
+
|
61
|
+
spec.post_install_message = <<-EOF
|
62
|
+
NOTE: The default key case for the JsonApi adapter has changed to dashed.
|
63
|
+
See https://github.com/rails-api/active_model_serializers/blob/master/docs/general/key_transform.md
|
64
|
+
for more information on configuring this behavior.
|
65
|
+
EOF
|
58
66
|
end
|