diff options
-rw-r--r-- | app/controllers/concerns/preview_markdown.rb | 1 | ||||
-rw-r--r-- | changelogs/unreleased/31583-osw-gfm-complete-status-indication.yml | 5 | ||||
-rw-r--r-- | spec/controllers/projects_controller_spec.rb | 29 |
3 files changed, 34 insertions, 1 deletions
diff --git a/app/controllers/concerns/preview_markdown.rb b/app/controllers/concerns/preview_markdown.rb index 90bb7a87b45..7ac63c914fa 100644 --- a/app/controllers/concerns/preview_markdown.rb +++ b/app/controllers/concerns/preview_markdown.rb @@ -10,6 +10,7 @@ module PreviewMarkdown when 'wikis' then { pipeline: :wiki, project_wiki: @project_wiki, page_slug: params[:id] } when 'snippets' then { skip_project_check: true } when 'groups' then { group: group } + when 'projects' then { issuable_state_filter_enabled: true } else {} end diff --git a/changelogs/unreleased/31583-osw-gfm-complete-status-indication.yml b/changelogs/unreleased/31583-osw-gfm-complete-status-indication.yml new file mode 100644 index 00000000000..6f2cf275592 --- /dev/null +++ b/changelogs/unreleased/31583-osw-gfm-complete-status-indication.yml @@ -0,0 +1,5 @@ +--- +title: Present state indication on GFM preview +merge_request: +author: +type: added diff --git a/spec/controllers/projects_controller_spec.rb b/spec/controllers/projects_controller_spec.rb index 27f04be3fdf..34ed835a388 100644 --- a/spec/controllers/projects_controller_spec.rb +++ b/spec/controllers/projects_controller_spec.rb @@ -616,13 +616,40 @@ describe ProjectsController do end describe 'POST #preview_markdown' do - it 'renders json in a correct format' do + before do 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' expect(JSON.parse(response.body).keys).to match_array(%w(body references)) 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 describe '#ensure_canonical_path' do |