-
-
Notifications
You must be signed in to change notification settings - Fork 909
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
weird error information #207
Comments
Do you have internationalized errors? Have you ever added anything in |
it's the same error after I remove
|
If you do a test without using shoulda-matchers, does it pass? Try creating a record, then creating a second record that violates the uniqueness constraint and checking |
|
Just looking at the error messages it seems clear that the matcher is looking for the short message in the |
Could someone put together a barebones repo that would reproduce this issue? It will make it easier for us to investigate. Thanks! |
I have exactly this same issue, I'm not sure if it's worth setting up a barebones repo, since my app has this matcher called in several places and it's just failing in one place. This is what I'm getting:
Hourly has the following validation: class Hourly < ActiveRecord::Base
...
validates :timestamp,
uniqueness: { scope: :source_id },
presence: true
...
end I've tried removing the presence validation, and deleting locale files with no luck . As I mentioned, there are other instances in the app where this matcher is working. Just updated to shoulda 3.4.0, and still have the same problem. Not sure what else can I add to this issue. |
Please try using verison 2.1.0 and if this is still a failure please let us know. Thanks. |
yes, it's still there with 2.1.0 |
As @opsdeveloper said, it's still present... |
Hi @mcmire, I know it's odd, but as said before in some models that problem is occurring, and in others not. This weekend will try to strip down my application in order to isolate the problem, and that would be a starting point. |
Hi @mcmire, I've forked your repo (http://github.com/ivanvc/sm-207-test-app), and added some code in order to reproduce it. I've found that in my case the problem appears to be somehow related, to have some nested parent models. Hope it helps to fix it. |
Also having this issue:
But I'm scoping to a polymorphic relationship with 2 columns. Or should I use something like subject.organizable to set it's polymorphic attribute to the previously created one? |
Re-implement how to get previous value in order to test validate_uniquenes_of matcher, after the scope changes. This way, new value should not be taken by a previous record. Fixes thoughtbot#207.
After some investigation, I've found that the problem (that was manifesting in my fork of sm-207-test-app), relates to a comment from validate_uniqueness_of_matcher.rb. And the problem is that when setting the new scoped value, it's already taken by another record. That makes I've fixed this issue, but not completely sure that is the best approach. Anyway, I'm creating a pull request right now, so you can review it. |
@ivanvc Ahhh... right. That makes sense. Thanks, I'll take a look. |
Re-implement how to get previous value in order to test validate_uniquenes_of matcher, after the scope changes. This way, new value should not be taken by a previous record. Fixes thoughtbot#207.
for the error information, I think this test should be passed, but it does not pass.
The text was updated successfully, but these errors were encountered: