Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEATURE ember-route-serializers] Introduce serialize method to Router DSL options and deprecate Route#serialize #13016

Merged
merged 1 commit into from
Apr 18, 2016

Conversation

trentmwillis
Copy link
Member

@trentmwillis trentmwillis commented Feb 26, 2016

Implementation of emberjs/rfcs#120.

TODO:

@trentmwillis
Copy link
Member Author

Updated to separate the serializefunctions from the route definitions.

deepEqual(router.location.path, '/posts/emberjs');
});

QUnit.test('Custom Route#serialize method raises deprecation warning but still works', function() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Usually we just prefix these tests with DEPRECATED:

@mixonic
Copy link
Member

mixonic commented Mar 18, 2016

This is a good PoC @trentmwillis! A requisite next step would be this needing a feature-flag, prefixed commit etc. See contributing guides on adding a feature and CONTRIBUTING.md.

It seems like @rwjblue would also like to see the testing coverage over both features be the same, which means either duplicating the tests or better yet coming up with a good abstraction to help test the feature. Other thoughts @rwjblue? Likely @stefanpenner and @dgeb want to review in detail.

@trentmwillis
Copy link
Member Author

Thanks for reviewing @mixonic! Now that the RFC has been merged I'll work on formalizing this a bit more. As for the tests, I don't think there will be a good way to abstract out the new feature vs. the old but I'll take a look.

@rwjblue
Copy link
Member

rwjblue commented Mar 19, 2016

Ya, duplicating them is fairly common (since when enabled we will delete the duplication anyways).

@trentmwillis trentmwillis changed the title [POC] Introduce serialize method to Router DSL options and deprecate Route#serialize [FEATURE ember-route-serializers] Introduce serialize method to Router DSL options and deprecate Route#serialize Mar 20, 2016
@trentmwillis
Copy link
Member Author

Bolstered tests, added a feature flag, and prefixed the commit. I also cleaned up some usage of serialize methods that didn't need to exist. Let me know if anything else needs to happen.

@homu
Copy link
Contributor

homu commented Mar 21, 2016

☔ The latest upstream changes (presumably #13144) made this pull request unmergeable. Please resolve the merge conflicts.

run(function() {
expectDeprecation(function() {
router.transitionTo('posts', { category: 'emberjs' });
});
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding the deprecation message as a second argument to expectDeprecation will ensure that we're catching the right deprecation.

@dgeb
Copy link
Member

dgeb commented Mar 22, 2016

Nice work @trentmwillis - LGTM except that one nit 👍

@trentmwillis
Copy link
Member Author

@dgeb updated with your suggestion. However, it's failing but says the actual and expected values are the same, so I don't know what to do.

@dgeb
Copy link
Member

dgeb commented Mar 26, 2016

@trentmwillis ok thanks - will investigate.

@homu
Copy link
Contributor

homu commented Apr 9, 2016

☔ The latest upstream changes (presumably #13285) made this pull request unmergeable. Please resolve the merge conflicts.

@rwjblue
Copy link
Member

rwjblue commented Apr 11, 2016

However, it's failing but says the actual and expected values are the same, so I don't know what to do.

The message says:

Failed assertion: Did not receive failing Ember.deprecate call matching 'Defining a serialize function on route 'posts' is deprecated. Instead, define it in the router's map as an option.', last was success with 'Defining a serialize function on route 'posts' is deprecated. Instead, define it in the router's map as an option.', expected: true, but was: false

I believe it is saying that deprecate was called with the right string, but the test argument was false instead of true.

@trentmwillis
Copy link
Member Author

Ah okay, that makes sense. Was not interpreting it that way. I'll look into that sometime soon.

@trentmwillis
Copy link
Member Author

@rwjblue @dgeb rebased and all green now.

@rwjblue
Copy link
Member

rwjblue commented Apr 16, 2016

@trentmwillis - Awesome! I added the following items to a checklist in the main PR description:

  • Add entry to FEATURES.md
  • Add entry to emberjs/website deprecation guide for ember-routing.serialize-function (and update deprecate calls here to include the url)
  • Review documentation, and determine update needs for guides and API docs (making an issue/PR in emberjs/guides for changes needed there, and an issue in emberjs/ember.js with a list of updates needed here when the feature is enabled).

@trentmwillis
Copy link
Member Author

Sounds good, I'll try to get to those sometime this weekend.

@rwjblue
Copy link
Member

rwjblue commented Apr 18, 2016

I believe the API docs for Route.prototype.serialize need to be updated, likely in a separate PR that we can merge when we enable the feature.

@trentmwillis
Copy link
Member Author

Yeah, I was going to look at the API docs tomorrow to identify what all would need to be updated. Only things I could think of were Route#serialize and, potentially, RouterDSL, but I don't think that is actually documented anywhere.

@rwjblue
Copy link
Member

rwjblue commented Apr 18, 2016

Yeah, I suspect it is documented in Ember.Router.prototype.map or the Ember.Router docs, but I haven't looked recently. We should end up with it documented somewhere in the API docs if it isn't already.

@trentmwillis
Copy link
Member Author

@rwjblue I've opened a PR for the API docs update, which I believe was the last pertinent documentation change.

@rwjblue
Copy link
Member

rwjblue commented Apr 18, 2016

Awesome work @trentmwillis, thanks for keeping on this!

@rwjblue rwjblue merged commit a8f6972 into emberjs:master Apr 18, 2016
@xg-wang
Copy link
Contributor

xg-wang commented Nov 10, 2020

@trentmwillis @rwjblue I saw #13360 was closed. Is it currently recommended to define serialize on Route class or options hash? The only documentation I can find is at Route class https://api.emberjs.com/ember/3.22/classes/Route/methods/serialize?anchor=serialize

@rwjblue
Copy link
Member

rwjblue commented Nov 10, 2020

Ya, current recommendation is for route class. Though this (somewhat fundamentally) means that lazily loaded routes cannot customize their serialization behavior. Ideally you just shouldn't need to customize...

@trentmwillis trentmwillis deleted the route-serialize branch January 27, 2021 19:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants