On Wed, Mar 23, 2011 at 04:52:21PM +0100, Jozef Zigmund wrote:
On 03/22/2011 09:12 PM, Steve Linabery wrote:
> Also added a length validation on pool_family name field since I couldn't find
any BZ for it.
> ---
> src/app/models/pool_family.rb | 3 +++
> src/spec/models/pool_family_spec.rb | 16 ++++++++++++++++
> 2 files changed, 19 insertions(+), 0 deletions(-)
>
> diff --git a/src/app/models/pool_family.rb b/src/app/models/pool_family.rb
> index 8d5c951..6b1165b 100644
> --- a/src/app/models/pool_family.rb
> +++ b/src/app/models/pool_family.rb
> @@ -39,6 +39,9 @@ class PoolFamily< ActiveRecord::Base
> has_many :pools, :dependent => :destroy
> has_and_belongs_to_many :provider_accounts
>
> + validates_length_of :name, :maximum => 255
> + validates_format_of :name, :with => /^[\w -]*$/n, :message => "must
only contain: numbers, letters, spaces, '_' and '-'"
> +
> validates_presence_of :name
> validates_uniqueness_of :name
> def self.default
> diff --git a/src/spec/models/pool_family_spec.rb
b/src/spec/models/pool_family_spec.rb
> index 68dfb42..b6669ad 100644
> --- a/src/spec/models/pool_family_spec.rb
> +++ b/src/spec/models/pool_family_spec.rb
> @@ -31,4 +31,20 @@ describe PoolFamily do
> @pool_family.provider_accounts[0].id.should == @provider_account.id
> end
>
> + it "should not be valid if name is too long" do
> + u = Factory(:pool)
> + u.name = ('a' * 256)
> + u.valid?.should be_false
> + u.errors[:name].should_not be_nil
> + u.errors[:name].should =~ /^is too long.*/
> + end
> +
> + it "should not be valid if name contains special characters" do
> + u = Factory(:pool)
> + u.name = '.'
> + u.valid?.should be_false
> + u.errors[:name].should_not be_nil
> + u.errors[:name].should =~ /^must only contain.*/
> + end
> +
> spec/models/pool_family_spec.rb
> end
It work fine, so ACK. But you should test :pool_family, not :pool, so
please fix
spec/models/pool_family_spec.rb file ;)
--
Jozef Zigmund
Ugh. ><}}}*>
_______________________________________________
aeolus-devel mailing list
aeolus-devel(a)lists.fedorahosted.org
https://fedorahosted.org/mailman/listinfo/aeolus-devel