Commit adf85379 authored by jplang's avatar jplang

Removes calls to #assert_template and #assigns in functional tests.

git-svn-id: https://svn.redmine.org/redmine/trunk@15695 e93f8b46-1217-0410-a6f0-8f06a7374b81
parent 7b1e9e67
......@@ -46,7 +46,7 @@
<% end %>
<% content_for :sidebar do %>
<%= form_tag({}, :method => :get) do %>
<%= form_tag({}, :method => :get, :id => 'activity_scope_form') do %>
<h3><%= l(:label_activity) %></h3>
<ul>
<% @activity.event_types.each do |t| %>
......
......@@ -35,7 +35,7 @@
</tr></thead>
<tbody>
<% @topics.each do |topic| %>
<tr class="message <%= cycle 'odd', 'even' %> <%= topic.sticky? ? 'sticky' : '' %> <%= topic.locked? ? 'locked' : '' %>">
<tr id="message-<%= topic.id %>" class="message <%= cycle 'odd', 'even' %> <%= topic.sticky? ? 'sticky' : '' %> <%= topic.locked? ? 'locked' : '' %>">
<td class="subject"><%= link_to topic.subject, board_message_path(@board, topic) %></td>
<td class="author"><%= link_to_user(topic.author) %></td>
<td class="created_on"><%= format_time(topic.created_on) %></td>
......
......@@ -3,6 +3,7 @@
<% if @conflict_journals.present? %>
<div class="conflict-details">
<% @conflict_journals.sort_by(&:id).each do |journal| %>
<div class="conflict-journal">
<p><%= authoring journal.created_on, journal.user, :label => :label_updated_time_by %></p>
<% if journal.details.any? %>
<ul class="details">
......@@ -14,6 +15,7 @@
<div class="wiki">
<%= textilizable(journal, :notes) unless journal.notes.blank? %>
</div>
</div>
<% end %>
</div>
<% end %>
......
......@@ -47,6 +47,13 @@ module Redmine
formats.map {|format| [::I18n.t(format.label), format.name] }.sort_by(&:first)
end
# Returns an array of formats that can be used for a custom field class
def self.formats_for_custom_field_class(klass=nil)
all.values.select do |format|
format.class.customized_class_names.nil? || format.class.customized_class_names.include?(klass.name)
end
end
class Base
include Singleton
include Redmine::I18n
......
......@@ -111,9 +111,8 @@ class AccountControllerOpenidTest < Redmine::ControllerTest
post :login, :openid_url => 'http://openid.example.com/good_user'
assert_response :success
assert_template 'register'
assert assigns(:user)
assert_equal 'http://openid.example.com/good_user', assigns(:user)[:identity_url]
assert_select 'input[name=?][value=?]', 'user[identity_url]', 'http://openid.example.com/good_user'
end
def test_login_with_openid_with_new_user_with_missing_information_should_register
......@@ -121,9 +120,6 @@ class AccountControllerOpenidTest < Redmine::ControllerTest
post :login, :openid_url => 'http://openid.example.com/good_blank_user'
assert_response :success
assert_template 'register'
assert assigns(:user)
assert_equal 'http://openid.example.com/good_blank_user', assigns(:user)[:identity_url]
assert_select 'input[name=?]', 'user[login]'
assert_select 'input[name=?]', 'user[password]'
......
......@@ -27,7 +27,6 @@ class AccountControllerTest < Redmine::ControllerTest
def test_get_login
get :login
assert_response :success
assert_template 'login'
assert_select 'input[name=username]'
assert_select 'input[name=password]'
......@@ -131,7 +130,6 @@ class AccountControllerTest < Redmine::ControllerTest
def test_login_with_wrong_password
post :login, :username => 'admin', :password => 'bad'
assert_response :success
assert_template 'login'
assert_select 'div.flash.error', :text => /Invalid user or password/
assert_select 'input[name=username][value=admin]'
......@@ -190,7 +188,6 @@ class AccountControllerTest < Redmine::ControllerTest
@request.session[:user_id] = 2
get :logout
assert_response :success
assert_template 'logout'
assert_equal 2, @request.session[:user_id]
end
......@@ -219,8 +216,6 @@ class AccountControllerTest < Redmine::ControllerTest
with_settings :self_registration => '3' do
get :register
assert_response :success
assert_template 'register'
assert_not_nil assigns(:user)
assert_select 'input[name=?]', 'user[password]'
assert_select 'input[name=?]', 'user[password_confirmation]'
......@@ -232,8 +227,7 @@ class AccountControllerTest < Redmine::ControllerTest
@request.env['HTTP_ACCEPT_LANGUAGE'] = 'fr,fr-fr;q=0.8,en-us;q=0.5,en;q=0.3'
get :register
assert_response :success
assert_not_nil assigns(:user)
assert_equal 'fr', assigns(:user).language
assert_select 'select[name=?]', 'user[language]' do
assert_select 'option[value=fr][selected=selected]'
end
......@@ -387,7 +381,6 @@ class AccountControllerTest < Redmine::ControllerTest
get :lost_password, :token => token.value
assert_response :success
assert_template 'password_recovery'
assert_select 'input[type=hidden][name=token][value=?]', token.value
end
......@@ -429,7 +422,6 @@ class AccountControllerTest < Redmine::ControllerTest
post :lost_password, :token => token.value, :new_password => 'newpass', :new_password_confirmation => 'wrongpass'
assert_response :success
assert_template 'password_recovery'
assert_not_nil Token.find_by_id(token.id), "Token was deleted"
assert_select 'input[type=hidden][name=token][value=?]', token.value
......
......@@ -32,8 +32,6 @@ class ActivitiesControllerTest < Redmine::ControllerTest
def test_project_index
get :index, :id => 1, :with_subprojects => 0
assert_response :success
assert_template 'index'
assert_not_nil assigns(:events_by_day)
assert_select 'h3', :text => /#{2.days.ago.to_date.day}/
assert_select 'dl dt.issue-edit a', :text => /(#{IssueStatus.find(2).name})/
......@@ -47,8 +45,6 @@ class ActivitiesControllerTest < Redmine::ControllerTest
def test_previous_project_index
get :index, :id => 1, :from => 2.days.ago.to_date
assert_response :success
assert_template 'index'
assert_not_nil assigns(:events_by_day)
assert_select 'h3', :text => /#{3.days.ago.to_date.day}/
assert_select 'dl dt.issue a', :text => /Cannot print recipes/
......@@ -58,8 +54,6 @@ class ActivitiesControllerTest < Redmine::ControllerTest
@request.session[:user_id] = 1
get :index
assert_response :success
assert_template 'index'
assert_not_nil assigns(:events_by_day)
i5 = Issue.find(5)
d5 = User.find(1).time_to_date(i5.created_on)
......@@ -72,8 +66,6 @@ class ActivitiesControllerTest < Redmine::ControllerTest
@request.session[:user_id] = 1
get :index, :user_id => 2
assert_response :success
assert_template 'index'
assert_not_nil assigns(:events_by_day)
assert_select 'h2 a[href="/users/2"]', :text => 'John Smith'
......@@ -92,7 +84,6 @@ class ActivitiesControllerTest < Redmine::ControllerTest
def test_index_atom_feed
get :index, :format => 'atom', :with_subprojects => 0
assert_response :success
assert_template 'common/feed'
assert_select 'feed' do
assert_select 'link[rel=self][href=?]', 'http://test.host/activity.atom?with_subprojects=0'
......@@ -115,7 +106,6 @@ class ActivitiesControllerTest < Redmine::ControllerTest
:show_wiki_edits => 1
assert_response :success
assert_template 'common/feed'
assert_select 'feed' do
assert_select 'link[rel=self][href=?]', 'http://test.host/activity.atom?show_changesets=1&show_documents=1&show_files=1&show_issues=1&show_messages=1&show_news=1&show_time_entries=1&show_wiki_edits=1&with_subprojects=0'
......@@ -130,7 +120,6 @@ class ActivitiesControllerTest < Redmine::ControllerTest
with_settings :default_language => 'en' do
get :index, :format => 'atom', :show_issues => '1'
assert_response :success
assert_template 'common/feed'
assert_select 'title', :text => /Issues/
end
......@@ -140,22 +129,21 @@ class ActivitiesControllerTest < Redmine::ControllerTest
get :index, :user_id => 2, :format => 'atom'
assert_response :success
assert_template 'common/feed'
assert_select 'title', :text => "Redmine: #{User.find(2).name}"
end
def test_index_should_show_private_notes_with_permission_only
journal = Journal.create!(:journalized => Issue.find(2), :notes => 'Private notes with searchkeyword', :private_notes => true)
journal = Journal.create!(:journalized => Issue.find(2), :notes => 'Private notes', :private_notes => true)
@request.session[:user_id] = 2
get :index
assert_response :success
assert_include journal, assigns(:events_by_day).values.flatten
assert_select 'dl', :text => /Private notes/
Role.find(1).remove_permission! :view_private_notes
get :index
assert_response :success
assert_not_include journal, assigns(:events_by_day).values.flatten
assert_select 'dl', :text => /Private notes/, :count => 0
end
def test_index_with_submitted_scope_should_save_as_preference
......@@ -174,6 +162,11 @@ class ActivitiesControllerTest < Redmine::ControllerTest
get :index
assert_response :success
assert_equal %w(issues news), assigns(:activity).scope
assert_select '#activity_scope_form' do
assert_select 'input[checked=checked]', 2
assert_select 'input[name=show_issues][checked=checked]'
assert_select 'input[name=show_news][checked=checked]'
end
end
end
......@@ -39,29 +39,21 @@ class AdminControllerTest < Redmine::ControllerTest
def test_projects
get :projects
assert_response :success
assert_template 'projects'
assert_not_nil assigns(:projects)
# active projects only
assert_nil assigns(:projects).detect {|u| !u.active?}
assert_select 'tr.project.closed', 0
end
def test_projects_with_status_filter
get :projects, :status => 1
assert_response :success
assert_template 'projects'
assert_not_nil assigns(:projects)
# active projects only
assert_nil assigns(:projects).detect {|u| !u.active?}
assert_select 'tr.project.closed', 0
end
def test_projects_with_name_filter
get :projects, :name => 'store', :status => ''
assert_response :success
assert_template 'projects'
projects = assigns(:projects)
assert_not_nil projects
assert_equal 1, projects.size
assert_equal 'OnlineStore', projects.first.name
assert_select 'tr.project td.name', :text => 'OnlineStore'
assert_select 'tr.project', 1
end
def test_load_default_configuration_data
......@@ -107,8 +99,7 @@ class AdminControllerTest < Redmine::ControllerTest
get :plugins
assert_response :success
assert_template 'plugins'
assert_equal [], assigns(:plugins)
assert_select '.nodata'
end
def test_plugins
......@@ -125,7 +116,6 @@ class AdminControllerTest < Redmine::ControllerTest
get :plugins
assert_response :success
assert_template 'plugins'
assert_select 'tr#plugin-foo' do
assert_select 'td span.name', :text => 'Foo plugin'
......@@ -140,7 +130,6 @@ class AdminControllerTest < Redmine::ControllerTest
def test_info
get :info
assert_response :success
assert_template 'info'
end
def test_admin_menu_plugin_extension
......
......@@ -38,7 +38,7 @@ class AttachmentsControllerTest < Redmine::ControllerTest
# 060719210727_changeset_utf8.diff
get :show, :id => 14, :type => dt
assert_response :success
assert_template 'diff'
assert_equal 'text/html', @response.content_type
assert_select 'th.filename', :text => /issues_controller.rb\t\(révision 1484\)/
assert_select 'td.line-code', :text => /Demande créée avec succès/
......@@ -52,7 +52,7 @@ class AttachmentsControllerTest < Redmine::ControllerTest
# 060719210727_changeset_iso8859-1.diff
get :show, :id => 5, :type => dt
assert_response :success
assert_template 'diff'
assert_equal 'text/html', @response.content_type
assert_select 'th.filename', :text => /issues_controller.rb\t\(r\?vision 1484\)/
assert_select 'td.line-code', :text => /Demande cr\?\?e avec succ\?s/
......@@ -67,7 +67,7 @@ class AttachmentsControllerTest < Redmine::ControllerTest
# 060719210727_changeset_iso8859-1.diff
get :show, :id => 5, :type => dt
assert_response :success
assert_template 'diff'
assert_equal 'text/html', @response.content_type
assert_select 'th.filename', :text => /issues_controller.rb\t\(révision 1484\)/
assert_select 'td.line-code', :text => /Demande créée avec succès/
......@@ -82,16 +82,15 @@ class AttachmentsControllerTest < Redmine::ControllerTest
user1.preference.save
user = User.find(1)
assert_nil user.pref[:diff_type]
@request.session[:user_id] = 1 # admin
get :show, :id => 5
assert_response :success
assert_template 'diff'
user.reload
assert_equal "inline", user.pref[:diff_type]
get :show, :id => 5, :type => 'sbs'
assert_response :success
assert_template 'diff'
user.reload
assert_equal "sbs", user.pref[:diff_type]
end
......@@ -106,7 +105,6 @@ class AttachmentsControllerTest < Redmine::ControllerTest
get :show, :id => a.id, :type => 'inline'
assert_response :success
assert_template 'diff'
assert_equal 'text/html', @response.content_type
assert_select 'th.filename', :text => 'test1.txt'
end
......@@ -114,7 +112,6 @@ class AttachmentsControllerTest < Redmine::ControllerTest
def test_show_text_file
get :show, :id => 4
assert_response :success
assert_template 'file'
assert_equal 'text/html', @response.content_type
set_tmp_attachments_directory
end
......@@ -131,7 +128,6 @@ class AttachmentsControllerTest < Redmine::ControllerTest
get :show, :id => a.id
assert_response :success
assert_template 'file'
assert_equal 'text/html', @response.content_type
assert_select 'tr#L1' do
assert_select 'th.line-num', :text => '1'
......@@ -150,7 +146,6 @@ class AttachmentsControllerTest < Redmine::ControllerTest
get :show, :id => a.id
assert_response :success
assert_template 'file'
assert_equal 'text/html', @response.content_type
assert_select 'tr#L7' do
assert_select 'th.line-num', :text => '7'
......@@ -170,7 +165,6 @@ class AttachmentsControllerTest < Redmine::ControllerTest
get :show, :id => a.id
assert_response :success
assert_template 'file'
assert_equal 'text/html', @response.content_type
assert_select 'tr#L7' do
assert_select 'th.line-num', :text => '7'
......@@ -180,12 +174,13 @@ class AttachmentsControllerTest < Redmine::ControllerTest
end
def test_show_text_file_should_show_other_if_too_big
@request.session[:user_id] = 2
with_settings :file_max_size_displayed => 512 do
Attachment.find(4).update_attribute :filesize, 754.kilobyte
get :show, :id => 4
assert_response :success
assert_template 'other'
assert_equal 'text/html', @response.content_type
assert_select '.nodata', :text => 'No preview available'
end
set_tmp_attachments_directory
end
......@@ -194,14 +189,13 @@ class AttachmentsControllerTest < Redmine::ControllerTest
@request.session[:user_id] = 2
get :show, :id => 16
assert_response :success
assert_template 'image'
assert_equal 'text/html', @response.content_type
assert_select 'img.filecontent', :src => attachments(:attachments_010).filename
end
def test_show_other
@request.session[:user_id] = 2
get :show, :id => 6
assert_template 'other'
assert_equal 'text/html', @response.content_type
assert_select '.nodata', :text => 'No preview available'
set_tmp_attachments_directory
......@@ -351,13 +345,12 @@ class AttachmentsControllerTest < Redmine::ControllerTest
@request.session[:user_id] = 2
get :edit, :object_type => 'issues', :object_id => '2'
assert_response :success
assert_template 'edit'
container = Issue.find(2)
assert_equal container, assigns(:container)
assert_equal container.attachments.size, assigns(:attachments).size
assert_select 'form[action=?]', '/attachments/issues/2' do
Issue.find(2).attachments.each do |attachment|
assert_select "tr#attachment-#{attachment.id}"
end
assert_select 'tr#attachment-4' do
assert_select 'input[name=?][value=?]', 'attachments[4][filename]', 'source.rb'
assert_select 'input[name=?][value=?]', 'attachments[4][description]', 'This is a Ruby source file'
......@@ -401,7 +394,6 @@ class AttachmentsControllerTest < Redmine::ControllerTest
}
assert_response :success
assert_template 'edit'
assert_select_error /file cannot be blank/i
# The other attachment should not be updated
......
......@@ -26,21 +26,12 @@ class AuthSourcesControllerTest < Redmine::ControllerTest
def test_index
get :index
assert_response :success
assert_template 'index'
assert_not_nil assigns(:auth_sources)
end
def test_new
get :new
assert_response :success
assert_template 'new'
source = assigns(:auth_source)
assert_equal AuthSourceLdap, source.class
assert source.new_record?
assert_select 'form#auth_source_form' do
assert_select 'input[name=type][value=AuthSourceLdap]'
......@@ -72,16 +63,13 @@ class AuthSourcesControllerTest < Redmine::ControllerTest
:auth_source => {:name => 'Test', :host => '',
:port => '389', :attr_login => 'cn'}
assert_response :success
assert_template 'new'
end
assert_select_error /host cannot be blank/i
end
def test_edit
get :edit, :id => 1
assert_response :success
assert_template 'edit'
assert_select 'form#auth_source_form' do
assert_select 'input[name=?]', 'auth_source[host]'
......@@ -117,7 +105,6 @@ class AuthSourcesControllerTest < Redmine::ControllerTest
:auth_source => {:name => 'Renamed', :host => '',
:port => '389', :attr_login => 'uid'}
assert_response :success
assert_template 'edit'
assert_select_error /host cannot be blank/i
end
......
......@@ -31,49 +31,43 @@ class AutoCompletesControllerTest < Redmine::ControllerTest
def test_issues_should_not_be_case_sensitive
get :issues, :project_id => 'ecookbook', :q => 'ReCiPe'
assert_response :success
assert_not_nil assigns(:issues)
assert assigns(:issues).detect {|issue| issue.subject.match /recipe/}
assert_include "recipe", response.body
end
def test_issues_should_accept_term_param
get :issues, :project_id => 'ecookbook', :term => 'ReCiPe'
assert_response :success
assert_not_nil assigns(:issues)
assert assigns(:issues).detect {|issue| issue.subject.match /recipe/}
assert_include "recipe", response.body
end
def test_issues_should_return_issue_with_given_id
get :issues, :project_id => 'subproject1', :q => '13'
assert_response :success
assert_not_nil assigns(:issues)
assert assigns(:issues).include?(Issue.find(13))
assert_include "Bug #13", response.body
end
def test_issues_should_return_issue_with_given_id_preceded_with_hash
get :issues, :project_id => 'subproject1', :q => '#13'
assert_response :success
assert_not_nil assigns(:issues)
assert assigns(:issues).include?(Issue.find(13))
assert_include "Bug #13", response.body
end
def test_auto_complete_with_scope_all_should_search_other_projects
get :issues, :project_id => 'ecookbook', :q => '13', :scope => 'all'
assert_response :success
assert_not_nil assigns(:issues)
assert assigns(:issues).include?(Issue.find(13))
assert_include "Bug #13", response.body
end
def test_auto_complete_without_project_should_search_all_projects
get :issues, :q => '13'
assert_response :success
assert_not_nil assigns(:issues)
assert assigns(:issues).include?(Issue.find(13))
assert_include "Bug #13", response.body
end
def test_auto_complete_without_scope_all_should_not_search_other_projects
get :issues, :project_id => 'ecookbook', :q => '13'
assert_response :success
assert_equal [], assigns(:issues)
assert_not_include "Bug #13", response.body
end
def test_issues_should_return_json
......
......@@ -27,9 +27,7 @@ class BoardsControllerTest < Redmine::ControllerTest
def test_index
get :index, :project_id => 1
assert_response :success
assert_template 'index'
assert_not_nil assigns(:boards)
assert_not_nil assigns(:project)
assert_select 'table.boards'
end
def test_index_not_found
......@@ -42,17 +40,18 @@ class BoardsControllerTest < Redmine::ControllerTest
get :index, :project_id => 1
assert_response :success
assert_template 'show'
assert_not_nil assigns(:topics)
assert_select 'table.boards', 0
assert_select 'table.messages'
end
def test_show
get :show, :project_id => 1, :id => 1
assert_response :success
assert_template 'show'
assert_not_nil assigns(:board)
assert_not_nil assigns(:project)
assert_not_nil assigns(:topics)
assert_select 'table.messages tbody' do
assert_select 'tr', Board.find(1).topics.count
end
end
def test_show_should_display_sticky_messages_first
......@@ -62,11 +61,12 @@ class BoardsControllerTest < Redmine::ControllerTest
get :show, :project_id => 1, :id => 1
assert_response :success
topics = assigns(:topics)
assert_not_nil topics
assert topics.size > 1, "topics size was #{topics.size}"
assert topics.first.sticky?
assert topics.first.updated_on < topics.second.updated_on
assert_select 'table.messages tbody' do
# row is here...
assert_select 'tr.sticky'
# ...and in first position
assert_select 'tr.sticky:first-child'
end
end
def test_show_should_display_message_with_last_reply_first
......@@ -79,16 +79,17 @@ class BoardsControllerTest < Redmine::ControllerTest
get :show, :project_id => 1, :id => 1
assert_response :success
topics = assigns(:topics)
assert_not_nil topics
assert_equal old_topic, topics.first
assert_select 'table.messages tbody' do
assert_select "tr#message-#{old_topic.id}"
assert_select "tr#message-#{old_topic.id}:first-child"
end
end
def test_show_with_permission_should_display_the_new_message_form
@request.session[:user_id] = 2
get :show, :project_id => 1, :id => 1
assert_response :success
assert_template 'show'
assert_select 'form#message-form' do
assert_select 'input[name=?]', 'message[subject]'
......@@ -98,10 +99,8 @@ class BoardsControllerTest < Redmine::ControllerTest
def test_show_atom
get :show, :project_id => 1, :id => 1, :format => 'atom'
assert_response :success
assert_template 'common/feed'
assert_not_nil assigns(:board)