File tree Expand file tree Collapse file tree 3 files changed +14
-0
lines changed Expand file tree Collapse file tree 3 files changed +14
-0
lines changed Original file line number Diff line number Diff line change 33
44* [ #1216 ] ( https://github.com/ruby-grape/grape/pull/1142 ) : Fix JSON error response when calling ` error! ` with non-Strings - [ @jrforrest ] ( https://github.com/jrforrest ) .
55* [ #1225 ] ( https://github.com/ruby-grape/grape/pull/1225 ) : Fix ` given ` with nested params not returning correct declared params - [ @JanStevens ] ( https://github.com/JanStevens ) .
6+ * [ #1227 ] ( https://github.com/ruby-grape/grape/pull/1227 ) : Store ` message_key ` on Grape::Exceptions::Validation - [ @stjhimy ] ( https://github.com/sthimy ) .
67* Your contribution here.
78
890.14.0 (12/07/2015)
Original file line number Diff line number Diff line change @@ -4,10 +4,12 @@ module Grape
44 module Exceptions
55 class Validation < Grape ::Exceptions ::Base
66 attr_accessor :params
7+ attr_accessor :message_key
78
89 def initialize ( args = { } )
910 fail 'Params are missing:' unless args . key? :params
1011 @params = args [ :params ]
12+ @message_key = args [ :message_key ]
1113 args [ :message ] = translate_message ( args [ :message_key ] ) if args . key? :message_key
1214 super
1315 end
Original file line number Diff line number Diff line change 1+ require 'spec_helper'
2+
3+ describe Grape ::Exceptions ::Validation do
4+ it 'fails when params are missing' do
5+ expect { Grape ::Exceptions ::Validation . new ( message_key : 'presence' ) } . to raise_error ( RuntimeError , 'Params are missing:' )
6+ end
7+
8+ it 'store message_key' do
9+ expect ( Grape ::Exceptions ::Validation . new ( params : [ 'id' ] , message_key : 'presence' ) . message_key ) . to eq ( 'presence' )
10+ end
11+ end
You can’t perform that action at this time.
0 commit comments