Commit 01a9fb9f35fb7f3a57a7d48174956f8fea09a820
1 parent
eae70c57
Exists in
ratings_minor_fixes
and in
4 other branches
api: return content of raw html block
Showing
2 changed files
with
19 additions
and
0 deletions
Show diff stats
app/models/raw_html_block.rb
@@ -20,4 +20,12 @@ class RawHTMLBlock < Block | @@ -20,4 +20,12 @@ class RawHTMLBlock < Block | ||
20 | user.has_permission?('edit_raw_html_block', environment) | 20 | user.has_permission?('edit_raw_html_block', environment) |
21 | end | 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 | end | 31 | end |
test/api/blocks_test.rb
@@ -83,4 +83,15 @@ class BlocksTest < ActiveSupport::TestCase | @@ -83,4 +83,15 @@ class BlocksTest < ActiveSupport::TestCase | ||
83 | json = JSON.parse(last_response.body) | 83 | json = JSON.parse(last_response.body) |
84 | assert_equal "test", json["block"]["api_content"]["some_content"]["name"] | 84 | assert_equal "test", json["block"]["api_content"]["some_content"]["name"] |
85 | end | 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 | end | 97 | end |