BigW Consortium Gitlab

gitlab_flavored_markdown_spec.rb 3.91 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 26
  end

  describe "for commits" do
    it "should render 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 32
    end

    it "should render 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 38
    end

    it "should render 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 44
    end

    it "should render 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 65
    end

    it "should render 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 71
    end

    it "should render 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 77
    end

    it "should render 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 86
    end
  end


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

    it "should render title in merge_requests#index" do
Vinnie Okada committed
91
      visit namespace_project_merge_requests_path(project.namespace, project)
92

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

    it "should render title in merge_requests#show" do
Vinnie Okada committed
97
      visit namespace_project_merge_request_path(project.namespace, project, @merge_request)
98

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


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

    it "should render title in milestones#index" do
Vinnie Okada committed
113
      visit namespace_project_milestones_path(project.namespace, project)
114

115
      expect(page).to have_link(issue.to_reference)
116 117 118
    end

    it "should render title in milestones#show" do
Vinnie Okada committed
119
      visit namespace_project_milestone_path(project.namespace, project, @milestone)
120

121
      expect(page).to have_link(issue.to_reference)
122 123 124
    end

    it "should render description in milestones#show" do
Vinnie Okada committed
125
      visit namespace_project_milestone_path(project.namespace, project, @milestone)
126

127
      expect(page).to have_link(fred.to_reference)
128 129 130
    end
  end
end