Commit ac983319d3dca597d9a1dcfa46f6acc6ebcfa07a

Authored by Dmitriy Zaporozhets
1 parent f598cc78

fixing some test

features/steps/project/project_merge_requests.rb
@@ -110,6 +110,7 @@ class ProjectMergeRequests < Spinach::FeatureSteps @@ -110,6 +110,7 @@ class ProjectMergeRequests < Spinach::FeatureSteps
110 end 110 end
111 111
112 And 'I leave a comment like "Line is wrong" on line 185 of the first file' do 112 And 'I leave a comment like "Line is wrong" on line 185 of the first file' do
  113 + save_and_open_page
113 within(:xpath, "//div[@class='diff_file'][1]") do 114 within(:xpath, "//div[@class='diff_file'][1]") do
114 click_link "add-diff-line-note-0_185_185" 115 click_link "add-diff-line-note-0_185_185"
115 end 116 end
features/steps/shared/diff_note.rb
@@ -20,7 +20,7 @@ module SharedDiffNote @@ -20,7 +20,7 @@ module SharedDiffNote
20 end 20 end
21 21
22 Given 'I leave a diff comment like "Typo, please fix"' do 22 Given 'I leave a diff comment like "Typo, please fix"' do
23 - find("#0_29_14.line_holder .js-add-diff-note-button").trigger("click") 23 + find("#586fb7c4e1add2d4d24e27566ed7064680098646_29_14.line_holder .js-add-diff-note-button").trigger("click")
24 within(".diff_file") do 24 within(".diff_file") do
25 fill_in "note[note]", with: "Typo, please fix" 25 fill_in "note[note]", with: "Typo, please fix"
26 #click_button("Add Comment") 26 #click_button("Add Comment")
@@ -29,7 +29,7 @@ module SharedDiffNote @@ -29,7 +29,7 @@ module SharedDiffNote
29 end 29 end
30 30
31 Given 'I preview a diff comment text like "Should fix it :smile:"' do 31 Given 'I preview a diff comment text like "Should fix it :smile:"' do
32 - find("#0_29_14.line_holder .js-add-diff-note-button").trigger("click") 32 + find("#586fb7c4e1add2d4d24e27566ed7064680098646_29_14.line_holder .js-add-diff-note-button").trigger("click")
33 within(".diff_file") do 33 within(".diff_file") do
34 fill_in "note[note]", with: "Should fix it :smile:" 34 fill_in "note[note]", with: "Should fix it :smile:"
35 find(".js-note-preview-button").trigger("click") 35 find(".js-note-preview-button").trigger("click")
@@ -37,7 +37,7 @@ module SharedDiffNote @@ -37,7 +37,7 @@ module SharedDiffNote
37 end 37 end
38 38
39 Given 'I preview another diff comment text like "DRY this up"' do 39 Given 'I preview another diff comment text like "DRY this up"' do
40 - find("#0_57_41.line_holder .js-add-diff-note-button").trigger("click") 40 + find("#586fb7c4e1add2d4d24e27566ed7064680098646_57_41.line_holder .js-add-diff-note-button").trigger("click")
41 within(".diff_file") do 41 within(".diff_file") do
42 fill_in "note[note]", with: "DRY this up" 42 fill_in "note[note]", with: "DRY this up"
43 find(".js-note-preview-button").trigger("click") 43 find(".js-note-preview-button").trigger("click")
@@ -45,11 +45,11 @@ module SharedDiffNote @@ -45,11 +45,11 @@ module SharedDiffNote
45 end 45 end
46 46
47 Given 'I open a diff comment form' do 47 Given 'I open a diff comment form' do
48 - find("#0_29_14.line_holder .js-add-diff-note-button").trigger("click") 48 + find("#586fb7c4e1add2d4d24e27566ed7064680098646_29_14.line_holder .js-add-diff-note-button").trigger("click")
49 end 49 end
50 50
51 Given 'I open another diff comment form' do 51 Given 'I open another diff comment form' do
52 - find("#0_57_41.line_holder .js-add-diff-note-button").trigger("click") 52 + find("#586fb7c4e1add2d4d24e27566ed7064680098646_57_41.line_holder .js-add-diff-note-button").trigger("click")
53 end 53 end
54 54
55 Given 'I write a diff comment like ":-1: I don\'t like this"' do 55 Given 'I write a diff comment like ":-1: I don\'t like this"' do
spec/requests/notes_on_merge_requests_spec.rb
@@ -6,7 +6,7 @@ describe "On a merge request", js: true do @@ -6,7 +6,7 @@ describe "On a merge request", js: true do
6 6
7 before do 7 before do
8 login_as :user 8 login_as :user
9 - project.add_access(@user, :read, :write) 9 + project.team << [@user, :master]
10 10
11 visit project_merge_request_path(project, merge_request) 11 visit project_merge_request_path(project, merge_request)
12 end 12 end
@@ -91,13 +91,11 @@ describe &quot;On a merge request diff&quot;, js: true, focus: true do @@ -91,13 +91,11 @@ describe &quot;On a merge request diff&quot;, js: true, focus: true do
91 let!(:project) { create(:project) } 91 let!(:project) { create(:project) }
92 let!(:merge_request) { create(:merge_request_with_diffs, project: project) } 92 let!(:merge_request) { create(:merge_request_with_diffs, project: project) }
93 93
94 - before(:all) do 94 + before do
95 login_as :user 95 login_as :user
96 - project.add_access(@user, :read, :write)  
97 -  
98 - visit project_merge_request_diff_path(project, merge_request) 96 + project.team << [@user, :master]
99 97
100 - save_and_open_page 98 + visit diffs_project_merge_request_path(project, merge_request)
101 99
102 click_link("Diff") 100 click_link("Diff")
103 end 101 end
@@ -106,21 +104,21 @@ describe &quot;On a merge request diff&quot;, js: true, focus: true do @@ -106,21 +104,21 @@ describe &quot;On a merge request diff&quot;, js: true, focus: true do
106 104
107 describe "when adding a note" do 105 describe "when adding a note" do
108 before do 106 before do
109 - find("#0_185_185.line_holder .js-add-diff-note-button").trigger("click") 107 + find("#4735dfc552ad7bf15ca468adc3cad9d05b624490_185_185.line_holder .js-add-diff-note-button").trigger("click")
110 end 108 end
111 109
112 describe "the notes holder" do 110 describe "the notes holder" do
113 - it { should have_css("#0_185_185.line_holder + .js-temp-notes-holder") } 111 + it { should have_css("#4735dfc552ad7bf15ca468adc3cad9d05b624490_185_185.line_holder + .js-temp-notes-holder") }
114 112
115 it { within(".js-temp-notes-holder") { should have_css(".new_note") } } 113 it { within(".js-temp-notes-holder") { should have_css(".new_note") } }
116 end 114 end
117 115
118 describe "the note form" do 116 describe "the note form" do
119 # set up hidden fields correctly 117 # set up hidden fields correctly
120 - it { within(".js-temp-notes-holder") { find("#note_noteable_type").value.should == "Commit" } } 118 + it { within(".js-temp-notes-holder") { find("#note_noteable_type").value.should == "MergeRequest" } }
121 it { within(".js-temp-notes-holder") { find("#note_noteable_id").value.should == "" } } 119 it { within(".js-temp-notes-holder") { find("#note_noteable_id").value.should == "" } }
122 it { within(".js-temp-notes-holder") { find("#note_commit_id").value.should == "bcf03b5de6c33f3869ef70d68cf06e679d1d7f9a" } } 120 it { within(".js-temp-notes-holder") { find("#note_commit_id").value.should == "bcf03b5de6c33f3869ef70d68cf06e679d1d7f9a" } }
123 - it { within(".js-temp-notes-holder") { find("#note_line_code").value.should == "0_185_185" } } 121 + it { within(".js-temp-notes-holder") { find("#note_line_code").value.should == "4735dfc552ad7bf15ca468adc3cad9d05b624490_185_185" } }
124 122
125 # buttons 123 # buttons
126 it { should have_button("Add Comment") } 124 it { should have_button("Add Comment") }
@@ -131,9 +129,9 @@ describe &quot;On a merge request diff&quot;, js: true, focus: true do @@ -131,9 +129,9 @@ describe &quot;On a merge request diff&quot;, js: true, focus: true do
131 it { should have_checked_field("Commit author") } 129 it { should have_checked_field("Commit author") }
132 130
133 it "shouldn't add a second form for same row" do 131 it "shouldn't add a second form for same row" do
134 - find("#0_185_185.line_holder .js-add-diff-note-button").trigger("click") 132 + find("#4735dfc552ad7bf15ca468adc3cad9d05b624490_185_185.line_holder .js-add-diff-note-button").trigger("click")
135 133
136 - should have_css("#0_185_185.line_holder + .js-temp-notes-holder form", count: 1) 134 + should have_css("#4735dfc552ad7bf15ca468adc3cad9d05b624490_185_185.line_holder + .js-temp-notes-holder form", count: 1)
137 end 135 end
138 136
139 it "should be removed when canceled" do 137 it "should be removed when canceled" do
@@ -146,8 +144,8 @@ describe &quot;On a merge request diff&quot;, js: true, focus: true do @@ -146,8 +144,8 @@ describe &quot;On a merge request diff&quot;, js: true, focus: true do
146 144
147 describe "with muliple note forms" do 145 describe "with muliple note forms" do
148 before do 146 before do
149 - find("#0_185_185.line_holder .js-add-diff-note-button").trigger("click")  
150 - find("#1_18_17.line_holder .js-add-diff-note-button").trigger("click") 147 + find("#4735dfc552ad7bf15ca468adc3cad9d05b624490_185_185.line_holder .js-add-diff-note-button").trigger("click")
  148 + find("#342e16cbbd482ac2047dc679b2749d248cc1428f_18_17.line_holder .js-add-diff-note-button").trigger("click")
151 end 149 end
152 150
153 # has two line forms 151 # has two line forms
@@ -156,46 +154,46 @@ describe &quot;On a merge request diff&quot;, js: true, focus: true do @@ -156,46 +154,46 @@ describe &quot;On a merge request diff&quot;, js: true, focus: true do
156 describe "previewing them separately" do 154 describe "previewing them separately" do
157 before do 155 before do
158 # add two separate texts and trigger previews on both 156 # add two separate texts and trigger previews on both
159 - within("#0_185_185.line_holder + .js-temp-notes-holder") do 157 + within("#4735dfc552ad7bf15ca468adc3cad9d05b624490_185_185.line_holder + .js-temp-notes-holder") do
160 fill_in "note[note]", with: "One comment on line 185" 158 fill_in "note[note]", with: "One comment on line 185"
161 find(".js-note-preview-button").trigger("click") 159 find(".js-note-preview-button").trigger("click")
162 end 160 end
163 - within("#1_18_17.line_holder + .js-temp-notes-holder") do 161 + within("#342e16cbbd482ac2047dc679b2749d248cc1428f_18_17.line_holder + .js-temp-notes-holder") do
164 fill_in "note[note]", with: "Another comment on line 17" 162 fill_in "note[note]", with: "Another comment on line 17"
165 find(".js-note-preview-button").trigger("click") 163 find(".js-note-preview-button").trigger("click")
166 end 164 end
167 end 165 end
168 166
169 # check if previews were rendered separately 167 # check if previews were rendered separately
170 - it { within("#0_185_185.line_holder + .js-temp-notes-holder") { should have_css(".js-note-preview", text: "One comment on line 185") } }  
171 - it { within("#1_18_17.line_holder + .js-temp-notes-holder") { should have_css(".js-note-preview", text: "Another comment on line 17") } } 168 + it { within("#4735dfc552ad7bf15ca468adc3cad9d05b624490_185_185.line_holder + .js-temp-notes-holder") { should have_css(".js-note-preview", text: "One comment on line 185") } }
  169 + it { within("#342e16cbbd482ac2047dc679b2749d248cc1428f_18_17.line_holder + .js-temp-notes-holder") { should have_css(".js-note-preview", text: "Another comment on line 17") } }
172 end 170 end
173 171
174 describe "posting a note" do 172 describe "posting a note" do
175 before do 173 before do
176 - within("#1_18_17.line_holder + .js-temp-notes-holder") do 174 + within("#342e16cbbd482ac2047dc679b2749d248cc1428f_18_17.line_holder + .js-temp-notes-holder") do
177 fill_in "note[note]", with: "Another comment on line 17" 175 fill_in "note[note]", with: "Another comment on line 17"
178 click_button("Add Comment") 176 click_button("Add Comment")
179 end 177 end
180 end 178 end
181 179
182 # removed form after submit 180 # removed form after submit
183 - it { should have_no_css("#1_18_17.line_holder + .js-temp-notes-holder") } 181 + it { should have_no_css("#342e16cbbd482ac2047dc679b2749d248cc1428f_18_17.line_holder + .js-temp-notes-holder") }
184 182
185 # added discussion 183 # added discussion
186 it { should have_content("Another comment on line 17") } 184 it { should have_content("Another comment on line 17") }
187 - it { should have_css("#1_18_17.line_holder + .notes_holder") }  
188 - it { should have_css("#1_18_17.line_holder + .notes_holder .note", count: 1) } 185 + it { should have_css("#342e16cbbd482ac2047dc679b2749d248cc1428f_18_17.line_holder + .notes_holder") }
  186 + it { should have_css("#342e16cbbd482ac2047dc679b2749d248cc1428f_18_17.line_holder + .notes_holder .note", count: 1) }
189 it { should have_link("Reply") } 187 it { should have_link("Reply") }
190 188
191 it "should remove last note of a discussion" do 189 it "should remove last note of a discussion" do
192 - within("#1_18_17.line_holder + .notes_holder") do 190 + within("#342e16cbbd482ac2047dc679b2749d248cc1428f_18_17.line_holder + .notes_holder") do
193 find(".js-note-delete").trigger("click") 191 find(".js-note-delete").trigger("click")
194 end 192 end
195 193
196 # removed whole discussion 194 # removed whole discussion
197 should_not have_css(".note_holder") 195 should_not have_css(".note_holder")
198 - should have_css("#1_18_17.line_holder + #1_18_18.line_holder") 196 + should have_css("#342e16cbbd482ac2047dc679b2749d248cc1428f_18_17.line_holder + #342e16cbbd482ac2047dc679b2749d248cc1428f_18_18.line_holder")
199 end 197 end
200 end 198 end
201 end 199 end
@@ -203,13 +201,13 @@ describe &quot;On a merge request diff&quot;, js: true, focus: true do @@ -203,13 +201,13 @@ describe &quot;On a merge request diff&quot;, js: true, focus: true do
203 describe "when replying to a note" do 201 describe "when replying to a note" do
204 before do 202 before do
205 # create first note 203 # create first note
206 - find("#0_184_184.line_holder .js-add-diff-note-button").trigger("click")  
207 - within("#0_184_184.line_holder + .js-temp-notes-holder") do 204 + find("#4735dfc552ad7bf15ca468adc3cad9d05b624490_184_184.line_holder .js-add-diff-note-button").trigger("click")
  205 + within("#4735dfc552ad7bf15ca468adc3cad9d05b624490_184_184.line_holder + .js-temp-notes-holder") do
208 fill_in "note[note]", with: "One comment on line 184" 206 fill_in "note[note]", with: "One comment on line 184"
209 click_button("Add Comment") 207 click_button("Add Comment")
210 end 208 end
211 # create second note 209 # create second note
212 - within("#0_184_184.line_holder + .notes_holder") do 210 + within("#4735dfc552ad7bf15ca468adc3cad9d05b624490_184_184.line_holder + .notes_holder") do
213 find(".js-discussion-reply-button").trigger("click") 211 find(".js-discussion-reply-button").trigger("click")
214 fill_in "note[note]", with: "An additional comment in reply" 212 fill_in "note[note]", with: "An additional comment in reply"
215 click_button("Add Comment") 213 click_button("Add Comment")
@@ -218,11 +216,11 @@ describe &quot;On a merge request diff&quot;, js: true, focus: true do @@ -218,11 +216,11 @@ describe &quot;On a merge request diff&quot;, js: true, focus: true do
218 216
219 # inserted note 217 # inserted note
220 it { should have_content("An additional comment in reply") } 218 it { should have_content("An additional comment in reply") }
221 - it { within("#0_184_184.line_holder + .notes_holder") { should have_css(".note", count: 2) } } 219 + it { within("#4735dfc552ad7bf15ca468adc3cad9d05b624490_184_184.line_holder + .notes_holder") { should have_css(".note", count: 2) } }
222 220
223 # removed form after reply 221 # removed form after reply
224 - it { within("#0_184_184.line_holder + .notes_holder") { should have_no_css("form") } }  
225 - it { within("#0_184_184.line_holder + .notes_holder") { should have_link("Reply") } } 222 + it { within("#4735dfc552ad7bf15ca468adc3cad9d05b624490_184_184.line_holder + .notes_holder") { should have_no_css("form") } }
  223 + it { within("#4735dfc552ad7bf15ca468adc3cad9d05b624490_184_184.line_holder + .notes_holder") { should have_link("Reply") } }
226 end 224 end
227 end 225 end
228 226
@@ -232,4 +230,4 @@ describe &quot;On merge request discussion&quot;, js: true do @@ -232,4 +230,4 @@ describe &quot;On merge request discussion&quot;, js: true do
232 describe "with merge request diff note" 230 describe "with merge request diff note"
233 describe "with commit note" 231 describe "with commit note"
234 describe "with commit diff note" 232 describe "with commit diff note"
235 -end  
236 \ No newline at end of file 233 \ No newline at end of file
  234 +end
spec/requests/notes_on_wall_spec.rb
@@ -6,8 +6,7 @@ describe &quot;On the project wall&quot;, js: true do @@ -6,8 +6,7 @@ describe &quot;On the project wall&quot;, js: true do
6 6
7 before do 7 before do
8 login_as :user 8 login_as :user
9 - project.add_access(@user, :read, :write)  
10 - 9 + project.team << [@user, :master]
11 visit wall_project_path(project) 10 visit wall_project_path(project)
12 end 11 end
13 12