Sha256: e4dab2391f7a9a11d5141f713be1f10c02c9ef31dba7e3876ef87d4d74925e0c
Contents?: true
Size: 1.62 KB
Versions: 1
Compression:
Stored size: 1.62 KB
Contents
require 'spec_helper' describe 'polymorphic error reraise' do class DummyController < ApplicationController def polymorphic_record_not_found raise ActiveRecord::StatementInvalid, 'Polymorphic record not found.' end def polymorphic_reference_exists raise ActiveRecord::StatementInvalid, 'Polymorphic reference exists.' end def not_a_polymorphic_error raise ActiveRecord::StatementInvalid, 'Not a Polymorphic Constraints error.' end end Rails.application.routes.draw do # The priority is based upon order of creation: first created -> highest priority. # See how all your routes lay out with "rake routes". get '/polymorphic_record_not_found', to: 'dummy#polymorphic_record_not_found' get '/polymorphic_reference_exists', to: 'dummy#polymorphic_reference_exists' get '/not_a_polymorphic_error', to: 'dummy#not_a_polymorphic_error' end describe DummyController, type: :controller do context 'polymorphic record not found' do it 're-raises ActiveRecord::RecordNotFound properly' do expect { get :polymorphic_record_not_found }.to raise_error(ActiveRecord::RecordNotFound) end end context 'polymorphic reference exists' do it 're-raises ActiveRecord::ReferenceViolation properly' do expect { get :polymorphic_reference_exists }.to raise_error(ActiveRecord::ReferenceViolation) end end context 'not a polymorphic constraints error' do it 're-raises ActiveRecord::StatementInvalid properly' do expect { get :not_a_polymorphic_error }.to raise_error(ActiveRecord::StatementInvalid) end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
polymorphic_constraints-1.0.0 | spec/lib/polymorphic_constraints/utils/polymorphic_error_handler_spec.rb |