File tree 3 files changed +15
-2
lines changed
3 files changed +15
-2
lines changed Original file line number Diff line number Diff line change 1
1
0.14.1 (Next)
2
2
=============
3
3
4
- * Your contribution here.
5
-
6
4
* [ #1216 ] ( https://github.com/ruby-grape/grape/pull/1142 ) : Fix JSON error response when calling ` error! ` with non-Strings - [ @jrforrest ] ( https://github.com/jrforrest ) .
7
5
* [ #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 ) .
7
+ * Your contribution here.
8
8
9
9
0.14.0 (12/07/2015)
10
10
===================
Original file line number Diff line number Diff line change @@ -4,10 +4,12 @@ module Grape
4
4
module Exceptions
5
5
class Validation < Grape ::Exceptions ::Base
6
6
attr_accessor :params
7
+ attr_accessor :message_key
7
8
8
9
def initialize ( args = { } )
9
10
fail 'Params are missing:' unless args . key? :params
10
11
@params = args [ :params ]
12
+ @message_key = args [ :message_key ]
11
13
args [ :message ] = translate_message ( args [ :message_key ] ) if args . key? :message_key
12
14
super
13
15
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