BigW Consortium Gitlab

gitlab_flavored_markdown_spec.rb 3.84 KB
Newer Older
1 2
require 'spec_helper'

3
describe "GitLab Flavored Markdown", feature: true do
4
  let(:project) { create(:project) }
5
  let(:issue) { create(:issue, project: project) }
6
  let(:merge_request) { create(:merge_request, source_project: project, target_project: project) }
7
  let(:fred) do
8 9 10
    u = create(:user, name: "fred")
    project.team << [u, :master]
    u
11 12 13
  end

  before do
14 15
    allow_any_instance_of(Commit).to receive(:title).
      and_return("fix #{issue.to_reference}\n\nask #{fred.to_reference} for details")
16
  end
randx committed
17

18
  let(:commit) { project.commit }
19 20 21

  before do
    login_as :user
Dmitriy Zaporozhets committed
22
    project.team << [@user, :developer]
23 24 25
  end

  describe "for commits" do
26
    it "renders title in commits#index" do
Vinnie Okada committed
27
      visit namespace_project_commits_path(project.namespace, project, 'master', limit: 1)
28

29
      expect(page).to have_link(issue.to_reference)
30 31
    end

32
    it "renders title in commits#show" do
Vinnie Okada committed
33
      visit namespace_project_commit_path(project.namespace, project, commit)
34

35
      expect(page).to have_link(issue.to_reference)
36 37
    end

38
    it "renders description in commits#show" do
Vinnie Okada committed
39
      visit namespace_project_commit_path(project.namespace, project, commit)
40

41
      expect(page).to have_link(fred.to_reference)
42 43
    end

44
    it "renders title in repositories#branches" do
Vinnie Okada committed
45
      visit namespace_project_branches_path(project.namespace, project)
46

47
      expect(page).to have_link(issue.to_reference)
48 49 50 51 52
    end
  end

  describe "for issues" do
    before do
53 54 55 56 57
      @other_issue = create(:issue,
                            author: @user,
                            assignee: @user,
                            project: project)
      @issue = create(:issue,
58 59
                      author: @user,
                      assignee: @user,
60
                      project: project,
61 62
                      title: "fix #{@other_issue.to_reference}",
                      description: "ask #{fred.to_reference} for details")
63 64
    end

65
    it "renders subject in issues#index" do
Vinnie Okada committed
66
      visit namespace_project_issues_path(project.namespace, project)
67

68
      expect(page).to have_link(@other_issue.to_reference)
69 70
    end

71
    it "renders subject in issues#show" do
Vinnie Okada committed
72
      visit namespace_project_issue_path(project.namespace, project, @issue)
73

74
      expect(page).to have_link(@other_issue.to_reference)
75 76
    end

77
    it "renders details in issues#show" do
Vinnie Okada committed
78
      visit namespace_project_issue_path(project.namespace, project, @issue)
79

80
      expect(page).to have_link(fred.to_reference)
81 82 83 84 85
    end
  end

  describe "for merge requests" do
    before do
86
      @merge_request = create(:merge_request, source_project: project, target_project: project, title: "fix #{issue.to_reference}")
87 88
    end

89
    it "renders title in merge_requests#index" do
Vinnie Okada committed
90
      visit namespace_project_merge_requests_path(project.namespace, project)
91

92
      expect(page).to have_link(issue.to_reference)
93 94
    end

95
    it "renders title in merge_requests#show" do
Vinnie Okada committed
96
      visit namespace_project_merge_request_path(project.namespace, project, @merge_request)
97

98
      expect(page).to have_link(issue.to_reference)
99 100 101 102 103
    end
  end

  describe "for milestones" do
    before do
104 105
      @milestone = create(:milestone,
                          project: project,
106 107
                          title: "fix #{issue.to_reference}",
                          description: "ask #{fred.to_reference} for details")
108 109
    end

110
    it "renders title in milestones#index" do
Vinnie Okada committed
111
      visit namespace_project_milestones_path(project.namespace, project)
112

113
      expect(page).to have_link(issue.to_reference)
114 115
    end

116
    it "renders title in milestones#show" do
Vinnie Okada committed
117
      visit namespace_project_milestone_path(project.namespace, project, @milestone)
118

119
      expect(page).to have_link(issue.to_reference)
120 121
    end

122
    it "renders description in milestones#show" do
Vinnie Okada committed
123
      visit namespace_project_milestone_path(project.namespace, project, @milestone)
124

125
      expect(page).to have_link(fred.to_reference)
126 127 128
    end
  end
end