Sha256: 812fbe1d3e3444b88e034abfff1bbc79e2055c00d11af286bd2f19dd13bb999d

Contents?: true

Size: 1.4 KB

Versions: 12

Compression:

Stored size: 1.4 KB

Contents

# frozen_string_literal: true

require 'rails_helper'

describe DHS::Item do
  before do
    class Presence < DHS::Record
      endpoint 'http://opm/presence'
    end

    I18n.reload!
    I18n.backend.store_translations(:en, YAML.safe_load(%q{
      dhs:
        warnings:
          records:
            presence:
              will_be_resized: 'The photos will be resized'
    }))
  end

  it 'provides warnings together with validation errors' do
    stub_request(:post, 'http://opm/presence?synchronize=false')
      .to_return(
        body: {
          field_warnings: [{
            code: 'WILL_BE_RESIZED',
            path: ['place', 'photos', 0],
            message: 'The image will be resized.'
          }],
          place: {
            href: 'http://storage/places/1',
            photos: [{
              href: 'http://bin.staticdepay.fi/123',
              width: 10,
              height: 10
            }]
          }
        }.to_json
      )
    presence = Presence.options(params: { synchronize: false }).create(
      place: { href: 'http://storage/places/1' }
    )
    expect(presence.warnings.any?).to eq true
    expect(presence.place.warnings.any?).to eq true
    expect(presence.place.photos.warnings.any?).to eq true
    expect(presence.place.photos[0].warnings.any?).to eq true
    expect(presence.place.photos[0].warnings.messages.first).to eq(
      'The photos will be resized'
    )
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
dhs-1.6.0 spec/item/warnings_spec.rb
dhs-1.5.0 spec/item/warnings_spec.rb
dhs-1.4.2 spec/item/warnings_spec.rb
dhs-1.4.1 spec/item/warnings_spec.rb
dhs-1.4.0 spec/item/warnings_spec.rb
dhs-1.3.0 spec/item/warnings_spec.rb
dhs-1.2.0 spec/item/warnings_spec.rb
dhs-1.1.0 spec/item/warnings_spec.rb
dhs-1.0.3 spec/item/warnings_spec.rb
dhs-1.0.2 spec/item/warnings_spec.rb
dhs-1.0.1 spec/item/warnings_spec.rb
dhs-1.0.0 spec/item/warnings_spec.rb