Patch by Jens Krämer.
git-svn-id: http://svn.redmine.org/redmine/trunk@17617
e93f8b46-1217-0410-a6f0-
8f06a7374b81
json = @struct.first.to_json
if jsonp.present?
json = "#{jsonp}(#{json})"
- response.content_type = 'application/javascript'
+ @response.content_type = 'application/javascript'
end
json
end
module Views
module Builders
class Structure < BlankSlate
- attr_accessor :request, :response
def initialize(request, response)
@struct = [{}]
- self.request = request
- self.response = response
+ @request = request
+ @response = response
end
def array(tag, options={}, &block)
end
end
+ def test_request_response
+ assert_json_output({'request' => { 'get' => 'book' }, 'response' => { 'book' => { 'title' => 'Book 1' } }}) do |b|
+ b.request do
+ b.get 'book'
+ end
+ b.response do
+ b.book title: 'Book 1'
+ end
+ end
+ end
+
def assert_json_output(expected, &block)
builder = Redmine::Views::Builders::Json.new(ActionDispatch::TestRequest.create, ActionDispatch::TestResponse.create)
block.call(builder)