rails/rails — pull request #3319 by martinsvalin (2011-10-13 16:44:36+00:00)
Title: ActiveModel::Errors#generate_message without i18n_scope, and more test cases for #add

ActiveModel::Errors#generate_message requires that the model we're adding errors to implements i18n_scope. This is not obvious from the documentation, and it is also not necessary as there are translation fallbacks that don't use i18n_scope.

The first of the three commits skips the translation defaults where i18n_scope is used if the model doesn't respond to it.

I also noticed that there were no tests on ActiveModel::Errors#add when message is a Symbol, or when message is a Proc. I wrote tests for these cases, each in it's own commit to make it easier if you'd like to pull these but not the commit dealing with i18n_scope.

Please bear in mind that, if you'd like to keep the requirement for 18n_scope on the model, the test case for when message is a Symbol won't pass. If generate_message doesn't check if the model responds, the test needs a minimal implementation of Person.i18n_scope to pass. I'll be happy to fix this.

PS. This is my first contribution to Rails. Yay! \o/
I attended an Open Source Hack Night in Stockholm on October 11. Kudos to Valtech for organizing it.