post :login, :username => 'jsmith', :password => 'jsmith'
assert_response 500
- assert_error_tag :content => /Something wrong/
+ assert_select_error /Something wrong/
end
def test_login_should_reset_session
assert_response :success
assert_template 'new'
end
- assert_error_tag :content => /host #{ESCAPED_CANT} be blank/i
+ assert_select_error /host #{ESCAPED_CANT} be blank/i
end
def test_edit
:port => '389', :attr_login => 'uid'}
assert_response :success
assert_template 'edit'
- assert_error_tag :content => /host #{ESCAPED_CANT} be blank/i
+ assert_select_error /host #{ESCAPED_CANT} be blank/i
end
def test_destroy
post :create, :issue_status => {:name => ''}
assert_response :success
assert_template 'new'
- assert_error_tag :content => /name #{ESCAPED_CANT} be blank/i
+ assert_select_error /name #{ESCAPED_CANT} be blank/i
end
def test_edit
put :update, :id => '3', :issue_status => {:name => ''}
assert_response :success
assert_template 'edit'
- assert_error_tag :content => /name #{ESCAPED_CANT} be blank/i
+ assert_select_error /name #{ESCAPED_CANT} be blank/i
end
def test_destroy
get :new, :project_id => 1
assert_response 500
- assert_error_tag :content => /No default issue/
+ assert_select_error /No default issue/
end
def test_get_new_with_no_tracker_should_display_an_error
get :new, :project_id => 1
assert_response 500
- assert_error_tag :content => /No tracker/
+ assert_select_error /No tracker/
end
def test_update_form_for_new_issue
assert_template 'new'
issue = assigns(:issue)
assert_not_nil issue
- assert_error_tag :content => /Database #{ESCAPED_CANT} be blank/
+ assert_select_error /Database #{ESCAPED_CANT} be blank/
end
def test_create_should_validate_required_fields
assert_template 'new'
end
- assert_error_tag :content => /Due date #{ESCAPED_CANT} be blank/i
- assert_error_tag :content => /Bar #{ESCAPED_CANT} be blank/i
+ assert_select_error /Due date #{ESCAPED_CANT} be blank/i
+ assert_select_error /Bar #{ESCAPED_CANT} be blank/i
end
def test_create_should_ignore_readonly_fields
assert_response :success
assert_select 'input[name=?][value=?]', 'issue[parent_issue_id]', '4'
- assert_error_tag :content => /Parent task is invalid/i
+ assert_select_error /Parent task is invalid/i
end
end
assert_response :success
assert_select 'input[name=?][value=?]', 'issue[parent_issue_id]', '01ABC'
- assert_error_tag :content => /Parent task is invalid/i
+ assert_select_error /Parent task is invalid/i
end
end
assert_response :success
assert_template 'edit'
- assert_error_tag :descendant => {:content => /Activity #{ESCAPED_CANT} be blank/}
+ assert_select_error /Activity #{ESCAPED_CANT} be blank/
assert_select 'textarea[name=?]', 'issue[notes]', :text => notes
assert_select 'input[name=?][value=?]', 'time_entry[hours]', '2z'
end
assert_response :success
assert_template 'edit'
- assert_error_tag :descendant => {:content => /Activity #{ESCAPED_CANT} be blank/}
- assert_error_tag :descendant => {:content => /Hours #{ESCAPED_CANT} be blank/}
+ assert_select_error /Activity #{ESCAPED_CANT} be blank/
+ assert_select_error /Hours #{ESCAPED_CANT} be blank/
assert_select 'textarea[name=?]', 'issue[notes]', :text => notes
assert_select 'input[name=?][value=?]', 'time_entry[comments]', 'this is my comment'
end
assert_response :success
assert_template 'edit'
attachment = Attachment.order('id DESC').first
- assert_tag 'input', :attributes => {:name => 'attachments[p0][token]', :value => attachment.token}
- assert_tag 'input', :attributes => {:name => 'attachments[p0][filename]', :value => 'testfile.txt'}
+ assert_select 'input[name=?][value=?]', 'attachments[p0][token]', attachment.token
+ assert_select 'input[name=?][value=?]', 'attachments[p0][filename]', 'testfile.txt'
end
def test_update_stale_issue_without_notes_should_not_show_add_notes_option
:lock_version => (issue.lock_version - 1)
}
- assert_tag 'div', :attributes => {:class => 'conflict'}
- assert_tag 'input', :attributes => {:name => 'conflict_resolution', :value => 'overwrite'}
- assert_no_tag 'input', :attributes => {:name => 'conflict_resolution', :value => 'add_notes'}
- assert_tag 'input', :attributes => {:name => 'conflict_resolution', :value => 'cancel'}
+ assert_select 'div.conflict'
+ assert_select 'input[name=conflict_resolution][value=overwrite]'
+ assert_select 'input[name=conflict_resolution][value=add_notes]', 0
+ assert_select 'input[name=conflict_resolution][value=cancel]'
end
def test_update_stale_issue_should_show_conflicting_journals
assert_not_nil assigns(:conflict_journals)
assert_equal 1, assigns(:conflict_journals).size
assert_equal 2, assigns(:conflict_journals).first.id
- assert_tag 'div', :attributes => {:class => 'conflict'},
- :descendant => {:content => /Some notes with Redmine links/}
+
+ assert_select 'div.conflict', :text => /Some notes with Redmine links/
end
def test_update_stale_issue_without_previous_journal_should_show_all_journals
assert_not_nil assigns(:conflict_journals)
assert_equal 2, assigns(:conflict_journals).size
- assert_tag 'div', :attributes => {:class => 'conflict'},
- :descendant => {:content => /Some notes with Redmine links/}
- assert_tag 'div', :attributes => {:class => 'conflict'},
- :descendant => {:content => /Journal notes/}
+ assert_select 'div.conflict', :text => /Some notes with Redmine links/
+ assert_select 'div.conflict', :text => /Journal notes/
end
def test_update_stale_issue_should_show_private_journals_with_permission_only
get :index
assert_response 500
- assert_tag 'p', :content => /An error occurred/
+ assert_select 'p', :text => /An error occurred/
assert_nil session[:query]
assert_nil session[:issues_index_sort]
end
assert_response :success
# tags required by MessagesController#quote
- assert_tag 'input', :attributes => {:id => 'message_subject'}
- assert_tag 'textarea', :attributes => {:id => 'message_content'}
- assert_tag 'div', :attributes => {:id => 'reply'}
+ assert_select 'input#message_subject'
+ assert_select 'textarea#message_content'
+ assert_select 'div#reply'
end
def test_show_with_pagination
get :show, :board_id => 1, :id => 1
assert_response :success
assert_template 'show'
- assert_tag :div, :attributes => { :id => 'reply' },
- :descendant => { :tag => 'textarea', :attributes => { :id => 'message_content' } }
+ assert_select 'div#reply textarea#message_content'
end
def test_show_message_not_found
assert_template 'account'
assert_equal User.find(2), assigns(:user)
- assert_tag :input, :attributes => { :name => 'user[custom_field_values][4]'}
+ assert_select 'input[name=?]', 'user[custom_field_values][4]'
end
def test_my_account_should_not_show_non_editable_custom_fields
assert_template 'account'
assert_equal User.find(2), assigns(:user)
- assert_no_tag :input, :attributes => { :name => 'user[custom_field_values][4]'}
+ assert_select 'input[name=?]', 'user[custom_field_values][4]', 0
end
def test_my_account_should_show_language_select
:new_password_confirmation => 'secret1234'
assert_response :success
assert_template 'password'
- assert_error_tag :content => /Password doesn.*t match confirmation/
+ assert_select_error /Password doesn.*t match confirmation/
# wrong password
post :password, :password => 'wrongpassword',
get :show, :id => 1
assert_response :success
assert_template 'show'
- assert_tag :tag => 'h2', :content => /eCookbook first release/
+ assert_select 'h2', :text => /eCookbook first release/
end
def test_show_should_show_attachments
get :show, :id => 1
assert_response :success
- assert_tag 'a', :content => attachment.filename
+ assert_select 'a', :text => attachment.filename
end
def test_show_with_comments_in_reverse_order
assert_template 'new'
assert_not_nil assigns(:news)
assert assigns(:news).new_record?
- assert_error_tag :content => /title #{ESCAPED_CANT} be blank/i
+ assert_select_error /title #{ESCAPED_CANT} be blank/i
end
def test_get_edit
put :update, :id => 1, :news => { :description => '' }
assert_response :success
assert_template 'edit'
- assert_error_tag :content => /description #{ESCAPED_CANT} be blank/i
+ assert_select_error /description #{ESCAPED_CANT} be blank/i
end
def test_destroy
assert_response :success
assert_template 'previews/issue'
assert_not_nil assigns(:notes)
- assert_tag :p, :content => 'Foo'
+ assert_select 'p', :text => 'Foo'
end
def test_preview_issue_notes_should_support_links_to_existing_attachments
:summary => ''}
assert_response :success
assert_template 'common/_preview'
- assert_tag :tag => 'fieldset', :attributes => { :class => 'preview' },
- :content => /News description/
+ assert_select 'fieldset.preview', :text => /News description/
end
def test_existing_new_news
assert_equal News.find(2), assigns(:previewed)
assert_not_nil assigns(:attachments)
- assert_tag :tag => 'fieldset', :attributes => { :class => 'preview' },
- :content => /News description/
+ assert_select 'fieldset.preview', :text => /News description/
end
end
post :update, :id => 1, :project => {:name => ''}
assert_response :success
assert_template 'settings'
- assert_error_tag :content => /name #{ESCAPED_CANT} be blank/i
+ assert_select_error /name #{ESCAPED_CANT} be blank/i
end
def test_update_should_be_denied_for_member_on_closed_project
assert_response :success
assert_template 'new'
assert_select 'input[name=?][value="0"][checked=checked]', 'query[visibility]'
- assert_tag :tag => 'input', :attributes => { :type => 'checkbox',
- :name => 'query_is_for_all',
- :checked => nil,
- :disabled => nil }
+ assert_select 'input[name=query_is_for_all][type=checkbox]:not([checked]):not([disabled])'
assert_select 'select[name=?]', 'c[]' do
assert_select 'option[value=tracker]'
assert_select 'option[value=subject]'
assert_response :success
assert_template 'new'
assert_select 'input[name=?]', 'query[visibility]', 0
- assert_tag :tag => 'input', :attributes => { :type => 'checkbox',
- :name => 'query_is_for_all',
- :checked => 'checked',
- :disabled => nil }
+ assert_select 'input[name=query_is_for_all][type=checkbox][checked]:not([disabled])'
end
def test_new_on_invalid_project
assert_response :success
assert_template 'edit'
assert_select 'input[name=?][value="2"][checked=checked]', 'query[visibility]'
- assert_tag :tag => 'input', :attributes => { :type => 'checkbox',
- :name => 'query_is_for_all',
- :checked => 'checked',
- :disabled => 'disabled' }
+ assert_select 'input[name=query_is_for_all][type=checkbox][checked=checked][disabled=disabled]'
end
def test_edit_global_private_query
assert_response :success
assert_template 'edit'
assert_select 'input[name=?]', 'query[visibility]', 0
- assert_tag :tag => 'input', :attributes => { :type => 'checkbox',
- :name => 'query_is_for_all',
- :checked => 'checked',
- :disabled => 'disabled' }
+ assert_select 'input[name=query_is_for_all][type=checkbox][checked=checked][disabled=disabled]'
end
def test_edit_project_private_query
assert_response :success
assert_template 'edit'
assert_select 'input[name=?]', 'query[visibility]', 0
- assert_tag :tag => 'input', :attributes => { :type => 'checkbox',
- :name => 'query_is_for_all',
- :checked => nil,
- :disabled => nil }
+ assert_select 'input[name=query_is_for_all][type=checkbox]:not([checked]):not([disabled])'
end
def test_edit_project_public_query
assert_response :success
assert_template 'edit'
assert_select 'input[name=?][value="2"][checked=checked]', 'query[visibility]'
- assert_tag :tag => 'input', :attributes => { :type => 'checkbox',
- :name => 'query_is_for_all',
- :checked => nil,
- :disabled => 'disabled' }
+ assert_select 'input[name=query_is_for_all][type=checkbox][disabled=disabled]:not([checked])'
end
def test_edit_sort_criteria
get :edit, :id => 5
assert_response :success
assert_template 'edit'
- assert_tag :tag => 'select', :attributes => { :name => 'query[sort_criteria][0][]' },
- :child => { :tag => 'option', :attributes => { :value => 'priority',
- :selected => 'selected' } }
- assert_tag :tag => 'select', :attributes => { :name => 'query[sort_criteria][0][]' },
- :child => { :tag => 'option', :attributes => { :value => 'desc',
- :selected => 'selected' } }
+ assert_select 'select[name=?]', 'query[sort_criteria][0][]' do
+ assert_select 'option[value=priority][selected=selected]'
+ assert_select 'option[value=desc][selected=selected]'
+ end
end
def test_edit_invalid_query
:path => repository_path_hash(['doc-mkdir.txt'])[:param]
assert_response :success
assert_template 'changes'
- assert_tag :tag => 'h2', :content => 'doc-mkdir.txt'
+ assert_select 'h2', :text => /doc-mkdir.txt/
end
def test_entry_show
assert_response :success
assert_template 'entry'
# Line 19
- assert_tag :tag => 'th',
- :content => /29/,
- :attributes => { :class => /line-num/ },
- :sibling => { :tag => 'td', :content => /Show help message/ }
+ assert_select 'tr#L29 td.line-code', :text => /Show help message/
end
def test_entry_download
assert_response :success
assert_template 'diff'
# Line 11 removed
- assert_tag :tag => 'th',
- :content => '11',
- :sibling => { :tag => 'td',
- :attributes => { :class => /diff_out/ },
- :content => /Display more information/ }
+ assert_select 'th.line-num:content(11) ~ td.diff_out', :text => /Display more information/
end
end
assert_template 'new'
assert_kind_of Repository::Subversion, assigns(:repository)
assert assigns(:repository).new_record?
- assert_tag 'input', :attributes => {:name => 'repository[url]', :disabled => nil}
+ assert_select 'input[name=?]:not([disabled])', 'repository[url]'
end
def test_new_should_propose_enabled_scm_only
assert_response :success
assert_template 'new'
assert_kind_of Repository::Mercurial, assigns(:repository)
- assert_tag 'select', :attributes => {:name => 'repository_scm'},
- :children => {:count => 3}
- assert_tag 'select', :attributes => {:name => 'repository_scm'},
- :child => {:tag => 'option', :attributes => {:value => 'Mercurial', :selected => 'selected'}}
- assert_tag 'select', :attributes => {:name => 'repository_scm'},
- :child => {:tag => 'option', :attributes => {:value => 'Git', :selected => nil}}
+
+ assert_select 'select[name=repository_scm]' do
+ assert_select 'option', 3
+ assert_select 'option[value=Mercurial][selected=selected]'
+ assert_select 'option[value=Git]:not([selected])'
+ end
end
def test_create
assert_response :success
assert_template 'edit'
assert_equal Repository.find(11), assigns(:repository)
- assert_tag 'input', :attributes => {:name => 'repository[url]', :value => 'svn://localhost/test', :disabled => 'disabled'}
+ assert_select 'input[name=?][value=?][disabled=disabled]', 'repository[url]', 'svn://localhost/test'
end
def test_update
get :revision, :id => 1, :rev => 1
assert_response :success
- assert_tag 'a', :attributes => {:href => '/projects/ecookbook/repository', :class => /repository/},
- :ancestor => {:attributes => {:id => 'main-menu'}}
+ assert_select '#main-menu a.repository[href=?]', '/projects/ecookbook/repository'
end
def test_revision_with_before_nil_and_afer_normal
get :revision, {:id => 1, :rev => 1}
assert_response :success
assert_template 'revision'
- assert_no_tag :tag => "div", :attributes => { :class => "contextual" },
- :child => { :tag => "a", :attributes => { :href => '/projects/ecookbook/repository/revisions/0'}
- }
- assert_tag :tag => "div", :attributes => { :class => "contextual" },
- :child => { :tag => "a", :attributes => { :href => '/projects/ecookbook/repository/revisions/2'}
- }
+
+ assert_select 'div.contextual' do
+ assert_select 'a[href=?]', '/projects/ecookbook/repository/revisions/0', 0
+ assert_select 'a[href=?]', '/projects/ecookbook/repository/revisions/2'
+ end
end
def test_add_related_issue
assert_response :success
assert_template 'committers'
- assert_tag :td, :content => 'dlopper',
- :sibling => { :tag => 'td',
- :child => { :tag => 'select', :attributes => { :name => %r{^committers\[\d+\]\[\]$} },
- :child => { :tag => 'option', :content => 'Dave Lopper',
- :attributes => { :value => '3', :selected => 'selected' }}}}
- assert_tag :td, :content => 'foo',
- :sibling => { :tag => 'td',
- :child => { :tag => 'select', :attributes => { :name => %r{^committers\[\d+\]\[\]$} }}}
- assert_no_tag :td, :content => 'foo',
- :sibling => { :tag => 'td',
- :descendant => { :tag => 'option', :attributes => { :selected => 'selected' }}}
+ assert_select 'td:content(dlopper) + td select' do
+ assert_select 'option[value="3"][selected=selected]', :text => 'Dave Lopper'
+ end
+
+ assert_select 'td:content(foo) + td select' do
+ assert_select 'option[value=""]'
+ assert_select 'option[selected=selected]', 0 # no option selected
+ end
end
def test_post_committers
:path => repository_path_hash(['sources', 'watchers_controller.rb'])[:param]
assert_response :success
assert_template 'entry'
- assert_no_tag :tag => 'td',
- :attributes => { :class => /line-code/},
- :content => /before_filter/
+ assert_select 'td.line-code', :text => /before_filter/, :count => 0
end
def test_entry_at_given_revision
assert_response :success
assert_template 'entry'
# this line was removed in r3
- assert_tag :tag => 'td',
- :attributes => { :class => /line-code/},
- :content => /before_filter/
+ assert_select 'td.line-code', :text => /before_filter/
end
def test_entry_not_found
assert_equal NUM_REV, @repository.changesets.count
get :entry, :id => PRJ_ID,
:path => repository_path_hash(['sources', 'zzz.c'])[:param]
- assert_tag :tag => 'p',
- :attributes => { :id => /errorExplanation/ },
- :content => /The entry or revision was not found in the repository/
+ assert_select 'p#errorExplanation', :text => /The entry or revision was not found in the repository/
end
def test_entry_download
get :diff, :id => PRJ_ID, :rev => 3, :type => dt
assert_response :success
assert_template 'diff'
- assert_tag :tag => 'td', :attributes => { :class => 'line-code diff_out' },
- :content => /before_filter :require_login/
- assert_tag :tag => 'td', :attributes => { :class => 'line-code diff_in' },
- :content => /with one change/
+ assert_select 'td.line-code.diff_out', :text => /before_filter :require_login/
+ assert_select 'td.line-code.diff_in', :text => /with one change/
end
end
get :diff, :id => PRJ_ID, :rev => 1, :type => dt
assert_response :success
assert_template 'diff'
- assert_tag :tag => 'td', :attributes => { :class => 'line-code diff_in' },
- :content => /watched.remove_watcher/
- assert_tag :tag => 'th', :attributes => { :class => 'filename' },
- :content => /test\/README/
- assert_tag :tag => 'th', :attributes => { :class => 'filename' },
- :content => /test\/images\/delete.png/
- assert_tag :tag => 'th', :attributes => { :class => 'filename' },
- :content => /test\/images\/edit.png/
- assert_tag :tag => 'th', :attributes => { :class => 'filename' },
- :content => /test\/sources\/watchers_controller.rb/
+ assert_select 'td.line-code.diff_in', :text => /watched.remove_watcher/
+ assert_select 'th.filename', :text => /test\/README/
+ assert_select 'th.filename', :text => /test\/images\/delete.png/
+ assert_select 'th.filename', :text => /test\/images\/edit.png/
+ assert_select 'th.filename', :text => /test\/sources\/watchers_controller.rb/
end
end
:path => repository_path_hash(['images', 'edit.png'])[:param]
assert_response :success
assert_template 'changes'
- assert_tag :tag => 'h2', :content => 'edit.png'
+ assert_select 'h2', :text => /edit.png/
end
def test_diff
assert_response :success
assert_template 'diff'
# Line 22 removed
- assert_tag :tag => 'th',
- :content => '22',
- :sibling => { :tag => 'td',
- :attributes => { :class => /diff_out/ },
- :content => /def remove/ }
+ assert_select 'th.line-num:content(22) ~ td.diff_out', :text => /def remove/
end
end
assert_not_nil assigns(:changesets)
assert assigns(:changesets).size == 0
- assert_no_tag 'input', :attributes => {:name => 'rev'}
- assert_no_tag 'a', :content => 'Statistics'
- assert_no_tag 'a', :content => 'Atom'
+ assert_select 'input[name=rev]', 0
+ assert_select 'a', :text => 'Statistics', :count => 0
+ assert_select 'a', :text => 'Atom', :count => 0
end
def test_show_no_extension
get :entry, :id => PRJ_ID, :path => repository_path_hash(['test'])[:param]
assert_response :success
assert_template 'entry'
- assert_tag :tag => 'th',
- :content => '1',
- :attributes => { :class => 'line-num' },
- :sibling => { :tag => 'td', :content => /TEST CAT/ }
+ assert_select 'tr#L1 td.line-code', :text => /TEST CAT/
end
def test_entry_download_no_extension
:path => repository_path_hash(['japanese', 'euc-jp.txt'])[:param]
assert_response :success
assert_template 'entry'
- assert_tag :tag => 'th',
- :content => '2',
- :attributes => { :class => 'line-num' },
- :sibling => { :tag => 'td', :content => /japanese/ }
+ assert_select 'tr#L2 td.line-code', :text => /japanese/
if @ruby19_non_utf8_pass
puts "TODO: show repository file contents test fails " +
"when Encoding.default_external is not UTF-8. " +
"Current value is '#{Encoding.default_external.to_s}'"
else
str_japanese = "\xe6\x97\xa5\xe6\x9c\xac\xe8\xaa\x9e".force_encoding('UTF-8')
- assert_tag :tag => 'th',
- :content => '3',
- :attributes => { :class => 'line-num' },
- :sibling => { :tag => 'td', :content => /#{str_japanese}/ }
+ assert_select 'tr#L3 td.line-code', :text => /#{str_japanese}/
end
end
end
get :entry, :id => PRJ_ID,
:path => repository_path_hash(['japanese', 'utf-16.txt'])[:param]
assert_response :success
- assert_tag :tag => 'th',
- :content => '2',
- :attributes => { :class => 'line-num' },
- :sibling => { :tag => 'td', :content => /japanese/ }
+ assert_select 'tr#L2 td.line-code', :text => /japanese/
end
end
:path => repository_path_hash(['images', 'edit.png'])[:param]
assert_response :success
assert_template 'changes'
- assert_tag :tag => 'h2', :content => 'edit.png'
+ assert_select 'h2', :text => /edit.png/
end
def test_entry_show
:path => repository_path_hash(['sources', 'watchers_controller.rb'])[:param]
assert_response :success
assert_template 'entry'
- # Line 19
- assert_tag :tag => 'th',
- :content => '11',
- :attributes => { :class => 'line-num' },
- :sibling => { :tag => 'td', :content => /WITHOUT ANY WARRANTY/ }
+ # Line 11
+ assert_select 'tr#L11 td.line-code', :text => /WITHOUT ANY WARRANTY/
end
def test_entry_show_latin_1
:rev => r1
assert_response :success
assert_template 'entry'
- assert_tag :tag => 'th',
- :content => '1',
- :attributes => { :class => 'line-num' },
- :sibling => { :tag => 'td',
- :content => /test-#{CHAR_1_HEX}.txt/ }
+ assert_select 'tr#L1 td.line-code', :text => /test-#{CHAR_1_HEX}.txt/
end
end
end
assert_response :success
assert_template 'diff'
# Line 22 removed
- assert_tag :tag => 'th',
- :content => /22/,
- :sibling => { :tag => 'td',
- :attributes => { :class => /diff_out/ },
- :content => /def remove/ }
- assert_tag :tag => 'h2', :content => /2f9c0091/
+ assert_select 'th.line-num:content(22) ~ td.diff_out', :text => /def remove/
+ assert_select 'h2', :text => /2f9c0091/
end
end
assert_response :success
assert_template 'diff'
# Line 22 removed
- assert_tag :tag => 'th',
- :content => '22',
- :sibling => { :tag => 'td',
- :attributes => { :class => /diff_out/ },
- :content => /def remove/ }
- assert_tag :tag => 'h2', :content => /2f9c0091/
+ assert_select 'th.line-num:content(22) ~ td.diff_out', :text => /def remove/
+ assert_select 'h2', :text => /2f9c0091/
end
end
end
assert_template 'diff'
diff = assigns(:diff)
assert_not_nil diff
- assert_tag :tag => 'h2', :content => /2f9c0091:61b685fb/
- assert_tag :tag => "form",
- :attributes => {
- :action => "/projects/subproject1/repository/revisions/" +
- "61b685fbe55ab05b5ac68402d5720c1a6ac973d1/diff"
- }
- assert_tag :tag => 'input',
- :attributes => {
- :id => "rev_to",
- :name => "rev_to",
- :type => "hidden",
- :value => '2f9c0091c754a91af7a9c478e36556b4bde8dcf7'
- }
+ assert_select 'h2', :text => /2f9c0091:61b685fb/
+ assert_select 'form[action=?]', '/projects/subproject1/repository/revisions/61b685fbe55ab05b5ac68402d5720c1a6ac973d1/diff'
+ assert_select 'input#rev_to[type=hidden][name=rev_to][value=?]', '2f9c0091c754a91af7a9c478e36556b4bde8dcf7'
end
end
assert_template 'diff'
diff = assigns(:diff)
assert_not_nil diff
- assert_tag :tag => "form",
- :attributes => {
- :action => "/projects/subproject1/repository/test-diff-path/" +
- "revisions/61b685fbe55ab05b/diff"
- }
- assert_tag :tag => 'input',
- :attributes => {
- :id => "rev_to",
- :name => "rev_to",
- :type => "hidden",
- :value => '2f9c0091c754a91a'
- }
+ assert_select 'form[action=?]', '/projects/subproject1/repository/test-diff-path/revisions/61b685fbe55ab05b/diff'
+ assert_select 'input#rev_to[type=hidden][name=rev_to][value=?]', '2f9c0091c754a91a'
end
def test_diff_latin_1
get :diff, :id => PRJ_ID, :rev => r1, :type => dt
assert_response :success
assert_template 'diff'
- assert_tag :tag => 'thead',
- :descendant => {
- :tag => 'th',
- :attributes => { :class => 'filename' } ,
- :content => /latin-1-dir\/test-#{CHAR_1_HEX}.txt/ ,
- },
- :sibling => {
- :tag => 'tbody',
- :descendant => {
- :tag => 'td',
- :attributes => { :class => /diff_in/ },
- :content => /test-#{CHAR_1_HEX}.txt/
- }
- }
+ assert_select 'table' do
+ assert_select 'thead th.filename', :text => /latin-1-dir\/test-#{CHAR_1_HEX}.txt/
+ assert_select 'tbody td.diff_in', :text => /test-#{CHAR_1_HEX}.txt/
+ end
end
end
end
:path => repository_path_hash(['sources', 'watchers_controller.rb'])[:param]
assert_response :success
assert_template 'annotate'
- assert_tag :tag => 'h2', :content => /@ deff712f/
+ assert_select 'h2', :text => /@ deff712f/
end
def test_annotate_binary_file
get :annotate, :id => PRJ_ID,
:path => repository_path_hash(['images', 'edit.png'])[:param]
assert_response 500
- assert_tag :tag => 'p', :attributes => { :id => /errorExplanation/ },
- :content => /cannot be annotated/
+ assert_select 'p#errorExplanation', :text => /cannot be annotated/
end
end
:path => repository_path_hash(['sources', 'watchers_controller.rb'])[:param],
:rev => 'deff712f'
assert_response 500
- assert_tag :tag => 'p', :attributes => { :id => /errorExplanation/ },
- :content => /exceeds the maximum text file size/
+ assert_select 'p#errorExplanation', :text => /exceeds the maximum text file size/
get :annotate, :id => PRJ_ID,
:path => repository_path_hash(['README'])[:param],
get :revisions, :id => PRJ_ID
assert_response :success
assert_template 'revisions'
- assert_tag :tag => 'form',
- :attributes => {
- :method => 'get',
- :action => '/projects/subproject1/repository/revision'
- }
+ assert_select 'form[method=get][action=?]', '/projects/subproject1/repository/revision'
end
def test_revision
['', ' ', nil].each do |r|
get :revision, :id => PRJ_ID, :rev => r
assert_response 404
- assert_error_tag :content => /was not found/
+ assert_select_error /was not found/
end
end
@repository.fetch_changesets
@project.reload
get :show, :id => PRJ_ID
- assert_tag 'form', :attributes => {:id => 'revision_selector', :action => '/projects/subproject1/repository/show'}
- assert_tag 'select', :attributes => {:name => 'branch'},
- :child => {:tag => 'option', :attributes => {:value => 'test-branch-01'}},
- :parent => {:tag => 'form', :attributes => {:id => 'revision_selector'}}
+ assert_select 'form#revision_selector[action=?]', '/projects/subproject1/repository/show' do
+ assert_select 'select[name=branch]' do
+ assert_select 'option[value=?]', 'test-branch-01'
+ end
+ end
end
def test_show_branch
:path => repository_path_hash(['images', 'edit.png'])[:param]
assert_response :success
assert_template 'changes'
- assert_tag :tag => 'h2', :content => 'edit.png'
+ assert_select 'h2', :text => /edit.png/
end
def test_entry_show
assert_response :success
assert_template 'entry'
# Line 10
- assert_tag :tag => 'th',
- :content => '10',
- :attributes => { :class => 'line-num' },
- :sibling => { :tag => 'td', :content => /WITHOUT ANY WARRANTY/ }
+ assert_select 'tr#L10 td.line-code', :text => /WITHOUT ANY WARRANTY/
end
def test_entry_show_latin_1_path
:rev => r1
assert_response :success
assert_template 'entry'
- assert_tag :tag => 'th',
- :content => '1',
- :attributes => { :class => 'line-num' },
- :sibling => { :tag => 'td',
- :content => /Mercurial is a distributed version control system/ }
+ assert_select 'tr#L1 td.line-code', :text => /Mercurial is a distributed version control system/
end
end
:rev => r1
assert_response :success
assert_template 'entry'
- assert_tag :tag => 'th',
- :content => '1',
- :attributes => { :class => 'line-num' },
- :sibling => { :tag => 'td',
- :content => /test-#{@char_1}.txt/ }
+ assert_select 'tr#L1 td.line-code', :text => /test-#{@char_1}.txt/
end
end
end
assert_template 'diff'
if @diff_c_support
# Line 22 removed
- assert_tag :tag => 'th',
- :content => '22',
- :sibling => { :tag => 'td',
- :attributes => { :class => /diff_out/ },
- :content => /def remove/ }
- assert_tag :tag => 'h2', :content => /4:def6d2f1254a/
+ assert_select 'th.line-num:content(22) ~ td.diff_out', :text => /def remove/
+ assert_select 'h2', :text => /4:def6d2f1254a/
end
end
end
assert_template 'diff'
diff = assigns(:diff)
assert_not_nil diff
- assert_tag :tag => 'h2',
- :content => /4:def6d2f1254a 2:400bb8672109/
+ assert_select 'h2', :text => /4:def6d2f1254a 2:400bb8672109/
end
end
end
get :diff, :id => PRJ_ID, :rev => r1, :type => dt
assert_response :success
assert_template 'diff'
- assert_tag :tag => 'thead',
- :descendant => {
- :tag => 'th',
- :attributes => { :class => 'filename' } ,
- :content => /latin-1-dir\/test-#{@char_1}-2.txt/ ,
- },
- :sibling => {
- :tag => 'tbody',
- :descendant => {
- :tag => 'td',
- :attributes => { :class => /diff_in/ },
- :content => /It is written in Python/
- }
- }
+ assert_select 'table' do
+ assert_select 'thead th.filename', :text => /latin-1-dir\/test-#{@char_1}-2.txt/
+ assert_select 'tbody td.diff_in', :text => /It is written in Python/
+ end
end
end
end
get :annotate, :id => PRJ_ID,
:path => repository_path_hash(['sources', 'welcome_controller.rb'])[:param]
assert_response 404
- assert_error_tag :content => /was not found/
+ assert_select_error /was not found/
end
def test_annotate_at_given_revision
:path => repository_path_hash(['sources', 'watchers_controller.rb'])[:param]
assert_response :success
assert_template 'annotate'
- assert_tag :tag => 'h2', :content => /@ 2:400bb8672109/
+ assert_select 'h2', :text => /@ 2:400bb8672109/
end
end
get :annotate, :id => PRJ_ID,
:path => repository_path_hash(['latin-1-dir', "test-#{@char_1}.txt"])[:param],
:rev => r1
- assert_tag :tag => 'th',
- :content => '1',
- :attributes => { :class => 'line-num' },
- :sibling => { :tag => 'td',
- :content => /test-#{@char_1}.txt/ }
+ assert_select 'tr#L1 td.line-code', :text => /test-#{@char_1}.txt/
end
end
end
['', ' ', nil].each do |r|
get :revision, :id => PRJ_ID, :rev => r
assert_response 404
- assert_error_tag :content => /was not found/
+ assert_select_error /was not found/
end
end
assert_equal 'dir', entry.kind
assert_select 'tr.dir a[href="/projects/subproject1/repository/show/subversion_test"]'
- assert_tag 'input', :attributes => {:name => 'rev'}
- assert_tag 'a', :content => 'Statistics'
- assert_tag 'a', :content => 'Atom'
- assert_tag :tag => 'a',
- :attributes => {:href => '/projects/subproject1/repository'},
- :content => 'root'
+ assert_select 'input[name=rev]'
+ assert_select 'a', :text => 'Statistics'
+ assert_select 'a', :text => 'Atom'
+ assert_select 'a[href=?]', '/projects/subproject1/repository', :text => 'root'
end
def test_show_non_default
entry = assigns(:entries).detect {|e| e.name == 'helloworld.c'}
assert_equal 'file', entry.kind
assert_equal 'subversion_test/helloworld.c', entry.path
- assert_tag :a, :content => 'helloworld.c', :attributes => { :class => /text\-x\-c/ }
+ assert_select 'a.text-x-c', :text => 'helloworld.c'
end
def test_browse_at_given_revision
if Redmine::Scm::Adapters::SubversionAdapter.client_version_above?([1, 5, 0])
assert_not_nil assigns(:properties)
assert_equal 'native', assigns(:properties)['svn:eol-style']
- assert_tag :ul,
- :child => { :tag => 'li',
- :child => { :tag => 'b', :content => 'svn:eol-style' },
- :child => { :tag => 'span', :content => 'native' } }
+ assert_select 'ul li' do
+ assert_select 'b', :text => 'svn:eol-style'
+ assert_select 'span', :text => 'native'
+ end
end
end
assert_response :success
assert_template 'entry'
# this line was removed in r3 and file was moved in r6
- assert_tag :tag => 'td', :attributes => { :class => /line-code/},
- :content => /Here's the code/
+ assert_select 'td.line-code', :text => /Here's the code/
end
def test_entry_not_found
assert_equal NUM_REV, @repository.changesets.count
get :entry, :id => PRJ_ID,
:path => repository_path_hash(['subversion_test', 'zzz.c'])[:param]
- assert_tag :tag => 'p', :attributes => { :id => /errorExplanation/ },
- :content => /The entry or revision was not found in the repository/
+ assert_select 'p#errorExplanation', :text => /The entry or revision was not found in the repository/
end
def test_entry_download
assert_equal NUM_REV, @repository.changesets.count
get :revision, :id => PRJ_ID, :rev => 'something_weird'
assert_response 404
- assert_error_tag :content => /was not found/
+ assert_select_error /was not found/
end
def test_invalid_revision_diff
get :diff, :id => PRJ_ID, :rev => '1', :rev_to => 'something_weird'
assert_response 404
- assert_error_tag :content => /was not found/
+ assert_select_error /was not found/
end
def test_empty_revision
['', ' ', nil].each do |r|
get :revision, :id => PRJ_ID, :rev => r
assert_response 404
- assert_error_tag :content => /was not found/
+ assert_select_error /was not found/
end
end
assert_not_nil diff
# 2 files modified
assert_equal 2, Redmine::UnifiedDiff.new(diff).size
- assert_tag :tag => 'h2', :content => /2:6/
+ assert_select 'h2', :text => /2:6/
end
end
:path => repository_path_hash(['subversion_test', 'helloworld.c'])[:param]
assert_response :success
assert_template 'annotate'
- assert_tag :tag => 'h2', :content => /@ 8/
+ assert_select 'h2', :text => /@ 8/
end
def test_destroy_valid_repository
assert_not_nil assigns(:roles)
assert_equal Role.order('builtin, position').to_a, assigns(:roles)
- assert_tag :tag => 'a', :attributes => { :href => '/roles/1/edit' },
- :content => 'Manager'
+ assert_select 'a[href="/roles/1/edit"]', :text => 'Manager'
end
def test_new
assert_response :success
assert_template 'new'
- assert_tag :tag => 'div', :attributes => { :id => 'errorExplanation' }
+ assert_select 'div#errorExplanation'
end
def test_create_without_workflow_copy
assert_not_nil assigns(:roles)
assert_equal Role.order('builtin, position').to_a, assigns(:roles)
- assert_tag :tag => 'input', :attributes => { :type => 'checkbox',
- :name => 'permissions[3][]',
- :value => 'add_issues',
- :checked => 'checked' }
-
- assert_tag :tag => 'input', :attributes => { :type => 'checkbox',
- :name => 'permissions[3][]',
- :value => 'delete_issues',
- :checked => nil }
+ assert_select 'input[name=?][type=checkbox][value=add_issues][checked=checked]', 'permissions[3][]'
+ assert_select 'input[name=?][type=checkbox][value=delete_issues]:not([checked])', 'permissions[3][]'
end
def test_post_permissions
assert assigns(:results).include?(Issue.find(2))
assert assigns(:results).include?(Issue.find(5))
assert assigns(:results).include?(Changeset.find(101))
- assert_tag :dt, :attributes => { :class => /issue/ },
- :child => { :tag => 'a', :content => /Add ingredients categories/ },
- :sibling => { :tag => 'dd', :content => /should be classified by categories/ }
+ assert_select 'dt.issue a', :text => /Add ingredients categories/
+ assert_select 'dd', :text => /should be classified by categories/
assert assigns(:results_by_type).is_a?(Hash)
assert_equal 5, assigns(:results_by_type)['changesets']
- assert_tag :a, :content => 'Changesets (5)'
+ assert_select 'a', :text => 'Changesets (5)'
end
def test_search_issues
assert_equal false, assigns(:titles_only)
assert assigns(:results).include?(Issue.find(8))
assert assigns(:results).include?(Issue.find(5))
- assert_tag :dt, :attributes => { :class => /issue closed/ },
- :child => { :tag => 'a', :content => /Closed/ }
+ assert_select 'dt.issue.closed a', :text => /Closed/
end
def test_search_issues_should_search_notes
assert_response :success
assert_template 'edit'
- assert_tag 'input', :attributes => {:name => 'settings[enabled_scm][]', :value => ''}
+ assert_select 'input[name=?][value=""]', 'settings[enabled_scm][]'
end
def test_get_edit_should_preselect_default_issue_list_columns
get :plugin, :id => 'foo'
assert_response :success
assert_template 'plugin'
- assert_tag 'form', :attributes => {:action => '/settings/plugin/foo'},
- :descendant => {:tag => 'input', :attributes => {:name => 'settings[sample_setting]', :value => 'Plugin setting value'}}
-
+ assert_select 'form[action="/settings/plugin/foo"]' do
+ assert_select 'input[name=?][value=?]', 'settings[sample_setting]', 'Plugin setting value'
+ end
ensure
Redmine::Plugin.unregister(:foo)
end
get :projects
assert_response :success
assert_equal 'application/xml', @response.content_type
- with_options :tag => 'projects' do |test|
- test.assert_tag :children => { :count => Project.active.has_module(:repository).count }
- test.assert_tag 'project', :child => {:tag => 'identifier', :sibling => {:tag => 'is-public'}}
+
+ assert_select 'projects' do
+ assert_select 'project', Project.active.has_module(:repository).count
+ assert_select 'project' do
+ assert_select 'identifier'
+ assert_select 'is-public'
+ end
end
- assert_no_tag 'extra-info'
- assert_no_tag 'extra_info'
+ assert_select 'extra-info', 0
+ assert_select 'extra_info', 0
end
def test_create_project_repository
assert r.is_a?(Repository::Subversion)
assert_equal 'file:///create/project/repository/subproject2', r.url
- assert_tag 'repository-subversion',
- :child => {
- :tag => 'id', :content => r.id.to_s,
- :sibling => {:tag => 'url', :content => r.url}
- }
- assert_no_tag 'extra-info'
- assert_no_tag 'extra_info'
+ assert_select 'repository-subversion' do
+ assert_select 'id', :text => r.id.to_s
+ assert_select 'url', :text => r.url
+ end
+ assert_select 'extra-info', 0
+ assert_select 'extra_info', 0
end
def test_create_already_existing
get :report, :project_id => 'ecookbook'
assert_response :success
assert_template 'report'
- assert_tag :form,
- :attributes => {:action => "/projects/ecookbook/time_entries/report", :id => 'query_form'}
+ assert_select 'form#query_form[action=?]', '/projects/ecookbook/time_entries/report'
end
def test_report_all_projects
get :report
assert_response :success
assert_template 'report'
- assert_tag :form,
- :attributes => {:action => "/time_entries/report", :id => 'query_form'}
+ assert_select 'form#query_form[action=?]', '/time_entries/report'
end
def test_report_all_projects_denied
assert_template 'report'
assert_not_nil assigns(:report)
assert_equal "162.90", "%.2f" % assigns(:report).total_hours
- assert_tag :tag => 'th', :content => '2007-03-12'
+ assert_select 'th', :text => '2007-03-12'
end
def test_report_one_criteria
assert_template 'report'
assert_not_nil assigns(:report)
assert_equal "154.25", "%.2f" % assigns(:report).total_hours
- assert_tag :form,
- :attributes => {:action => "/issues/1/time_entries/report", :id => 'query_form'}
+ assert_select 'form#query_form[action=?]', '/issues/1/time_entries/report'
end
def test_report_by_week_should_use_commercial_year
get :report, :project_id => 1, :criteria => ['status']
assert_response :success
assert_template 'report'
- assert_tag :tag => 'th', :content => 'Status'
- assert_tag :tag => 'td', :content => 'New'
+ assert_select 'th', :text => 'Status'
+ assert_select 'td', :text => 'New'
end
def test_report_all_projects_csv_export
@request.session[:user_id] = 3
get :new, :project_id => 1
assert_response :success
- assert_no_tag 'option', :content => 'Inactive Activity'
+ assert_select 'option', :text => 'Inactive Activity', :count => 0
end
def test_get_edit_existing_time
get :edit, :id => 2, :project_id => nil
assert_response :success
assert_template 'edit'
- assert_tag :tag => 'form', :attributes => { :action => '/time_entries/2' }
+ assert_select 'form[action=?]', '/time_entries/2'
end
def test_get_edit_with_an_existing_time_entry_with_inactive_activity
assert_response :success
assert_template 'edit'
# Blank option since nothing is pre-selected
- assert_tag :tag => 'option', :content => '--- Please select ---'
+ assert_select 'option', :text => '--- Please select ---'
end
def test_post_create
end
assert_response :success
- assert_tag 'select', :attributes => {:name => 'time_entry[project_id]'},
- :child => {:tag => 'option', :attributes => {:value => '1', :selected => 'selected'}}
+ assert_select 'select[name=?]', 'time_entry[project_id]' do
+ assert_select 'option[value="1"][selected=selected]'
+ end
end
def test_update
assert_template 'index'
assert_not_nil assigns(:total_hours)
assert_equal "162.90", "%.2f" % assigns(:total_hours)
- assert_tag :form,
- :attributes => {:action => "/time_entries", :id => 'query_form'}
+ assert_select 'form#query_form[action=?]', '/time_entries'
end
def test_index_all_projects_should_show_log_time_link
get :index
assert_response :success
assert_template 'index'
- assert_tag 'a', :attributes => {:href => '/time_entries/new'}, :content => /Log time/
+ assert_select 'a[href=?]', '/time_entries/new', :text => /Log time/
end
def test_index_my_spent_time
assert_equal [1, 3], assigns(:entries).collect(&:project_id).uniq.sort
assert_not_nil assigns(:total_hours)
assert_equal "162.90", "%.2f" % assigns(:total_hours)
- assert_tag :form,
- :attributes => {:action => "/projects/ecookbook/time_entries", :id => 'query_form'}
+ assert_select 'form#query_form[action=?]', '/projects/ecookbook/time_entries'
end
def test_index_with_display_subprojects_issues_to_false_should_not_include_subproject_entries
assert_equal 3, assigns(:entries).size
assert_not_nil assigns(:total_hours)
assert_equal "12.90", "%.2f" % assigns(:total_hours)
- assert_tag :form,
- :attributes => {:action => "/projects/ecookbook/time_entries", :id => 'query_form'}
+ assert_select 'form#query_form[action=?]', '/projects/ecookbook/time_entries'
end
def test_index_at_project_level_with_date_range_using_from_and_to_params
assert_equal 3, assigns(:entries).size
assert_not_nil assigns(:total_hours)
assert_equal "12.90", "%.2f" % assigns(:total_hours)
- assert_tag :form,
- :attributes => {:action => "/projects/ecookbook/time_entries", :id => 'query_form'}
+ assert_select 'form#query_form[action=?]', '/projects/ecookbook/time_entries'
end
def test_index_at_project_level_with_period
assert_template 'index'
assert_not_nil assigns(:entries)
assert_not_nil assigns(:total_hours)
- assert_tag :form,
- :attributes => {:action => "/projects/ecookbook/time_entries", :id => 'query_form'}
+ assert_select 'form#query_form[action=?]', '/projects/ecookbook/time_entries'
end
def test_index_at_issue_level
# display all time
assert_nil assigns(:from)
assert_nil assigns(:to)
- assert_tag :form,
- :attributes => {:action => "/issues/1/time_entries", :id => 'query_form'}
+ assert_select 'form#query_form[action=?]', '/issues/1/time_entries'
end
def test_index_should_sort_by_spent_on_and_created_on
end
assert_response :success
assert_template 'new'
- assert_error_tag :content => /name #{ESCAPED_CANT} be blank/i
+ assert_select_error /name #{ESCAPED_CANT} be blank/i
end
def test_edit
assert_response :success
assert_template 'edit'
- assert_tag :input, :attributes => { :name => 'tracker[project_ids][]',
- :value => '1',
- :checked => 'checked' }
+ assert_select 'input[name=?][value="1"][checked=checked]', 'tracker[project_ids][]'
+ assert_select 'input[name=?][value="2"]:not([checked])', 'tracker[project_ids][]'
- assert_tag :input, :attributes => { :name => 'tracker[project_ids][]',
- :value => '2',
- :checked => nil }
-
- assert_tag :input, :attributes => { :name => 'tracker[project_ids][]',
- :value => '',
- :type => 'hidden'}
+ assert_select 'input[name=?][value=""][type=hidden]', 'tracker[project_ids][]'
end
def test_edit_should_check_core_fields
put :update, :id => 1, :tracker => { :name => '' }
assert_response :success
assert_template 'edit'
- assert_error_tag :content => /name #{ESCAPED_CANT} be blank/i
+ assert_select_error /name #{ESCAPED_CANT} be blank/i
end
def test_move_lower
assert_template 'show'
assert_not_nil assigns(:user)
- assert_tag 'li', :content => /Phone number/
+ assert_select 'li', :text => /Phone number/
end
def test_show_should_not_display_hidden_custom_fields
assert_template 'show'
assert_not_nil assigns(:user)
- assert_no_tag 'li', :content => /Phone number/
+ assert_select 'li', :text => /Phone number/, :count => 0
end
def test_show_should_not_fail_when_custom_values_are_nil
assert_template 'show'
assert_not_nil assigns(:version)
- assert_tag :tag => 'h2', :content => /1.0/
+ assert_select 'h2', :text => /1.0/
end
def test_show_should_display_nil_counts
@request.session[:user_id] = 2
get :index
- assert_no_tag 'script',
- :attributes => {:type => "text/javascript"},
- :content => %r{warnLeavingUnsaved}
+ assert_select 'script', :text => %r{warnLeavingUnsaved}, :count => 0
end
def test_logout_link_should_post
get :show, :project_id => 'ecookbook'
assert_response :success
assert_template 'show'
- assert_tag :tag => 'h1', :content => /CookBook documentation/
+ assert_select 'h1', :text => /CookBook documentation/
# child_pages macro
- assert_tag :ul, :attributes => { :class => 'pages-hierarchy' },
- :child => { :tag => 'li',
- :child => { :tag => 'a', :attributes => { :href => '/projects/ecookbook/wiki/Page_with_an_inline_image' },
- :content => 'Page with an inline image' } }
+ assert_select 'ul.pages-hierarchy>li>a[href=?]', '/projects/ecookbook/wiki/Page_with_an_inline_image',
+ :text => 'Page with an inline image'
end
def test_export_link
Role.anonymous.add_permission! :export_wiki_pages
get :show, :project_id => 'ecookbook'
assert_response :success
- assert_tag 'a', :attributes => {:href => '/projects/ecookbook/wiki/CookBook_documentation.txt'}
+ assert_select 'a[href=?]', '/projects/ecookbook/wiki/CookBook_documentation.txt'
end
def test_show_page_with_name
get :show, :project_id => 1, :id => 'Another_page'
assert_response :success
assert_template 'show'
- assert_tag :tag => 'h1', :content => /Another page/
+ assert_select 'h1', :text => /Another page/
# Included page with an inline image
- assert_tag :tag => 'p', :content => /This is an inline image/
- assert_tag :tag => 'img', :attributes => { :src => '/attachments/download/3/logo.gif',
- :alt => 'This is a logo' }
+ assert_select 'p', :text => /This is an inline image/
+ assert_select 'img[src=?][alt=?]', '/attachments/download/3/logo.gif', 'This is a logo'
end
def test_show_old_version
get :show, :project_id => 1, :id => 'Another_page'
assert_response :success
- assert_tag :tag => 'div', :attributes => {:id => 'sidebar'},
- :content => /Side bar content for test_show_with_sidebar/
+ assert_select 'div#sidebar', :text => /Side bar content for test_show_with_sidebar/
end
def test_show_should_display_section_edit_links
@request.session[:user_id] = 2
get :show, :project_id => 1, :id => 'Page with sections'
- assert_no_tag 'a', :attributes => {
- :href => '/projects/ecookbook/wiki/Page_with_sections/edit?section=1'
- }
- assert_tag 'a', :attributes => {
- :href => '/projects/ecookbook/wiki/Page_with_sections/edit?section=2'
- }
- assert_tag 'a', :attributes => {
- :href => '/projects/ecookbook/wiki/Page_with_sections/edit?section=3'
- }
+
+ assert_select 'a[href=?]', '/projects/ecookbook/wiki/Page_with_sections/edit?section=1', 0
+ assert_select 'a[href=?]', '/projects/ecookbook/wiki/Page_with_sections/edit?section=2'
+ assert_select 'a[href=?]', '/projects/ecookbook/wiki/Page_with_sections/edit?section=3'
end
def test_show_current_version_should_display_section_edit_links
@request.session[:user_id] = 2
get :show, :project_id => 1, :id => 'Page with sections', :version => 3
- assert_tag 'a', :attributes => {
- :href => '/projects/ecookbook/wiki/Page_with_sections/edit?section=2'
- }
+ assert_select 'a[href=?]', '/projects/ecookbook/wiki/Page_with_sections/edit?section=2'
end
def test_show_old_version_should_not_display_section_edit_links
@request.session[:user_id] = 2
get :show, :project_id => 1, :id => 'Page with sections', :version => 2
- assert_no_tag 'a', :attributes => {
- :href => '/projects/ecookbook/wiki/Page_with_sections/edit?section=2'
- }
+ assert_select 'a[href=?]', '/projects/ecookbook/wiki/Page_with_sections/edit?section=2', 0
end
def test_show_unexistent_page_without_edit_right
get :show, :project_id => 1, :id => 'Unexistent page', :parent => 'Another_page'
assert_response :success
assert_template 'edit'
- assert_tag 'select', :attributes => {:name => 'wiki_page[parent_id]'},
- :child => {:tag => 'option', :attributes => {:value => '2', :selected => 'selected'}}
+ assert_select 'select[name=?] option[value="2"][selected=selected]', 'wiki_page[parent_id]'
end
def test_show_should_not_show_history_without_permission
assert_response :success
assert_template 'edit'
- assert_tag 'textarea',
- :attributes => { :name => 'content[text]' },
- :content => "\n"+WikiPage.find_by_title('Another_page').content.text
+ assert_select 'textarea[name=?]', 'content[text]',
+ :text => WikiPage.find_by_title('Another_page').content.text
end
def test_edit_section
page = WikiPage.find_by_title('Page_with_sections')
section, hash = Redmine::WikiFormatting::Textile::Formatter.new(page.content.text).get_section(2)
- assert_tag 'textarea',
- :attributes => { :name => 'content[text]' },
- :content => "\n"+section
- assert_tag 'input',
- :attributes => { :name => 'section', :type => 'hidden', :value => '2' }
- assert_tag 'input',
- :attributes => { :name => 'section_hash', :type => 'hidden', :value => hash }
+ assert_select 'textarea[name=?]', 'content[text]', :text => section
+ assert_select 'input[name=section][type=hidden][value="2"]'
+ assert_select 'input[name=section_hash][type=hidden][value=?]', hash
end
def test_edit_invalid_section_should_respond_with_404
assert_response :success
assert_template 'edit'
- assert_error_tag :descendant => {:content => /Comment is too long/}
- assert_tag :tag => 'textarea', :attributes => {:id => 'content_text'}, :content => "\nedited"
- assert_tag :tag => 'input', :attributes => {:id => 'content_version', :value => '1'}
+ assert_select_error /Comment is too long/
+ assert_select 'textarea#content_text', :text => "edited"
+ assert_select 'input#content_version[value="1"]'
end
def test_update_page_with_parent_change_only_should_not_create_content_version
end
assert_response :success
assert_template 'edit'
- assert_tag :div,
- :attributes => { :class => /error/ },
- :content => /Data has been updated by another user/
- assert_tag 'textarea',
- :attributes => { :name => 'content[text]' },
- :content => /Text should not be lost/
- assert_tag 'input',
- :attributes => { :name => 'content[comments]', :value => 'My comments' }
+ assert_select 'div.error', :text => /Data has been updated by another user/
+ assert_select 'textarea[name=?]', 'content[text]', :text => /Text should not be lost/
+ assert_select 'input[name=?][value=?]', 'content[comments]', 'My comments'
c.reload
assert_equal 'Previous text', c.text
end
assert_response :success
assert_template 'edit'
- assert_tag :div,
- :attributes => { :class => /error/ },
- :content => /Data has been updated by another user/
- assert_tag 'textarea',
- :attributes => { :name => 'content[text]' },
- :content => /Text should not be lost/
- assert_tag 'input',
- :attributes => { :name => 'content[comments]', :value => 'My comments' }
+ assert_select 'div.error', :text => /Data has been updated by another user/
+ assert_select 'textarea[name=?]', 'content[text]', :text => /Text should not be lost/
+ assert_select 'input[name=?][value=?]', 'content[comments]', 'My comments'
end
def test_preview
:version => 3 }
assert_response :success
assert_template 'common/_preview'
- assert_tag :tag => 'strong', :content => /previewed text/
+ assert_select 'strong', :text => /previewed text/
end
def test_preview_new_page
:version => 0 }
assert_response :success
assert_template 'common/_preview'
- assert_tag :tag => 'h1', :content => /New page/
+ assert_select 'h1', :text => /New page/
end
def test_history
assert_template 'annotate'
# Line 1
- assert_tag :tag => 'tr', :child => {
- :tag => 'th', :attributes => {:class => 'line-num'}, :content => '1', :sibling => {
- :tag => 'td', :attributes => {:class => 'author'}, :content => /John Smith/, :sibling => {
- :tag => 'td', :content => /h1\. CookBook documentation/
- }
- }
- }
+ assert_select 'table.annotate tr:nth-child(1)' do
+ assert_select 'th.line-num', :text => '1'
+ assert_select 'td.author', :text => /John Smith/
+ assert_select 'td', :text => /h1\. CookBook documentation/
+ end
# Line 5
- assert_tag :tag => 'tr', :child => {
- :tag => 'th', :attributes => {:class => 'line-num'}, :content => '5', :sibling => {
- :tag => 'td', :attributes => {:class => 'author'}, :content => /Redmine Admin/, :sibling => {
- :tag => 'td', :content => /Some updated \[\[documentation\]\] here/
- }
- }
- }
+ assert_select 'table.annotate tr:nth-child(5)' do
+ assert_select 'th.line-num', :text => '5'
+ assert_select 'td.author', :text => /Redmine Admin/
+ assert_select 'td', :text => /Some updated \[\[documentation\]\] here/
+ end
end
def test_annotate_with_invalid_version_should_respond_with_404
get :rename, :project_id => 1, :id => 'Another_page'
assert_response :success
assert_template 'rename'
- assert_tag 'option',
- :attributes => {:value => ''},
- :content => '',
- :parent => {:tag => 'select', :attributes => {:name => 'wiki_page[parent_id]'}}
- assert_no_tag 'option',
- :attributes => {:selected => 'selected'},
- :parent => {:tag => 'select', :attributes => {:name => 'wiki_page[parent_id]'}}
+
+ assert_select 'select[name=?]', 'wiki_page[parent_id]' do
+ assert_select 'option[value=""]', :text => ''
+ assert_select 'option[selected=selected]', 0
+ end
end
def test_get_rename_child_page
get :rename, :project_id => 1, :id => 'Child_1'
assert_response :success
assert_template 'rename'
- assert_tag 'option',
- :attributes => {:value => ''},
- :content => '',
- :parent => {:tag => 'select', :attributes => {:name => 'wiki_page[parent_id]'}}
- assert_tag 'option',
- :attributes => {:value => '2', :selected => 'selected'},
- :content => /Another page/,
- :parent => {
- :tag => 'select',
- :attributes => {:name => 'wiki_page[parent_id]'}
- }
+
+ assert_select 'select[name=?]', 'wiki_page[parent_id]' do
+ assert_select 'option[value=""]', :text => ''
+ assert_select 'option[value="2"][selected=selected]', :text => /Another page/
+ end
end
def test_rename_with_redirect
assert_equal Project.find(1).wiki.pages.size, pages.size
assert_equal pages.first.content.updated_on, pages.first.updated_on
- assert_tag :ul, :attributes => { :class => 'pages-hierarchy' },
- :child => { :tag => 'li', :child => { :tag => 'a', :attributes => { :href => '/projects/ecookbook/wiki/CookBook_documentation' },
- :content => 'CookBook documentation' },
- :child => { :tag => 'ul',
- :child => { :tag => 'li',
- :child => { :tag => 'a', :attributes => { :href => '/projects/ecookbook/wiki/Page_with_an_inline_image' },
- :content => 'Page with an inline image' } } } },
- :child => { :tag => 'li', :child => { :tag => 'a', :attributes => { :href => '/projects/ecookbook/wiki/Another_page' },
- :content => 'Another page' } }
+ assert_select 'ul.pages-hierarchy' do
+ assert_select 'li' do
+ assert_select 'a[href=?]', '/projects/ecookbook/wiki/CookBook_documentation', :text => 'CookBook documentation'
+ assert_select 'ul li a[href=?]', '/projects/ecookbook/wiki/Page_with_an_inline_image', :text => 'Page with an inline image'
+ end
+ assert_select 'li a[href=?]', '/projects/ecookbook/wiki/Another_page', :text => 'Another page'
+ end
end
def test_index_should_include_atom_link
get :index, :project_id => 'ecookbook'
- assert_tag 'a', :attributes => { :href => '/projects/ecookbook/activity.atom?show_wiki_edits=1'}
+ assert_select 'a[href=?]', '/projects/ecookbook/activity.atom?show_wiki_edits=1'
end
def test_export_to_html
assert_not_nil assigns(:pages)
assert_not_nil assigns(:pages_by_date)
- assert_tag 'a', :attributes => { :href => '/projects/ecookbook/activity.atom?show_wiki_edits=1'}
+ assert_select 'a[href=?]', '/projects/ecookbook/activity.atom?show_wiki_edits=1'
end
def test_not_found
get :show, :project_id => 1
assert_response :success
assert_template 'show'
- assert_tag :tag => 'a', :attributes => { :href => '/projects/1/wiki/CookBook_documentation/edit' }
+ assert_select 'a[href=?]', '/projects/1/wiki/CookBook_documentation/edit'
end
def test_show_page_without_edit_link
get :show, :project_id => 1
assert_response :success
assert_template 'show'
- assert_no_tag :tag => 'a', :attributes => { :href => '/projects/1/wiki/CookBook_documentation/edit' }
+ assert_select 'a[href=?]', '/projects/1/wiki/CookBook_documentation/edit', 0
end
def test_show_pdf
assert_equal 'text/html', @response.content_type
assert_equal 'attachment; filename="CookBook_documentation.html"',
@response.headers['Content-Disposition']
- assert_tag 'h1', :content => 'CookBook documentation'
+ assert_select 'h1', :text => /CookBook documentation/
end
def test_show_versioned_html
assert_equal 'text/html', @response.content_type
assert_equal 'attachment; filename="CookBook_documentation.html"',
@response.headers['Content-Disposition']
- assert_tag 'h1', :content => 'CookBook documentation'
+ assert_select 'h1', :text => /CookBook documentation/
end
def test_show_txt
assert_template 'index'
count = WorkflowTransition.where(:role_id => 1, :tracker_id => 2).count
- assert_tag :tag => 'a', :content => count.to_s,
- :attributes => { :href => '/workflows/edit?role_id=1&tracker_id=2' }
+ assert_select 'a[href=?]', '/workflows/edit?role_id=1&tracker_id=2', :content => count.to_s
end
def test_get_edit
post '/login', :username => 'foo', :password => 'bar'
assert_response :success
assert_template 'account/register'
- assert_tag :input, :attributes => { :name => 'user[firstname]', :value => '' }
- assert_tag :input, :attributes => { :name => 'user[lastname]', :value => 'Smith' }
- assert_no_tag :input, :attributes => { :name => 'user[login]' }
- assert_no_tag :input, :attributes => { :name => 'user[password]' }
+ assert_select 'input[name=?][value=""]', 'user[firstname]'
+ assert_select 'input[name=?][value=Smith]', 'user[lastname]'
+ assert_select 'input[name=?]', 'user[login]', 0
+ assert_select 'input[name=?]', 'user[password]', 0
post 'account/register',
:user => {:firstname => 'Foo', :lastname => 'Smith', :mail => 'foo@bar.com'}
get '/attachments/7.xml', {}, credentials('jsmith')
assert_response :success
assert_equal 'application/xml', @response.content_type
- assert_tag :tag => 'attachment',
- :child => {
- :tag => 'id',
- :content => '7',
- :sibling => {
- :tag => 'filename',
- :content => 'archive.zip',
- :sibling => {
- :tag => 'content_url',
- :content => 'http://www.example.com/attachments/download/7/archive.zip'
- }
- }
- }
+ assert_select 'attachment id:content(7)' do
+ assert_select '~ filename', :text => 'archive.zip'
+ assert_select '~ content_url', :text => 'http://www.example.com/attachments/download/7/archive.zip'
+ end
end
test "GET /attachments/:id.xml should deny access without credentials" do
assert_no_difference 'Attachment.count' do
post '/uploads.xml', ('x' * 2048), {"CONTENT_TYPE" => 'application/octet-stream'}.merge(credentials('jsmith'))
assert_response 422
- assert_tag 'error', :content => /exceeds the maximum allowed file size/
+ assert_select 'error', :text => /exceeds the maximum allowed file size/
end
end
end
get '/projects/1/issue_categories.xml', {}, credentials('jsmith')
assert_response :success
assert_equal 'application/xml', @response.content_type
- assert_tag :tag => 'issue_categories',
- :child => {:tag => 'issue_category', :child => {:tag => 'id', :content => '2'}}
+ assert_select 'issue_categories issue_category id', :text => '2'
end
test "GET /issue_categories/:id.xml should return the issue category" do
get '/issue_categories/2.xml', {}, credentials('jsmith')
assert_response :success
assert_equal 'application/xml', @response.content_type
- assert_tag :tag => 'issue_category',
- :child => {:tag => 'id', :content => '2'}
+ assert_select 'issue_category id', :text => '2'
end
test "POST /projects/:project_id/issue_categories.xml should return create issue category" do
assert_response :unprocessable_entity
assert_equal 'application/xml', @response.content_type
- assert_tag 'errors', :child => {:tag => 'error', :content => "Name can't be blank"}
+ assert_select 'errors error', :text => "Name can't be blank"
end
test "PUT /issue_categories/:id.xml with valid parameters should update the issue category" do
assert_response :unprocessable_entity
assert_equal 'application/xml', @response.content_type
- assert_tag 'errors', :child => {:tag => 'error', :content => "Name can't be blank"}
+ assert_select 'errors error', :text => "Name can't be blank"
end
test "DELETE /issue_categories/:id.xml should destroy the issue category" do
assert_response :success
assert_equal 'application/xml', @response.content_type
- assert_tag :tag => 'relations',
- :attributes => { :type => 'array' },
- :child => {
- :tag => 'relation',
- :child => {
- :tag => 'id',
- :content => '1'
- }
- }
+ assert_select 'relations[type=array] relation id', :text => '1'
end
test "POST /issues/:issue_id/relations.xml should create the relation" do
assert_response :created
assert_equal 'application/xml', @response.content_type
- assert_tag 'relation', :child => {:tag => 'id', :content => relation.id.to_s}
+ assert_select 'relation id', :text => relation.id.to_s
end
test "POST /issues/:issue_id/relations.xml with failure should return errors" do
end
assert_response :unprocessable_entity
- assert_tag :errors, :child => {:tag => 'error', :content => /relation_type is not included in the list/}
+ assert_select 'errors error', :text => /relation_type is not included in the list/
end
test "GET /relations/:id.xml should return the relation" do
assert_response :success
assert_equal 'application/xml', @response.content_type
- assert_tag 'relation', :child => {:tag => 'id', :content => '2'}
+ assert_select 'relation id', :text => '2'
end
test "DELETE /relations/:id.xml should delete the relation" do
assert_response :success
assert_equal 'application/xml', @response.content_type
- assert_tag :tag => 'issue_statuses',
- :attributes => {:type => 'array'},
- :child => {
- :tag => 'issue_status',
- :child => {
- :tag => 'id',
- :content => '2',
- :sibling => {
- :tag => 'name',
- :content => 'Assigned'
- }
- }
- }
+ assert_select 'issue_statuses[type=array] issue_status id:content(2)' do
+ assert_select '~ name', :text => 'Assigned'
+ end
end
end
should "contain metadata" do
get '/issues.xml'
- assert_tag :tag => 'issues',
- :attributes => {
- :type => 'array',
- :total_count => assigns(:issue_count),
- :limit => 25,
- :offset => 0
- }
+ assert_select 'issues[type=array][total_count=?][limit="25"][offset="0"]', assigns(:issue_count).to_s
end
context "with offset and limit" do
assert_equal 3, assigns(:limit)
assert_equal 2, assigns(:offset)
- assert_tag :tag => 'issues', :children => {:count => 3, :only => {:tag => 'issue'}}
+ assert_select 'issues issue', 3
end
end
should "not contain metadata" do
get '/issues.xml?nometa=1'
- assert_tag :tag => 'issues',
- :attributes => {
- :type => 'array',
- :total_count => nil,
- :limit => nil,
- :offset => nil
- }
+ assert_select 'issues[type=array]:not([total_count]):not([limit]):not([offset])'
end
end
should "not contain metadata" do
get '/issues.xml', {}, {'X-Redmine-Nometa' => '1'}
- assert_tag :tag => 'issues',
- :attributes => {
- :type => 'array',
- :total_count => nil,
- :limit => nil,
- :offset => nil
- }
+ assert_select 'issues[type=array]:not([total_count]):not([limit]):not([offset])'
end
end
assert_response :success
assert_equal 'application/xml', @response.content_type
- assert_tag 'relations',
- :parent => {:tag => 'issue', :child => {:tag => 'id', :content => '3'}},
- :children => {:count => 1},
- :child => {
- :tag => 'relation',
- :attributes => {:id => '2', :issue_id => '2', :issue_to_id => '3',
- :relation_type => 'relates'}
- }
- assert_tag 'relations',
- :parent => {:tag => 'issue', :child => {:tag => 'id', :content => '1'}},
- :children => {:count => 0}
+
+ assert_select 'issue id:content(3)' do
+ assert_select '~ relations relation', 1
+ assert_select '~ relations relation[id="2"][issue_id="2"][issue_to_id="3"][relation_type=relates]'
+ end
+
+ assert_select 'issue id:content(1)' do
+ assert_select '~ relations'
+ assert_select '~ relations relation', 0
+ end
end
end
assert_response :unprocessable_entity
assert_equal 'application/xml', @response.content_type
- assert_tag 'errors', :child => {:tag => 'error', :content => "Start date can't be blank"}
+ assert_select 'errors error', :text => "Start date can't be blank"
end
end
should "display journals" do
get '/issues/1.xml?include=journals'
- assert_tag :tag => 'issue',
- :child => {
- :tag => 'journals',
- :attributes => { :type => 'array' },
- :child => {
- :tag => 'journal',
- :attributes => { :id => '1'},
- :child => {
- :tag => 'details',
- :attributes => { :type => 'array' },
- :child => {
- :tag => 'detail',
- :attributes => { :name => 'status_id' },
- :child => {
- :tag => 'old_value',
- :content => '1',
- :sibling => {
- :tag => 'new_value',
- :content => '2'
- }
- }
- }
- }
- }
- }
+ assert_select 'issue journals[type=array]' do
+ assert_select 'journal[id="1"]' do
+ assert_select 'details[type=array]' do
+ assert_select 'detail[name=status_id]' do
+ assert_select 'old_value', :text => '1'
+ assert_select 'new_value', :text => '2'
+ end
+ end
+ end
+ end
end
end
end
should "display custom fields" do
get '/issues/3.xml'
- assert_tag :tag => 'issue',
- :child => {
- :tag => 'custom_fields',
- :attributes => { :type => 'array' },
- :child => {
- :tag => 'custom_field',
- :attributes => { :id => '1'},
- :child => {
- :tag => 'value',
- :content => 'MySQL'
- }
- }
- }
+ assert_select 'issue custom_fields[type=array]' do
+ assert_select 'custom_field[id="1"]' do
+ assert_select 'value', :text => 'MySQL'
+ end
+ end
assert_nothing_raised do
Hash.from_xml(response.body).to_xml
should "display custom fields" do
get '/issues/3.xml'
assert_response :success
- assert_tag :tag => 'issue',
- :child => {
- :tag => 'custom_fields',
- :attributes => { :type => 'array' },
- :child => {
- :tag => 'custom_field',
- :attributes => { :id => '1'},
- :child => {
- :tag => 'value',
- :attributes => { :type => 'array' },
- :children => { :count => 2 }
- }
- }
- }
+
+ assert_select 'issue custom_fields[type=array]' do
+ assert_select 'custom_field[id="1"]' do
+ assert_select 'value[type=array] value', 2
+ end
+ end
xml = Hash.from_xml(response.body)
custom_fields = xml['issue']['custom_fields']
context ".xml" do
should "display custom fields" do
get '/issues/3.xml'
- assert_response :success
- assert_tag :tag => 'issue',
- :child => {
- :tag => 'custom_fields',
- :attributes => { :type => 'array' },
- :child => {
- :tag => 'custom_field',
- :attributes => { :id => '1'},
- :child => {
- :tag => 'value',
- :attributes => { :type => 'array' },
- :children => { :count => 0 }
- }
- }
- }
+
+ assert_select 'issue custom_fields[type=array]' do
+ assert_select 'custom_field[id="1"]' do
+ assert_select 'value[type=array]:empty'
+ end
+ end
xml = Hash.from_xml(response.body)
custom_fields = xml['issue']['custom_fields']
should "display attachments" do
get '/issues/3.xml?include=attachments'
- assert_tag :tag => 'issue',
- :child => {
- :tag => 'attachments',
- :children => {:count => 5},
- :child => {
- :tag => 'attachment',
- :child => {
- :tag => 'filename',
- :content => 'source.rb',
- :sibling => {
- :tag => 'content_url',
- :content => 'http://www.example.com/attachments/download/4/source.rb'
- }
- }
- }
- }
+ assert_select 'issue attachments[type=array]' do
+ assert_select 'attachment', 5
+ assert_select 'attachment id:content(4)' do
+ assert_select '~ filename', :text => 'source.rb'
+ assert_select '~ content_url', :text => 'http://www.example.com/attachments/download/4/source.rb'
+ end
+ end
end
end
end
should "display children" do
get '/issues/1.xml?include=children'
- assert_tag :tag => 'issue',
- :child => {
- :tag => 'children',
- :children => {:count => 2},
- :child => {
- :tag => 'issue',
- :attributes => {:id => @c1.id.to_s},
- :child => {
- :tag => 'subject',
- :content => 'child c1',
- :sibling => {
- :tag => 'children',
- :children => {:count => 1},
- :child => {
- :tag => 'issue',
- :attributes => {:id => @c3.id.to_s}
- }
- }
- }
- }
- }
+ assert_select 'issue children[type=array]' do
+ assert_select 'issue', 2
+ assert_select 'issue[id=?]', @c1.id.to_s do
+ assert_select 'subject', :text => 'child c1'
+ assert_select 'children' do
+ assert_select 'issue[id=?]', @c3.id.to_s
+ end
+ end
+ end
end
context ".json" do
assert_response :created
assert_equal 'application/xml', @response.content_type
- assert_tag 'issue', :child => {:tag => 'id', :content => issue.id.to_s}
+ assert_select 'issue > id', :text => issue.id.to_s
end
end
post '/issues.xml', {:issue => {:project_id => 1}}, credentials('jsmith')
end
- assert_tag :errors, :child => {:tag => 'error', :content => "Subject can't be blank"}
+ assert_select 'errors error', :text => "Subject can't be blank"
end
end
should "have an errors tag" do
put '/issues/6.xml', @parameters, credentials('jsmith')
- assert_tag :errors, :child => {:tag => 'error', :content => "Subject can't be blank"}
+ assert_select 'errors error', :text => "Subject can't be blank"
end
end
assert_response :success
assert_equal 'application/xml', @response.content_type
- assert_tag :tag => 'memberships',
- :attributes => {:type => 'array'},
- :child => {
- :tag => 'membership',
- :child => {
- :tag => 'id',
- :content => '2',
- :sibling => {
- :tag => 'user',
- :attributes => {:id => '3', :name => 'Dave Lopper'},
- :sibling => {
- :tag => 'roles',
- :child => {
- :tag => 'role',
- :attributes => {:id => '2', :name => 'Developer'}
- }
- }
- }
- }
- }
+ assert_select 'memberships[type=array] membership id:content(2)' do
+ assert_select '~ user[id=3][name=Dave Lopper]'
+ assert_select '~ roles role[id=2][name=Developer]'
+ end
end
test "GET /projects/:project_id/memberships.json should return memberships" do
assert_response :unprocessable_entity
assert_equal 'application/xml', @response.content_type
- assert_tag 'errors', :child => {:tag => 'error', :content => "Principal can't be blank"}
+ assert_select 'errors error', :text => "Principal can't be blank"
end
end
assert_response :success
assert_equal 'application/xml', @response.content_type
- assert_tag :tag => 'membership',
- :child => {
- :tag => 'id',
- :content => '2',
- :sibling => {
- :tag => 'user',
- :attributes => {:id => '3', :name => 'Dave Lopper'},
- :sibling => {
- :tag => 'roles',
- :child => {
- :tag => 'role',
- :attributes => {:id => '2', :name => 'Developer'}
- }
- }
- }
- }
+ assert_select 'membership id:content(2)' do
+ assert_select '~ user[id=3][name=Dave Lopper]'
+ assert_select '~ roles role[id=2][name=Developer]'
+ end
end
test "GET /memberships/:id.json should return the membership" do
assert_response :unprocessable_entity
assert_equal 'application/xml', @response.content_type
- assert_tag 'errors', :child => {:tag => 'error', :content => /role can't be empty/i}
+ assert_select 'errors error', :text => "Role can't be empty"
end
test "DELETE /memberships/:id.xml should destroy the membership" do
test "GET /news.xml should return news" do
get '/news.xml'
- assert_tag :tag => 'news',
- :attributes => {:type => 'array'},
- :child => {
- :tag => 'news',
- :child => {
- :tag => 'id',
- :content => '2'
- }
- }
+ assert_select 'news[type=array] news id', :text => '2'
end
test "GET /news.json should return news" do
test "GET /projects/:project_id/news.xml should return news" do
get '/projects/ecookbook/news.xml'
- assert_tag :tag => 'news',
- :attributes => {:type => 'array'},
- :child => {
- :tag => 'news',
- :child => {
- :tag => 'id',
- :content => '2'
- }
- }
+ assert_select 'news[type=array] news id', :text => '2'
end
test "GET /projects/:project_id/news.json should return news" do
assert_response :success
assert_equal 'application/xml', @response.content_type
- assert_tag 'issue_categories',
- :attributes => {:type => 'array'},
- :child => {
- :tag => 'issue_category',
- :attributes => {
- :id => '2',
- :name => 'Recipes'
- }
- }
+ assert_select 'issue_categories[type=array] issue_category[id=2][name=Recipes]'
end
test "GET /projects.xml with include=trackers should return trackers" do
assert_response :success
assert_equal 'application/xml', @response.content_type
- assert_tag 'trackers',
- :attributes => {:type => 'array'},
- :child => {
- :tag => 'tracker',
- :attributes => {
- :id => '2',
- :name => 'Feature request'
- }
- }
+ assert_select 'trackers[type=array] tracker[id=2][name=Feature request]'
end
test "GET /projects.xml with include=enabled_modules should return enabled modules" do
assert_response :success
assert_equal 'application/xml', @response.content_type
- assert_tag 'enabled_modules',
- :attributes => {:type => 'array'},
- :child => {
- :tag => 'enabled_module',
- :attributes => {
- :name => 'issue_tracking'
- }
- }
+ assert_select 'enabled_modules[type=array] enabled_module[name=issue_tracking]'
end
test "GET /projects/:id.xml should return the project" do
assert_select 'project>is_public', :text => 'true'
assert_select 'custom_field[name=Development status]', :text => 'Stable'
- assert_no_tag 'trackers'
- assert_no_tag 'issue_categories'
+ assert_select 'trackers', 0
+ assert_select 'issue_categories', 0
end
test "GET /projects/:id.json should return the project" do
assert_response :success
assert_equal 'application/xml', @response.content_type
- assert_no_tag 'custom_field',
- :attributes => {:name => 'Development status'}
+ assert_select 'custom_field[name=?]', 'Development status', 0
end
test "GET /projects/:id.xml with include=issue_categories should return categories" do
assert_response :success
assert_equal 'application/xml', @response.content_type
- assert_tag 'issue_categories',
- :attributes => {:type => 'array'},
- :child => {
- :tag => 'issue_category',
- :attributes => {
- :id => '2',
- :name => 'Recipes'
- }
- }
+ assert_select 'issue_categories[type=array] issue_category[id=2][name=Recipes]'
end
test "GET /projects/:id.xml with include=trackers should return trackers" do
assert_response :success
assert_equal 'application/xml', @response.content_type
- assert_tag 'trackers',
- :attributes => {:type => 'array'},
- :child => {
- :tag => 'tracker',
- :attributes => {
- :id => '2',
- :name => 'Feature request'
- }
- }
+ assert_select 'trackers[type=array] tracker[id=2][name=Feature request]'
end
test "GET /projects/:id.xml with include=enabled_modules should return enabled modules" do
assert_response :success
assert_equal 'application/xml', @response.content_type
- assert_tag 'enabled_modules',
- :attributes => {:type => 'array'},
- :child => {
- :tag => 'enabled_module',
- :attributes => {
- :name => 'issue_tracking'
- }
- }
+ assert_select 'enabled_modules[type=array] enabled_module[name=issue_tracking]'
end
test "POST /projects.xml with valid parameters should create the project" do
assert_response :created
assert_equal 'application/xml', @response.content_type
- assert_tag 'project', :child => {:tag => 'id', :content => project.id.to_s}
+ assert_select 'project id', :text => project.id.to_s
end
test "POST /projects.xml should accept enabled_module_names attribute" do
assert_response :unprocessable_entity
assert_equal 'application/xml', @response.content_type
- assert_tag 'errors', :child => {:tag => 'error', :content => "Identifier can't be blank"}
+ assert_select 'errors error', :text => "Identifier can't be blank"
end
test "PUT /projects/:id.xml with valid parameters should update the project" do
assert_response :unprocessable_entity
assert_equal 'application/xml', @response.content_type
- assert_tag 'errors', :child => {:tag => 'error', :content => "Name can't be blank"}
+ assert_select 'errors error', :text => "Name can't be blank"
end
test "DELETE /projects/:id.xml should delete the project" do
assert_response :success
assert_equal 'application/xml', @response.content_type
- assert_tag :tag => 'queries',
- :attributes => {:type => 'array'},
- :child => {
- :tag => 'query',
- :child => {
- :tag => 'id',
- :content => '4',
- :sibling => {
- :tag => 'name',
- :content => 'Public query for all projects'
- }
- }
- }
+ assert_select 'queries[type=array] query id:content(4)' do
+ assert_select '~ name', :text => 'Public query for all projects'
+ end
end
end
assert_equal 'application/xml', @response.content_type
assert_equal 3, assigns(:roles).size
- assert_tag :tag => 'roles',
- :attributes => {:type => 'array'},
- :child => {
- :tag => 'role',
- :child => {
- :tag => 'id',
- :content => '2',
- :sibling => {
- :tag => 'name',
- :content => 'Developer'
- }
- }
- }
+ assert_select 'roles[type=array] role id:content(2)' do
+ assert_select '~ name', :text => 'Developer'
+ end
end
test "GET /roles.json should return the roles" do
get '/time_entries.xml', {}, credentials('jsmith')
assert_response :success
assert_equal 'application/xml', @response.content_type
- assert_tag :tag => 'time_entries',
- :child => {:tag => 'time_entry', :child => {:tag => 'id', :content => '2'}}
+ assert_select 'time_entries[type=array] time_entry id', :text => '2'
end
test "GET /time_entries.xml with limit should return limited results" do
get '/time_entries.xml?limit=2', {}, credentials('jsmith')
assert_response :success
assert_equal 'application/xml', @response.content_type
- assert_tag :tag => 'time_entries',
- :children => {:count => 2}
+ assert_select 'time_entries[type=array] time_entry', 2
end
test "GET /time_entries/:id.xml should return the time entry" do
get '/time_entries/2.xml', {}, credentials('jsmith')
assert_response :success
assert_equal 'application/xml', @response.content_type
- assert_tag :tag => 'time_entry',
- :child => {:tag => 'id', :content => '2'}
+ assert_select 'time_entry id', :text => '2'
end
test "POST /time_entries.xml with issue_id should create time entry" do
assert_response :unprocessable_entity
assert_equal 'application/xml', @response.content_type
- assert_tag 'errors', :child => {:tag => 'error', :content => "Hours can't be blank"}
+ assert_select 'errors error', :text => "Hours can't be blank"
end
test "PUT /time_entries/:id.xml with valid parameters should update time entry" do
assert_response :unprocessable_entity
assert_equal 'application/xml', @response.content_type
- assert_tag 'errors', :child => {:tag => 'error', :content => "Hours can't be blank"}
+ assert_select 'errors error', :text => "Hours can't be blank"
end
test "DELETE /time_entries/:id.xml should destroy time entry" do
assert_response :success
assert_equal 'application/xml', @response.content_type
- assert_tag :tag => 'trackers',
- :attributes => {:type => 'array'},
- :child => {
- :tag => 'tracker',
- :child => {
- :tag => 'id',
- :content => '2',
- :sibling => {
- :tag => 'name',
- :content => 'Feature request'
- }
- }
- }
+
+ assert_select 'trackers[type=array] tracker id:content(2)' do
+ assert_select '~ name', :text => 'Feature request'
+ end
end
end
get '/users/2.xml'
assert_response :success
- assert_tag :tag => 'user',
- :child => {:tag => 'id', :content => '2'}
+ assert_select 'user id', :text => '2'
end
test "GET /users/:id.json should return the user" do
get '/users/2.xml?include=memberships'
assert_response :success
- assert_tag :tag => 'memberships',
- :parent => {:tag => 'user'},
- :children => {:count => 1}
+ assert_select 'user memberships', 1
end
test "GET /users/:id.json with include=memberships should include memberships" do
test "GET /users/current.xml should return current user" do
get '/users/current.xml', {}, credentials('jsmith')
- assert_tag :tag => 'user',
- :child => {:tag => 'id', :content => '2'}
+ assert_select 'user id', :text => '2'
end
test "GET /users/:id should not return login for other user" do
get '/users/3.xml', {}, credentials('jsmith')
assert_response :success
- assert_no_tag 'user', :child => {:tag => 'login'}
+ assert_select 'user login', 0
end
test "GET /users/:id should return login for current user" do
get '/users/2.xml', {}, credentials('jsmith')
assert_response :success
- assert_tag 'user', :child => {:tag => 'login', :content => 'jsmith'}
+ assert_select 'user login', :text => 'jsmith'
end
test "GET /users/:id should not return api_key for other user" do
get '/users/3.xml', {}, credentials('jsmith')
assert_response :success
- assert_no_tag 'user', :child => {:tag => 'api_key'}
+ assert_select 'user api_key', 0
end
test "GET /users/:id should return api_key for current user" do
get '/users/2.xml', {}, credentials('jsmith')
assert_response :success
- assert_tag 'user', :child => {:tag => 'api_key', :content => User.find(2).api_key}
+ assert_select 'user api_key', :text => User.find(2).api_key
end
test "GET /users/:id should not return status for standard user" do
get '/users/3.xml', {}, credentials('jsmith')
assert_response :success
- assert_no_tag 'user', :child => {:tag => 'status'}
+ assert_select 'user status', 0
end
test "GET /users/:id should return status for administrators" do
get '/users/2.xml', {}, credentials('admin')
assert_response :success
- assert_tag 'user', :child => {:tag => 'status', :content => User.find(1).status.to_s}
+ assert_select 'user status', :text => User.find(1).status.to_s
end
test "POST /users.xml with valid parameters should create the user" do
assert_response :created
assert_equal 'application/xml', @response.content_type
- assert_tag 'user', :child => {:tag => 'id', :content => user.id.to_s}
+ assert_select 'user id', :text => user.id.to_s
end
test "POST /users.json with valid parameters should create the user" do
assert_response :unprocessable_entity
assert_equal 'application/xml', @response.content_type
- assert_tag 'errors', :child => {
- :tag => 'error',
- :content => "First name can't be blank"
- }
+ assert_select 'errors error', :text => "First name can't be blank"
end
test "POST /users.json with with invalid parameters should return errors" do
assert_response :unprocessable_entity
assert_equal 'application/xml', @response.content_type
- assert_tag 'errors', :child => {
- :tag => 'error',
- :content => "First name can't be blank"
- }
+ assert_select 'errors error', :text => "First name can't be blank"
end
test "PUT /users/:id.json with invalid parameters" do
assert_response :success
assert_equal 'application/xml', @response.content_type
- assert_tag :tag => 'versions',
- :attributes => {:type => 'array'},
- :child => {
- :tag => 'version',
- :child => {
- :tag => 'id',
- :content => '2',
- :sibling => {
- :tag => 'name',
- :content => '1.0'
- }
- }
- }
+
+ assert_select 'versions[type=array] version id:content(2)' do
+ assert_select '~ name', :text => '1.0'
+ end
end
test "POST /projects/:project_id/versions.xml should create the version" do
assert_response :created
assert_equal 'application/xml', @response.content_type
- assert_tag 'version', :child => {:tag => 'id', :content => version.id.to_s}
+ assert_select 'version id', :text => version.id.to_s
end
test "POST /projects/:project_id/versions.xml should create the version with due date" do
assert_response :created
assert_equal 'application/xml', @response.content_type
- assert_tag 'version', :child => {:tag => 'id', :content => version.id.to_s}
+ assert_select 'version id', :text => version.id.to_s
end
test "POST /projects/:project_id/versions.xml should create the version with custom fields" do
end
assert_response :unprocessable_entity
- assert_tag :errors, :child => {:tag => 'error', :content => "Name can't be blank"}
+ assert_select 'errors error', :text => "Name can't be blank"
end
test "GET /versions/:id.xml should return the version" do
# a french user
get 'projects', { }, 'HTTP_ACCEPT_LANGUAGE' => 'fr,fr-fr;q=0.8,en-us;q=0.5,en;q=0.3'
assert_response :success
- assert_tag :tag => 'h2', :content => 'Projets'
+ assert_select 'h2', :text => 'Projets'
assert_equal :fr, current_language
assert_select "html[lang=?]", "fr"
# then an italien user
get 'projects', { }, 'HTTP_ACCEPT_LANGUAGE' => 'it;q=0.8,en-us;q=0.5,en;q=0.3'
assert_response :success
- assert_tag :tag => 'h2', :content => 'Progetti'
+ assert_select 'h2', :text => 'Progetti'
assert_equal :it, current_language
assert_select "html[lang=?]", "it"
# not a supported language: default language should be used
get 'projects', { }, 'HTTP_ACCEPT_LANGUAGE' => 'zz'
assert_response :success
- assert_tag :tag => 'h2', :content => 'Projects'
+ assert_select 'h2', :text => 'Projects'
assert_select "html[lang=?]", "en"
end
get '/projects/ecookbook/issues'
%w(Atom PDF CSV).each do |format|
- assert_tag :a, :content => format,
- :attributes => { :href => "/projects/ecookbook/issues.#{format.downcase}",
- :rel => 'nofollow' }
+ assert_select 'a[rel=nofollow][href=?]', "/projects/ecookbook/issues.#{format.downcase}", :text => format
end
end
get '/issues', :project_id => 'ecookbook'
%w(Atom PDF CSV).each do |format|
- assert_tag :a, :content => format,
- :attributes => { :href => "/projects/ecookbook/issues.#{format.downcase}",
- :rel => 'nofollow' }
+ assert_select 'a[rel=nofollow][href=?]', "/projects/ecookbook/issues.#{format.downcase}", :text => format
end
end
with_settings :per_page_options => '2' do
get '/projects/ecookbook/issues'
- assert_tag :a, :content => '2',
- :attributes => { :href => '/projects/ecookbook/issues?page=2' }
+ assert_select 'a[href=?]', '/projects/ecookbook/issues?page=2', :text => '2'
end
end
with_settings :per_page_options => '2' do
get '/issues', :project_id => 'ecookbook'
- assert_tag :a, :content => '2',
- :attributes => { :href => '/projects/ecookbook/issues?page=2' }
+ assert_select 'a[href=?]', '/projects/ecookbook/issues?page=2', :text => '2'
end
end
# Issue form
get '/projects/ecookbook/issues/new'
assert_response :success
- assert_tag :select,
- :attributes => {:name => "issue[custom_field_values][#{@field.id}]"},
- :children => {:count => (users.size + 1)}, # +1 for blank value
- :child => {
- :tag => 'option',
- :attributes => {:value => tester.id.to_s},
- :content => tester.name
- }
+ assert_select 'select[name=?]', "issue[custom_field_values][#{@field.id}]" do
+ assert_select 'option', users.size + 1 # +1 for blank value
+ assert_select 'option[value=?]', tester.id.to_s, :text => tester.name
+ end
# Create issue
assert_difference 'Issue.count' do
# Issue view
follow_redirect!
- assert_tag :th,
- :content => /Tester/,
- :sibling => {
- :tag => 'td',
- :content => tester.name
- }
- assert_tag :select,
- :attributes => {:name => "issue[custom_field_values][#{@field.id}]"},
- :children => {:count => (users.size + 1)}, # +1 for blank value
- :child => {
- :tag => 'option',
- :attributes => {:value => tester.id.to_s, :selected => 'selected'},
- :content => tester.name
- }
+ assert_select 'th:content(Tester:) + td', :text => tester.name
+ assert_select 'select[name=?]', "issue[custom_field_values][#{@field.id}]" do
+ assert_select 'option', users.size + 1 # +1 for blank value
+ assert_select 'option[value=?][selected=selected]', tester.id.to_s, :text => tester.name
+ end
# Update issue
new_tester = users[1]
# Issue view
follow_redirect!
- assert_tag :content => 'Tester',
- :ancestor => {:tag => 'ul', :attributes => {:class => /details/}},
- :sibling => {
- :content => tester.name,
- :sibling => {
- :content => new_tester.name
- }
- }
+ assert_select 'ul.details li', :text => "Tester changed from #{tester} to #{new_tester}"
end
def test_update_using_invalid_http_verbs
Role.anonymous.add_permission! :add_issues
get '/projects/ecookbook/issues/new'
- assert_tag :script,
- :attributes => {:src => %r{^/javascripts/jstoolbar/jstoolbar-textile.min.js}},
- :parent => {:tag => 'head'}
+ assert_select 'head script[src=?]', '/javascripts/jstoolbar/jstoolbar-textile.min.js'
end
def test_calendar_header_tags
Redmine::Hook.add_listener(ProjectBasedTemplate)
get '/projects/ecookbook'
- assert_tag :tag => 'link', :attributes => {:href => '/stylesheets/ecookbook.css'},
- :parent => {:tag => 'head'}
+ assert_select 'head link[href=?]', '/stylesheets/ecookbook.css'
end
def test_empty_sidebar_should_be_hidden
def test_project_menu_with_specific_locale
get 'projects/ecookbook/issues', { }, 'HTTP_ACCEPT_LANGUAGE' => 'fr,fr-fr;q=0.8,en-us;q=0.5,en;q=0.3'
- assert_tag :div, :attributes => { :id => 'main-menu' },
- :descendant => { :tag => 'li', :child => { :tag => 'a', :content => ll('fr', :label_activity),
- :attributes => { :href => '/projects/ecookbook/activity',
- :class => 'activity' } } }
- assert_tag :div, :attributes => { :id => 'main-menu' },
- :descendant => { :tag => 'li', :child => { :tag => 'a', :content => ll('fr', :label_issue_plural),
- :attributes => { :href => '/projects/ecookbook/issues',
- :class => 'issues selected' } } }
+ assert_select 'div#main-menu' do
+ assert_select 'li a.activity[href=?]', '/projects/ecookbook/activity', :text => ll('fr', :label_activity)
+ assert_select 'li a.issues.selected[href=?]', '/projects/ecookbook/issues', :text => ll('fr', :label_issue_plural)
+ end
end
def test_project_menu_with_additional_menu_items
end
get 'projects/ecookbook'
- assert_tag :div, :attributes => { :id => 'main-menu' },
- :descendant => { :tag => 'li', :child => { :tag => 'a', :content => 'Foo',
- :attributes => { :class => 'foo' } } }
-
- assert_tag :div, :attributes => { :id => 'main-menu' },
- :descendant => { :tag => 'li', :child => { :tag => 'a', :content => 'Bar',
- :attributes => { :class => 'bar' } },
- :before => { :tag => 'li', :child => { :tag => 'a', :content => 'ECOOKBOOK' } } }
- assert_tag :div, :attributes => { :id => 'main-menu' },
- :descendant => { :tag => 'li', :child => { :tag => 'a', :content => 'ECOOKBOOK',
- :attributes => { :class => 'hello' } },
- :before => { :tag => 'li', :child => { :tag => 'a', :content => 'Activity' } } }
+ assert_select 'div#main-menu ul' do
+ assert_select 'li:last-child a.foo[href=?]', '/projects/ecookbook', :text => 'Foo'
+ assert_select 'li:nth-child(2) a.bar[href=?]', '/projects/ecookbook', :text => 'Bar'
+ assert_select 'li:nth-child(3) a.hello[href=?]', '/projects/ecookbook', :text => 'ECOOKBOOK'
+ assert_select 'li:nth-child(4) a', :text => 'Activity'
+ end
# Remove the menu items
Redmine::MenuManager.map :project_menu do |menu|
assert_equal true, saved, message
end
- def assert_error_tag(options={})
- assert_tag({:attributes => { :id => 'errorExplanation' }}.merge(options))
+ def assert_select_error(arg)
+ assert_select '#errorExplanation', :text => arg
end
def assert_include(expected, s, message=nil)