aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorteddywing2018-04-25 14:19:00 +0200
committerGitHub2018-04-25 14:19:00 +0200
commitf838c165685972992d1ee7f597c9d94662099d89 (patch)
treefeba4abe58639a8cf71c937136b6a6cebec91dea
parent94406e685f252451b87fc7f8aa4445761858c9fd (diff)
parent7851a5e2b998b6ec460af169ac79558009849e5f (diff)
downloadchouette-core-f838c165685972992d1ee7f597c9d94662099d89.tar.bz2
Merge pull request #474 from af83/6445-referential-period-error-display-and-validation
Refs #6445 Change ReferentialMetada validationto allowed one day peri…
-rw-r--r--app/models/referential_metadata.rb4
-rw-r--r--config/locales/referentials.en.yml2
-rw-r--r--config/locales/referentials.fr.yml2
-rw-r--r--spec/models/referential_metadata_spec.rb2
4 files changed, 5 insertions, 5 deletions
diff --git a/app/models/referential_metadata.rb b/app/models/referential_metadata.rb
index 7a8a01774..a4e6333d7 100644
--- a/app/models/referential_metadata.rb
+++ b/app/models/referential_metadata.rb
@@ -44,8 +44,8 @@ class ReferentialMetadata < ApplicationModel
validate :check_end_greather_than_begin
def check_end_greather_than_begin
- if self.begin and self.end and self.begin >= self.end
- errors.add(:base, I18n.t('referentials.errors.short_period'))
+ if self.begin and self.end and self.begin > self.end
+ errors.add(:base, I18n.t('referentials.errors.invalid_period'))
end
end
diff --git a/config/locales/referentials.en.yml b/config/locales/referentials.en.yml
index 1381d5ddd..f52eaa1cb 100644
--- a/config/locales/referentials.en.yml
+++ b/config/locales/referentials.en.yml
@@ -47,7 +47,7 @@ en:
user_excluded: "%{user} is a reserved value"
overlapped_referential: "%{referential} cover the same perimeter"
overlapped_period: "Another period is on the same period"
- short_period: Min period length is two days
+ invalid_period: The begin date must be before end date
overview:
head:
dates: Dates
diff --git a/config/locales/referentials.fr.yml b/config/locales/referentials.fr.yml
index cf012ef8e..c4633014b 100644
--- a/config/locales/referentials.fr.yml
+++ b/config/locales/referentials.fr.yml
@@ -47,7 +47,7 @@ fr:
user_excluded: "%{user} est une valeur réservée"
overlapped_referential: "%{referential} couvre le même périmètre d'offre"
overlapped_period: "Une autre période chevauche cette période"
- short_period: "La durée minimum d'une période est de deux jours"
+ invalid_period: La date de début doit être antérieure à la date de fin
overview:
head:
dates: Dates
diff --git a/spec/models/referential_metadata_spec.rb b/spec/models/referential_metadata_spec.rb
index 88a12b2bb..210f95e14 100644
--- a/spec/models/referential_metadata_spec.rb
+++ b/spec/models/referential_metadata_spec.rb
@@ -100,7 +100,7 @@ RSpec.describe ReferentialMetadata, :type => :model do
it "should validate that end is greather than or equlals to begin" do
expect(period(begin: "2016-11-21", end: "2016-11-22")).to be_valid
- expect(period(begin: "2016-11-21", end: "2016-11-21")).to_not be_valid
+ expect(period(begin: "2016-11-21", end: "2016-11-21")).to be_valid
expect(period(begin: "2016-11-22", end: "2016-11-21")).to_not be_valid
end