aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoraf832017-07-03 13:40:56 +0200
committeraf832017-07-03 13:40:56 +0200
commit5220e7bad9e252983e1bfc1850fd3459ca802267 (patch)
tree800a4fbb02cf1f920a2bde2d3c76bf904bacf7ea
parent3fc84b19b1ba7a230a208d2f5b5dffb68003da8e (diff)
downloadchouette-core-5220e7bad9e252983e1bfc1850fd3459ca802267.tar.bz2
Adapt test & controller according to convert_to_timetable fix
-rw-r--r--app/controllers/time_tables_controller.rb4
-rw-r--r--spec/models/calendar_spec.rb6
2 files changed, 5 insertions, 5 deletions
diff --git a/app/controllers/time_tables_controller.rb b/app/controllers/time_tables_controller.rb
index 3704f2885..6d2639981 100644
--- a/app/controllers/time_tables_controller.rb
+++ b/app/controllers/time_tables_controller.rb
@@ -49,8 +49,8 @@ class TimeTablesController < ChouetteController
calendar.dates.each_with_index do |date, i|
@time_table.dates << Chouette::TimeTableDate.new(date: date, position: i, in_out: true)
end
- calendar.date_ranges.each_with_index do |date_range, i|
- @time_table.periods << Chouette::TimeTablePeriod.new(period_start: date_range.begin, period_end: date_range.end, position: i)
+ calendar.periods.each_with_index do |period, i|
+ @time_table.periods << Chouette::TimeTablePeriod.new(period_start: period.begin, period_end: period.end, position: i)
end
end
diff --git a/spec/models/calendar_spec.rb b/spec/models/calendar_spec.rb
index cf7e4aa27..f5020ebf8 100644
--- a/spec/models/calendar_spec.rb
+++ b/spec/models/calendar_spec.rb
@@ -8,13 +8,13 @@ RSpec.describe Calendar, :type => :model do
it { is_expected.to validate_uniqueness_of(:short_name) }
describe '#to_time_table' do
- let(:calendar) { create(:calendar, date_ranges: [Date.today..(Date.today + 1.month)]) }
+ let(:calendar) { create(:calendar, date_ranges: [Date.today...(Date.today + 1.month)]) }
it 'should convert calendar to an instance of Chouette::TimeTable' do
time_table = calendar.convert_to_time_table
expect(time_table).to be_an_instance_of(Chouette::TimeTable)
- expect(time_table.periods[0].period_start).to eq(calendar.date_ranges[0].begin)
- expect(time_table.periods[0].period_end).to eq(calendar.date_ranges[0].end)
+ expect(time_table.periods[0].period_start).to eq(calendar.periods[0].begin)
+ expect(time_table.periods[0].period_end).to eq(calendar.periods[0].end)
expect(time_table.dates.map(&:date)).to match_array(calendar.dates)
end
end