require 'rails_helper' module Logistics module Core RSpec.describe Operation, type: :model do it 'has a valid factory' do expect(create(:operation)).to be_valid end it 'is invalid with no operation number' do expect(build(:operation, :operation_number => nil)).not_to be_valid end it 'minimally serializes request_no and operation_number' do ofr = create(:offer_request) op = Operation.create(operation_number: FFaker::Name.name, offer_request: ofr) data = ActiveModelSerializers::SerializableResource.new(op).as_json expect(data[:offer_request_id]).to eq ofr.id expect(data[:operation_number]).to eq op.operation_number end end end end