diff options
| author | Zog | 2018-02-02 13:08:51 +0100 |
|---|---|---|
| committer | Zog | 2018-02-02 13:08:51 +0100 |
| commit | a192d4736028b535a1030c0f506597845a3bc4a4 (patch) | |
| tree | 57855ee98f7905dd54543a776ae6d0b0651244bc /spec/controllers | |
| parent | 9f30b2debe7ece403d9e588df9763c119436d967 (diff) | |
| download | chouette-core-a192d4736028b535a1030c0f506597845a3bc4a4.tar.bz2 | |
Refs #5835; Timetables inherit application days from calendars5835-fix-timetable-creation
Diffstat (limited to 'spec/controllers')
| -rw-r--r-- | spec/controllers/time_tables_controller_spec.rb | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/spec/controllers/time_tables_controller_spec.rb b/spec/controllers/time_tables_controller_spec.rb new file mode 100644 index 000000000..85f2c10e4 --- /dev/null +++ b/spec/controllers/time_tables_controller_spec.rb @@ -0,0 +1,29 @@ +RSpec.describe TimeTablesController, :type => :controller do + login_user + + describe 'POST create' do + let(:request){ post :create, referential_id: referential.id, time_table: time_table_params } + let(:time_table_params){{comment: "test"}} + + it "should create a timetable" do + expect{request}.to change{ Chouette::TimeTable.count }.by 1 + expect(Chouette::TimeTable.last.comment).to eq "test" + %i(monday tuesday wednesday thursday friday saturday sunday).each do |d| + expect(Chouette::TimeTable.last.send(d)).to be_falsy + end + end + + context "when given a calendar" do + let(:calendar){ create :calendar, int_day_types: Calendar::MONDAY | Calendar::SUNDAY } + let(:time_table_params){{comment: "test", calendar_id: calendar.id}} + it "should create a timetable" do + expect{request}.to change{ Chouette::TimeTable.count }.by 1 + expect(Chouette::TimeTable.last.comment).to eq "test" + expect(Chouette::TimeTable.last.calendar).to eq calendar + %i(monday tuesday wednesday thursday friday saturday sunday).each do |d| + expect(Chouette::TimeTable.last.send(d)).to eq calendar.send(d) + end + end + end + end +end |
