Conversation
vfonic
left a comment
There was a problem hiding this comment.
This pretty-much works. The difference is that, in order to see the detailed explanation of the error (problems), you'll have to catch the error and then do error.problems. Otherwise, in the terminal console, you'll only see Validation Error with no explanation.
So I'm not sure if adding the full error immediately is better.
| field_with_validation: "sh\nrt", | ||
| } | ||
| begin | ||
| client.create_item(COLLECTION_ID, data) |
There was a problem hiding this comment.
If this line doesn't raise, this (and preview test) will pass, without actually testing anything.
| items.each do |item| | ||
| result = client.delete_item(item) | ||
| assert_equal({"deleted"=>1}, result) | ||
| assert_equal({"deleted"=>{}}, result) |
There was a problem hiding this comment.
This is strange. We also have this test when testing our after_destroy callback: https://github.com/vfonic/webflow_sync/blob/master/spec/jobs/webflow_sync/destroy_item_job_spec.rb#L38
|
Here's how rails does it: [1] pry(main)> doc = Document.new;
[2] pry(main)> doc.save!
ActiveRecord::RecordInvalid: Validation failed: Entity must exist, Municipality must exist, File url can't be blank, Title can't be blank, Type is not included in the list
from /Users/viktor/.rvm/gems/ruby-2.6.6/gems/activerecord-6.0.3.4/lib/active_record/validations.rb:80:in `raise_validation_error'It returns all of the validation errors joined together in a single string: |
06f32cb to
5d35ca9
Compare
|
Thank you, @phoet! 🚀 |
#14
@vfonic i think that this approach is the more rubyesque way to solve this issue. you would need to handle errors and maybe even have your own error-class to show improved error-messages or validation hints.