BZ Bug 679387 - PGError : value too long on Pool field (https://bugzilla.redhat.com/show_bug.cgi?id=679387)
From: Jiri Tomasek jtomasek@redhat.com
--- src/app/models/pool.rb | 1 + 1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/src/app/models/pool.rb b/src/app/models/pool.rb index ce36d7d..ebee420 100644 --- a/src/app/models/pool.rb +++ b/src/app/models/pool.rb @@ -52,6 +52,7 @@ class Pool < ActiveRecord::Base validates_presence_of :pool_family validates_uniqueness_of :name validates_uniqueness_of :exported_as, :if => :exported_as + validates_length_of :name, :maximum => 255
validates_format_of :name, :with => /^[\w -]*$/n, :message => "must only contain: numbers, letters, spaces, '_' and '-'"
From: Jiri Tomasek jtomasek@redhat.com
--- src/spec/models/pool_spec.rb | 25 +++++++++++++++++++++++++ 1 files changed, 25 insertions(+), 0 deletions(-) create mode 100644 src/spec/models/pool_spec.rb
diff --git a/src/spec/models/pool_spec.rb b/src/spec/models/pool_spec.rb new file mode 100644 index 0000000..ca754fa --- /dev/null +++ b/src/spec/models/pool_spec.rb @@ -0,0 +1,25 @@ +require 'spec_helper' + +describe Pool do + before(:each) do + end + + it "should require unique name" do + pool1 = Factory.create(:pool) + pool2 = Factory.create(:pool) + pool1.should be_valid + pool2.should be_valid + + pool2.name = pool1.name + pool2.should_not be_valid + 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 + +end
On 03/22/2011 01:05 PM, jtomasek@redhat.com wrote:
BZ Bug 679387 - PGError : value too long on Pool field (https://bugzilla.redhat.com/show_bug.cgi?id=679387)
aeolus-devel mailing list aeolus-devel@lists.fedorahosted.org https://fedorahosted.org/mailman/listinfo/aeolus-devel
ACK to the both patches.
-- Jozef Zigmund
aeolus-devel@lists.fedorahosted.org