validate description max lenth

This commit is contained in:
Rafael Schouten
2014-10-12 21:57:01 +11:00
parent 01c179856a
commit 5dd9879b96
2 changed files with 2 additions and 1 deletions

View File

@@ -1,7 +1,6 @@
class Enterprise < ActiveRecord::Base
TYPES = %w(full single profile)
ENTERPRISE_SEARCH_RADIUS = 100
self.inheritance_column = nil
acts_as_gmappable :process_geocoding => false
@@ -52,6 +51,7 @@ class Enterprise < ActiveRecord::Base
validates :email, presence: true
validates_presence_of :owner
validate :enforce_ownership_limit, if: lambda { owner_id_changed? && !owner_id.nil? }
validates_length_of :description, :maximum => 255
before_validation :ensure_owner_is_manager, if: lambda { owner_id_changed? && !owner_id.nil? }
before_validation :set_unused_address_fields

View File

@@ -86,6 +86,7 @@ describe Enterprise do
subject { FactoryGirl.create(:distributor_enterprise, :address => FactoryGirl.create(:address)) }
it { should validate_presence_of(:name) }
it { should validate_presence_of(:email) }
it { should validate_length_of(:description, :maximum => 255) }
it "requires an owner" do
expect{