Commit d038fac4 authored by Oswaldo Ferreira's avatar Oswaldo Ferreira

Present state indication on GFM preview

parent 26998c68
...@@ -10,6 +10,7 @@ module PreviewMarkdown ...@@ -10,6 +10,7 @@ module PreviewMarkdown
when 'wikis' then { pipeline: :wiki, project_wiki: @project_wiki, page_slug: params[:id] } when 'wikis' then { pipeline: :wiki, project_wiki: @project_wiki, page_slug: params[:id] }
when 'snippets' then { skip_project_check: true } when 'snippets' then { skip_project_check: true }
when 'groups' then { group: group } when 'groups' then { group: group }
when 'projects' then { issuable_state_filter_enabled: true }
else {} else {}
end end
......
---
title: Present state indication on GFM preview
merge_request:
author:
type: added
...@@ -616,13 +616,40 @@ describe ProjectsController do ...@@ -616,13 +616,40 @@ describe ProjectsController do
end end
describe 'POST #preview_markdown' do describe 'POST #preview_markdown' do
it 'renders json in a correct format' do before do
sign_in(user) sign_in(user)
end
it 'renders json in a correct format' do
post :preview_markdown, namespace_id: public_project.namespace, id: public_project, text: '*Markdown* text' post :preview_markdown, namespace_id: public_project.namespace, id: public_project, text: '*Markdown* text'
expect(JSON.parse(response.body).keys).to match_array(%w(body references)) expect(JSON.parse(response.body).keys).to match_array(%w(body references))
end end
context 'state filter on references' do
let(:issue) { create(:issue, :closed, project: public_project) }
let(:merge_request) { create(:merge_request, :closed, target_project: public_project) }
it 'renders JSON body with state filter for issues' do
post :preview_markdown, namespace_id: public_project.namespace,
id: public_project,
text: issue.to_reference
json_response = JSON.parse(response.body)
expect(json_response['body']).to match(/\##{issue.iid} \(closed\)/)
end
it 'renders JSON body with state filter for MRs' do
post :preview_markdown, namespace_id: public_project.namespace,
id: public_project,
text: merge_request.to_reference
json_response = JSON.parse(response.body)
expect(json_response['body']).to match(/\!#{merge_request.iid} \(closed\)/)
end
end
end end
describe '#ensure_canonical_path' do describe '#ensure_canonical_path' do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment