Commit 01a9fb9f35fb7f3a57a7d48174956f8fea09a820

Authored by Victor Costa
1 parent eae70c57

api: return content of raw html block

app/models/raw_html_block.rb
... ... @@ -20,4 +20,12 @@ class RawHTMLBlock < Block
20 20 user.has_permission?('edit_raw_html_block', environment)
21 21 end
22 22  
  23 + def api_content
  24 + { html: html }
  25 + end
  26 +
  27 + def display_api_content_by_default?
  28 + true
  29 + end
  30 +
23 31 end
... ...
test/api/blocks_test.rb
... ... @@ -83,4 +83,15 @@ class BlocksTest < ActiveSupport::TestCase
83 83 json = JSON.parse(last_response.body)
84 84 assert_equal "test", json["block"]["api_content"]["some_content"]["name"]
85 85 end
  86 +
  87 + should 'display api content of raw html block' do
  88 + box = fast_create(Box, :owner_id => environment.id, :owner_type => Environment.name)
  89 + block = fast_create(RawHTMLBlock, box_id: box.id)
  90 + block.html = '<div>test</div>'
  91 + block.save!
  92 + get "/api/v1/blocks/#{block.id}?#{params.to_query}"
  93 + json = JSON.parse(last_response.body)
  94 + assert_equal "<div>test</div>", json["block"]["api_content"]["html"]
  95 + end
  96 +
86 97 end
... ...