File tree 1 file changed +15
-0
lines changed
lib/generators/rspec/scaffold/templates 1 file changed +15
-0
lines changed Original file line number Diff line number Diff line change 83
83
}.to change(<%= class_name %>, :count).by(0)
84
84
end
85
85
86
+ <% if Rails.version.to_f < 7.0 %>
86
87
it "renders a successful response (i.e. to display the 'new' template)" do
87
88
post <%= index_helper %>_url, params: { <%= singular_table_name %>: invalid_attributes }
88
89
expect(response).to be_successful
89
90
end
91
+ <% else %>
92
+ it "renders a response with 422 status (i.e. to display the 'new' template)" do
93
+ post <%= index_helper %>_url, params: { <%= singular_table_name %>: invalid_attributes }
94
+ expect(response).to have_http_status(:unprocessable_entity)
95
+ end
96
+ <% end %>
90
97
end
91
98
end
92
99
112
119
end
113
120
114
121
context "with invalid parameters" do
122
+ <% if Rails.version.to_f < 7.0 %>
115
123
it "renders a successful response (i.e. to display the 'edit' template)" do
116
124
<%= file_name %> = <%= class_name %>.create! valid_attributes
117
125
patch <%= show_helper %>, params: { <%= singular_table_name %>: invalid_attributes }
118
126
expect(response).to be_successful
119
127
end
128
+ <% else %>
129
+ it "renders a response with 422 status (i.e. to display the 'edit' template)" do
130
+ <%= file_name %> = <%= class_name %>.create! valid_attributes
131
+ patch <%= show_helper %>, params: { <%= singular_table_name %>: invalid_attributes }
132
+ expect(response).to have_http_status(:unprocessable_entity)
133
+ end
134
+ <% end %>
120
135
end
121
136
end
122
137
You can’t perform that action at this time.
0 commit comments