debian-mirror-gitlab/spec/frontend/fixtures/api_markdown.rb

66 lines
2 KiB
Ruby
Raw Normal View History

2021-04-29 21:17:54 +05:30
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe API::MergeRequests, '(JavaScript fixtures)', type: :request do
include ApiHelpers
2021-09-30 23:02:18 +05:30
include WikiHelpers
2021-04-29 21:17:54 +05:30
include JavaScriptFixturesHelpers
2021-10-27 15:23:28 +05:30
let_it_be(:user) { create(:user, username: 'gitlab') }
2021-09-30 23:02:18 +05:30
let_it_be(:group) { create(:group, :public) }
let_it_be(:project) { create(:project, :public, :repository, group: group) }
2021-10-27 15:23:28 +05:30
let_it_be(:label) { create(:label, project: project, title: 'bug') }
let_it_be(:milestone) { create(:milestone, project: project, title: '1.1') }
let_it_be(:issue) { create(:issue, project: project) }
let_it_be(:merge_request) { create(:merge_request, source_project: project) }
let_it_be(:project_wiki) { create(:project_wiki, project: project, user: user) }
2021-09-30 23:02:18 +05:30
let(:project_wiki_page) { create(:wiki_page, wiki: project_wiki) }
2021-04-29 21:17:54 +05:30
before(:all) do
2021-09-30 23:02:18 +05:30
group.add_owner(user)
project.add_maintainer(user)
end
before do
sign_in(user)
2021-04-29 21:17:54 +05:30
end
markdown_examples = begin
yaml_file_path = File.expand_path('api_markdown.yml', __dir__)
yaml = File.read(yaml_file_path)
YAML.safe_load(yaml, symbolize_names: true)
end
markdown_examples.each do |markdown_example|
2021-09-30 23:02:18 +05:30
context = markdown_example.fetch(:context, '')
2021-04-29 21:17:54 +05:30
name = markdown_example.fetch(:name)
2021-09-30 23:02:18 +05:30
context "for #{name}#{!context.empty? ? " (context: #{context})" : ''}" do
2021-04-29 21:17:54 +05:30
let(:markdown) { markdown_example.fetch(:markdown) }
2021-09-30 23:02:18 +05:30
name = "#{context}_#{name}" unless context.empty?
2021-11-18 22:05:49 +05:30
it "api/markdown/#{name}.json" do
2021-09-30 23:02:18 +05:30
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
2021-04-29 21:17:54 +05:30
2021-09-30 23:02:18 +05:30
post api_url, params: { text: markdown, gfm: true }
2021-04-29 21:17:54 +05:30
expect(response).to be_successful
end
end
end
end