project_merge_requests.rb 4.67 KB
Newer Older
Nihad Abbasov's avatar
Nihad Abbasov committed
1
2
3
4
5
6
class ProjectMergeRequests < Spinach::FeatureSteps
  include SharedAuthentication
  include SharedProject
  include SharedNote
  include SharedPaths

7
8
  Given 'I click link "New Merge Request"' do
    click_link "New Merge Request"
Nihad Abbasov's avatar
Nihad Abbasov committed
9
10
  end

11
12
13
14
15
16
  Given 'I click link "Bug NS-04"' do
    click_link "Bug NS-04"
  end

  Given 'I click link "All"' do
    click_link "All"
Nihad Abbasov's avatar
Nihad Abbasov committed
17
18
19
20
21
22
  end

  Given 'I click link "Closed"' do
    click_link "Closed"
  end

23
24
  Then 'I should see merge request "Wiki Feature"' do
    page.should have_content "Wiki Feature"
Nihad Abbasov's avatar
Nihad Abbasov committed
25
26
27
28
  end

  Then 'I should see closed merge request "Bug NS-04"' do
    mr = MergeRequest.find_by_title("Bug NS-04")
Andrew8xx8's avatar
Andrew8xx8 committed
29
    mr.closed?.should be_true
Nihad Abbasov's avatar
Nihad Abbasov committed
30
31
32
    page.should have_content "Closed by"
  end

33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
  Then 'I should see merge request "Bug NS-04"' do
    page.should have_content "Bug NS-04"
  end

  Then 'I should see "Bug NS-04" in merge requests' do
    page.should have_content "Bug NS-04"
  end

  Then 'I should see "Feature NS-03" in merge requests' do
    page.should have_content "Feature NS-03"
  end

  And 'I should not see "Feature NS-03" in merge requests' do
    page.should_not have_content "Feature NS-03"
  end


  And 'I should not see "Bug NS-04" in merge requests' do
    page.should_not have_content "Bug NS-04"
  end

  And 'I click link "Close"' do
    click_link "Close"
Nihad Abbasov's avatar
Nihad Abbasov committed
56
57
58
59
60
61
  end

  And 'I submit new merge request "Wiki Feature"' do
    fill_in "merge_request_title", :with => "Wiki Feature"
    select "master", :from => "merge_request_source_branch"
    select "stable", :from => "merge_request_target_branch"
62
    click_button "Submit merge request"
Nihad Abbasov's avatar
Nihad Abbasov committed
63
64
65
66
  end

  And 'project "Shop" have "Bug NS-04" open merge request' do
    project = Project.find_by_name("Shop")
Andrew8xx8's avatar
Andrew8xx8 committed
67
    create(:merge_request,
68
69
70
71
72
73
74
75
76
77
78
           title: "Bug NS-04",
           project: project,
           author: project.users.first)
  end

  And 'project "Shop" have "Bug NS-05" open merge request with diffs inside' do
    project = Project.find_by_name("Shop")
    create(:merge_request_with_diffs,
           title: "Bug NS-05",
           project: project,
           author: project.users.first)
Nihad Abbasov's avatar
Nihad Abbasov committed
79
80
81
82
  end

  And 'project "Shop" have "Feature NS-03" closed merge request' do
    project = Project.find_by_name("Shop")
Andrew8xx8's avatar
Andrew8xx8 committed
83
    create(:closed_merge_request,
84
85
           title: "Feature NS-03",
           project: project,
Andrew8xx8's avatar
Andrew8xx8 committed
86
           author: project.users.first)
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
  end

  And 'I switch to the diff tab' do
    mr = MergeRequest.find_by_title("Bug NS-05")
    visit diffs_project_merge_request_path(mr.project, mr)
  end

  And 'I switch to the merge request\'s comments tab' do
    mr = MergeRequest.find_by_title("Bug NS-05")
    visit project_merge_request_path(mr.project, mr)
  end

  And 'I click on the first commit in the merge request' do
    mr = MergeRequest.find_by_title("Bug NS-05")
    click_link mr.commits.first.short_id(8)
  end

  And 'I leave a comment on the diff page' do
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
105
106
    find("#4735dfc552ad7bf15ca468adc3cad9d05b624490_185_185 .add-diff-note").click

Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
107
    within('.js-temp-notes-holder') do
108
109
110
111
112
113
      fill_in "note_note", with: "One comment to rule them all"
      click_button "Add Comment"
    end
  end

  And 'I leave a comment like "Line is wrong" on line 185 of the first file' do
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
114
    find("#4735dfc552ad7bf15ca468adc3cad9d05b624490_185_185 .add-diff-note").click
115

Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
116
    within(".js-temp-notes-holder") do
117
118
      fill_in "note_note", with: "Line is wrong"
      click_button "Add Comment"
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
119
      sleep 0.05
120
121
122
123
124
125
    end
  end

  Then 'I should see a discussion has started on line 185' do
    mr = MergeRequest.find_by_title("Bug NS-05")
    first_commit = mr.commits.first
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
126
    first_diff   = first_commit.diffs.first
127
128
129
130
131
132
133
134
    page.should have_content "#{current_user.name} started a discussion on this merge request diff"
    page.should have_content "#{first_diff.b_path}:L185"
    page.should have_content "Line is wrong"
  end

  Then 'I should see a discussion has started on commit bcf03b5de6c:L185' do
    mr = MergeRequest.find_by_title("Bug NS-05")
    first_commit = mr.commits.first
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
135
    first_diff   = first_commit.diffs.first
136
137
138
139
140
141
142
143
144
    page.should have_content "#{current_user.name} started a discussion on commit"
    page.should have_content first_commit.short_id(8)
    page.should have_content "#{first_diff.b_path}:L185"
    page.should have_content "Line is wrong"
  end

  Then 'I should see a discussion has started on commit bcf03b5de6c' do
    mr = MergeRequest.find_by_title("Bug NS-05")
    first_commit = mr.st_commits.first
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
145
146
    first_diff   = first_commit.diffs.first
    page.should have_content "#{current_user.name} started a discussion on commit bcf03b5de6c"
147
148
    page.should have_content first_commit.short_id(8)
    page.should have_content "One comment to rule them all"
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
149
    page.should have_content "#{first_diff.b_path}:L185"
Nihad Abbasov's avatar
Nihad Abbasov committed
150
151
  end
end