project_merge_requests.rb 4.9 KB
Newer Older
1
class ProjectMergeRequests < Spinach::FeatureSteps
N
Nihad Abbasov 已提交
2 3 4 5 6
  include SharedAuthentication
  include SharedProject
  include SharedNote
  include SharedPaths

R
Riyad Preukschas 已提交
7 8
  Given 'I click link "New Merge Request"' do
    click_link "New Merge Request"
9 10
  end

R
Riyad Preukschas 已提交
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"
17 18 19 20 21 22
  end

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

R
Riyad Preukschas 已提交
23 24
  Then 'I should see merge request "Wiki Feature"' do
    page.should have_content "Wiki Feature"
25 26
  end

R
Riyad Preukschas 已提交
27
  Then 'I should see closed merge request "Bug NS-04"' do
28 29
    merge_request = MergeRequest.find_by_title!("Bug NS-04")
    merge_request.closed?.should be_true
R
Riyad Preukschas 已提交
30
    page.should have_content "Closed by"
31 32
  end

R
Riyad Preukschas 已提交
33 34
  Then 'I should see merge request "Bug NS-04"' do
    page.should have_content "Bug NS-04"
35 36
  end

R
Riyad Preukschas 已提交
37 38
  Then 'I should see "Bug NS-04" in merge requests' do
    page.should have_content "Bug NS-04"
39 40
  end

R
Riyad Preukschas 已提交
41 42
  Then 'I should see "Feature NS-03" in merge requests' do
    page.should have_content "Feature NS-03"
43 44
  end

R
Riyad Preukschas 已提交
45 46
  And 'I should not see "Feature NS-03" in merge requests' do
    page.should_not have_content "Feature NS-03"
47 48
  end

R
Riyad Preukschas 已提交
49 50 51

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

R
Riyad Preukschas 已提交
54 55
  And 'I click link "Close"' do
    click_link "Close"
56 57 58
  end

  And 'I submit new merge request "Wiki Feature"' do
I
Izaak Alpert 已提交
59
    #this must come first, so that the target branch is set by the time the "select" for "notes_refactoring" is executed
I
Izaak Alpert 已提交
60
    select project.path_with_namespace, :from => "merge_request_target_project_id"
I
Izaak Alpert 已提交
61
    fill_in "merge_request_title", :with => "Wiki Feature"
I
Izaak Alpert 已提交
62
    select "master", :from => "merge_request_source_branch"
I
Izaak Alpert 已提交
63 64 65 66 67 68 69
    find(:select, "merge_request_target_project_id", {}).value.should == project.id.to_s
    find(:select, "merge_request_source_project_id", {}).value.should == project.id.to_s

    #using "notes_refactoring" because "Bug NS-04" uses master/stable, this will fail merge_request validation if the branches are the same
    find(:select, "merge_request_target_branch", {}).find(:option, "notes_refactoring", {}).value.should == "notes_refactoring"
    select "notes_refactoring", :from => "merge_request_target_branch"

70
    click_button "Submit merge request"
71 72 73
  end

  And 'project "Shop" have "Bug NS-04" open merge request' do
A
Andrew8xx8 已提交
74
    create(:merge_request,
R
Riyad Preukschas 已提交
75
           title: "Bug NS-04",
I
Izaak Alpert 已提交
76 77
           source_project: project,
           target_project: project,
R
Riyad Preukschas 已提交
78 79 80 81 82 83
           author: project.users.first)
  end

  And 'project "Shop" have "Bug NS-05" open merge request with diffs inside' do
    create(:merge_request_with_diffs,
           title: "Bug NS-05",
I
Izaak Alpert 已提交
84 85
           source_project: project,
           target_project: project,
R
Riyad Preukschas 已提交
86
           author: project.users.first)
87 88 89
  end

  And 'project "Shop" have "Feature NS-03" closed merge request' do
A
Andrew8xx8 已提交
90
    create(:closed_merge_request,
R
Riyad Preukschas 已提交
91
           title: "Feature NS-03",
I
Izaak Alpert 已提交
92 93
           source_project: project,
           target_project: project,
A
Andrew8xx8 已提交
94
           author: project.users.first)
R
Riyad Preukschas 已提交
95 96 97
  end

  And 'I switch to the diff tab' do
98
    visit diffs_project_merge_request_path(project, merge_request)
R
Riyad Preukschas 已提交
99 100 101
  end

  And 'I switch to the merge request\'s comments tab' do
102
    visit project_merge_request_path(project, merge_request)
R
Riyad Preukschas 已提交
103 104 105
  end

  And 'I click on the first commit in the merge request' do
106 107

    click_link merge_request.commits.first.short_id(8)
R
Riyad Preukschas 已提交
108 109 110
  end

  And 'I leave a comment on the diff page' do
111
    init_diff_note
D
Dmitriy Zaporozhets 已提交
112

D
Dmitriy Zaporozhets 已提交
113
    within('.js-temp-notes-holder') do
R
Riyad Preukschas 已提交
114 115 116 117 118 119
      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
120
    init_diff_note
R
Riyad Preukschas 已提交
121

D
Dmitriy Zaporozhets 已提交
122
    within(".js-temp-notes-holder") do
R
Riyad Preukschas 已提交
123 124
      fill_in "note_note", with: "Line is wrong"
      click_button "Add Comment"
D
Dmitriy Zaporozhets 已提交
125
      sleep 0.05
R
Riyad Preukschas 已提交
126 127 128 129 130
    end
  end

  Then 'I should see a discussion has started on line 185' do
    page.should have_content "#{current_user.name} started a discussion on this merge request diff"
D
Dmitriy Zaporozhets 已提交
131
    page.should have_content "app/assets/stylesheets/tree.scss:L185"
R
Riyad Preukschas 已提交
132 133 134 135 136
    page.should have_content "Line is wrong"
  end

  Then 'I should see a discussion has started on commit bcf03b5de6c:L185' do
    page.should have_content "#{current_user.name} started a discussion on commit"
D
Dmitriy Zaporozhets 已提交
137
    page.should have_content "app/assets/stylesheets/tree.scss:L185"
R
Riyad Preukschas 已提交
138 139 140 141
    page.should have_content "Line is wrong"
  end

  Then 'I should see a discussion has started on commit bcf03b5de6c' do
D
Dmitriy Zaporozhets 已提交
142
    page.should have_content "#{current_user.name} started a discussion on commit bcf03b5de6c"
R
Riyad Preukschas 已提交
143
    page.should have_content "One comment to rule them all"
D
Dmitriy Zaporozhets 已提交
144
    page.should have_content "app/assets/stylesheets/tree.scss:L185"
145
  end
146 147 148 149 150 151 152 153

  def project
    @project ||= Project.find_by_name!("Shop")
  end

  def merge_request
    @merge_request ||= MergeRequest.find_by_title!("Bug NS-05")
  end
154 155 156 157

  def init_diff_note
    find('a[data-line-code="4735dfc552ad7bf15ca468adc3cad9d05b624490_185_185"]').click
  end
158
end