1
0
mirror of https://github.com/meineerde/redmine.git synced 2026-01-05 07:01:30 +00:00

Removes request and response accessors from Structure class (#28564).

Patch by Jens Krämer.


git-svn-id: http://svn.redmine.org/redmine/trunk@17617 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Go MAEDA 2018-11-03 08:11:22 +00:00
parent 46b028b1b8
commit 9c99d50713
3 changed files with 14 additions and 4 deletions

View File

@ -35,7 +35,7 @@ module Redmine
json = @struct.first.to_json
if jsonp.present?
json = "#{jsonp}(#{json})"
response.content_type = 'application/javascript'
@response.content_type = 'application/javascript'
end
json
end

View File

@ -21,12 +21,11 @@ module Redmine
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)

View File

@ -86,6 +86,17 @@ class Redmine::Views::Builders::JsonTest < ActiveSupport::TestCase
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)