2018-05-07 16:47:29 -07:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
2016-04-03 00:57:43 +05:30
|
|
|
require 'spec_helper'
|
|
|
|
|
describe SpeakerSerializer, type: :serializer do
|
|
|
|
|
let(:speaker) { create(:user, name: 'John Doe', affiliation: 'JohnDoesInc', biography: nil) }
|
|
|
|
|
let(:serializer) { SpeakerSerializer.new(speaker) }
|
|
|
|
|
|
|
|
|
|
context 'speaker does not have biography' do
|
|
|
|
|
it 'sets name and affiliation' do
|
|
|
|
|
expected_json = {
|
2022-10-27 12:57:42 -07:00
|
|
|
url: "http://localhost:3000/users/#{speaker.id}",
|
2018-09-29 16:13:38 -07:00
|
|
|
name: 'John Doe',
|
|
|
|
|
affiliation: 'JohnDoesInc',
|
|
|
|
|
biography: nil
|
2016-04-03 00:57:43 +05:30
|
|
|
}.to_json
|
|
|
|
|
|
|
|
|
|
expect(serializer.to_json).to eq expected_json
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
context 'speaker has biography' do
|
2022-02-14 17:53:58 +01:00
|
|
|
before{ speaker.update_attribute(:biography, 'Doest of all Jon Does') }
|
2016-04-03 00:57:43 +05:30
|
|
|
|
|
|
|
|
it 'sets name, affiliation and biography' do
|
|
|
|
|
expected_json = {
|
2022-10-27 12:57:42 -07:00
|
|
|
url: "http://localhost:3000/users/#{speaker.id}",
|
2018-09-29 16:13:38 -07:00
|
|
|
name: 'John Doe',
|
|
|
|
|
affiliation: 'JohnDoesInc',
|
|
|
|
|
biography: 'Doest of all Jon Does'
|
2016-04-03 00:57:43 +05:30
|
|
|
}.to_json
|
|
|
|
|
|
|
|
|
|
expect(serializer.to_json).to eq expected_json
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|