BigW Consortium Gitlab

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

3
describe "GitLab Flavored Markdown" do
4
  let(:user) { create(:user) }
5
  let(:project) { create(:project) }
6
  let(:issue) { create(:issue, project: project) }
7
  let(:fred) do
8 9 10
    create(:user, name: 'fred') do |user|
      project.add_master(user)
    end
11 12 13
  end

  before do
14 15
    sign_in(user)
    project.add_developer(user)
16
  end
randx committed
17

18 19 20
  describe "for commits" do
    let(:project) { create(:project, :repository) }
    let(:commit) { project.commit }
21

22
    before do
23 24
      allow_any_instance_of(Commit).to receive(:title)
        .and_return("fix #{issue.to_reference}\n\nask #{fred.to_reference} for details")
25
    end
26

27
    it "renders title in commits#index" do
28
      visit project_commits_path(project, 'master', limit: 1)
29

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

33
    it "renders title in commits#show" do
34
      visit project_commit_path(project, commit)
35

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

39
    it "renders description in commits#show" do
40
      visit project_commit_path(project, commit)
41

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

45
    it "renders title in repositories#branches" do
46
      visit project_branches_path(project)
47

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

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

      @note = create(:note_on_issue, noteable: @issue, project: @issue.project, note: "Hello world")
66 67
    end

68
    it "renders subject in issues#index" do
69
      visit project_issues_path(project)
70

71
      expect(page).to have_link(@other_issue.to_reference)
72 73
    end

74
    it "renders subject in issues#show" do
75
      visit project_issue_path(project, @issue)
76

77
      expect(page).to have_link(@other_issue.to_reference)
78 79
    end

80
    it "renders details in issues#show" do
81
      visit project_issue_path(project, @issue)
82

83
      expect(page).to have_link(fred.to_reference)
84 85 86 87
    end
  end

  describe "for merge requests" do
88 89
    let(:project) { create(:project, :repository) }

90
    before do
91
      @merge_request = create(:merge_request, source_project: project, target_project: project, title: "fix #{issue.to_reference}")
92 93
    end

94
    it "renders title in merge_requests#index" do
95
      visit project_merge_requests_path(project)
96

97
      expect(page).to have_link(issue.to_reference)
98 99
    end

100
    it "renders title in merge_requests#show" do
101
      visit project_merge_request_path(project, @merge_request)
102

103
      expect(page).to have_link(issue.to_reference)
104 105 106 107 108
    end
  end

  describe "for milestones" do
    before do
109 110
      @milestone = create(:milestone,
                          project: project,
111 112
                          title: "fix #{issue.to_reference}",
                          description: "ask #{fred.to_reference} for details")
113 114
    end

115
    it "renders title in milestones#index" do
116
      visit project_milestones_path(project)
117

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

121
    it "renders title in milestones#show" do
122
      visit project_milestone_path(project, @milestone)
123

124
      expect(page).to have_link(issue.to_reference)
125 126
    end

127
    it "renders description in milestones#show" do
128
      visit project_milestone_path(project, @milestone)
129

130
      expect(page).to have_link(fred.to_reference)
131 132 133
    end
  end
end