aboutsummaryrefslogtreecommitdiffstats
path: root/spec
diff options
context:
space:
mode:
authorXinhui2017-04-26 15:10:35 +0200
committerXinhui2017-04-26 15:10:41 +0200
commit489a05ee6469b711140ca6d4ad6ebe296bc2d82f (patch)
treefb78336a9755bd8a624c77c7cb753a41f4189f26 /spec
parent6dde8056e94515f885c73ecf1a07485784eaaca6 (diff)
downloadchouette-core-489a05ee6469b711140ca6d4ad6ebe296bc2d82f.tar.bz2
Wip TimeTables#update save day_types
Refs #2899
Diffstat (limited to 'spec')
-rw-r--r--spec/models/chouette/time_table_spec.rb27
1 files changed, 25 insertions, 2 deletions
diff --git a/spec/models/chouette/time_table_spec.rb b/spec/models/chouette/time_table_spec.rb
index a3a361e7b..fd9f70740 100644
--- a/spec/models/chouette/time_table_spec.rb
+++ b/spec/models/chouette/time_table_spec.rb
@@ -7,6 +7,29 @@ describe Chouette::TimeTable, :type => :model do
it { is_expected.to validate_presence_of :comment }
it { is_expected.to validate_uniqueness_of :objectid }
+ describe "Update state" do
+ def time_table_to_state time_table
+ time_table.slice('id', 'comment').tap do |item|
+ item['day_types'] = "Di,Lu,Ma,Me,Je,Ve,Sa"
+ end
+ end
+
+ let(:state) { time_table_to_state subject }
+
+ it 'should update comment' do
+ state['comment'] = "Edited timetable name"
+ subject.state_update state
+ expect(subject.reload.comment).to eq state['comment']
+ end
+
+ it 'should update day_types' do
+ state['day_types'] = "Di,Lu,Je,Ma"
+ subject.state_update state
+ expect(subject.reload.valid_days).to include(7, 1, 4, 2)
+ expect(subject.reload.valid_days).not_to include(3, 5, 6)
+ end
+ end
+
describe "#periods_max_date" do
context "when all period extends from 04/10/2013 to 04/15/2013," do
before(:each) do
@@ -1204,8 +1227,8 @@ end
expect(subject.dates[9].date).to eq(Date.new(2014,8,27))
end
end
-
-
+
+
context "with same definition : dsjointed timetable should be empty" do
before do
subject.periods.clear