aboutsummaryrefslogtreecommitdiffstats
path: root/spec/models/referential_spec.rb
diff options
context:
space:
mode:
authorAlban Peignier2016-11-22 16:00:24 +0100
committerAlban Peignier2016-11-22 16:00:24 +0100
commit847a3bfc3ecaf0a3fe981359fe7a3eaaae3fac24 (patch)
treeed74741b945ef562a207a0684e73e1a44de093c4 /spec/models/referential_spec.rb
parent58dd80dee1d26890aba89354470304555a54dc29 (diff)
downloadchouette-core-847a3bfc3ecaf0a3fe981359fe7a3eaaae3fac24.tar.bz2
Manage several ReferentialMetadata::Periods in ReferentialMetadata. Refs #2035
Diffstat (limited to 'spec/models/referential_spec.rb')
-rw-r--r--spec/models/referential_spec.rb35
1 files changed, 21 insertions, 14 deletions
diff --git a/spec/models/referential_spec.rb b/spec/models/referential_spec.rb
index 2086f66d5..539af4db4 100644
--- a/spec/models/referential_spec.rb
+++ b/spec/models/referential_spec.rb
@@ -52,12 +52,16 @@ describe Referential, :type => :model do
"data_format"=>"neptune",
"metadatas_attributes"=> {
"0"=> {
- "first_period_begin(3i)"=>"19",
- "first_period_begin(2i)"=>"11",
- "first_period_begin(1i)"=>"2016",
- "first_period_end(3i)"=>"19",
- "first_period_end(2i)"=>"12",
- "first_period_end(1i)"=>"2016",
+ "periods_attributes" => {
+ "0" => {
+ "begin"=>"2016-09-19",
+ "end" => "2016-10-19",
+ },
+ "15918593" => {
+ "begin"=>"2016-11-19",
+ "end" => "2016-12-19",
+ },
+ },
"lines"=> [""] + lines.map { |l| l.id.to_s }
}
},
@@ -70,21 +74,24 @@ describe Referential, :type => :model do
let(:new_referential) { Referential.new(attributes) }
let(:first_metadata) { new_referential.metadatas.first }
- it "should create a metadata" do
- expect(new_referential.metadatas.size).to eq(1)
+ let(:expected_ranges) do
+ [
+ Range.new(Date.new(2016,9,19), Date.new(2016,10,19)),
+ Range.new(Date.new(2016,11,19), Date.new(2016,12,19)),
+ ]
end
- it "should define first_period_begin" do
- expect(first_metadata.first_period_begin).to eq(Date.new(2016,11,19))
+ it "should create a metadata" do
+ expect(new_referential.metadatas.size).to eq(1)
end
- it "should define first_period_end" do
- expect(first_metadata.first_period_end).to eq(Date.new(2016,12,19))
+ it "should define metadata periods" do
+ expect(first_metadata.periods.map(&:range)).to eq(expected_ranges)
end
- it "should define period" do
+ it "should define periodes" do
new_referential.save!
- expect(first_metadata.first_period).to eq(Range.new(Date.new(2016,11,19), Date.new(2016,12,19)))
+ expect(first_metadata.periodes).to eq(expected_ranges)
end
it "should define period" do