Add markdown to article api response (#3394)

* Add failing test asserting markdown is returned

* Add markdown to the get article api response
This commit is contained in:
Zak Henry 2019-07-09 15:09:20 +01:00 committed by Ben Halpern
parent 5db8b7e1e5
commit a9acb8642e
2 changed files with 6 additions and 0 deletions

View file

@ -21,6 +21,7 @@ json.published_at @article.published_at&.utc&.iso8601
json.last_comment_at @article.last_comment_at&.utc&.iso8601
json.body_html @article.processed_html
json.body_markdown @article.body_markdown
json.ltag_style(@article.liquid_tags_used.map { |ltag| Rails.application.assets["ltags/#{ltag}.css"].to_s.html_safe })
json.ltag_script(@article.liquid_tags_used.map { |ltag| ltag.script.html_safe })

View file

@ -83,6 +83,11 @@ RSpec.describe "Api::V0::Articles", type: :request do
get "/api/articles/#{article.id}"
expect(json_response["title"]).to eq(article.title)
end
it "contains article markdown content" do
get "/api/articles/#{article.id}"
expect(json_response["body_markdown"]).to eq(article.body_markdown)
end
it "fails with an unpublished article" do
article.update_columns(published: false)