]> source.dussan.org Git - redmine.git/commitdiff
Removes request and response accessors from Structure class (#28564).
authorGo MAEDA <maeda@farend.jp>
Sat, 3 Nov 2018 08:11:22 +0000 (08:11 +0000)
committerGo MAEDA <maeda@farend.jp>
Sat, 3 Nov 2018 08:11:22 +0000 (08:11 +0000)
Patch by Jens Krämer.

git-svn-id: http://svn.redmine.org/redmine/trunk@17617 e93f8b46-1217-0410-a6f0-8f06a7374b81

lib/redmine/views/builders/json.rb
lib/redmine/views/builders/structure.rb
test/unit/lib/redmine/views/builders/json_test.rb

index 97ac1250a4934f8594eacc7b407e9e5ef03465c0..299fd9255d22a68a9ef8410015e73abdd0f7390e 100644 (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
index 5e59f8978a58e1fd7f742b9355eb6edecb7582ca..3f4468b8e05312a1193d95c2046638a15926fa9c 100644 (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)
index b1b50b80a3ade9461623db395f5794e6ab356edf..8ffb71fa7f70298607bcf501acfb35d0515fc0a9 100644 (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)