summaryrefslogtreecommitdiff
path: root/spec/features/gitlab_flavored_markdown_spec.rb
blob: a507f0314c6bb2492efe395179007de0e08f9180 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
require 'spec_helper'

describe "GitLab Flavored Markdown" do
  let(:project) { create(:project) }
  let(:issue) { create(:issue, project: project) }
  let(:merge_request) { create(:merge_request, source_project: project, target_project: project) }
  let(:fred) do
    u = create(:user, name: "fred")
    project.team << [u, :master]
    u
  end

  before do
    Commit.any_instance.stub(title: "fix ##{issue.iid}\n\nask @#{fred.username} for details")
  end

  let(:commit) { project.repository.commit }

  before do
    login_as :user
    project.team << [@user, :developer]
  end

  describe "for commits" do
    it "should render title in commits#index" do
      visit project_commits_path(project, 'master', limit: 1)

      page.should have_link("##{issue.iid}")
    end

    it "should render title in commits#show" do
      visit project_commit_path(project, commit)

      page.should have_link("##{issue.iid}")
    end

    it "should render description in commits#show" do
      visit project_commit_path(project, commit)

      page.should have_link("@#{fred.username}")
    end

    it "should render title in repositories#branches" do
      visit project_branches_path(project)

      page.should have_link("##{issue.iid}")
    end
  end

  describe "for issues" do
    before do
      @other_issue = create(:issue,
                            author: @user,
                            assignee: @user,
                            project: project)
      @issue = create(:issue,
                      author: @user,
                      assignee: @user,
                      project: project,
                      title: "fix ##{@other_issue.iid}",
                      description: "ask @#{fred.username} for details")
    end

    it "should render subject in issues#index" do
      visit project_issues_path(project)

      page.should have_link("##{@other_issue.iid}")
    end

    it "should render subject in issues#show" do
      visit project_issue_path(project, @issue)

      page.should have_link("##{@other_issue.iid}")
    end

    it "should render details in issues#show" do
      visit project_issue_path(project, @issue)

      page.should have_link("@#{fred.username}")
    end
  end


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

    it "should render title in merge_requests#index" do
      visit project_merge_requests_path(project)

      page.should have_link("##{issue.iid}")
    end

    it "should render title in merge_requests#show" do
      visit project_merge_request_path(project, @merge_request)

      page.should have_link("##{issue.iid}")
    end
  end


  describe "for milestones" do
    before do
      @milestone = create(:milestone,
                          project: project,
                          title: "fix ##{issue.iid}",
                          description: "ask @#{fred.username} for details")
    end

    it "should render title in milestones#index" do
      visit project_milestones_path(project)

      page.should have_link("##{issue.iid}")
    end

    it "should render title in milestones#show" do
      visit project_milestone_path(project, @milestone)

      page.should have_link("##{issue.iid}")
    end

    it "should render description in milestones#show" do
      visit project_milestone_path(project, @milestone)

      page.should have_link("@#{fred.username}")
    end
  end
end