Project

General

Profile

Feature #25198 » fix-test.diff

fix test for above patch - okkez _, 2017-02-26 10:13

View differences:

test/functional/search_controller_test.rb
38 38
    get :index, :q => "cook"
39 39
    assert_response :success
40 40
    assert_template 'index'
41
    assert assigns(:results).include?(Project.find(1))
41
    assert assigns(:results).map(&:first).include?(Project.find(1))
42 42
  end
43 43

  
44 44
  def test_search_on_archived_project_should_return_404
......
71 71
    assert_response :success
72 72
    assert_template 'index'
73 73

  
74
    assert assigns(:results).include?(Issue.find(2))
75
    assert assigns(:results).include?(Issue.find(5))
76
    assert assigns(:results).include?(Changeset.find(101))
74
    assert assigns(:results).map(&:first).include?(Issue.find(2))
75
    assert assigns(:results).map(&:first).include?(Issue.find(5))
76
    assert assigns(:results).map(&:first).include?(Changeset.find(101))
77 77
    assert_select 'dt.issue a', :text => /Add ingredients categories/
78 78
    assert_select 'dd', :text => /should be classified by categories/
79 79

  
......
89 89

  
90 90
    assert_equal true, assigns(:all_words)
91 91
    assert_equal false, assigns(:titles_only)
92
    assert assigns(:results).include?(Issue.find(8))
93
    assert assigns(:results).include?(Issue.find(5))
92
    assert assigns(:results).map(&:first).include?(Issue.find(8))
93
    assert assigns(:results).map(&:first).include?(Issue.find(5))
94 94
    assert_select 'dt.issue.closed a',  :text => /Closed/
95 95
  end
96 96

  
......
99 99

  
100 100
    get :index, :q => 'searchkeyword', :issues => 1
101 101
    assert_response :success
102
    assert_include Issue.find(2), assigns(:results)
102
    assert_include Issue.find(2), assigns(:results).map(&:first)
103 103
  end
104 104

  
105 105
  def test_search_issues_with_multiple_matches_in_journals_should_return_issue_once
......
108 108

  
109 109
    get :index, :q => 'searchkeyword', :issues => 1
110 110
    assert_response :success
111
    assert_include Issue.find(2), assigns(:results)
111
    assert_include Issue.find(2), assigns(:results).map(&:first)
112 112
    assert_equal 1, assigns(:results).size
113 113
  end
114 114

  
......
119 119
    Role.find(1).add_permission! :view_private_notes
120 120
    get :index, :q => 'searchkeyword', :issues => 1
121 121
    assert_response :success
122
    assert_include Issue.find(2), assigns(:results)
122
    assert_include Issue.find(2), assigns(:results).map(&:first)
123 123

  
124 124
    Role.find(1).remove_permission! :view_private_notes
125 125
    get :index, :q => 'searchkeyword', :issues => 1
126 126
    assert_response :success
127
    assert_not_include Issue.find(2), assigns(:results)
127
    assert_not_include Issue.find(2), assigns(:results).map(&:first)
128 128
  end
129 129

  
130 130
  def test_search_all_projects_with_scope_param
......
139 139
    get :index, :id => 1, :q => 'recipe subproject', :scope => 'my_projects', :all_words => ''
140 140
    assert_response :success
141 141
    assert_template 'index'
142
    assert assigns(:results).include?(Issue.find(1))
143
    assert !assigns(:results).include?(Issue.find(5))
142
    assert assigns(:results).map(&:first).include?(Issue.find(1))
143
    assert !assigns(:results).map(&:first).include?(Issue.find(5))
144 144
  end
145 145

  
146 146
  def test_search_my_projects_without_memberships
......
155 155
    get :index, :id => 1, :q => 'recipe subproject', :scope => 'subprojects', :all_words => ''
156 156
    assert_response :success
157 157
    assert_template 'index'
158
    assert assigns(:results).include?(Issue.find(1))
159
    assert assigns(:results).include?(Issue.find(5))
158
    assert assigns(:results).map(&:first).include?(Issue.find(1))
159
    assert assigns(:results).map(&:first).include?(Issue.find(5))
160 160
  end
161 161

  
162 162
  def test_search_without_searchable_custom_fields
......
175 175
  def test_search_with_searchable_custom_fields
176 176
    get :index, :id => 1, :q => "stringforcustomfield"
177 177
    assert_response :success
178
    results = assigns(:results)
178
    results = assigns(:results).map(&:first)
179 179
    assert_not_nil results
180 180
    assert_equal 1, results.size
181 181
    assert results.include?(Issue.find(7))
......
186 186
    attachment = Attachment.generate! :container => Issue.find(1), :filename => 'search_attachments.patch'
187 187

  
188 188
    get :index, :id => 1, :q => 'search_attachments', :attachments => '0'
189
    results = assigns(:results)
189
    results = assigns(:results).map(&:first)
190 190
    assert_equal 1, results.size
191 191
    assert_equal issue, results.first
192 192
  end
......
196 196
    attachment = Attachment.generate! :container => Issue.find(1), :filename => 'search_attachments.patch'
197 197

  
198 198
    get :index, :id => 1, :q => 'search_attachments', :attachments => 'only'
199
    results = assigns(:results)
199
    results = assigns(:results).map(&:first)
200 200
    assert_equal 1, results.size
201 201
    assert_equal attachment.container, results.first
202 202
  end
......
206 206
    Attachment.generate! :container => Issue.find(1), :filename => 'search_attachments.patch'
207 207

  
208 208
    get :index, :id => 1, :q => 'search_attachments', :attachments => '1'
209
    results = assigns(:results)
209
    results = assigns(:results).map(&:first)
210 210
    assert_equal 2, results.size
211 211
  end
212 212

  
......
215 215
    Issue.generate! :subject => 'search_open', :status_id => 5
216 216

  
217 217
    get :index, :id => 1, :q => 'search_open', :open_issues => '1'
218
    results = assigns(:results)
218
    results = assigns(:results).map(&:first)
219 219
    assert_equal 1, results.size
220 220
  end
221 221

  
......
223 223
    # 'all words' is on by default
224 224
    get :index, :id => 1, :q => 'recipe updating saving', :all_words => '1'
225 225
    assert_equal true, assigns(:all_words)
226
    results = assigns(:results)
226
    results = assigns(:results).map(&:first)
227 227
    assert_not_nil results
228 228
    assert_equal 1, results.size
229 229
    assert results.include?(Issue.find(3))
......
232 232
  def test_search_one_of_the_words
233 233
    get :index, :id => 1, :q => 'recipe updating saving', :all_words => ''
234 234
    assert_equal false, assigns(:all_words)
235
    results = assigns(:results)
235
    results = assigns(:results).map(&:first)
236 236
    assert_not_nil results
237 237
    assert_equal 3, results.size
238 238
    assert results.include?(Issue.find(3))
......
240 240

  
241 241
  def test_search_titles_only_without_result
242 242
    get :index, :id => 1, :q => 'recipe updating saving', :titles_only => '1'
243
    results = assigns(:results)
243
    results = assigns(:results).map(&:first)
244 244
    assert_not_nil results
245 245
    assert_equal 0, results.size
246 246
  end
......
248 248
  def test_search_titles_only
249 249
    get :index, :id => 1, :q => 'recipe', :titles_only => '1'
250 250
    assert_equal true, assigns(:titles_only)
251
    results = assigns(:results)
251
    results = assigns(:results).map(&:first)
252 252
    assert_not_nil results
253 253
    assert_equal 2, results.size
254 254
  end
......
257 257
    Issue.where(:id => 1).update_all("description = 'This is a searchkeywordinthecontent'")
258 258
    get :index, :id => 1, :q => 'searchkeywordinthecontent', :titles_only => ''
259 259
    assert_equal false, assigns(:titles_only)
260
    results = assigns(:results)
260
    results = assigns(:results).map(&:first)
261 261
    assert_not_nil results
262 262
    assert_equal 1, results.size
263 263
  end
......
267 267

  
268 268
    get :index, :q => 'search_with_limited_results'
269 269
    assert_response :success
270
    assert_equal issue[0..9], assigns(:results)
270
    assert_equal issue[0..9], assigns(:results).map(&:first)
271 271

  
272 272
    get :index, :q => 'search_with_limited_results', :page => 2
273 273
    assert_response :success
274
    assert_equal issue[10..19], assigns(:results)
274
    assert_equal issue[10..19], assigns(:results).map(&:first)
275 275

  
276 276
    get :index, :q => 'search_with_limited_results', :page => 3
277 277
    assert_response :success
278
    assert_equal issue[20..24], assigns(:results)
278
    assert_equal issue[20..24], assigns(:results).map(&:first)
279 279

  
280 280
    get :index, :q => 'search_with_limited_results', :page => 4
281 281
    assert_response :success
282
    assert_equal [], assigns(:results)
282
    assert_equal [], assigns(:results).map(&:first)
283 283
  end
284 284

  
285 285
  def test_search_with_invalid_project_id
test/integration/api_test/search_test.rb
61 61
      assert_select 'result', :count => assigns(:results).count
62 62
      assigns(:results).size.times.each do |i|
63 63
        assert_select 'result' do
64
          assert_select 'id',          :text => assigns(:results)[i].id.to_s
65
          assert_select 'title',       :text => assigns(:results)[i].event_title
66
          assert_select 'type',        :text => assigns(:results)[i].event_type
67
          assert_select 'url',         :text => url_for(assigns(:results)[i].event_url(:only_path => false))
68
          assert_select 'description', :text => assigns(:results)[i].event_description
64
          assert_select 'id',          :text => assigns(:results)[i].first.id.to_s
65
          assert_select 'title',       :text => assigns(:results)[i].first.event_title
66
          assert_select 'type',        :text => assigns(:results)[i].first.event_type
67
          assert_select 'url',         :text => url_for(assigns(:results)[i].first.event_url(:only_path => false))
68
          assert_select 'description', :text => assigns(:results)[i].first.event_description
69 69
          assert_select 'datetime'
70 70
        end
71 71
      end
(2-2/2)