aboutsummaryrefslogtreecommitdiffstats
path: root/app/models
diff options
context:
space:
mode:
authorRobert2017-11-02 08:20:08 +0100
committerRobert2017-11-03 14:44:56 +0100
commit6c24de52de8481c84e83c414563953cad13e869d (patch)
tree4282d67e9cd415c8d47c4bb19740128651e8f34e /app/models
parentc3c32ae541cfb018877af964f122b15f6f15b984 (diff)
downloadchouette-core-6c24de52de8481c84e83c414563953cad13e869d.tar.bz2
Refs:#4802@0.5h;
CodeReview: - Exchange fr and en translation files for referential_suites - Consistent usage of `jeu de donées` and `espace de travail` dans les *fr.yml Fixes: #4802@0.2h; Replaying former work. To identify spec regression Step 3: Added validation of reference_suite#new/current Made all specs pass
Diffstat (limited to 'app/models')
-rw-r--r--app/models/referential_suite.rb13
1 files changed, 13 insertions, 0 deletions
diff --git a/app/models/referential_suite.rb b/app/models/referential_suite.rb
index 9fd25ef3f..93c2c3f36 100644
--- a/app/models/referential_suite.rb
+++ b/app/models/referential_suite.rb
@@ -1,6 +1,19 @@
class ReferentialSuite < ActiveRecord::Base
belongs_to :new, class_name: 'Referential'
+ validate def validate_consistent_new
+ return true if new_id.nil?
+ return true if new.referential_suite_id == id
+ errors.add(:inconsistent_new,
+ I18n.t('referential_suites.errors.inconsistent_new', name: new.name))
+ end
+
belongs_to :current, class_name: 'Referential'
+ validate def validate_consistent_current
+ return true if current_id.nil?
+ return true if current.referential_suite_id == id
+ errors.add(:inconsistent_current,
+ I18n.t('referential_suites.errors.inconsistent_current', name: current.name))
+ end
has_many :referentials
end