2eecfd8f9d
This allows using `CacheMarkdownField` for models that are not backed by ActiveRecord. When the including class inherits `ActiveRecord::Base` we include `Gitlab::MarkdownCache::ActiveRecord::Extension`. This will cause the markdown fields to be rendered and the generated HTML stored in a `<field>_html` attribute on the record. We also store the version used for generating the markdown. All other classes that include this model will include the `Gitlab::MarkdownCache::Redis::Extension`. This add the `<field>_html` attributes to that model and will generate the html in them. The generated HTML will be cached in redis under the key `markdown_cache:<class>:<id>`. The class this included in must therefore respond to `id`.
132 lines
3.6 KiB
Ruby
132 lines
3.6 KiB
Ruby
require 'spec_helper'
|
|
|
|
describe "GitLab Flavored Markdown" do
|
|
let(:user) { create(:user) }
|
|
let(:project) { create(:project) }
|
|
let(:issue) { create(:issue, project: project) }
|
|
let(:fred) do
|
|
create(:user, name: 'fred') do |user|
|
|
project.add_maintainer(user)
|
|
end
|
|
end
|
|
|
|
before do
|
|
sign_in(user)
|
|
project.add_developer(user)
|
|
end
|
|
|
|
describe "for commits" do
|
|
let(:project) { create(:project, :repository) }
|
|
let(:commit) { project.commit }
|
|
|
|
before do
|
|
create_commit("fix #{issue.to_reference}\n\nask #{fred.to_reference} for details", project, user, 'master')
|
|
end
|
|
|
|
it "renders title in commits#index" do
|
|
visit project_commits_path(project, 'master', limit: 1)
|
|
|
|
expect(page).to have_link(issue.to_reference)
|
|
end
|
|
|
|
it "renders title in commits#show" do
|
|
visit project_commit_path(project, commit)
|
|
|
|
expect(page).to have_link(issue.to_reference)
|
|
end
|
|
|
|
it "renders description in commits#show" do
|
|
visit project_commit_path(project, commit)
|
|
|
|
expect(page).to have_link(fred.to_reference)
|
|
end
|
|
|
|
it "renders title in repositories#branches" do
|
|
visit project_branches_path(project)
|
|
|
|
expect(page).to have_link(issue.to_reference)
|
|
end
|
|
end
|
|
|
|
describe "for issues", :js do
|
|
before do
|
|
@other_issue = create(:issue,
|
|
author: user,
|
|
assignees: [user],
|
|
project: project)
|
|
@issue = create(:issue,
|
|
author: user,
|
|
assignees: [user],
|
|
project: project,
|
|
title: "fix #{@other_issue.to_reference}",
|
|
description: "ask #{fred.to_reference} for details")
|
|
|
|
@note = create(:note_on_issue, noteable: @issue, project: @issue.project, note: "Hello world")
|
|
end
|
|
|
|
it "renders subject in issues#index" do
|
|
visit project_issues_path(project)
|
|
|
|
expect(page).to have_link(@other_issue.to_reference)
|
|
end
|
|
|
|
it "renders subject in issues#show" do
|
|
visit project_issue_path(project, @issue)
|
|
|
|
expect(page).to have_link(@other_issue.to_reference)
|
|
end
|
|
|
|
it "renders details in issues#show" do
|
|
visit project_issue_path(project, @issue)
|
|
|
|
expect(page).to have_link(fred.to_reference)
|
|
end
|
|
end
|
|
|
|
describe "for merge requests" do
|
|
let(:project) { create(:project, :repository) }
|
|
|
|
before do
|
|
@merge_request = create(:merge_request, source_project: project, target_project: project, title: "fix #{issue.to_reference}")
|
|
end
|
|
|
|
it "renders title in merge_requests#index" do
|
|
visit project_merge_requests_path(project)
|
|
|
|
expect(page).to have_link(issue.to_reference)
|
|
end
|
|
|
|
it "renders title in merge_requests#show" do
|
|
visit project_merge_request_path(project, @merge_request)
|
|
|
|
expect(page).to have_link(issue.to_reference)
|
|
end
|
|
end
|
|
|
|
describe "for milestones" do
|
|
before do
|
|
@milestone = create(:milestone,
|
|
project: project,
|
|
title: "fix #{issue.to_reference}",
|
|
description: "ask #{fred.to_reference} for details")
|
|
end
|
|
|
|
it "renders title in milestones#index" do
|
|
visit project_milestones_path(project)
|
|
|
|
expect(page).to have_link(issue.to_reference)
|
|
end
|
|
|
|
it "renders title in milestones#show" do
|
|
visit project_milestone_path(project, @milestone)
|
|
|
|
expect(page).to have_link(issue.to_reference)
|
|
end
|
|
|
|
it "renders description in milestones#show" do
|
|
visit project_milestone_path(project, @milestone)
|
|
|
|
expect(page).to have_link(fred.to_reference)
|
|
end
|
|
end
|
|
end
|