[feat]Implement FullCalendar#rooms_to_resources and add tests
This commit is contained in:
parent
40916b6a36
commit
abe2ea9bb3
4 changed files with 59 additions and 29 deletions
|
|
@ -109,6 +109,7 @@ class SchedulesController < ApplicationController
|
||||||
@event_schedules_by_room_id = event_schedules.select { |s| @selected_schedules_ids.include?(s.schedule_id) }.group_by(&:room_id)
|
@event_schedules_by_room_id = event_schedules.select { |s| @selected_schedules_ids.include?(s.schedule_id) }.group_by(&:room_id)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def app
|
def app
|
||||||
@qr_code = RQRCode::QRCode.new(conference_schedule_url).as_svg(offset: 20, color: '000', shape_rendering: 'crispEdges', module_size: 11)
|
@qr_code = RQRCode::QRCode.new(conference_schedule_url).as_svg(offset: 20, color: '000', shape_rendering: 'crispEdges', module_size: 11)
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,16 @@
|
||||||
class FullCalendarFormatter
|
class FullCalendarFormatter
|
||||||
def rooms_to_resources(rooms); end
|
def self.rooms_to_resources(rooms)
|
||||||
|
rooms.map { |room| room_to_resource(room) }.to_json
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.event_schedules_to_resources(event_schedules); end
|
||||||
|
|
||||||
|
private_class_method
|
||||||
|
|
||||||
|
def self.room_to_resource(room)
|
||||||
|
{
|
||||||
|
id: room.guid,
|
||||||
|
title: room.name
|
||||||
|
}
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,10 @@ feature Schedule do
|
||||||
before(:each) do
|
before(:each) do
|
||||||
visit vertical_schedule_conference_schedule_path
|
visit vertical_schedule_conference_schedule_path
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it 'returns a successful response' do
|
||||||
|
expect(response.status).to eq(200)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -3,12 +3,24 @@
|
||||||
require 'spec_helper'
|
require 'spec_helper'
|
||||||
|
|
||||||
describe FullCalendarFormatter do
|
describe FullCalendarFormatter do
|
||||||
let!(:room0) { create(:room) }
|
|
||||||
let!(:room1) { create(:room) }
|
let!(:room1) { create(:room) }
|
||||||
|
let!(:room2) { create(:room) }
|
||||||
|
|
||||||
describe 'JSON formatting for FullCalendar' do
|
describe 'JSON formatting for FullCalendar' do
|
||||||
it 'translates rooms to resources' do
|
it 'translates rooms to resources' do
|
||||||
room_list = [room1, room2] # TODO
|
rooms = [room1, room2]
|
||||||
|
resources = described_class.rooms_to_resources(rooms)
|
||||||
|
expected_json = [
|
||||||
|
{
|
||||||
|
id: room1.guid,
|
||||||
|
title: room1.name
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: room2.guid,
|
||||||
|
title: room2.name
|
||||||
|
}
|
||||||
|
].to_json
|
||||||
|
expect(resources).to eq(expected_json)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue