Sha256: fecb71ab3c8cf531c3f754c616059070aab8f893aaec54815ade7b050cd22f79

Contents?: true

Size: 1.1 KB

Versions: 6

Compression:

Stored size: 1.1 KB

Contents

require File.expand_path(File.dirname(__FILE__) + '/../../../test_helper')

module ActiveResource
  class ValidationsTest < ActiveSupport::TestCase
    context ActiveResource::Validations do
      context "with ESP::Team" do
        context '#load_remote_errors' do
          should 'should parse an active record response and put error messages in the errors object' do
            stub_request(:post, /teams.json*/).to_return(status: 422, body: json(:error, :active_record))

            team = ESP::Team.create

            assert_contains team.errors.full_messages, "Name can't be blank"
            assert_contains team.errors.full_messages, "Name is invalid"
            assert_contains team.errors.full_messages, "Description can't be blank"
          end

          should 'should parse a non active record response and put error messages in the errors object' do
            stub_request(:post, /teams.json*/).to_return(status: 422, body: json(:error))

            team = ESP::Team.create

            assert_contains team.errors.full_messages, "Access Denied"
          end
        end
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
esp_sdk-2.8.0 test/esp/extensions/active_resource/validations_test.rb
esp_sdk-2.7.0 test/esp/extensions/active_resource/validations_test.rb
esp_sdk-2.6.0 test/esp/extensions/active_resource/validations_test.rb
esp_sdk-2.5.0 test/esp/extensions/active_resource/validations_test.rb
esp_sdk-2.4.0 test/esp/extensions/active_resource/validations_test.rb
esp_sdk-2.3.0 test/esp/extensions/active_resource/validations_test.rb