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

Patch api_request_spec template PATCH/update #2344

Merged
merged 1 commit into from
May 25, 2020

Conversation

phanyzewski
Copy link
Contributor

Generating api request specs using rails g scaffold creates invalid default test cases for PATCH/update.

new_attributes should be used in place of invalid_attributes in the template

Copy link
Member

@JonRowe JonRowe left a comment

Choose a reason for hiding this comment

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

Can you close one or the other PRs? We don't need duplicate PRs as it is easier for us to cherry-pick the merge commit across to the other, my preference is to merge PRs to master and cherry-pick across to 4-0-maintenance but I don't mind which you keep.

Can you fix the spec so the build passes and then I'm happy with this.

<%= file_name %>.reload
skip("Add assertions for updated state")
end

it "renders a JSON response with the <%= ns_file_name %>" do
<%= file_name %> = <%= class_name %>.create! valid_attributes
patch <%= show_helper.tr('@', '') %>,
params: { <%= singular_table_name %>: invalid_attributes }, headers: valid_headers, as: :json
params: { <%= singular_table_name %>: new_attributes }, headers: valid_headers, as: :json
expect(response).to have_http_status(:ok)
expect(response.content_type).to eq("application/json")
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
expect(response.content_type).to eq("application/json")
expect(response.content_type).to match(a_string_including("application/json"))

@phanyzewski phanyzewski requested a review from JonRowe May 25, 2020 17:52
@JonRowe JonRowe merged commit e0ec5a9 into rspec:master May 25, 2020
@JonRowe
Copy link
Member

JonRowe commented May 25, 2020

Thanks!

JonRowe added a commit that referenced this pull request May 25, 2020
JonRowe added a commit that referenced this pull request May 25, 2020
Patch api_request_spec template PATCH/update
JonRowe added a commit that referenced this pull request May 25, 2020
This was referenced Mar 15, 2021
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.

2 participants