Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Addas to encode a request as a specific mime type.#21671

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged

Conversation

@kaspth
Copy link
Contributor

Turns longish integration test setup like

postarticles_path(format::json),params:{article:{title:'Ahoy!'}}.to_json,headers:{'Content-Type'=>'application/json'}

into

postarticles_path,params:{article:{title:'Ahoy!'}},as::json

And removes the need to add helpers likepost_json etc.

I'm not sure ifencoder is the term to use internally. Perhapsinterpreter would be better. Suggestions welcome.

Perhaps we'd need more mime types. Suggestions welcome.

@kaspthkaspth self-assigned thisSep 18, 2015
@kaspthkaspth added this to the5.0.0 milestoneSep 18, 2015
@kaspthkaspthforce-pushed theintegration-request-encoding-helpers branch frome8e5f46 to749b74bCompareSeptember 19, 2015 20:29
@kaspth
Copy link
ContributorAuthor

All right, added some tests and documentation.

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

Am I right in making this claim? Definitely feels like it could use some shine, but don't have a fully formed idea of which direction to take it.

Copy link
Member

Choose a reason for hiding this comment

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

I don't think so. Try to test it in a controller with curl.

@arthurnn
Copy link
Member

I like the idea behind this. 👍 I remember having to do those setups before, and indeed we could make that setup easier.

@arthurnn
Copy link
Member

dont forget to add a changelog for it.

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

Should probably do a test for how much of an impact this has on our integration test speed.

Copy link
Member

Choose a reason for hiding this comment

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

Can we defer the path parsing toappend_format_to? If we don't need to append a format and if the paths is not a full path there is no need to parsing.

@kaspth
Copy link
ContributorAuthor

@arthurnn cool 😁

@rafaelfrancarafaelfranca modified the milestones:5.0.0,5.0.0 [temp]Dec 31, 2015
Turns```post articles_path(format: :json), params: { article: { name: 'Ahoy!' } }.to_json,  headers: { 'Content-Type' => 'application/json' }```into```post articles_path, params: { article: { name: 'Ahoy!' } }, as: :json```
@kaspthkaspthforce-pushed theintegration-request-encoding-helpers branch from749b74b to52bb2d3CompareJanuary 4, 2016 22:07
Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

@rafaelfranca tried your suggestion to call a custom controller via curl, but couldn't get it to work.

When I byebugrequest_parameters it seems tofetch_header which calls@env.fetch which already seems to have an empty hash for that key. Would you have any ideas why? I'll keep digging 😁

@kaspth
Copy link
ContributorAuthor

Reworked this to use Mime types as well, which simplified the tiny public API some more.

@dhh
Copy link
Member

dhh commentedFeb 10, 2016

Lovely! We have one of those annoying post_json helpers as well.

dhh pushed a commit that referenced this pull requestFeb 10, 2016
…lpersAdd `as` to encode a request as a specific mime type.
@dhhdhh merged commit688996d intorails:masterFeb 10, 2016
@kaspthkaspth deleted the integration-request-encoding-helpers branchFebruary 10, 2016 21:06
y-yagi added a commit to y-yagi/rails that referenced this pull requestMay 27, 2016
prathamesh-sonpatki added a commit to prathamesh-sonpatki/rails that referenced this pull requestJun 7, 2016
-Fixesrails#25183.- The `as: :json` feature was added inrails#21671 and recommended to use for  JSON endpoints so let's use it by default for API controller tests.
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

No reviews

Assignees

@kaspthkaspth

Labels

Projects

None yet

Milestone

5.0.0

Development

Successfully merging this pull request may close these issues.

4 participants

@kaspth@arthurnn@dhh@rafaelfranca

[8]ページ先頭

©2009-2025 Movatter.jp