aboutsummaryrefslogtreecommitdiffstats
path: root/spec
diff options
context:
space:
mode:
authorXinhui2017-05-31 11:26:22 +0200
committerXinhui2017-05-31 11:26:29 +0200
commitb7ed505e00a26ebcf3c1e564cd32abaafee02e38 (patch)
treec96b8c72c7a39ba77e3de18765ee5047121d7fee /spec
parent8eb1c7fc424d0801e9322a0c0cfffb6346fe6fc4 (diff)
downloadchouette-core-b7ed505e00a26ebcf3c1e564cd32abaafee02e38.tar.bz2
Fix time_table should keep int_day_types on #actualize
Refs #3445
Diffstat (limited to 'spec')
-rw-r--r--spec/models/chouette/time_table_spec.rb26
1 files changed, 26 insertions, 0 deletions
diff --git a/spec/models/chouette/time_table_spec.rb b/spec/models/chouette/time_table_spec.rb
index 3d45bd346..de3e8e07d 100644
--- a/spec/models/chouette/time_table_spec.rb
+++ b/spec/models/chouette/time_table_spec.rb
@@ -7,6 +7,32 @@ describe Chouette::TimeTable, :type => :model do
it { is_expected.to validate_presence_of :comment }
it { is_expected.to validate_uniqueness_of :objectid }
+ describe "actualize" do
+ let(:calendar) { create(:calendar) }
+ let(:int_day_types) { 508 }
+
+ before do
+ subject.int_day_types = int_day_types
+ subject.calendar = calendar
+ subject.save
+ subject.actualize
+ end
+
+ it 'should override dates' do
+ expect(subject.dates.map(&:date)).to match_array calendar.dates
+ end
+
+ it 'should override periods' do
+ [:period_start, :period_end].each do |key|
+ expect(subject.periods.map(&key)).to match_array calendar.convert_to_time_table.periods.map(&key)
+ end
+ end
+
+ it 'should not change int_day_types' do
+ expect(subject.int_day_types).to eq(int_day_types)
+ end
+ end
+
describe "Update state" do
def time_table_to_state time_table
time_table.slice('id', 'comment').tap do |item|