Do not use JS to initialize the schedule

- Only use JS for the drag&drop functionality and to the set/alter the time and rooms of the EventSchedule object.

- Introduce has_many :events, through: :event_schedules association to get unscheduled event easily
This commit is contained in:
Ana 2016-07-31 18:41:27 +02:00
parent 71dab6b79c
commit a394293500
12 changed files with 66 additions and 125 deletions

View file

@ -259,27 +259,6 @@ describe Event do
end
end
describe '#as_json' do
it 'adds the event\'s track_color, track_text_color and length' do
create(:event_schedule, event: event)
event.track = create(:track, color: '#efefef')
json_hash = event.as_json
expect(json_hash[:track_color]).to eq('#EFEFEF')
expect(json_hash[:track_text_color]).to eq('black')
expect(json_hash[:length]).to eq(30)
end
it 'uses correct default values for track_color, track_text_color and length' do
event.event_type = nil
json_hash = event.as_json
expect(json_hash[:track_color]).to eq('#FFFFFF')
expect(json_hash[:track_text_color]).to eq('black')
expect(json_hash[:length]).to eq(15)
end
end
describe '#transition_possible?(transition)' do
shared_examples 'transition_possible?(transition)' do |state, transition, expected|
it "returns #{expected} for #{transition} transition, when the event is #{state}}" do

View file

@ -5,5 +5,6 @@ describe Schedule do
describe 'association' do
it { should belong_to(:program) }
it { should have_many(:event_schedules).dependent(:destroy) }
it { should have_many(:events).through(:event_schedules) }
end
end