Project

General

Profile

Patch #28564 » 0001-removes-request-and-response-accessors-from-Structur.patch

Jens Krämer, 2018-04-17 03:42

View differences:

lib/redmine/views/builders/json.rb
35 35
          json = @struct.first.to_json
36 36
          if jsonp.present?
37 37
            json = "#{jsonp}(#{json})"
38
            response.content_type = 'application/javascript'
38
            @response.content_type = 'application/javascript'
39 39
          end
40 40
          json
41 41
        end
lib/redmine/views/builders/structure.rb
21 21
  module Views
22 22
    module Builders
23 23
      class Structure < BlankSlate
24
        attr_accessor :request, :response
25 24

  
26 25
        def initialize(request, response)
27 26
          @struct = [{}]
28
          self.request = request
29
          self.response = response
27
          @request = request
28
          @response = response
30 29
        end
31 30

  
32 31
        def array(tag, options={}, &block)
test/unit/lib/redmine/views/builders/json_test.rb
86 86
    end
87 87
  end
88 88

  
89
  def test_request_response
90
    assert_json_output({'request' => { 'get' => 'book' }, 'response' => { 'book' => { 'title' => 'Book 1' } }}) do |b|
91
      b.request do
92
        b.get 'book'
93
      end
94
      b.response do
95
        b.book title: 'Book 1'
96
      end
97
    end
98
  end
99

  
89 100
  def assert_json_output(expected, &block)
90 101
    builder = Redmine::Views::Builders::Json.new(ActionDispatch::TestRequest.create, ActionDispatch::TestResponse.create)
91 102
    block.call(builder)
    (1-1/1)