0001-Project-search-should-select-subprojects-scope-when-.patch

Marius BALTEANU, 2019-03-24 09:54

Download (7.02 KB)

View differences:

app/views/layouts/base.html.erb
78 78
        <%= hidden_field_tag 'scope', default_search_project_scope, :id => nil %>
79 79
        <%= hidden_field_tag(controller.default_search_scope, 1, :id => nil) if controller.default_search_scope %>
80 80
        <label for='q'>
81
          <%= link_to l(:label_search), {:controller => 'search', :action => 'index', :id => @project}, :accesskey => accesskey(:search) %>:
81
          <%= link_to l(:label_search), {:controller => 'search', :action => 'index', :id => @project, :scope => default_search_project_scope}, :accesskey => accesskey(:search) %>:
82 82
        </label>
83 83
        <%= text_field_tag 'q', @question, :size => 20, :class => 'small', :accesskey => accesskey(:quick_search) %>
84 84
        <% end %>
test/functional/projects_controller_test.rb
173 173
          :identifier => "blog",
174 174
          :is_public => 1,
175 175
          :custom_field_values => {
176
            '3' => 'Beta' 
177
          },    
176
            '3' => 'Beta'
177
          },
178 178
          :tracker_ids => ['1', '3'],
179 179
          # an issue custom field that is not for all project
180 180
          :issue_custom_field_ids => ['9'],
......
207 207
            :identifier => "blog",
208 208
            :is_public => 1,
209 209
            :custom_field_values => {
210
              '3' => 'Beta' 
211
            },    
210
              '3' => 'Beta'
211
            },
212 212
            :parent_id => 1
213
            
213

  
214 214
          }
215 215
        }
216 216
      assert_redirected_to '/projects/blog/settings'
......
229 229
          :project => {
230 230
            :name => "blog",
231 231
            :identifier => "blog"
232
          },  
232
          },
233 233
          :continue => 'Create and continue'
234 234
        }
235 235
    end
......
247 247
          :identifier => "blog",
248 248
          :is_public => 1,
249 249
          :custom_field_values => {
250
            '3' => 'Beta' 
251
          },    
250
            '3' => 'Beta'
251
          },
252 252
          :tracker_ids => ['1', '3'],
253 253
          :enabled_module_names => ['issue_tracking', 'news', 'repository']
254
          
254

  
255 255
        }
256 256
      }
257 257

  
......
282 282
            :identifier => "blog",
283 283
            :is_public => 1,
284 284
            :custom_field_values => {
285
              '3' => 'Beta' 
286
            },    
285
              '3' => 'Beta'
286
            },
287 287
            :parent_id => 1
288
            
288

  
289 289
          }
290 290
        }
291 291
    end
......
305 305
          :identifier => "blog",
306 306
          :is_public => 1,
307 307
          :custom_field_values => {
308
            '3' => 'Beta' 
309
          },    
308
            '3' => 'Beta'
309
          },
310 310
          :parent_id => 1
311
          
311

  
312 312
        }
313 313
      }
314 314
    assert_redirected_to '/projects/blog/settings'
......
329 329
            :identifier => "blog",
330 330
            :is_public => 1,
331 331
            :custom_field_values => {
332
              '3' => 'Beta' 
333
            }    
334
            
332
              '3' => 'Beta'
333
            }
334

  
335 335
          }
336 336
        }
337 337
    end
......
353 353
            :identifier => "blog",
354 354
            :is_public => 1,
355 355
            :custom_field_values => {
356
              '3' => 'Beta' 
357
            },    
356
              '3' => 'Beta'
357
            },
358 358
            :parent_id => 6
359
            
359

  
360 360
          }
361 361
        }
362 362
    end
......
377 377
              :name => "blog1",
378 378
              :identifier => "blog1",
379 379
              :enabled_module_names => ["issue_tracking", "repository"]
380
              
380

  
381 381
            }
382 382
          }
383 383
      end
......
390 390
              :name => "blog2",
391 391
              :identifier => "blog2",
392 392
              :enabled_module_names => ["issue_tracking", "repository"]
393
              
393

  
394 394
            }
395 395
          }
396 396
      end
......
410 410
            :identifier => 'inherited',
411 411
            :parent_id => parent.id,
412 412
            :inherit_members => '1'
413
            
413

  
414 414
          }
415 415
        }
416 416
      assert_response 302
......
432 432
              :name => "blog",
433 433
              :identifier => "",
434 434
              :enabled_module_names => %w(issue_tracking news)
435
              
435

  
436 436
            }
437 437
          }
438 438
      end
......
542 542
    @request.session[:user_id] = 1
543 543
    project = Project.find_by_identifier('ecookbook')
544 544
    project.archive
545
  
545

  
546 546
    get :show, :params => {
547 547
        :id => 'ecookbook'
548 548
      }
......
960 960
            :identifier => 'unique-copy',
961 961
            :tracker_ids => ['1', '2', '3', ''],
962 962
            :enabled_module_names => %w(issue_tracking time_tracking)
963
            
964
          },  
963

  
964
          },
965 965
          :only => %w(issues versions)
966 966
        }
967 967
    end
......
1044 1044
      }
1045 1045
    assert_select 'body.project-ecookbook'
1046 1046
  end
1047

  
1048
  def test_default_search_scope_in_global_page
1049
    get :index
1050

  
1051
    assert_select 'div#quick-search form' do
1052
      assert_select 'input[name=scope][type=hidden]'
1053
      assert_select 'a[href=?]', '/search'
1054
    end
1055
  end
1056

  
1057
  def test_default_search_scope_for_project_without_subprojects
1058
    get :show, :params => {
1059
      :id => 4,
1060
    }
1061

  
1062
    assert_select 'div#quick-search form' do
1063
      assert_select 'input[name=scope][type=hidden]'
1064
      assert_select 'a[href=?]', '/projects/subproject2/search'
1065
    end
1066
  end
1067

  
1068
  def test_default_search_scope_for_project_with_subprojects
1069
    get :show, :params => {
1070
      :id => 1,
1071
    }
1072

  
1073
    assert_select 'div#quick-search form' do
1074
      assert_select 'input[name=scope][type=hidden][value=subprojects]'
1075
      assert_select 'a[href=?]', '/projects/ecookbook/search?scope=subprojects'
1076
    end
1077
  end
1047 1078
end
1048
-