Skip to content

Commit 7beec80

Browse files
committed
Allow all Fixnum statuses
1 parent 514a2e5 commit 7beec80

File tree

2 files changed

+3
-8
lines changed

2 files changed

+3
-8
lines changed

lib/grape/dsl/inside_route.rb

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -102,11 +102,7 @@ def status(status = nil)
102102
fail ArgumentError, "Status code :#{status} is invalid."
103103
end
104104
when Fixnum
105-
if Rack::Utils::HTTP_STATUS_CODES.keys.include?(status)
106-
@status = status
107-
else
108-
fail ArgumentError, "Status code #{status} is invalid."
109-
end
105+
@status = status
110106
when nil
111107
return @status if @status
112108
case request.request_method.to_s.upcase

spec/grape/dsl/inside_route_spec.rb

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,9 +118,8 @@ def initialize
118118
.to raise_error(ArgumentError, 'Status code :foo_bar is invalid.')
119119
end
120120

121-
it 'raises error if unknow status code is passed' do
122-
expect { subject.status 210 }
123-
.to raise_error(ArgumentError, 'Status code 210 is invalid.')
121+
it 'accepts unknown Fixnum status codes' do
122+
expect { subject.status 210 }.to_not raise_error
124123
end
125124

126125
it 'raises error if status is not a fixnum or symbol' do

0 commit comments

Comments
 (0)