Commit ccb58e659f4a4401b150d05ef5fd8fee9435d256

Authored by Rafael Manzo
1 parent 02e15f4c

Project validation fixed, so it doesn't break the other tests.

It's there are still missing
app/models/project.rb
... ... @@ -23,8 +23,8 @@ class Project < KalibroEntities::Entities::Project
23 23 end
24 24  
25 25 def save
26   - if (self.valid? and self.kalibro_errors.nil?)
27   - super.save
  26 + if self.valid? and self.kalibro_errors.empty?
  27 + super
28 28 else
29 29 false
30 30 end
... ...
app/models/validators/kalibro_uniqueness_validator.rb
... ... @@ -2,7 +2,8 @@ class KalibroUniquenessValidator < ActiveModel::EachValidator
2 2 def validate_each(record, attribute, value)
3 3 record.class.all.each do |entity|
4 4 if entity.send(attribute) == value
5   - record.kalibro_errors << "There's already a #{record.class} with this #{attribute}! Please, choose another one."
  5 + record.errors[:attribute] << "There's already a #{record.class} with #{attribute} #{value}! Please, choose another one."
  6 + break
6 7 end
7 8 end
8 9 end
... ...