Skip to content

Commit 957b8e6

Browse files
committed
check if tests will pass for older rails too
1 parent 620633f commit 957b8e6

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

lib/generators/rspec/scaffold/templates/request_spec.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,11 +118,19 @@
118118
end
119119
120120
context "with invalid parameters" do
121+
<% if Rails.version.to_f < 6.1 || Rails.version == '6.1.0' %>
121122
it "renders a successful response (i.e. to display the 'edit' template)" do
122123
<%= file_name %> = <%= class_name %>.create! valid_attributes
123124
patch <%= show_helper.tr('@', '') %>, params: { <%= singular_table_name %>: invalid_attributes }
124125
expect(response).to be_successful
125126
end
127+
<% else %>
128+
it "renders a response with 422 status - unporcessable entity" do
129+
<%= file_name %> = <%= class_name %>.create! valid_attributes
130+
patch <%= show_helper.tr('@', '') %>, params: { <%= singular_table_name %>: invalid_attributes }
131+
expect(response.status).to eq(422)
132+
end
133+
<% end %>
126134
end
127135
end
128136

0 commit comments

Comments
 (0)