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
get :index, :q => "cook"
assert_response :success
assert_template 'index'
assert assigns(:results).include?(Project.find(1))
assert assigns(:results).map(&:first).include?(Project.find(1))
end
def test_search_on_archived_project_should_return_404
......
assert_response :success
assert_template 'index'
assert assigns(:results).include?(Issue.find(2))
assert assigns(:results).include?(Issue.find(5))
assert assigns(:results).include?(Changeset.find(101))
assert assigns(:results).map(&:first).include?(Issue.find(2))
assert assigns(:results).map(&:first).include?(Issue.find(5))
assert assigns(:results).map(&:first).include?(Changeset.find(101))
assert_select 'dt.issue a', :text => /Add ingredients categories/
assert_select 'dd', :text => /should be classified by categories/
......
assert_equal true, assigns(:all_words)
assert_equal false, assigns(:titles_only)
assert assigns(:results).include?(Issue.find(8))
assert assigns(:results).include?(Issue.find(5))
assert assigns(:results).map(&:first).include?(Issue.find(8))
assert assigns(:results).map(&:first).include?(Issue.find(5))
assert_select 'dt.issue.closed a', :text => /Closed/
end
......
get :index, :q => 'searchkeyword', :issues => 1
assert_response :success
assert_include Issue.find(2), assigns(:results)
assert_include Issue.find(2), assigns(:results).map(&:first)
end
def test_search_issues_with_multiple_matches_in_journals_should_return_issue_once
......
get :index, :q => 'searchkeyword', :issues => 1
assert_response :success
assert_include Issue.find(2), assigns(:results)
assert_include Issue.find(2), assigns(:results).map(&:first)
assert_equal 1, assigns(:results).size
end
......
Role.find(1).add_permission! :view_private_notes
get :index, :q => 'searchkeyword', :issues => 1
assert_response :success
assert_include Issue.find(2), assigns(:results)
assert_include Issue.find(2), assigns(:results).map(&:first)
Role.find(1).remove_permission! :view_private_notes
get :index, :q => 'searchkeyword', :issues => 1
assert_response :success
assert_not_include Issue.find(2), assigns(:results)
assert_not_include Issue.find(2), assigns(:results).map(&:first)
end
def test_search_all_projects_with_scope_param
......
get :index, :id => 1, :q => 'recipe subproject', :scope => 'my_projects', :all_words => ''
assert_response :success
assert_template 'index'
assert assigns(:results).include?(Issue.find(1))
assert !assigns(:results).include?(Issue.find(5))
assert assigns(:results).map(&:first).include?(Issue.find(1))
assert !assigns(:results).map(&:first).include?(Issue.find(5))
end
def test_search_my_projects_without_memberships
......
get :index, :id => 1, :q => 'recipe subproject', :scope => 'subprojects', :all_words => ''
assert_response :success
assert_template 'index'
assert assigns(:results).include?(Issue.find(1))
assert assigns(:results).include?(Issue.find(5))
assert assigns(:results).map(&:first).include?(Issue.find(1))
assert assigns(:results).map(&:first).include?(Issue.find(5))
end
def test_search_without_searchable_custom_fields
......
def test_search_with_searchable_custom_fields
get :index, :id => 1, :q => "stringforcustomfield"
assert_response :success
results = assigns(:results)
results = assigns(:results).map(&:first)
assert_not_nil results
assert_equal 1, results.size
assert results.include?(Issue.find(7))
......
attachment = Attachment.generate! :container => Issue.find(1), :filename => 'search_attachments.patch'
get :index, :id => 1, :q => 'search_attachments', :attachments => '0'
results = assigns(:results)
results = assigns(:results).map(&:first)
assert_equal 1, results.size
assert_equal issue, results.first
end
......
attachment = Attachment.generate! :container => Issue.find(1), :filename => 'search_attachments.patch'
get :index, :id => 1, :q => 'search_attachments', :attachments => 'only'
results = assigns(:results)
results = assigns(:results).map(&:first)
assert_equal 1, results.size
assert_equal attachment.container, results.first
end
......
Attachment.generate! :container => Issue.find(1), :filename => 'search_attachments.patch'
get :index, :id => 1, :q => 'search_attachments', :attachments => '1'
results = assigns(:results)
results = assigns(:results).map(&:first)
assert_equal 2, results.size
end
......
Issue.generate! :subject => 'search_open', :status_id => 5
get :index, :id => 1, :q => 'search_open', :open_issues => '1'
results = assigns(:results)
results = assigns(:results).map(&:first)
assert_equal 1, results.size
end
......
# 'all words' is on by default
get :index, :id => 1, :q => 'recipe updating saving', :all_words => '1'
assert_equal true, assigns(:all_words)
results = assigns(:results)
results = assigns(:results).map(&:first)
assert_not_nil results
assert_equal 1, results.size
assert results.include?(Issue.find(3))
......
def test_search_one_of_the_words
get :index, :id => 1, :q => 'recipe updating saving', :all_words => ''
assert_equal false, assigns(:all_words)
results = assigns(:results)
results = assigns(:results).map(&:first)
assert_not_nil results
assert_equal 3, results.size
assert results.include?(Issue.find(3))
......
def test_search_titles_only_without_result
get :index, :id => 1, :q => 'recipe updating saving', :titles_only => '1'
results = assigns(:results)
results = assigns(:results).map(&:first)
assert_not_nil results
assert_equal 0, results.size
end
......
def test_search_titles_only
get :index, :id => 1, :q => 'recipe', :titles_only => '1'
assert_equal true, assigns(:titles_only)
results = assigns(:results)
results = assigns(:results).map(&:first)
assert_not_nil results
assert_equal 2, results.size
end
......
Issue.where(:id => 1).update_all("description = 'This is a searchkeywordinthecontent'")
get :index, :id => 1, :q => 'searchkeywordinthecontent', :titles_only => ''
assert_equal false, assigns(:titles_only)
results = assigns(:results)
results = assigns(:results).map(&:first)
assert_not_nil results
assert_equal 1, results.size
end
......
get :index, :q => 'search_with_limited_results'
assert_response :success
assert_equal issue[0..9], assigns(:results)
assert_equal issue[0..9], assigns(:results).map(&:first)
get :index, :q => 'search_with_limited_results', :page => 2
assert_response :success
assert_equal issue[10..19], assigns(:results)
assert_equal issue[10..19], assigns(:results).map(&:first)
get :index, :q => 'search_with_limited_results', :page => 3
assert_response :success
assert_equal issue[20..24], assigns(:results)
assert_equal issue[20..24], assigns(:results).map(&:first)
get :index, :q => 'search_with_limited_results', :page => 4
assert_response :success
assert_equal [], assigns(:results)
assert_equal [], assigns(:results).map(&:first)
end
def test_search_with_invalid_project_id
test/integration/api_test/search_test.rb
assert_select 'result', :count => assigns(:results).count
assigns(:results).size.times.each do |i|
assert_select 'result' do
assert_select 'id', :text => assigns(:results)[i].id.to_s
assert_select 'title', :text => assigns(:results)[i].event_title
assert_select 'type', :text => assigns(:results)[i].event_type
assert_select 'url', :text => url_for(assigns(:results)[i].event_url(:only_path => false))
assert_select 'description', :text => assigns(:results)[i].event_description
assert_select 'id', :text => assigns(:results)[i].first.id.to_s
assert_select 'title', :text => assigns(:results)[i].first.event_title
assert_select 'type', :text => assigns(:results)[i].first.event_type
assert_select 'url', :text => url_for(assigns(:results)[i].first.event_url(:only_path => false))
assert_select 'description', :text => assigns(:results)[i].first.event_description
assert_select 'datetime'
end
end
(2-2/2)