Skip to content
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

Unexpected ActiveRecord::StatementInvalid #14

Conversation

HugsDaniel
Copy link

What ? Why ?

Closes openfoodfoundation/openfoodnetwork#2537

I replaced the RecordNotUnique by StatementInvalid with SQLite3::ConstraintException to fit the expected record not unique error.

Copy link
Member

@mkllnk mkllnk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pau and I discussed at some point that we would like to test with Postgres instead of Sqlite, because that's the database we use in OFN. Can you try to run it with Postgres and see if that solves this spec issue? Do you have access to the Semaphore project to change the configuration?

@product2 = create(:product, :name => 'foo')
lambda do
@product2.update_attributes(:permalink => @product1.permalink)
end.should raise_error(ActiveRecord::RecordNotUnique)
end.should raise_error(ActiveRecord::StatementInvalid, /SQLite3::ConstraintException/)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a more general error we can test here? We actually don't want to use sqlite.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was able to test with Postgres and it doesn't fail ! Should we keep AR::RecordNotUnique then ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, the fewer patches we need, the better. :-) Thank you for testing.

@HugsDaniel
Copy link
Author

This can be closed since #17 solve the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants