Skip to content

Commit

Permalink
Merge branch 'render-status-code' of https://github.com/audionerd/roa…
Browse files Browse the repository at this point in the history
  • Loading branch information
apotonick committed Dec 31, 2014
2 parents 40d2587 + e0c7e7d commit 3afc177
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGES.markdown
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
## Unreleased

* Added a dependency on `responders` gem for Rails 4.2 support
* `#render` from `ControllerAdditions::Render` now accepts a status code

## 1.0.0

Expand Down
3 changes: 2 additions & 1 deletion lib/roar/rails/controller_additions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,8 @@ def _resource_or_body(resource)
module Render
def render(options)
format = options.keys.first
super format => prepare_model_for(format, options.values.first, options)
status = options[:status] || :ok
super format => prepare_model_for(format, options.values.first, options), :status => status
end
end
end
Expand Down
5 changes: 3 additions & 2 deletions test/render_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ module SingerRepresenter

def show
singer = Musician.new("Bumi")
render :json => singer
render :json => singer, status: 201
end
end

Expand All @@ -26,5 +26,6 @@ def show
test "should use Representer for #render" do
get :show, :id => "bumi", :format => :json
assert_body '{"title":"Bumi"}'
assert_equal 201, response.status
end
end
end

0 comments on commit 3afc177

Please sign in to comment.