This project is archived and is in readonly mode.
ActiveResource::Base.save (PUT) doesn't clear out errors
-
Yehuda Katz (wycats)
- Milestone set to 2.3.6
-
Rizwan Reza
- Tag changed from activeresource, validation to activeresource, bugmash, validation
-
Josh Kalderimis
- Tag changed from activeresource, bugmash, validation to activeresource, bugmash, patch, validation
Here are failing tests and a patch tested against 2-3-stable
-
Josh Kalderimis
Sorry, was fighting LH there for a sec, here is the patch
-
Anil Wadghule
-1
Looks like it still have some issues. See pastie http://pastie.org/962508
after setting
a.name = nil
a.valid? should return false. But it's returning true. -
Josh Kalderimis
Hi Anil,
valid? on AResource works differently than ARecrod. In ARecord you can check against the validations, but in AResource you need to post again as validations are on the server. save is the only way to run the validations again, which this patch corrects (clearing errors before save).
What you are asking for is not supported in AResource.
Josh
-
Josh Kalderimis
Sorry, I didn't add before that the original bug is verified
-
Josh Kalderimis
- Tag changed from activeresource, bugmash, patch, validation to activeresource, bugmash, bugmash-review, patch, validation
-
Jeroen van Dijk
applies cleanly and tests pass for 1.8.7, but tests do not pass for 1.8.6 so I can't give a plus one.
I don't think it has to do with this pathch though. This is the error I get:
1) Error: test_exists_without_http_mock(BaseTest): NoMethodError: undefined method `any_instance' for ActiveResource::Connection:Class ./test/base_test.rb:989:in `test_exists_without_http_mock' 2) Error: test_accept_http_header(ConnectionTest): NoMethodError: undefined method `mock' for #<ConnectionTest:0xb78ae2a8> ./test/connection_test.rb:203:in `test_accept_http_header' 3) Error: test_ssl_error(ConnectionTest): NoMethodError: undefined method `expects' for #<ActiveResource::Connection:0xb7bb7a1c> ./test/connection_test.rb:223:in `test_ssl_error' 4) Error: test_timeout(ConnectionTest): NoMethodError: undefined method `mock' for #<ConnectionTest:0xb78adf74> ./test/connection_test.rb:185:in `test_timeout' 162 tests, 501 assertions, 0 failures, 4 errorsCode looks good too. One thing though, i think the test should be as follows
[ :json, :xml ].each do |format| def test_should_clear_errors_when_error_is_corrected set_mocks_to_invalid invalid_user_using_format(format) do assert !@person.valid? @person.name = "Joe Shmoe" @person.age = 56 set_mocks_to_valid assert @person.save assert @person.valid? end end endThis way the tests for xml and json fail seperately if ever.
-
Jeroen van Dijk
sorry, i get those errors without this patch too. Anyone else?
-
Jeroen van Dijk
Here is the improved example http://gist.github.com/403156
-
Josh Kalderimis
Is anyone able to verify and comment on this patch?
-
Jacques Crocker
+1
I can still repro this issue in Rails3
-
Ryan Bigg
Automatic cleanup of spam.
-
Ryan Bigg
Automatic cleanup of spam.
-
Santiago Pastorino
- State changed from new to open
This issue has been automatically marked as stale because it has not been commented on for at least three months.
The resources of the Rails core team are limited, and so we are asking for your help. If you can still reproduce this error on the 3-0-stable branch or on master, please reply with all of the information you have about it and add "[state:open]" to your comment. This will reopen the ticket for review. Likewise, if you feel that this is a very important feature for Rails to include, please reply with your explanation so we can consider it.
Thank you for all your contributions, and we hope you will understand this step to focus our efforts where they are most helpful.
-
Santiago Pastorino
- State changed from open to stale
