Sha256: 4806bd526f43af3f8d54b597986c5fa9735ecd8cbae756d3b08a41056fe7486c

Contents?: true

Size: 1.37 KB

Versions: 19

Compression:

Stored size: 1.37 KB

Contents

require 'rails_helper'

describe LHS::Item do

  before do
    class Presence < LHS::Record
      endpoint 'http://opm/presence'
    end

    I18n.reload!
    I18n.backend.store_translations(:en, YAML.safe_load(%q{
      lhs:
        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.staticlocal.ch/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

19 entries across 19 versions & 1 rubygems

Version Path
lhs-16.1.5 spec/item/warnings_spec.rb
lhs-16.1.4 spec/item/warnings_spec.rb
lhs-16.1.3 spec/item/warnings_spec.rb
lhs-16.1.2 spec/item/warnings_spec.rb
lhs-16.1.1 spec/item/warnings_spec.rb
lhs-16.1.0 spec/item/warnings_spec.rb
lhs-16.0.1 spec/item/warnings_spec.rb
lhs-16.0.0 spec/item/warnings_spec.rb
lhs-15.7.0 spec/item/warnings_spec.rb
lhs-15.6.1 spec/item/warnings_spec.rb
lhs-15.6.0 spec/item/warnings_spec.rb
lhs-15.5.1 spec/item/warnings_spec.rb
lhs-15.5.0 spec/item/warnings_spec.rb
lhs-15.4.1 spec/item/warnings_spec.rb
lhs-15.4.0 spec/item/warnings_spec.rb
lhs-15.4.0.pre.hasone.1 spec/item/warnings_spec.rb
lhs-15.3.3 spec/item/warnings_spec.rb
lhs-15.3.3.pre.fixoptions.1 spec/item/warnings_spec.rb
lhs-15.3.2 spec/item/warnings_spec.rb