diff options
| author | cedricnjanga | 2017-07-31 10:24:56 +0200 |
|---|---|---|
| committer | cedricnjanga | 2017-07-31 11:09:51 +0200 |
| commit | bba83cb56a56d2f26e9c380b22fc542228d2eabc (patch) | |
| tree | e77d3ce0ae356769294e7f12e43176982723e2b7 /spec | |
| parent | 8d3e2d9dcbc61ce17053f5b66b742189f885ba06 (diff) | |
| download | chouette-core-bba83cb56a56d2f26e9c380b22fc542228d2eabc.tar.bz2 | |
Delete Timetable unnacessary methods and update specs
Diffstat (limited to 'spec')
| -rw-r--r-- | spec/models/chouette/time_table_spec.rb | 13 | ||||
| -rw-r--r-- | spec/models/time_table_combination_spec.rb | 54 |
2 files changed, 6 insertions, 61 deletions
diff --git a/spec/models/chouette/time_table_spec.rb b/spec/models/chouette/time_table_spec.rb index 304cb0184..f13e13d52 100644 --- a/spec/models/chouette/time_table_spec.rb +++ b/spec/models/chouette/time_table_spec.rb @@ -52,20 +52,19 @@ describe Chouette::TimeTable, :type => :model do expect(subject.int_day_types).to eq int_day_types end - it 'should merge date in_out false' do + it 'should not merge date in_out false' do another_tt.dates.last.in_out = false another_tt.save subject.merge!(another_tt) - expect(subject.dates.map(&:date)).to include(another_tt.dates.last.date) + expect(subject.dates.map(&:date)).not_to include(another_tt.dates.last.date) end - it 'should remove date in_out false if other tt doesnt have them' do + it 'should remove all date in_out false' do subject.dates.create(in_out: false, date: Date.today + 5.day + 1.year) - - expect { - subject.merge!(another_tt) - }.to change {subject.reload.excluded_days.count}.by(-1) + another_tt.dates.last.in_out = false + subject.merge!(another_tt) + expect(subject.reload.excluded_days.count).to eq(0) end end diff --git a/spec/models/time_table_combination_spec.rb b/spec/models/time_table_combination_spec.rb index ee934f50d..81f9dd7a6 100644 --- a/spec/models/time_table_combination_spec.rb +++ b/spec/models/time_table_combination_spec.rb @@ -44,60 +44,6 @@ describe TimeTableCombination, :type => :model do end end - describe '#continuous_periods' do - it 'should group continuous periods' do - source.periods.clear - - start_date = Date.today + 1.year - end_date = start_date + 10 - - # 6 more continuous dates, 2 isolated dates - 0.upto(4) do |i| - source.periods.create(period_start: start_date, period_end: end_date) - start_date = end_date + 1 - end_date = start_date + 10 - end - - expect(source.reload.continuous_periods.flatten.count).to eq(5) - end - end - - describe '#convert_continuous_periods_into_one' do - it 'should convert continuous periods into one' do - source.periods.clear - - start_date = Date.today + 1.year - end_date = start_date + 10 - - # 6 more continuous dates, 2 isolated dates - 0.upto(4) do |i| - source.periods.create(period_start: start_date, period_end: end_date) - start_date = end_date + 1 - end_date = start_date + 10 - end - - expect { - source.reload.convert_continuous_periods_into_one - }.to change {source.periods.count}.by(-4) - end - end - - describe '#optimize_continuous_dates_and_periods' do - it 'should update period if timetable has in_date just before or after ' do - source.dates.clear - source.periods.clear - - source.periods.create(period_start: Date.today, period_end: Date.today + 10.day) - source.dates.create(date: Date.today - 1.day, in_out: true) - - expect { - source.periods = source.optimize_continuous_dates_and_periods - }.to change {source.dates.count}.by(-1) - - expect(source.reload.periods.first.period_start).to eq(Date.today - 1.day) - end - end - describe "#combine" do context "when operation is union" do before(:each) do |
