From b8a1196b6bf74de54ddbf5a96405e905f6d91067 Mon Sep 17 00:00:00 2001 From: Paul Trippett Date: Thu, 4 Oct 2018 15:00:07 +0100 Subject: [PATCH] Add missing fields to Upload Fabricator (#6448) --- spec/fabricators/upload_fabricator.rb | 2 ++ spec/serializers/upload_serializer_spec.rb | 16 ++++++++++++++++ 2 files changed, 18 insertions(+) create mode 100644 spec/serializers/upload_serializer_spec.rb diff --git a/spec/fabricators/upload_fabricator.rb b/spec/fabricators/upload_fabricator.rb index c306a784b3e..c1a6604be41 100644 --- a/spec/fabricators/upload_fabricator.rb +++ b/spec/fabricators/upload_fabricator.rb @@ -5,6 +5,8 @@ Fabricator(:upload) do filesize 1234 width 100 height 200 + thumbnail_width 30 + thumbnail_height 60 url do |attrs| sequence(:url) do |n| diff --git a/spec/serializers/upload_serializer_spec.rb b/spec/serializers/upload_serializer_spec.rb new file mode 100644 index 00000000000..8d048c9c107 --- /dev/null +++ b/spec/serializers/upload_serializer_spec.rb @@ -0,0 +1,16 @@ +require 'rails_helper' + +RSpec.describe UploadSerializer do + let(:upload) { Fabricate(:upload) } + let(:subject) { UploadSerializer.new(upload, root: false) } + + it 'should render without errors' do + json_data = JSON.load(subject.to_json) + + expect(json_data['id']).to eql upload.id + expect(json_data['width']).to eql upload.width + expect(json_data['height']).to eql upload.height + expect(json_data['thumbnail_width']).to eql upload.thumbnail_width + expect(json_data['thumbnail_height']).to eql upload.thumbnail_height + end +end