Commit d621aa45 authored by jplang's avatar jplang

Replaced some #assert_tag with #assert_select.

git-svn-id: https://svn.redmine.org/redmine/trunk@13620 e93f8b46-1217-0410-a6f0-8f06a7374b81
parent d735481e
......@@ -40,12 +40,8 @@ class AttachmentsControllerTest < ActionController::TestCase
assert_response :success
assert_template 'diff'
assert_equal 'text/html', @response.content_type
assert_tag 'th',
:attributes => {:class => /filename/},
:content => /issues_controller.rb\t\(révision 1484\)/
assert_tag 'td',
:attributes => {:class => /line-code/},
:content => /Demande créée avec succès/
assert_select 'th.filename', :text => /issues_controller.rb\t\(révision 1484\)/
assert_select 'td.line-code', :text => /Demande créée avec succès/
end
set_tmp_attachments_directory
end
......@@ -58,12 +54,8 @@ class AttachmentsControllerTest < ActionController::TestCase
assert_response :success
assert_template 'diff'
assert_equal 'text/html', @response.content_type
assert_tag 'th',
:attributes => {:class => "filename"},
:content => /issues_controller.rb\t\(r\?vision 1484\)/
assert_tag 'td',
:attributes => {:class => /line-code/},
:content => /Demande cr\?\?e avec succ\?s/
assert_select 'th.filename', :text => /issues_controller.rb\t\(r\?vision 1484\)/
assert_select 'td.line-code', :text => /Demande cr\?\?e avec succ\?s/
end
end
set_tmp_attachments_directory
......@@ -77,12 +69,8 @@ class AttachmentsControllerTest < ActionController::TestCase
assert_response :success
assert_template 'diff'
assert_equal 'text/html', @response.content_type
assert_tag 'th',
:attributes => {:class => "filename"},
:content => /issues_controller.rb\t\(révision 1484\)/
assert_tag 'td',
:attributes => {:class => /line-code/},
:content => /Demande créée avec succès/
assert_select 'th.filename', :text => /issues_controller.rb\t\(révision 1484\)/
assert_select 'td.line-code', :text => /Demande créée avec succès/
end
end
set_tmp_attachments_directory
......@@ -145,10 +133,10 @@ class AttachmentsControllerTest < ActionController::TestCase
assert_response :success
assert_template 'file'
assert_equal 'text/html', @response.content_type
assert_tag :tag => 'th',
:content => '1',
:attributes => { :class => 'line-num' },
:sibling => { :tag => 'td', :content => /#{str_japanese}/ }
assert_select 'tr#L1' do
assert_select 'th.line-num', :text => '1'
assert_select 'td', :text => /#{str_japanese}/
end
end
def test_show_text_file_replace_cannot_convert_content
......@@ -164,10 +152,10 @@ class AttachmentsControllerTest < ActionController::TestCase
assert_response :success
assert_template 'file'
assert_equal 'text/html', @response.content_type
assert_tag :tag => 'th',
:content => '7',
:attributes => { :class => 'line-num' },
:sibling => { :tag => 'td', :content => /Demande cr\?\?e avec succ\?s/ }
assert_select 'tr#L7' do
assert_select 'th.line-num', :text => '7'
assert_select 'td', :text => /Demande cr\?\?e avec succ\?s/
end
end
end
......@@ -184,11 +172,11 @@ class AttachmentsControllerTest < ActionController::TestCase
assert_response :success
assert_template 'file'
assert_equal 'text/html', @response.content_type
assert_tag :tag => 'th',
:content => '7',
:attributes => { :class => 'line-num' },
:sibling => { :tag => 'td', :content => /Demande créée avec succès/ }
assert_select 'tr#L7' do
assert_select 'th.line-num', :text => '7'
assert_select 'td', :text => /Demande créée avec succès/
end
end
end
def test_show_text_file_should_send_if_too_big
......@@ -218,7 +206,7 @@ class AttachmentsControllerTest < ActionController::TestCase
@request.session[:user_id] = 2
get :show, :id => 15
assert_response :success
assert_tag 'h2', :content => /private.diff/
assert_select 'h2', :text => /private.diff/
set_tmp_attachments_directory
end
......
......@@ -60,9 +60,7 @@ class ContextMenusControllerTest < ActionController::TestCase
get :issues, :ids => [1]
assert_response :success
assert_template 'context_menus/issues'
assert_tag :tag => 'a', :content => 'Delete',
:attributes => { :href => '#',
:class => 'icon-del disabled' }
assert_select 'a.icon-del.disabled[href="#"]', :text => 'Delete'
end
end
......
......@@ -192,7 +192,7 @@ class CustomFieldsControllerTest < ActionController::TestCase
get :edit, :id => 1
assert_response :success
assert_template 'edit'
assert_tag 'input', :attributes => {:name => 'custom_field[name]', :value => 'Database'}
assert_select 'input[name=?][value=?]', 'custom_field[name]', 'Database'
end
def test_edit_invalid_custom_field_should_render_404
......
......@@ -37,31 +37,30 @@ class DocumentsControllerTest < ActionController::TestCase
assert_not_nil assigns(:grouped)
# Default category selected in the new document form
assert_tag :select, :attributes => {:name => 'document[category_id]'},
:child => {:tag => 'option', :attributes => {:selected => 'selected'},
:content => 'Technical documentation'}
assert_select 'select[name=?]', 'document[category_id]' do
assert_select 'option[selected=selected]', :text => 'Technical documentation'
assert ! DocumentCategory.find(16).active?
assert_no_tag :option, :attributes => {:value => '16'},
:parent => {:tag => 'select', :attributes => {:id => 'document_category_id'} }
assert ! DocumentCategory.find(16).active?
assert_select 'option[value="16"]', 0
end
end
def test_index_grouped_by_date
get :index, :project_id => 'ecookbook', :sort_by => 'date'
assert_response :success
assert_tag 'h3', :content => '2007-02-12'
assert_select 'h3', :text => '2007-02-12'
end
def test_index_grouped_by_title
get :index, :project_id => 'ecookbook', :sort_by => 'title'
assert_response :success
assert_tag 'h3', :content => 'T'
assert_select 'h3', :text => 'T'
end
def test_index_grouped_by_author
get :index, :project_id => 'ecookbook', :sort_by => 'author'
assert_response :success
assert_tag 'h3', :content => 'John Smith'
assert_select 'h3', :text => 'John Smith'
end
def test_index_with_long_description
......
......@@ -41,8 +41,8 @@ class EnumerationsControllerTest < ActionController::TestCase
assert_response :success
assert_template 'new'
assert_kind_of IssuePriority, assigns(:enumeration)
assert_tag 'input', :attributes => {:name => 'enumeration[type]', :value => 'IssuePriority'}
assert_tag 'input', :attributes => {:name => 'enumeration[name]'}
assert_select 'input[name=?][value=?]', 'enumeration[type]', 'IssuePriority'
assert_select 'input[name=?]', 'enumeration[name]'
end
def test_new_with_invalid_type_should_respond_with_404
......@@ -71,7 +71,7 @@ class EnumerationsControllerTest < ActionController::TestCase
get :edit, :id => 6
assert_response :success
assert_template 'edit'
assert_tag 'input', :attributes => {:name => 'enumeration[name]', :value => 'High'}
assert_select 'input[name=?][value=?]', 'enumeration[name]', 'High'
end
def test_edit_invalid_should_respond_with_404
......
......@@ -41,12 +41,10 @@ class FilesControllerTest < ActionController::TestCase
assert_not_nil assigns(:containers)
# file attached to the project
assert_tag :a, :content => 'project_file.zip',
:attributes => { :href => '/attachments/download/8/project_file.zip' }
assert_select 'a[href=?]', '/attachments/download/8/project_file.zip', :text => 'project_file.zip'
# file attached to a project's version
assert_tag :a, :content => 'version_file.zip',
:attributes => { :href => '/attachments/download/9/version_file.zip' }
assert_select 'a[href=?]', '/attachments/download/9/version_file.zip', :text => 'version_file.zip'
end
def test_new
......@@ -55,7 +53,7 @@ class FilesControllerTest < ActionController::TestCase
assert_response :success
assert_template 'new'
assert_tag 'select', :attributes => {:name => 'version_id'}
assert_select 'select[name=?]', 'version_id'
end
def test_new_without_versions
......@@ -65,7 +63,7 @@ class FilesControllerTest < ActionController::TestCase
assert_response :success
assert_template 'new'
assert_no_tag 'select', :attributes => {:name => 'version_id'}
assert_select 'select[name=?]', 'version_id', 0
end
def test_create_file
......
......@@ -73,11 +73,11 @@ class GanttsControllerTest < ActionController::TestCase
get :show
assert_response :success
assert_template 'gantts/show'
assert_tag 'a', :content => /eCookbook/
assert_select 'a', :text => /eCookbook/
# Root private project
assert_no_tag 'a', {:content => /OnlineStore/}
assert_select 'a', :text => /OnlineStore/, :count => 0
# Private children of a public project
assert_no_tag 'a', :content => /Private child of eCookbook/
assert_select 'a', :text => /Private child of eCookbook/, :count => 0
end
def test_gantt_should_display_relations
......
......@@ -51,12 +51,8 @@ class JournalsControllerTest < ActionController::TestCase
assert_response :success
assert_template 'diff'
assert_tag 'span',
:attributes => {:class => 'diff_out'},
:content => /removed/
assert_tag 'span',
:attributes => {:class => 'diff_in'},
:content => /added/
assert_select 'span.diff_out', :text => /removed/
assert_select 'span.diff_in', :text => /added/
end
def test_reply_to_issue
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment