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 #2345

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

@phanyzewski phanyzewski changed the base branch from master to 4-0-maintenance May 25, 2020 02:53
@phanyzewski phanyzewski changed the title Patch 4 0 api request generator Patch api_request_spec template PATCH/update May 25, 2020
@phanyzewski
Copy link
Contributor Author

Original PR has failing tests related to rails 6
#2344

expect(response.content_type).to eq "application/json"

expected: "application/json"
         got: "application/json; charset=utf-8"

Rebased this change against the 4-0 maintenance branch after seeing this discussion.
#2134

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 deleted the patch_4-0_api_request_generator branch May 25, 2020 16:12
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