summaryrefslogtreecommitdiff
path: root/spec/frontend/fixtures/api_markdown.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/frontend/fixtures/api_markdown.rb')
-rw-r--r--spec/frontend/fixtures/api_markdown.rb34
1 files changed, 32 insertions, 2 deletions
diff --git a/spec/frontend/fixtures/api_markdown.rb b/spec/frontend/fixtures/api_markdown.rb
index 1c3967b2c36..94db262e4fd 100644
--- a/spec/frontend/fixtures/api_markdown.rb
+++ b/spec/frontend/fixtures/api_markdown.rb
@@ -4,12 +4,29 @@ require 'spec_helper'
RSpec.describe API::MergeRequests, '(JavaScript fixtures)', type: :request do
include ApiHelpers
+ include WikiHelpers
include JavaScriptFixturesHelpers
+ let_it_be(:user) { create(:user) }
+
+ let_it_be(:group) { create(:group, :public) }
+ let_it_be(:project) { create(:project, :public, :repository, group: group) }
+
+ let_it_be(:project_wiki) { create(:project_wiki, user: user) }
+
+ let(:project_wiki_page) { create(:wiki_page, wiki: project_wiki) }
+
fixture_subdir = 'api/markdown'
before(:all) do
clean_frontend_fixtures(fixture_subdir)
+
+ group.add_owner(user)
+ project.add_maintainer(user)
+ end
+
+ before do
+ sign_in(user)
end
markdown_examples = begin
@@ -19,14 +36,27 @@ RSpec.describe API::MergeRequests, '(JavaScript fixtures)', type: :request do
end
markdown_examples.each do |markdown_example|
+ context = markdown_example.fetch(:context, '')
name = markdown_example.fetch(:name)
- context "for #{name}" do
+ context "for #{name}#{!context.empty? ? " (context: #{context})" : ''}" do
let(:markdown) { markdown_example.fetch(:markdown) }
+ name = "#{context}_#{name}" unless context.empty?
+
it "#{fixture_subdir}/#{name}.json" do
- post api("/markdown"), params: { text: markdown, gfm: true }
+ api_url = case context
+ when 'project'
+ "/#{project.full_path}/preview_markdown"
+ when 'group'
+ "/groups/#{group.full_path}/preview_markdown"
+ when 'project_wiki'
+ "/#{project.full_path}/-/wikis/#{project_wiki_page.slug}/preview_markdown"
+ else
+ api "/markdown"
+ end
+ post api_url, params: { text: markdown, gfm: true }
expect(response).to be_successful
end
end