diff options
| -rw-r--r-- | app/controllers/time_tables_controller.rb | 4 | ||||
| -rw-r--r-- | spec/models/calendar_spec.rb | 6 |
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 |
