Skip to content

Commit b16eb0a

Browse files
committed
Use to_sentence in ResourceController#destroy
1 parent a8bef20 commit b16eb0a

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

backend/app/controllers/spree/admin/resource_controller.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ def destroy
108108
invoke_callbacks(:destroy, :fails)
109109
respond_with(@object) do |format|
110110
format.html { redirect_to location_after_destroy }
111-
format.js { render status: :unprocessable_entity, plain: @object.errors.full_messages.join(', ') }
111+
format.js { render status: :unprocessable_entity, plain: @object.errors.full_messages.to_sentence }
112112
end
113113
end
114114
end

backend/spec/controllers/spree/admin/resource_controller_spec.rb

+2-1
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ def model_class
3737
def check_destroy_constraints
3838
return unless name == 'undestroyable'
3939
errors.add :base, "You can't destroy undestroyable things!"
40+
errors.add :base, "Terrible things might happen."
4041
throw(:abort)
4142
end
4243
end
@@ -164,7 +165,7 @@ def check_destroy_constraints
164165
it 'responds with error message' do
165166
subject
166167
expect(response).to be_unprocessable
167-
expect(response.body).to eq assigns(:widget).errors.full_messages.join(', ')
168+
expect(response.body).to eq assigns(:widget).errors.full_messages.to_sentence
168169
end
169170
end
170171
end

0 commit comments

Comments
 (0)