2021-04-24 19:30:52 -07:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
|
|
describe FullCalendarFormatter do
|
|
|
|
|
let!(:room1) { create(:room) }
|
2021-04-26 09:48:16 +08:00
|
|
|
let!(:room2) { create(:room) }
|
2021-04-24 19:30:52 -07:00
|
|
|
|
|
|
|
|
describe 'JSON formatting for FullCalendar' do
|
|
|
|
|
it 'translates rooms to resources' do
|
2021-04-26 09:48:16 +08:00
|
|
|
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)
|
2021-04-24 19:30:52 -07:00
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|