summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--app/views/activities/index.html.erb2
-rw-r--r--app/views/boards/show.html.erb2
-rw-r--r--app/views/issues/_conflict.html.erb2
-rw-r--r--lib/redmine/field_format.rb7
-rw-r--r--test/functional/account_controller_openid_test.rb8
-rw-r--r--test/functional/account_controller_test.rb10
-rw-r--r--test/functional/activities_controller_test.rb25
-rw-r--r--test/functional/admin_controller_test.rb23
-rw-r--r--test/functional/attachments_controller_test.rb32
-rw-r--r--test/functional/auth_sources_controller_test.rb13
-rw-r--r--test/functional/auto_completes_controller_test.rb20
-rw-r--r--test/functional/boards_controller_test.rb45
-rw-r--r--test/functional/calendars_controller_test.rb7
-rw-r--r--test/functional/context_menus_controller_test.rb23
-rw-r--r--test/functional/custom_field_enumerations_controller_test.rb10
-rw-r--r--test/functional/custom_fields_controller_test.rb40
-rw-r--r--test/functional/documents_controller_test.rb10
-rw-r--r--test/functional/email_addresses_controller_test.rb7
-rw-r--r--test/functional/enumerations_controller_test.rb12
-rw-r--r--test/functional/files_controller_test.rb7
-rw-r--r--test/functional/gantts_controller_test.rb22
-rw-r--r--test/functional/groups_controller_test.rb13
-rw-r--r--test/functional/imports_controller_test.rb13
-rw-r--r--test/functional/issue_categories_controller_test.rb12
-rw-r--r--test/functional/issue_relations_controller_test.rb12
-rw-r--r--test/functional/issue_statuses_controller_test.rb8
-rw-r--r--test/functional/issues_controller_test.rb500
-rw-r--r--test/functional/issues_controller_transaction_test.rb20
-rw-r--r--test/functional/issues_custom_fields_visibility_test.rb6
-rw-r--r--test/functional/journals_controller_test.rb18
-rw-r--r--test/functional/members_controller_test.rb4
-rw-r--r--test/test_helper.rb23
32 files changed, 358 insertions, 598 deletions
diff --git a/app/views/activities/index.html.erb b/app/views/activities/index.html.erb
index 8f5cd08e6..033ae3cb6 100644
--- a/app/views/activities/index.html.erb
+++ b/app/views/activities/index.html.erb
@@ -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| %>
diff --git a/app/views/boards/show.html.erb b/app/views/boards/show.html.erb
index a9734318a..b032a5939 100644
--- a/app/views/boards/show.html.erb
+++ b/app/views/boards/show.html.erb
@@ -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>
diff --git a/app/views/issues/_conflict.html.erb b/app/views/issues/_conflict.html.erb
index c13ace665..ea4c35d7d 100644
--- a/app/views/issues/_conflict.html.erb
+++ b/app/views/issues/_conflict.html.erb
@@ -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 %>
diff --git a/lib/redmine/field_format.rb b/lib/redmine/field_format.rb
index 3385989ac..f6b120dc4 100644
--- a/lib/redmine/field_format.rb
+++ b/lib/redmine/field_format.rb
@@ -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
diff --git a/test/functional/account_controller_openid_test.rb b/test/functional/account_controller_openid_test.rb
index 6e6723e5b..b76e4bca2 100644
--- a/test/functional/account_controller_openid_test.rb
+++ b/test/functional/account_controller_openid_test.rb
@@ -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]'
diff --git a/test/functional/account_controller_test.rb b/test/functional/account_controller_test.rb
index 3ef771f56..37a67d475 100644
--- a/test/functional/account_controller_test.rb
+++ b/test/functional/account_controller_test.rb
@@ -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
diff --git a/test/functional/activities_controller_test.rb b/test/functional/activities_controller_test.rb
index fa3e44abf..5aacf6228 100644
--- a/test/functional/activities_controller_test.rb
+++ b/test/functional/activities_controller_test.rb
@@ -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
diff --git a/test/functional/admin_controller_test.rb b/test/functional/admin_controller_test.rb
index 4752fb389..70a8ca683 100644
--- a/test/functional/admin_controller_test.rb
+++ b/test/functional/admin_controller_test.rb
@@ -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
diff --git a/test/functional/attachments_controller_test.rb b/test/functional/attachments_controller_test.rb
index 08c31078a..66039cf67 100644
--- a/test/functional/attachments_controller_test.rb
+++ b/test/functional/attachments_controller_test.rb
@@ -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
diff --git a/test/functional/auth_sources_controller_test.rb b/test/functional/auth_sources_controller_test.rb
index 521fcf817..1ad829655 100644
--- a/test/functional/auth_sources_controller_test.rb
+++ b/test/functional/auth_sources_controller_test.rb
@@ -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
diff --git a/test/functional/auto_completes_controller_test.rb b/test/functional/auto_completes_controller_test.rb
index 48a1c7758..5360eac9b 100644
--- a/test/functional/auto_completes_controller_test.rb
+++ b/test/functional/auto_completes_controller_test.rb
@@ -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
diff --git a/test/functional/boards_controller_test.rb b/test/functional/boards_controller_test.rb
index d6c8e89f8..dcb32d708 100644
--- a/test/functional/boards_controller_test.rb
+++ b/test/functional/boards_controller_test.rb
@@ -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)
- assert_not_nil assigns(:project)
- assert_not_nil assigns(:messages)
+
+ assert_select 'feed > entry > title', :text => 'Help: RE: post 2'
end
def test_show_not_found
@@ -113,7 +112,6 @@ class BoardsControllerTest < Redmine::ControllerTest
@request.session[:user_id] = 2
get :new, :project_id => 1
assert_response :success
- assert_template 'new'
assert_select 'select[name=?]', 'board[parent_id]' do
assert_select 'option', (Project.find(1).boards.size + 1)
@@ -132,7 +130,6 @@ class BoardsControllerTest < Redmine::ControllerTest
get :new, :project_id => 1
assert_response :success
- assert_template 'new'
assert_select 'select[name=?]', 'board[parent_id]', 0
end
diff --git a/test/functional/calendars_controller_test.rb b/test/functional/calendars_controller_test.rb
index becf11945..453e51e23 100644
--- a/test/functional/calendars_controller_test.rb
+++ b/test/functional/calendars_controller_test.rb
@@ -34,22 +34,19 @@ class CalendarsControllerTest < Redmine::ControllerTest
def test_show
get :show, :project_id => 1
assert_response :success
- assert_template :partial => '_calendar'
- assert_not_nil assigns(:calendar)
end
def test_show_should_run_custom_queries
- @query = IssueQuery.create!(:name => 'Calendar', :visibility => IssueQuery::VISIBILITY_PUBLIC)
+ @query = IssueQuery.create!(:name => 'Calendar Query', :visibility => IssueQuery::VISIBILITY_PUBLIC)
get :show, :query_id => @query.id
assert_response :success
+ assert_select 'h2', :text => 'Calendar Query'
end
def test_cross_project_calendar
get :show
assert_response :success
- assert_template :partial => '_calendar'
- assert_not_nil assigns(:calendar)
end
def test_week_number_calculation
diff --git a/test/functional/context_menus_controller_test.rb b/test/functional/context_menus_controller_test.rb
index c674e5d97..58ca8d094 100644
--- a/test/functional/context_menus_controller_test.rb
+++ b/test/functional/context_menus_controller_test.rb
@@ -37,7 +37,6 @@ class ContextMenusControllerTest < Redmine::ControllerTest
@request.session[:user_id] = 2
get :issues, :ids => [1]
assert_response :success
- assert_template 'context_menus/issues'
assert_select 'a.icon-edit[href=?]', '/issues/1/edit', :text => 'Edit'
assert_select 'a.icon-copy[href=?]', '/projects/ecookbook/issues/1/copy', :text => 'Copy'
@@ -59,7 +58,7 @@ class ContextMenusControllerTest < Redmine::ControllerTest
with_settings :default_language => 'en' do
get :issues, :ids => [1]
assert_response :success
- assert_template 'context_menus/issues'
+
assert_select 'a.icon-del.disabled[href="#"]', :text => 'Delete'
end
end
@@ -68,11 +67,8 @@ class ContextMenusControllerTest < Redmine::ControllerTest
@request.session[:user_id] = 2
get :issues, :ids => [1, 2]
assert_response :success
- assert_template 'context_menus/issues'
- assert_not_nil assigns(:issues)
- assert_equal [1, 2], assigns(:issues).map(&:id).sort
- ids = assigns(:issues).map(&:id).sort.map {|i| "ids%5B%5D=#{i}"}.join('&')
+ ids = [1, 2].map {|i| "ids%5B%5D=#{i}"}.join('&')
assert_select 'a.icon-edit[href=?]', "/issues/bulk_edit?#{ids}", :text => 'Edit'
assert_select 'a.icon-copy[href=?]', "/issues/bulk_edit?copy=1&#{ids}", :text => 'Copy'
@@ -87,11 +83,8 @@ class ContextMenusControllerTest < Redmine::ControllerTest
@request.session[:user_id] = 2
get :issues, :ids => [1, 2, 6]
assert_response :success
- assert_template 'context_menus/issues'
- assert_not_nil assigns(:issues)
- assert_equal [1, 2, 6], assigns(:issues).map(&:id).sort
- ids = assigns(:issues).map(&:id).sort.map {|i| "ids%5B%5D=#{i}"}.join('&')
+ ids = [1, 2, 6].map {|i| "ids%5B%5D=#{i}"}.join('&')
assert_select 'a.icon-edit[href=?]', "/issues/bulk_edit?#{ids}", :text => 'Edit'
assert_select 'a.icon-del[href=?]', "/issues?#{ids}", :text => 'Delete'
@@ -214,7 +207,6 @@ class ContextMenusControllerTest < Redmine::ControllerTest
@request.session[:user_id] = 2
get :issues, :ids => [1]
assert_response :success
- assert_template 'context_menus/issues'
assert_select 'a[href=?]', '/issues/bulk_update?ids%5B%5D=1&issue%5Bassigned_to_id%5D=2', :text => / me /
end
@@ -225,9 +217,7 @@ class ContextMenusControllerTest < Redmine::ControllerTest
get :issues, :ids => [1, 4]
assert_response :success
- assert_template 'context_menus/issues'
- assert_include version, assigns(:versions)
assert_select 'a', :text => 'eCookbook - Shared'
end
@@ -245,7 +235,6 @@ class ContextMenusControllerTest < Redmine::ControllerTest
@request.session[:user_id] = 2
get :time_entries, :ids => [1, 2]
assert_response :success
- assert_template 'context_menus/time_entries'
assert_select 'a:not(.disabled)', :text => 'Edit'
end
@@ -254,7 +243,6 @@ class ContextMenusControllerTest < Redmine::ControllerTest
@request.session[:user_id] = 2
get :time_entries, :ids => [1]
assert_response :success
- assert_template 'context_menus/time_entries'
assert_select 'a:not(.disabled)', :text => 'Edit'
end
@@ -265,6 +253,7 @@ class ContextMenusControllerTest < Redmine::ControllerTest
@request.session[:user_id] = 2
get :time_entries, :ids => [1, 2]
assert_response :success
+
assert_select "li.cf_#{field.id}" do
assert_select 'a[href="#"]', :text => "Field"
assert_select 'ul' do
@@ -284,7 +273,7 @@ class ContextMenusControllerTest < Redmine::ControllerTest
get :time_entries, :ids => ids
assert_response :success
- assert_template 'context_menus/time_entries'
+
assert_select 'a:not(.disabled)', :text => 'Edit'
end
@@ -294,7 +283,7 @@ class ContextMenusControllerTest < Redmine::ControllerTest
get :time_entries, :ids => [1, 2]
assert_response :success
- assert_template 'context_menus/time_entries'
+
assert_select 'a.disabled', :text => 'Edit'
end
end
diff --git a/test/functional/custom_field_enumerations_controller_test.rb b/test/functional/custom_field_enumerations_controller_test.rb
index c9fa39621..539600125 100644
--- a/test/functional/custom_field_enumerations_controller_test.rb
+++ b/test/functional/custom_field_enumerations_controller_test.rb
@@ -32,7 +32,10 @@ class CustomFieldEnumerationsControllerTest < Redmine::ControllerTest
def test_index
get :index, :custom_field_id => @field.id
assert_response :success
- assert_template 'index'
+
+ assert_select 'ul#custom_field_enumerations' do
+ assert_select 'li', 2
+ end
end
def test_create
@@ -91,8 +94,9 @@ class CustomFieldEnumerationsControllerTest < Redmine::ControllerTest
assert_no_difference 'CustomFieldEnumeration.count' do
delete :destroy, :custom_field_id => @field.id, :id => @foo.id
- assert_response 200
- assert_template 'destroy'
+ assert_response :success
+
+ assert_select 'select[name=?]', 'reassign_to_id'
end
end
diff --git a/test/functional/custom_fields_controller_test.rb b/test/functional/custom_fields_controller_test.rb
index b8d67b7b4..f13e7d0f8 100644
--- a/test/functional/custom_fields_controller_test.rb
+++ b/test/functional/custom_fields_controller_test.rb
@@ -38,27 +38,28 @@ class CustomFieldsControllerTest < Redmine::ControllerTest
def test_index
get :index
assert_response :success
- assert_template 'index'
+
+ assert_select 'table.custom_fields'
end
def test_new_without_type_should_render_select_type
get :new
assert_response :success
- assert_template 'select_type'
+
assert_select 'input[name=type]', CustomFieldsHelper::CUSTOM_FIELDS_TABS.size
assert_select 'input[name=type][checked=checked]', 1
end
def test_new_should_work_for_each_customized_class_and_format
custom_field_classes.each do |klass|
- Redmine::FieldFormat.available_formats.each do |format_name|
- get :new, :type => klass.name, :custom_field => {:field_format => format_name}
+ Redmine::FieldFormat.formats_for_custom_field_class(klass).each do |format|
+ get :new, :type => klass.name, :custom_field => {:field_format => format.name}
assert_response :success
- assert_template 'new'
- assert_kind_of klass, assigns(:custom_field)
- assert_equal format_name, assigns(:custom_field).format.name
+
assert_select 'form#custom_field_form' do
- assert_select 'select#custom_field_field_format[name=?]', 'custom_field[field_format]'
+ assert_select 'select[name=?]', 'custom_field[field_format]' do
+ assert_select 'option[value=?][selected=selected]', format.name
+ end
assert_select 'input[type=hidden][name=type][value=?]', klass.name
end
end
@@ -68,13 +69,16 @@ class CustomFieldsControllerTest < Redmine::ControllerTest
def test_new_should_have_string_default_format
get :new, :type => 'IssueCustomField'
assert_response :success
- assert_equal 'string', assigns(:custom_field).format.name
+
+ assert_select 'select[name=?]', 'custom_field[field_format]' do
+ assert_select 'option[value=?][selected=selected]', 'string'
+ end
end
def test_new_issue_custom_field
get :new, :type => 'IssueCustomField'
assert_response :success
- assert_template 'new'
+
assert_select 'form#custom_field_form' do
assert_select 'select#custom_field_field_format[name=?]', 'custom_field[field_format]' do
assert_select 'option[value=user]', :text => 'User'
@@ -89,7 +93,7 @@ class CustomFieldsControllerTest < Redmine::ControllerTest
def test_new_time_entry_custom_field_should_not_show_trackers_and_projects
get :new, :type => 'TimeEntryCustomField'
assert_response :success
- assert_template 'new'
+
assert_select 'form#custom_field_form' do
assert_select 'input[name=?]', 'custom_field[tracker_ids][]', 0
assert_select 'input[name=?]', 'custom_field[project_ids][]', 0
@@ -125,17 +129,16 @@ class CustomFieldsControllerTest < Redmine::ControllerTest
def test_new_js
xhr :get, :new, :type => 'IssueCustomField', :custom_field => {:field_format => 'list'}, :format => 'js'
assert_response :success
- assert_template 'new'
assert_equal 'text/javascript', response.content_type
- field = assigns(:custom_field)
- assert_equal 'list', field.field_format
+ assert_include '<option selected=\"selected\" value=\"list\">List<\/option>', response.body
end
def test_new_with_invalid_custom_field_class_should_render_select_type
get :new, :type => 'UnknownCustomField'
assert_response :success
- assert_template 'select_type'
+
+ assert_select 'input[type=radio][name=type]'
end
def test_create_list_custom_field
@@ -176,7 +179,7 @@ class CustomFieldsControllerTest < Redmine::ControllerTest
post :create, :type => "IssueCustomField", :custom_field => {:name => ''}
end
assert_response :success
- assert_template 'new'
+ assert_select_error /name cannot be blank/i
end
def test_create_without_type_should_render_select_type
@@ -184,13 +187,12 @@ class CustomFieldsControllerTest < Redmine::ControllerTest
post :create, :custom_field => {:name => ''}
end
assert_response :success
- assert_template 'select_type'
+ assert_select 'input[type=radio][name=type]'
end
def test_edit
get :edit, :id => 1
assert_response :success
- assert_template 'edit'
assert_select 'input[name=?][value=?]', 'custom_field[name]', 'Database'
end
@@ -210,7 +212,7 @@ class CustomFieldsControllerTest < Redmine::ControllerTest
def test_update_with_failure
put :update, :id => 1, :custom_field => {:name => ''}
assert_response :success
- assert_template 'edit'
+ assert_select_error /name cannot be blank/i
end
def test_destroy
diff --git a/test/functional/documents_controller_test.rb b/test/functional/documents_controller_test.rb
index 94ba46cd9..ad1e6b567 100644
--- a/test/functional/documents_controller_test.rb
+++ b/test/functional/documents_controller_test.rb
@@ -33,8 +33,6 @@ class DocumentsControllerTest < Redmine::ControllerTest
get :index, :project_id => 'ecookbook'
assert_response :success
- assert_template 'index'
- assert_not_nil assigns(:grouped)
# Default category selected in the new document form
assert_select 'select[name=?]', 'document[category_id]' do
@@ -74,7 +72,6 @@ LOREM
get :index, :project_id => 'ecookbook'
assert_response :success
- assert_template 'index'
# should only truncate on new lines to avoid breaking wiki formatting
assert_select '.wiki p', :text => (doc.description.split("\n").first + '...')
@@ -84,14 +81,12 @@ LOREM
def test_show
get :show, :id => 1
assert_response :success
- assert_template 'show'
end
def test_new
@request.session[:user_id] = 2
get :new, :project_id => 1
assert_response :success
- assert_template 'new'
end
def test_create_with_one_attachment
@@ -122,7 +117,7 @@ LOREM
post :create, :project_id => 'ecookbook', :document => { :title => ''}
end
assert_response :success
- assert_template 'new'
+ assert_select_error /title cannot be blank/i
end
def test_create_non_default_category
@@ -146,7 +141,6 @@ LOREM
@request.session[:user_id] = 2
get :edit, :id => 1
assert_response :success
- assert_template 'edit'
end
def test_update
@@ -161,7 +155,7 @@ LOREM
@request.session[:user_id] = 2
put :update, :id => 1, :document => {:title => ''}
assert_response :success
- assert_template 'edit'
+ assert_select_error /title cannot be blank/i
end
def test_destroy
diff --git a/test/functional/email_addresses_controller_test.rb b/test/functional/email_addresses_controller_test.rb
index c18862d59..b6dda82da 100644
--- a/test/functional/email_addresses_controller_test.rb
+++ b/test/functional/email_addresses_controller_test.rb
@@ -28,7 +28,6 @@ class EmailAddressesControllerTest < Redmine::ControllerTest
@request.session[:user_id] = 2
get :index, :user_id => 2
assert_response :success
- assert_template 'index'
end
def test_index_with_additional_emails
@@ -37,7 +36,6 @@ class EmailAddressesControllerTest < Redmine::ControllerTest
get :index, :user_id => 2
assert_response :success
- assert_template 'index'
assert_select '.email', :text => 'another@somenet.foo'
end
@@ -47,7 +45,6 @@ class EmailAddressesControllerTest < Redmine::ControllerTest
xhr :get, :index, :user_id => 2
assert_response :success
- assert_template 'index'
assert_include 'another@somenet.foo', response.body
end
@@ -55,7 +52,6 @@ class EmailAddressesControllerTest < Redmine::ControllerTest
@request.session[:user_id] = 1
get :index, :user_id => 2
assert_response :success
- assert_template 'index'
end
def test_index_by_another_user_should_be_denied
@@ -88,7 +84,8 @@ class EmailAddressesControllerTest < Redmine::ControllerTest
@request.session[:user_id] = 2
assert_no_difference 'EmailAddress.count' do
post :create, :user_id => 2, :email_address => {:address => 'invalid'}
- assert_response 200
+ assert_response :success
+ assert_select_error /email is invalid/i
end
end
diff --git a/test/functional/enumerations_controller_test.rb b/test/functional/enumerations_controller_test.rb
index 4c499e8aa..b44f3f4d1 100644
--- a/test/functional/enumerations_controller_test.rb
+++ b/test/functional/enumerations_controller_test.rb
@@ -27,7 +27,7 @@ class EnumerationsControllerTest < Redmine::ControllerTest
def test_index
get :index
assert_response :success
- assert_template 'index'
+ assert_select 'table.enumerations'
end
def test_index_should_require_admin
@@ -39,8 +39,7 @@ class EnumerationsControllerTest < Redmine::ControllerTest
def test_new
get :new, :type => 'IssuePriority'
assert_response :success
- assert_template 'new'
- assert_kind_of IssuePriority, assigns(:enumeration)
+
assert_select 'input[name=?][value=?]', 'enumeration[type]', 'IssuePriority'
assert_select 'input[name=?]', 'enumeration[name]'
end
@@ -64,13 +63,12 @@ class EnumerationsControllerTest < Redmine::ControllerTest
post :create, :enumeration => {:type => 'IssuePriority', :name => ''}
end
assert_response :success
- assert_template 'new'
+ assert_select_error /name cannot be blank/i
end
def test_edit
get :edit, :id => 6
assert_response :success
- assert_template 'edit'
assert_select 'input[name=?][value=?]', 'enumeration[name]', 'High'
end
@@ -93,7 +91,7 @@ class EnumerationsControllerTest < Redmine::ControllerTest
put :update, :id => 6, :enumeration => {:type => 'IssuePriority', :name => ''}
end
assert_response :success
- assert_template 'edit'
+ assert_select_error /name cannot be blank/i
end
def test_destroy_enumeration_not_in_use
@@ -109,7 +107,7 @@ class EnumerationsControllerTest < Redmine::ControllerTest
delete :destroy, :id => 4
end
assert_response :success
- assert_template 'destroy'
+
assert_not_nil Enumeration.find_by_id(4)
assert_select 'select[name=reassign_to_id]' do
assert_select 'option[value="6"]', :text => 'High'
diff --git a/test/functional/files_controller_test.rb b/test/functional/files_controller_test.rb
index 23231ff49..a24187db5 100644
--- a/test/functional/files_controller_test.rb
+++ b/test/functional/files_controller_test.rb
@@ -39,8 +39,6 @@ class FilesControllerTest < Redmine::ControllerTest
def test_index
get :index, :project_id => 1
assert_response :success
- assert_template 'index'
- assert_not_nil assigns(:containers)
# file attached to the project
assert_select 'a[href=?]', '/attachments/download/8/project_file.zip', :text => 'project_file.zip'
@@ -53,7 +51,6 @@ class FilesControllerTest < Redmine::ControllerTest
@request.session[:user_id] = 2
get :new, :project_id => 1
assert_response :success
- assert_template 'new'
assert_select 'select[name=?]', 'version_id'
end
@@ -63,7 +60,6 @@ class FilesControllerTest < Redmine::ControllerTest
@request.session[:user_id] = 2
get :new, :project_id => 1
assert_response :success
- assert_template 'new'
assert_select 'select[name=?]', 'version_id', 0
end
@@ -112,8 +108,7 @@ class FilesControllerTest < Redmine::ControllerTest
assert_no_difference 'Attachment.count' do
post :create, :project_id => 1, :version_id => ''
- assert_response 200
- assert_template 'new'
+ assert_response :success
end
assert_select 'div.error', 'File is invalid'
end
diff --git a/test/functional/gantts_controller_test.rb b/test/functional/gantts_controller_test.rb
index ef38f53bc..abb9ca10b 100644
--- a/test/functional/gantts_controller_test.rb
+++ b/test/functional/gantts_controller_test.rb
@@ -32,8 +32,7 @@ class GanttsControllerTest < Redmine::ControllerTest
i2.update_attribute(:due_date, 1.month.from_now)
get :show, :project_id => 1
assert_response :success
- assert_template 'gantts/show'
- assert_not_nil assigns(:gantt)
+
# Issue with start and due dates
i = Issue.find(1)
assert_not_nil i.due_date
@@ -46,21 +45,19 @@ class GanttsControllerTest < Redmine::ControllerTest
def test_gantt_at_minimal_zoom
get :show, :project_id => 1, :zoom => 1
assert_response :success
- assert_equal 1, assigns(:gantt).zoom
+ assert_select 'input[type=hidden][name=zoom][value=?]', '1'
end
def test_gantt_at_maximal_zoom
get :show, :project_id => 1, :zoom => 4
assert_response :success
- assert_equal 4, assigns(:gantt).zoom
+ assert_select 'input[type=hidden][name=zoom][value=?]', '4'
end
def test_gantt_should_work_without_issue_due_dates
Issue.update_all("due_date = NULL")
get :show, :project_id => 1
assert_response :success
- assert_template 'gantts/show'
- assert_not_nil assigns(:gantt)
end
def test_gantt_should_work_without_issue_and_version_due_dates
@@ -68,23 +65,17 @@ class GanttsControllerTest < Redmine::ControllerTest
Version.update_all("effective_date = NULL")
get :show, :project_id => 1
assert_response :success
- assert_template 'gantts/show'
- assert_not_nil assigns(:gantt)
end
def test_gantt_should_work_cross_project
get :show
assert_response :success
- assert_template 'gantts/show'
- assert_not_nil assigns(:gantt)
- assert_not_nil assigns(:gantt).query
- assert_nil assigns(:gantt).project
end
def test_gantt_should_not_disclose_private_projects
get :show
assert_response :success
- assert_template 'gantts/show'
+
assert_select 'a', :text => /eCookbook/
# Root private project
assert_select 'a', :text => /OnlineStore/, :count => 0
@@ -101,9 +92,6 @@ class GanttsControllerTest < Redmine::ControllerTest
get :show
assert_response :success
- relations = assigns(:gantt).relations
- assert_kind_of Hash, relations
- assert relations.present?
assert_select 'div.task_todo[id=?][data-rels*=?]', "task-todo-issue-#{issue1.id}", issue2.id.to_s
assert_select 'div.task_todo[id=?]:not([data-rels])', "task-todo-issue-#{issue2.id}"
end
@@ -113,7 +101,6 @@ class GanttsControllerTest < Redmine::ControllerTest
assert_response :success
assert_equal 'application/pdf', @response.content_type
assert @response.body.starts_with?('%PDF')
- assert_not_nil assigns(:gantt)
end
def test_gantt_should_export_to_pdf_cross_project
@@ -121,7 +108,6 @@ class GanttsControllerTest < Redmine::ControllerTest
assert_response :success
assert_equal 'application/pdf', @response.content_type
assert @response.body.starts_with?('%PDF')
- assert_not_nil assigns(:gantt)
end
if Object.const_defined?(:Magick)
diff --git a/test/functional/groups_controller_test.rb b/test/functional/groups_controller_test.rb
index 680a18d6a..481460a06 100644
--- a/test/functional/groups_controller_test.rb
+++ b/test/functional/groups_controller_test.rb
@@ -27,7 +27,7 @@ class GroupsControllerTest < Redmine::ControllerTest
def test_index
get :index
assert_response :success
- assert_template 'index'
+ assert_select 'table.groups'
end
def test_index_should_show_user_count
@@ -39,7 +39,6 @@ class GroupsControllerTest < Redmine::ControllerTest
def test_show
get :show, :id => 10
assert_response :success
- assert_template 'show'
end
def test_show_invalid_should_return_404
@@ -50,7 +49,6 @@ class GroupsControllerTest < Redmine::ControllerTest
def test_new
get :new
assert_response :success
- assert_template 'new'
assert_select 'input[name=?]', 'group[name]'
end
@@ -78,13 +76,12 @@ class GroupsControllerTest < Redmine::ControllerTest
post :create, :group => {:name => ''}
end
assert_response :success
- assert_template 'new'
+ assert_select_error /Name cannot be blank/i
end
def test_edit
get :edit, :id => 10
assert_response :success
- assert_template 'edit'
assert_select 'div#tab-content-users'
assert_select 'div#tab-content-memberships' do
@@ -103,7 +100,7 @@ class GroupsControllerTest < Redmine::ControllerTest
def test_update_with_failure
put :update, :id => 10, :group => {:name => ''}
assert_response :success
- assert_template 'edit'
+ assert_select_error /Name cannot be blank/i
end
def test_destroy
@@ -116,7 +113,7 @@ class GroupsControllerTest < Redmine::ControllerTest
def test_new_users
get :new_users, :id => 10
assert_response :success
- assert_template 'new_users'
+ assert_select 'input[name=?]', 'user_search'
end
def test_xhr_new_users
@@ -135,7 +132,6 @@ class GroupsControllerTest < Redmine::ControllerTest
assert_difference 'Group.find(10).users.count', 2 do
xhr :post, :add_users, :id => 10, :user_ids => ['2', '3']
assert_response :success
- assert_template 'add_users'
assert_equal 'text/javascript', response.content_type
end
assert_match /John Smith/, response.body
@@ -151,7 +147,6 @@ class GroupsControllerTest < Redmine::ControllerTest
assert_difference 'Group.find(10).users.count', -1 do
xhr :delete, :remove_user, :id => 10, :user_id => '8'
assert_response :success
- assert_template 'remove_user'
assert_equal 'text/javascript', response.content_type
end
end
diff --git a/test/functional/imports_controller_test.rb b/test/functional/imports_controller_test.rb
index 526e9e874..3b271b0ce 100644
--- a/test/functional/imports_controller_test.rb
+++ b/test/functional/imports_controller_test.rb
@@ -44,7 +44,6 @@ class ImportsControllerTest < Redmine::ControllerTest
def test_new_should_display_the_upload_form
get :new
assert_response :success
- assert_template 'new'
assert_select 'input[name=?]', 'file'
end
@@ -62,7 +61,10 @@ class ImportsControllerTest < Redmine::ControllerTest
import = generate_import
get :settings, :id => import.to_param
assert_response :success
- assert_template 'settings'
+ assert_select 'select[name=?]', 'import_settings[separator]'
+ assert_select 'select[name=?]', 'import_settings[wrapper]'
+ assert_select 'select[name=?]', 'import_settings[encoding]'
+ assert_select 'select[name=?]', 'import_settings[date_format]'
end
def test_post_settings_should_update_settings
@@ -107,7 +109,6 @@ class ImportsControllerTest < Redmine::ControllerTest
get :mapping, :id => import.to_param
assert_response :success
- assert_template 'mapping'
assert_select 'select[name=?]', 'import_settings[mapping][subject]' do
assert_select 'option', 4
@@ -139,7 +140,7 @@ class ImportsControllerTest < Redmine::ControllerTest
get :run, :id => import
assert_response :success
- assert_template 'run'
+ assert_select '#import-progress'
end
def test_post_run_should_import_the_file
@@ -183,7 +184,7 @@ class ImportsControllerTest < Redmine::ControllerTest
get :show, :id => import.to_param
assert_response :success
- assert_template 'show'
+
assert_select 'ul#saved-items'
assert_select 'ul#saved-items li', import.saved_items.count
assert_select 'table#unsaved-items', 0
@@ -197,7 +198,7 @@ class ImportsControllerTest < Redmine::ControllerTest
get :show, :id => import.to_param
assert_response :success
- assert_template 'show'
+
assert_select 'table#unsaved-items'
assert_select 'table#unsaved-items tbody tr', import.unsaved_items.count
end
diff --git a/test/functional/issue_categories_controller_test.rb b/test/functional/issue_categories_controller_test.rb
index 51092859a..908d4d1c5 100644
--- a/test/functional/issue_categories_controller_test.rb
+++ b/test/functional/issue_categories_controller_test.rb
@@ -30,7 +30,6 @@ class IssueCategoriesControllerTest < Redmine::ControllerTest
@request.session[:user_id] = 2 # manager
get :new, :project_id => '1'
assert_response :success
- assert_template 'new'
assert_select 'input[name=?]', 'issue_category[name]'
end
@@ -39,7 +38,6 @@ class IssueCategoriesControllerTest < Redmine::ControllerTest
xhr :get, :new, :project_id => '1'
assert_response :success
- assert_template 'new'
assert_equal 'text/javascript', response.content_type
end
@@ -58,7 +56,7 @@ class IssueCategoriesControllerTest < Redmine::ControllerTest
@request.session[:user_id] = 2
post :create, :project_id => '1', :issue_category => {:name => ''}
assert_response :success
- assert_template 'new'
+ assert_select_error /Name cannot be blank/i
end
def test_create_from_issue_form
@@ -70,7 +68,6 @@ class IssueCategoriesControllerTest < Redmine::ControllerTest
assert_equal 'New category', category.name
assert_response :success
- assert_template 'create'
assert_equal 'text/javascript', response.content_type
end
@@ -81,15 +78,14 @@ class IssueCategoriesControllerTest < Redmine::ControllerTest
end
assert_response :success
- assert_template 'new'
assert_equal 'text/javascript', response.content_type
+ assert_include 'Name cannot be blank', response.body
end
def test_edit
@request.session[:user_id] = 2
get :edit, :id => 2
assert_response :success
- assert_template 'edit'
assert_select 'input[name=?][value=?]', 'issue_category[name]', 'Recipes'
end
@@ -104,7 +100,7 @@ class IssueCategoriesControllerTest < Redmine::ControllerTest
def test_update_failure
put :update, :id => 2, :issue_category => { :name => '' }
assert_response :success
- assert_template 'edit'
+ assert_select_error /Name cannot be blank/i
end
def test_update_not_found
@@ -121,8 +117,8 @@ class IssueCategoriesControllerTest < Redmine::ControllerTest
def test_destroy_category_in_use
delete :destroy, :id => 1
assert_response :success
- assert_template 'destroy'
assert_not_nil IssueCategory.find_by_id(1)
+ assert_select 'select[name=?]', 'reassign_to_id'
end
def test_destroy_category_in_use_with_reassignment
diff --git a/test/functional/issue_relations_controller_test.rb b/test/functional/issue_relations_controller_test.rb
index ca0e81571..f740e2234 100644
--- a/test/functional/issue_relations_controller_test.rb
+++ b/test/functional/issue_relations_controller_test.rb
@@ -59,14 +59,13 @@ class IssueRelationsControllerTest < Redmine::ControllerTest
assert_difference 'IssueRelation.count' do
xhr :post, :create, :issue_id => 3, :relation => {:issue_to_id => '1', :relation_type => 'relates', :delay => ''}
assert_response :success
- assert_template 'create'
assert_equal 'text/javascript', response.content_type
end
relation = IssueRelation.order('id DESC').first
assert_equal 3, relation.issue_from_id
assert_equal 1, relation.issue_to_id
- assert_match /Bug #1/, response.body
+ assert_include 'Bug #1', response.body
end
def test_create_should_accept_id_with_hash
@@ -104,7 +103,7 @@ class IssueRelationsControllerTest < Redmine::ControllerTest
xhr :post, :create, :issue_id => issue2.id,
:relation => {:issue_to_id => issue1.id, :relation_type => 'follows', :delay => ''}
end
- assert_match /Followed issue/, response.body
+ assert_include 'Followed issue', response.body
end
def test_should_create_relations_with_visible_issues_only
@@ -122,11 +121,9 @@ class IssueRelationsControllerTest < Redmine::ControllerTest
xhr :post, :create, :issue_id => 3, :relation => {:issue_to_id => '999', :relation_type => 'relates', :delay => ''}
assert_response :success
- assert_template 'create'
assert_equal 'text/javascript', response.content_type
end
-
- assert_match /errorExplanation/, response.body
+ assert_include 'Related issue cannot be blank', response.body
end
def test_destroy
@@ -152,9 +149,8 @@ class IssueRelationsControllerTest < Redmine::ControllerTest
xhr :delete, :destroy, :id => '2'
assert_response :success
- assert_template 'destroy'
assert_equal 'text/javascript', response.content_type
- assert_match /relation-2/, response.body
+ assert_include 'relation-2', response.body
end
end
end
diff --git a/test/functional/issue_statuses_controller_test.rb b/test/functional/issue_statuses_controller_test.rb
index 34074a786..047576705 100644
--- a/test/functional/issue_statuses_controller_test.rb
+++ b/test/functional/issue_statuses_controller_test.rb
@@ -28,7 +28,7 @@ class IssueStatusesControllerTest < Redmine::ControllerTest
def test_index
get :index
assert_response :success
- assert_template 'index'
+ assert_select 'table.issue_statuses'
end
def test_index_by_anonymous_should_redirect_to_login_form
@@ -46,7 +46,7 @@ class IssueStatusesControllerTest < Redmine::ControllerTest
def test_new
get :new
assert_response :success
- assert_template 'new'
+ assert_select 'input[name=?]', 'issue_status[name]'
end
def test_create
@@ -61,14 +61,13 @@ class IssueStatusesControllerTest < Redmine::ControllerTest
def test_create_with_failure
post :create, :issue_status => {:name => ''}
assert_response :success
- assert_template 'new'
assert_select_error /name cannot be blank/i
end
def test_edit
get :edit, :id => '3'
assert_response :success
- assert_template 'edit'
+ assert_select 'input[name=?][value=?]', 'issue_status[name]', 'Resolved'
end
def test_update
@@ -81,7 +80,6 @@ class IssueStatusesControllerTest < Redmine::ControllerTest
def test_update_with_failure
put :update, :id => '3', :issue_status => {:name => ''}
assert_response :success
- assert_template 'edit'
assert_select_error /name cannot be blank/i
end
diff --git a/test/functional/issues_controller_test.rb b/test/functional/issues_controller_test.rb
index bf84302b8..142ccc356 100644
--- a/test/functional/issues_controller_test.rb
+++ b/test/functional/issues_controller_test.rb
@@ -55,9 +55,6 @@ class IssuesControllerTest < Redmine::ControllerTest
with_settings :default_language => "en" do
get :index
assert_response :success
- assert_template 'index'
- assert_not_nil assigns(:issues)
- assert_nil assigns(:project)
# links to visible issues
assert_select 'a[href="/issues/1"]', :text => /Cannot print recipes/
@@ -74,9 +71,6 @@ class IssuesControllerTest < Redmine::ControllerTest
EnabledModule.where("name = 'issue_tracking' AND project_id = 1").delete_all
get :index
assert_response :success
- assert_template 'index'
- assert_not_nil assigns(:issues)
- assert_nil assigns(:project)
assert_select 'a[href="/issues/1"]', 0
assert_select 'a[href="/issues/5"]', :text => /Subproject issue/
@@ -85,16 +79,16 @@ class IssuesControllerTest < Redmine::ControllerTest
def test_index_should_list_visible_issues_only
get :index, :per_page => 100
assert_response :success
- assert_not_nil assigns(:issues)
- assert_nil assigns(:issues).detect {|issue| !issue.visible?}
+
+ Issue.open.each do |issue|
+ assert_select "tr#issue-#{issue.id}", issue.visible? ? 1 : 0
+ end
end
def test_index_with_project
Setting.display_subprojects_issues = 0
get :index, :project_id => 1
assert_response :success
- assert_template 'index'
- assert_not_nil assigns(:issues)
assert_select 'a[href="/issues/1"]', :text => /Cannot print recipes/
assert_select 'a[href="/issues/5"]', 0
@@ -104,8 +98,6 @@ class IssuesControllerTest < Redmine::ControllerTest
Setting.display_subprojects_issues = 1
get :index, :project_id => 1
assert_response :success
- assert_template 'index'
- assert_not_nil assigns(:issues)
assert_select 'a[href="/issues/1"]', :text => /Cannot print recipes/
assert_select 'a[href="/issues/5"]', :text => /Subproject issue/
@@ -117,8 +109,6 @@ class IssuesControllerTest < Redmine::ControllerTest
Setting.display_subprojects_issues = 1
get :index, :project_id => 1
assert_response :success
- assert_template 'index'
- assert_not_nil assigns(:issues)
assert_select 'a[href="/issues/1"]', :text => /Cannot print recipes/
assert_select 'a[href="/issues/5"]', :text => /Subproject issue/
@@ -128,13 +118,9 @@ class IssuesControllerTest < Redmine::ControllerTest
def test_index_with_project_and_default_filter
get :index, :project_id => 1, :set_filter => 1
assert_response :success
- assert_template 'index'
- assert_not_nil assigns(:issues)
- query = assigns(:query)
- assert_not_nil query
# default filter
- assert_equal({'status_id' => {:operator => 'o', :values => ['']}}, query.filters)
+ assert_query_filters [['status_id', 'o', '']]
end
def test_index_with_project_and_filter
@@ -143,12 +129,8 @@ class IssuesControllerTest < Redmine::ControllerTest
:op => {'tracker_id' => '='},
:v => {'tracker_id' => ['1']}
assert_response :success
- assert_template 'index'
- assert_not_nil assigns(:issues)
- query = assigns(:query)
- assert_not_nil query
- assert_equal({'tracker_id' => {:operator => '=', :values => ['1']}}, query.filters)
+ assert_query_filters [['tracker_id', '=', '1']]
end
def test_index_with_short_filters
@@ -208,15 +190,10 @@ class IssuesControllerTest < Redmine::ControllerTest
expression_and_expected.each do |filter_expression, expected|
get :index, :set_filter => 1, field => filter_expression
-
assert_response :success
- assert_template 'index'
- assert_not_nil assigns(:issues)
- query = assigns(:query)
- assert_not_nil query
- assert query.has_filter?(field)
- assert_equal(default_filter.merge({field => {:operator => expected[:op], :values => expected[:values]}}), query.filters)
+ expected_with_default = default_filter.merge({field => {:operator => expected[:op], :values => expected[:values]}})
+ assert_query_filters expected_with_default.map {|f, v| [f, v[:operator], v[:values]]}
end
end
end
@@ -224,13 +201,9 @@ class IssuesControllerTest < Redmine::ControllerTest
def test_index_with_project_and_empty_filters
get :index, :project_id => 1, :set_filter => 1, :fields => ['']
assert_response :success
- assert_template 'index'
- assert_not_nil assigns(:issues)
- query = assigns(:query)
- assert_not_nil query
# no filter
- assert_equal({}, query.filters)
+ assert_query_filters []
end
def test_index_with_project_custom_field_filter
@@ -243,58 +216,46 @@ class IssuesControllerTest < Redmine::ControllerTest
get :index, :set_filter => 1,
:f => [filter_name],
:op => {filter_name => '='},
- :v => {filter_name => ['Foo']}
+ :v => {filter_name => ['Foo']},
+ :c => ['project']
assert_response :success
- assert_template 'index'
- assert_equal [3, 5], assigns(:issues).map(&:project_id).uniq.sort
+
+ assert_equal [3, 5], issues_in_list.map(&:project_id).uniq.sort
end
def test_index_with_query
get :index, :project_id => 1, :query_id => 5
assert_response :success
- assert_template 'index'
- assert_not_nil assigns(:issues)
- assert_nil assigns(:issue_count_by_group)
end
def test_index_with_query_grouped_by_tracker
get :index, :project_id => 1, :query_id => 6
assert_response :success
- assert_template 'index'
- assert_not_nil assigns(:issues)
- assert_not_nil assigns(:issue_count_by_group)
+ assert_select 'tr.group span.count'
end
def test_index_with_query_grouped_and_sorted_by_category
get :index, :project_id => 1, :set_filter => 1, :group_by => "category", :sort => "category"
assert_response :success
- assert_template 'index'
- assert_not_nil assigns(:issues)
- assert_not_nil assigns(:issue_count_by_group)
+ assert_select 'tr.group span.count'
end
def test_index_with_query_grouped_and_sorted_by_fixed_version
get :index, :project_id => 1, :set_filter => 1, :group_by => "fixed_version", :sort => "fixed_version"
assert_response :success
- assert_template 'index'
- assert_not_nil assigns(:issues)
- assert_not_nil assigns(:issue_count_by_group)
+ assert_select 'tr.group span.count'
end
def test_index_with_query_grouped_and_sorted_by_fixed_version_in_reverse_order
get :index, :project_id => 1, :set_filter => 1, :group_by => "fixed_version", :sort => "fixed_version:desc"
assert_response :success
- assert_template 'index'
- assert_not_nil assigns(:issues)
- assert_not_nil assigns(:issue_count_by_group)
+ assert_select 'tr.group span.count'
end
def test_index_with_query_grouped_by_list_custom_field
get :index, :project_id => 1, :query_id => 9
assert_response :success
- assert_template 'index'
- assert_not_nil assigns(:issues)
- assert_not_nil assigns(:issue_count_by_group)
+ assert_select 'tr.group span.count'
end
def test_index_with_query_grouped_by_key_value_custom_field
@@ -308,9 +269,6 @@ class IssuesControllerTest < Redmine::ControllerTest
get :index, :project_id => 1, :set_filter => 1, :group_by => "cf_#{cf.id}"
assert_response :success
- assert_template 'index'
- assert_not_nil assigns(:issues)
- assert_not_nil assigns(:issue_count_by_group)
assert_select 'tr.group', 3
assert_select 'tr.group' do
@@ -369,9 +327,9 @@ class IssuesControllerTest < Redmine::ControllerTest
with_settings :default_language => 'en' do
get :index, :project_id => 1, :set_filter => 1, "cf_#{cf.id}" => "*", :group_by => "cf_#{cf.id}"
assert_response :success
- assert_equal [1, 2], assigns(:issues).map(&:id).sort
end
+ assert_equal [1, 2], issues_in_list.map(&:id).sort
assert_select 'tr.group', 1
assert_select 'tr.group', :text => /No/
end
@@ -382,8 +340,8 @@ class IssuesControllerTest < Redmine::ControllerTest
get :index, :set_filter => 1, :group_by => 'tracker', :sort => 'id:desc'
assert_response :success
- trackers = assigns(:issues).map(&:tracker).uniq
- assert_equal [1, 2, 3], trackers.map(&:id)
+ assert_equal ["Bug", "Feature request", "Support request"],
+ css_select("tr.issue td.tracker").map(&:text).uniq
end
def test_index_with_query_grouped_by_tracker_in_reverse_order
@@ -392,8 +350,8 @@ class IssuesControllerTest < Redmine::ControllerTest
get :index, :set_filter => 1, :group_by => 'tracker', :sort => 'id:desc,tracker:desc'
assert_response :success
- trackers = assigns(:issues).map(&:tracker).uniq
- assert_equal [3, 2, 1], trackers.map(&:id)
+ assert_equal ["Bug", "Feature request", "Support request"].reverse,
+ css_select("tr.issue td.tracker").map(&:text).uniq
end
def test_index_with_query_id_and_project_id_should_set_session_query
@@ -410,17 +368,16 @@ class IssuesControllerTest < Redmine::ControllerTest
end
def test_index_with_cross_project_query_in_session_should_show_project_issues
- q = IssueQuery.create!(:name => "test", :user_id => 2, :visibility => IssueQuery::VISIBILITY_PRIVATE, :project => nil)
+ q = IssueQuery.create!(:name => "cross_project_query", :user_id => 2, :project => nil, :column_names => ['project'])
@request.session[:issue_query] = {:id => q.id, :project_id => 1}
with_settings :display_subprojects_issues => '0' do
get :index, :project_id => 1
end
assert_response :success
- assert_not_nil assigns(:query)
- assert_equal q.id, assigns(:query).id
- assert_equal 1, assigns(:query).project_id
- assert_equal [1], assigns(:issues).map(&:project_id).uniq
+
+ assert_select 'h2', :text => q.name
+ assert_equal ["eCookbook"], css_select("tr.issue td.project").map(&:text).uniq
end
def test_private_query_should_not_be_available_to_other_users
@@ -496,17 +453,18 @@ class IssuesControllerTest < Redmine::ControllerTest
def test_index_csv
get :index, :format => 'csv'
assert_response :success
- assert_not_nil assigns(:issues)
+
assert_equal 'text/csv; header=present', @response.content_type
- assert @response.body.starts_with?("#,")
- lines = @response.body.chomp.split("\n")
- assert_equal assigns(:query).columns.size, lines[0].split(',').size
+ assert response.body.starts_with?("#,")
+ lines = response.body.chomp.split("\n")
+ # default columns + id and project
+ assert_equal Setting.issue_list_default_columns.size + 2, lines[0].split(',').size
end
def test_index_csv_with_project
get :index, :project_id => 1, :format => 'csv'
assert_response :success
- assert_not_nil assigns(:issues)
+
assert_equal 'text/csv; header=present', @response.content_type
end
@@ -515,7 +473,8 @@ class IssuesControllerTest < Redmine::ControllerTest
Issue.create!(:project_id => 1, :tracker_id => 1, :status_id => 5, :subject => 'Closed issue', :author_id => 1)
get :index, :set_filter => 1, :f => [], :format => 'csv'
assert_response :success
- assert_equal Issue.count, assigns(:issues).count
+ # -1 for headers
+ assert_equal Issue.count, response.body.chomp.split("\n").size - 1
end
def test_index_csv_with_description
@@ -524,7 +483,6 @@ class IssuesControllerTest < Redmine::ControllerTest
with_settings :default_language => 'en' do
get :index, :format => 'csv', :csv => {:description => '1'}
assert_response :success
- assert_not_nil assigns(:issues)
end
assert_equal 'text/csv; header=present', response.content_type
@@ -547,11 +505,11 @@ class IssuesControllerTest < Redmine::ControllerTest
def test_index_csv_with_all_columns
get :index, :format => 'csv', :csv => {:columns => 'all'}
assert_response :success
- assert_not_nil assigns(:issues)
+
assert_equal 'text/csv; header=present', @response.content_type
assert_match /\A#,/, response.body
lines = response.body.chomp.split("\n")
- assert_equal assigns(:query).available_inline_columns.size, lines[0].split(',').size
+ assert_equal IssueQuery.new.available_inline_columns.size, lines[0].split(',').size
end
def test_index_csv_with_multi_column_field
@@ -680,21 +638,17 @@ class IssuesControllerTest < Redmine::ControllerTest
get :index
assert_response :success
- assert_template 'index'
get :index, :format => 'pdf'
assert_response :success
- assert_not_nil assigns(:issues)
assert_equal 'application/pdf', @response.content_type
get :index, :project_id => 1, :format => 'pdf'
assert_response :success
- assert_not_nil assigns(:issues)
assert_equal 'application/pdf', @response.content_type
get :index, :project_id => 1, :query_id => 6, :format => 'pdf'
assert_response :success
- assert_not_nil assigns(:issues)
assert_equal 'application/pdf', @response.content_type
end
end
@@ -703,15 +657,12 @@ class IssuesControllerTest < Redmine::ControllerTest
def test_index_pdf_with_query_grouped_by_list_custom_field
get :index, :project_id => 1, :query_id => 9, :format => 'pdf'
assert_response :success
- assert_not_nil assigns(:issues)
- assert_not_nil assigns(:issue_count_by_group)
assert_equal 'application/pdf', @response.content_type
end
def test_index_atom
get :index, :project_id => 'ecookbook', :format => 'atom'
assert_response :success
- assert_template 'common/feed'
assert_equal 'application/atom+xml', response.content_type
assert_select 'feed' do
@@ -735,10 +686,7 @@ class IssuesControllerTest < Redmine::ControllerTest
assert sort_params.is_a?(String)
assert_equal 'tracker,id:desc', sort_params
- issues = assigns(:issues)
- assert_not_nil issues
- assert !issues.empty?
- assert_equal issues.sort {|a,b| a.tracker == b.tracker ? b.id <=> a.id : a.tracker <=> b.tracker }.collect(&:id), issues.collect(&:id)
+ assert_equal issues_in_list.sort_by {|issue| [issue.tracker.position, -issue.id]}, issues_in_list
assert_select 'table.issues.sort-by-tracker.sort-asc'
end
@@ -750,7 +698,8 @@ class IssuesControllerTest < Redmine::ControllerTest
def test_index_sort_by_assigned_to
get :index, :sort => 'assigned_to'
assert_response :success
- assignees = assigns(:issues).collect(&:assigned_to).compact
+
+ assignees = issues_in_list.map(&:assigned_to).compact
assert_equal assignees.sort, assignees
assert_select 'table.issues.sort-by-assigned-to.sort-asc'
end
@@ -758,7 +707,8 @@ class IssuesControllerTest < Redmine::ControllerTest
def test_index_sort_by_assigned_to_desc
get :index, :sort => 'assigned_to:desc'
assert_response :success
- assignees = assigns(:issues).collect(&:assigned_to).compact
+
+ assignees = issues_in_list.map(&:assigned_to).compact
assert_equal assignees.sort.reverse, assignees
assert_select 'table.issues.sort-by-assigned-to.sort-desc'
end
@@ -769,16 +719,18 @@ class IssuesControllerTest < Redmine::ControllerTest
end
def test_index_sort_by_author
- get :index, :sort => 'author'
+ get :index, :sort => 'author', :c => ['author']
assert_response :success
- authors = assigns(:issues).collect(&:author)
+
+ authors = issues_in_list.map(&:author)
assert_equal authors.sort, authors
end
-
+
def test_index_sort_by_author_desc
get :index, :sort => 'author:desc'
assert_response :success
- authors = assigns(:issues).collect(&:author)
+
+ authors = issues_in_list.map(&:author)
assert_equal authors.sort.reverse, authors
end
@@ -790,21 +742,21 @@ class IssuesControllerTest < Redmine::ControllerTest
def test_index_sort_by_spent_hours
get :index, :sort => 'spent_hours:desc'
assert_response :success
- hours = assigns(:issues).collect(&:spent_hours)
+ hours = issues_in_list.map(&:spent_hours)
assert_equal hours.sort.reverse, hours
end
def test_index_sort_by_total_spent_hours
get :index, :sort => 'total_spent_hours:desc'
assert_response :success
- hours = assigns(:issues).collect(&:total_spent_hours)
+ hours = issues_in_list.map(&:total_spent_hours)
assert_equal hours.sort.reverse, hours
end
def test_index_sort_by_total_estimated_hours
get :index, :sort => 'total_estimated_hours:desc'
assert_response :success
- hours = assigns(:issues).collect(&:total_estimated_hours)
+ hours = issues_in_list.map(&:total_estimated_hours)
assert_equal hours.sort.reverse, hours
end
@@ -818,7 +770,7 @@ class IssuesControllerTest < Redmine::ControllerTest
get :index, :project_id => 1, :set_filter => 1, :sort => "cf_#{cf.id},id"
assert_response :success
- assert_equal [2, 3, 1], assigns(:issues).select {|issue| issue.custom_field_value(cf).present?}.map(&:id)
+ assert_equal [2, 3, 1], issues_in_list.select {|issue| issue.custom_field_value(cf).present?}.map(&:id)
end
def test_index_with_columns
@@ -826,10 +778,8 @@ class IssuesControllerTest < Redmine::ControllerTest
get :index, :set_filter => 1, :c => columns
assert_response :success
- # query should use specified columns
- query = assigns(:query)
- assert_kind_of IssueQuery, query
- assert_equal columns, query.column_names.map(&:to_s)
+ # query should use specified columns + id and checkbox
+ assert_select 'table.issues thead th', columns.size + 2
# columns should be stored in session
assert_kind_of Hash, session[:issue_query]
@@ -849,9 +799,7 @@ class IssuesControllerTest < Redmine::ControllerTest
get :index, :set_filter => 1
# query should use specified columns
- query = assigns(:query)
- assert_kind_of IssueQuery, query
- assert_equal [:id, :project, :tracker, :subject, :assigned_to], query.columns.map(&:name)
+ assert_equal ["#", "Project", "Tracker", "Subject", "Assignee"], columns_in_issues_list
end
def test_index_without_project_and_explicit_default_columns_should_not_add_project_column
@@ -860,9 +808,7 @@ class IssuesControllerTest < Redmine::ControllerTest
get :index, :set_filter => 1, :c => columns
# query should use specified columns
- query = assigns(:query)
- assert_kind_of IssueQuery, query
- assert_equal columns.map(&:to_sym), query.columns.map(&:name)
+ assert_equal ["#", "Tracker", "Subject", "Assignee"], columns_in_issues_list
end
def test_index_with_default_columns_should_respect_default_columns_order
@@ -870,8 +816,7 @@ class IssuesControllerTest < Redmine::ControllerTest
with_settings :issue_list_default_columns => columns do
get :index, :project_id => 1, :set_filter => 1
- query = assigns(:query)
- assert_equal (['id'] + columns).map(&:to_sym), query.columns.map(&:name)
+ assert_equal ["#", "Assignee", "Subject", "Status", "Tracker"], columns_in_issues_list
end
end
@@ -881,10 +826,7 @@ class IssuesControllerTest < Redmine::ControllerTest
assert_response :success
# query should use specified columns
- query = assigns(:query)
- assert_kind_of IssueQuery, query
- assert_equal columns, query.column_names.map(&:to_s)
-
+ assert_equal ["#", "Tracker", "Subject", "Searchable field"], columns_in_issues_list
assert_select 'table.issues td.cf_2.string'
end
@@ -1081,7 +1023,7 @@ class IssuesControllerTest < Redmine::ControllerTest
def test_index_send_html_if_query_is_invalid
get :index, :f => ['start_date'], :op => {:start_date => '='}
assert_equal 'text/html', @response.content_type
- assert_template 'index'
+ assert_select_error /Start date cannot be blank/i
end
def test_index_send_nothing_if_query_is_invalid
@@ -1169,8 +1111,7 @@ class IssuesControllerTest < Redmine::ControllerTest
def test_show_by_anonymous
get :show, :id => 1
assert_response :success
- assert_template 'show'
- assert_equal Issue.find(1), assigns(:issue)
+
assert_select 'div.issue div.description', :text => /Unable to print recipes/
# anonymous role is allowed to add a note
assert_select 'form#issue-form' do
@@ -1185,7 +1126,7 @@ class IssuesControllerTest < Redmine::ControllerTest
def test_show_by_manager
@request.session[:user_id] = 2
get :show, :id => 1
- assert_response :success
+
assert_select 'a', :text => /Quote/
assert_select 'form#issue-form' do
assert_select 'fieldset' do
@@ -1395,8 +1336,6 @@ class IssuesControllerTest < Redmine::ControllerTest
def test_show_should_not_display_prev_next_links_without_query_in_session
get :show, :id => 1
assert_response :success
- assert_nil assigns(:prev_issue_id)
- assert_nil assigns(:next_issue_id)
assert_select 'div.next-prev-links', 0
end
@@ -1408,14 +1347,11 @@ class IssuesControllerTest < Redmine::ControllerTest
with_settings :display_subprojects_issues => '0' do
get :show, :id => 3
end
-
assert_response :success
- # Previous and next issues for all projects
- assert_equal 2, assigns(:prev_issue_id)
- assert_equal 5, assigns(:next_issue_id)
count = Issue.open.visible.count
+ # Previous and next issues for all projects
assert_select 'div.next-prev-links' do
assert_select 'a[href="/issues/2"]', :text => /Previous/
assert_select 'a[href="/issues/5"]', :text => /Next/
@@ -1430,13 +1366,9 @@ class IssuesControllerTest < Redmine::ControllerTest
@request.session[:query] = {:id => query.id, :project_id => nil}
get :show, :id => 11
-
assert_response :success
- assert_equal query, assigns(:query)
- # Previous and next issues for all projects
- assert_equal 8, assigns(:prev_issue_id)
- assert_equal 12, assigns(:next_issue_id)
+ # Previous and next issues for all projects
assert_select 'div.next-prev-links' do
assert_select 'a[href="/issues/8"]', :text => /Previous/
assert_select 'a[href="/issues/12"]', :text => /Next/
@@ -1465,12 +1397,9 @@ class IssuesControllerTest < Redmine::ControllerTest
with_settings :display_subprojects_issues => '0' do
get :show, :id => 3
end
-
assert_response :success
- # Previous and next issues inside project
- assert_equal 2, assigns(:prev_issue_id)
- assert_equal 7, assigns(:next_issue_id)
+ # Previous and next issues inside project
assert_select 'div.next-prev-links' do
assert_select 'a[href="/issues/2"]', :text => /Previous/
assert_select 'a[href="/issues/7"]', :text => /Next/
@@ -1484,10 +1413,7 @@ class IssuesControllerTest < Redmine::ControllerTest
with_settings :display_subprojects_issues => '0' do
get :show, :id => 1
end
-
assert_response :success
- assert_nil assigns(:prev_issue_id)
- assert_equal 2, assigns(:next_issue_id)
assert_select 'div.next-prev-links' do
assert_select 'a', :text => /Previous/, :count => 0
@@ -1500,10 +1426,7 @@ class IssuesControllerTest < Redmine::ControllerTest
@request.session['issues_index_sort'] = 'id'
get :show, :id => 1
-
assert_response :success
- assert_nil assigns(:prev_issue_id)
- assert_nil assigns(:next_issue_id)
assert_select 'a', :text => /Previous/, :count => 0
assert_select 'a', :text => /Next/, :count => 0
@@ -1523,9 +1446,6 @@ class IssuesControllerTest < Redmine::ControllerTest
get :show, :id => 3
assert_response :success
- assert_equal 2, assigns(:prev_issue_id)
- assert_equal 1, assigns(:next_issue_id)
-
assert_select 'div.next-prev-links' do
assert_select 'a[href="/issues/2"]', :text => /Previous/
assert_select 'a[href="/issues/1"]', :text => /Next/
@@ -1673,18 +1593,18 @@ class IssuesControllerTest < Redmine::ControllerTest
get :show, :id => 2
assert_response :success
- assert_include journal, assigns(:journals)
+ assert_select "#change-#{journal.id}", 1
Role.find(1).remove_permission! :view_private_notes
get :show, :id => 2
assert_response :success
- assert_not_include journal, assigns(:journals)
+ assert_select "#change-#{journal.id}", 0
end
def test_show_atom
get :show, :id => 2, :format => 'atom'
assert_response :success
- assert_template 'journals/index'
+ assert_equal 'application/atom+xml', response.content_type
# Inline image
assert_select 'content', :text => Regexp.new(Regexp.quote('http://test.host/attachments/download/10'))
end
@@ -1696,7 +1616,6 @@ class IssuesControllerTest < Redmine::ControllerTest
assert_response :success
assert_equal 'application/pdf', @response.content_type
assert @response.body.starts_with?('%PDF')
- assert_not_nil assigns(:issue)
end
def test_export_to_pdf_with_utf8_u_fffd
@@ -1710,7 +1629,6 @@ class IssuesControllerTest < Redmine::ControllerTest
assert_response :success
assert_equal 'application/pdf', @response.content_type
assert @response.body.starts_with?('%PDF')
- assert_not_nil assigns(:issue)
end
end
end
@@ -1765,7 +1683,6 @@ class IssuesControllerTest < Redmine::ControllerTest
@request.session[:user_id] = 2
get :new, :project_id => 1, :tracker_id => 1
assert_response :success
- assert_template 'new'
assert_select 'form#issue-form[action=?]', '/projects/ecookbook/issues'
assert_select 'form#issue-form' do
@@ -1801,7 +1718,6 @@ class IssuesControllerTest < Redmine::ControllerTest
@request.session[:user_id] = 2
get :new, :project_id => 1, :tracker_id => 1
assert_response :success
- assert_template 'new'
assert_select 'form#issue-form' do
assert_select 'input[name=?]', 'issue[is_private]', 0
@@ -1827,15 +1743,11 @@ class IssuesControllerTest < Redmine::ControllerTest
@request.session[:user_id] = 2
get :new
assert_response :success
- assert_template 'new'
assert_select 'form#issue-form[action=?]', '/issues'
assert_select 'form#issue-form' do
assert_select 'select[name=?]', 'issue[project_id]'
end
-
- assert_nil assigns(:project)
- assert_not_nil assigns(:issue)
end
def test_new_should_select_default_status
@@ -1843,7 +1755,6 @@ class IssuesControllerTest < Redmine::ControllerTest
get :new, :project_id => 1
assert_response :success
- assert_template 'new'
assert_select 'select[name=?]', 'issue[status_id]' do
assert_select 'option[value="1"][selected=selected]'
end
@@ -1913,7 +1824,6 @@ class IssuesControllerTest < Redmine::ControllerTest
get :new, :project_id => 1
assert_response :success
- assert_equal version, assigns(:issue).fixed_version
assert_select 'select[name=?]', 'issue[fixed_version_id]' do
assert_select 'option[value=?][selected=selected]', version.id.to_s
end
@@ -1923,7 +1833,6 @@ class IssuesControllerTest < Redmine::ControllerTest
@request.session[:user_id] = 2
get :new, :project_id => 1, :tracker_id => 1
assert_response :success
- assert_template 'new'
assert_select 'select.list_cf[name=?]', 'issue[custom_field_values][1]' do
assert_select 'option', 4
@@ -1938,7 +1847,6 @@ class IssuesControllerTest < Redmine::ControllerTest
@request.session[:user_id] = 2
get :new, :project_id => 1, :tracker_id => 1
assert_response :success
- assert_template 'new'
assert_select 'select[name=?][multiple=multiple]', 'issue[custom_field_values][1][]' do
assert_select 'option', 3
@@ -1954,7 +1862,6 @@ class IssuesControllerTest < Redmine::ControllerTest
@request.session[:user_id] = 2
get :new, :project_id => 1, :tracker_id => 1
assert_response :success
- assert_template 'new'
assert_select 'select[name=?][multiple=multiple]', "issue[custom_field_values][#{field.id}][]" do
assert_select 'option', Project.find(1).users.count
@@ -1988,7 +1895,6 @@ class IssuesControllerTest < Redmine::ControllerTest
@request.session[:user_id] = 2
get :new, :project_id => 1, :tracker_id => 1
assert_response :success
- assert_template 'new'
assert_select 'input[name=?]', 'issue[start_date]'
assert_select 'input[name=?][value]', 'issue[start_date]', 0
end
@@ -1999,7 +1905,6 @@ class IssuesControllerTest < Redmine::ControllerTest
@request.session[:user_id] = 2
get :new, :project_id => 1, :tracker_id => 1
assert_response :success
- assert_template 'new'
assert_select 'input[name=?][value=?]', 'issue[start_date]',
Date.today.to_s
end
@@ -2008,6 +1913,7 @@ class IssuesControllerTest < Redmine::ControllerTest
def test_get_new_form_should_allow_attachment_upload
@request.session[:user_id] = 2
get :new, :project_id => 1, :tracker_id => 1
+ assert_response :success
assert_select 'form[id=issue-form][method=post][enctype="multipart/form-data"]' do
assert_select 'input[name=?][type=file]', 'attachments[dummy][file]'
@@ -2019,11 +1925,6 @@ class IssuesControllerTest < Redmine::ControllerTest
get :new, :project_id => 1,
:issue => {:tracker_id => 3, :description => 'Prefilled', :custom_field_values => {'2' => 'Custom field value'}}
- issue = assigns(:issue)
- assert_equal 3, issue.tracker_id
- assert_equal 'Prefilled', issue.description
- assert_equal 'Custom field value', issue.custom_field_value(2)
-
assert_select 'select[name=?]', 'issue[tracker_id]' do
assert_select 'option[value="3"][selected=selected]'
end
@@ -2041,7 +1942,6 @@ class IssuesControllerTest < Redmine::ControllerTest
get :new, :project_id => 1
assert_response :success
- assert_template 'new'
assert_select 'label[for=issue_start_date]' do
assert_select 'span[class=required]', 0
@@ -2067,7 +1967,6 @@ class IssuesControllerTest < Redmine::ControllerTest
get :new, :project_id => 1
assert_response :success
- assert_template 'new'
assert_select 'input[name=?]', 'issue[start_date]'
assert_select 'input[name=?]', 'issue[due_date]', 0
@@ -2084,18 +1983,19 @@ class IssuesControllerTest < Redmine::ControllerTest
get :new, :project_id => 1, :issue => {:status_id => 2}
assert_select 'select[name=?]', 'issue[tracker_id]', 0
- assert_equal 2, assigns(:issue).status_id
+ assert_select 'select[name=?]', 'issue[status_id]' do
+ assert_select 'option[value=?][selected=selected]', '2'
+ end
end
def test_get_new_without_tracker_id
@request.session[:user_id] = 2
get :new, :project_id => 1
assert_response :success
- assert_template 'new'
- issue = assigns(:issue)
- assert_not_nil issue
- assert_equal Project.find(1).trackers.first, issue.tracker
+ assert_select 'select[name=?]', 'issue[tracker_id]' do
+ assert_select 'option[value=?][selected=selected]', Project.find(1).trackers.first.id.to_s
+ end
end
def test_get_new_with_no_default_status_should_display_an_error
@@ -2147,15 +2047,8 @@ class IssuesControllerTest < Redmine::ControllerTest
:description => 'This is the description',
:priority_id => 5}
assert_response :success
- assert_template 'new'
- assert_template :partial => '_form'
assert_equal 'text/javascript', response.content_type
-
- issue = assigns(:issue)
- assert_kind_of Issue, issue
- assert_equal 1, issue.project_id
- assert_equal 2, issue.tracker_id
- assert_equal 'This is the test_new issue', issue.subject
+ assert_include 'This is the test_new issue', response.body
end
def test_update_form_for_new_issue_should_propose_transitions_based_on_initial_status
@@ -2165,13 +2058,16 @@ class IssuesControllerTest < Redmine::ControllerTest
WorkflowTransition.create!(:role_id => 1, :tracker_id => 1, :old_status_id => 0, :new_status_id => 5)
WorkflowTransition.create!(:role_id => 1, :tracker_id => 1, :old_status_id => 5, :new_status_id => 4)
- xhr :post, :new, :project_id => 1,
- :issue => {:tracker_id => 1,
- :status_id => 5,
- :subject => 'This is an issue'}
+ post :new, :project_id => 1,
+ :issue => {:tracker_id => 1,
+ :status_id => 5,
+ :subject => 'This is an issue'}
- assert_equal 5, assigns(:issue).status_id
- assert_equal [2,5], assigns(:allowed_statuses).map(&:id).sort
+ assert_select 'select[name=?]', 'issue[status_id]' do
+ assert_select 'option[value=?][selected=selected]', '5'
+ assert_select 'option[value=?]', '2'
+ assert_select 'option', :count => 2
+ end
end
def test_update_form_with_default_status_should_ignore_submitted_status_id_if_equals
@@ -2180,12 +2076,15 @@ class IssuesControllerTest < Redmine::ControllerTest
tracker.update! :default_status_id => 2
tracker.generate_transitions! 2, 1, :clear => true
- xhr :post, :new, :project_id => 1,
- :issue => {:tracker_id => 2,
- :status_id => 1},
- :was_default_status => 1
+ post :new, :project_id => 1,
+ :issue => {:tracker_id => 2,
+ :status_id => 1},
+ :was_default_status => 1
+ assert_response :success
- assert_equal 2, assigns(:issue).status_id
+ assert_select 'select[name=?]', 'issue[status_id]' do
+ assert_select 'option[value=?][selected=selected]', '2'
+ end
end
def test_update_form_for_new_issue_should_ignore_version_when_changing_project
@@ -2193,15 +2092,17 @@ class IssuesControllerTest < Redmine::ControllerTest
Project.find(1).update_attribute :default_version_id, version.id
@request.session[:user_id] = 2
- xhr :post, :new, :issue => {:project_id => 1,
- :fixed_version_id => ''},
- :form_update_triggered_by => 'issue_project_id'
+ post :new, :issue => {:project_id => 1,
+ :fixed_version_id => ''},
+ :form_update_triggered_by => 'issue_project_id'
assert_response :success
- assert_template 'new'
- issue = assigns(:issue)
- assert_equal 1, issue.project_id
- assert_equal version, issue.fixed_version
+ assert_select 'select[name=?]', 'issue[project_id]' do
+ assert_select 'option[value=?][selected=selected]', '1'
+ end
+ assert_select 'select[name=?]', 'issue[fixed_version_id]' do
+ assert_select 'option[value=?][selected=selected]', version.id.to_s
+ end
end
def test_post_create
@@ -2391,9 +2292,6 @@ class IssuesControllerTest < Redmine::ControllerTest
:priority_id => 5}
end
assert_response :success
- assert_template 'new'
- issue = assigns(:issue)
- assert_not_nil issue
assert_select_error /Database cannot be blank/
end
@@ -2415,7 +2313,6 @@ class IssuesControllerTest < Redmine::ControllerTest
:custom_field_values => {cf1.id.to_s => '', cf2.id.to_s => ''}
}
assert_response :success
- assert_template 'new'
end
assert_select_error /Due date cannot be blank/i
@@ -2440,7 +2337,6 @@ class IssuesControllerTest < Redmine::ControllerTest
:custom_field_values => {cf1.id.to_s => '', cf2.id.to_s => ['']}
}
assert_response :success
- assert_template 'new'
end
assert_select_error /Foo cannot be blank/i
@@ -2648,7 +2544,7 @@ class IssuesControllerTest < Redmine::ControllerTest
end
end
- def test_create_without_project_id_with_failure
+ def test_create_without_project_id_with_failure_should_not_set_project
@request.session[:user_id] = 2
post :create,
@@ -2656,7 +2552,8 @@ class IssuesControllerTest < Redmine::ControllerTest
:tracker_id => 2,
:subject => ''}
assert_response :success
- assert_nil assigns(:project)
+ # no project menu
+ assert_select '#main-menu', 0
end
def test_post_create_should_send_a_notification
@@ -2688,7 +2585,6 @@ class IssuesControllerTest < Redmine::ControllerTest
:priority_id => 6,
:custom_field_values => {'1' => 'Oracle', '2' => 'Value for field 2'}}
assert_response :success
- assert_template 'new'
assert_select 'textarea[name=?]', 'issue[description]', :text => 'This is a description'
assert_select 'select[name=?]', 'issue[priority_id]' do
@@ -2709,7 +2605,6 @@ class IssuesControllerTest < Redmine::ControllerTest
:issue => {:tracker_id => 1,
:watcher_user_ids => ['3', '8']}
assert_response :success
- assert_template 'new'
assert_select 'input[name=?][value="2"]:not(checked)', 'issue[watcher_user_ids][]'
assert_select 'input[name=?][value="3"][checked=checked]', 'issue[watcher_user_ids][]'
@@ -2779,7 +2674,6 @@ class IssuesControllerTest < Redmine::ControllerTest
:issue => { :tracker_id => '1', :subject => '' },
:attachments => {'1' => {'file' => uploaded_test_file('testfile.txt', 'text/plain'), 'description' => 'test file'}}
assert_response :success
- assert_template 'new'
end
end
@@ -2803,7 +2697,6 @@ class IssuesControllerTest < Redmine::ControllerTest
:issue => { :tracker_id => '1', :subject => '' },
:attachments => {'p0' => {'token' => attachment.token}}
assert_response :success
- assert_template 'new'
end
end
@@ -2842,14 +2735,10 @@ class IssuesControllerTest < Redmine::ControllerTest
setup_without_workflow_privilege
get :new, :project_id => 1
assert_response :success
- assert_template 'new'
-
- issue = assigns(:issue)
- assert_not_nil issue.default_status
assert_select 'select[name=?]', 'issue[status_id]' do
assert_select 'option', 1
- assert_select 'option[value=?]', issue.default_status.id.to_s
+ assert_select 'option[value=?][selected=selected]', '1'
end
end
@@ -2944,23 +2833,18 @@ class IssuesControllerTest < Redmine::ControllerTest
end
def test_new_as_copy
+ orig = Issue.find(1)
@request.session[:user_id] = 2
- get :new, :project_id => 1, :copy_from => 1
+ get :new, :project_id => 1, :copy_from => orig.id
assert_response :success
- assert_template 'new'
-
- assert_not_nil assigns(:issue)
- orig = Issue.find(1)
- assert_equal 1, assigns(:issue).project_id
- assert_equal orig.subject, assigns(:issue).subject
- assert assigns(:issue).copy?
assert_select 'form[id=issue-form][action="/projects/ecookbook/issues"]' do
assert_select 'select[name=?]', 'issue[project_id]' do
assert_select 'option[value="1"][selected=selected]', :text => 'eCookbook'
assert_select 'option[value="2"]:not([selected])', :text => 'OnlineStore'
end
+ assert_select 'input[name=?][value=?]', 'issue[subject]', orig.subject
assert_select 'input[name=copy_from][value="1"]'
end
end
@@ -2970,9 +2854,8 @@ class IssuesControllerTest < Redmine::ControllerTest
@request.session[:user_id] = user.id
get :new, :project_id => 1, :copy_from => 1
-
assert_response :success
- assert_template 'new'
+
assert_select 'select[name=?]', 'issue[project_id]' do
assert_select 'option[value="1"]', 0
assert_select 'option[value="2"]', :text => 'OnlineStore'
@@ -3024,9 +2907,6 @@ class IssuesControllerTest < Redmine::ControllerTest
assert_difference 'Issue.count' do
post :create, :project_id => 1, :copy_from => 1,
:issue => {:project_id => '2', :tracker_id => '3', :status_id => '1', :subject => 'Copy'}
-
- assert_not_nil assigns(:issue)
- assert assigns(:issue).copy?
end
issue = Issue.order('id DESC').first
assert_redirected_to "/issues/#{issue.id}"
@@ -3202,10 +3082,6 @@ class IssuesControllerTest < Redmine::ControllerTest
:issue => {:project_id => '2', :tracker_id => '3', :status_id => '1', :subject => ''}
assert_response :success
- assert_template 'new'
-
- assert_not_nil assigns(:issue)
- assert assigns(:issue).copy?
assert_select 'form#issue-form[action="/projects/ecookbook/issues"]' do
assert_select 'select[name=?]', 'issue[project_id]' do
@@ -3232,9 +3108,6 @@ class IssuesControllerTest < Redmine::ControllerTest
@request.session[:user_id] = 2
get :edit, :id => 1
assert_response :success
- assert_template 'edit'
- assert_not_nil assigns(:issue)
- assert_equal Issue.find(1), assigns(:issue)
# Be sure we don't display inactive IssuePriorities
assert ! IssuePriority.find(15).active?
@@ -3264,17 +3137,11 @@ class IssuesControllerTest < Redmine::ControllerTest
get :edit, :id => 1, :issue => { :status_id => 5, :priority_id => 7 },
:time_entry => { :hours => '2.5', :comments => 'test_get_edit_with_params', :activity_id => 10 }
assert_response :success
- assert_template 'edit'
- issue = assigns(:issue)
- assert_not_nil issue
-
- assert_equal 5, issue.status_id
assert_select 'select[name=?]', 'issue[status_id]' do
assert_select 'option[value="5"][selected=selected]', :text => 'Closed'
end
- assert_equal 7, issue.priority_id
assert_select 'select[name=?]', 'issue[priority_id]' do
assert_select 'option[value="7"][selected=selected]', :text => 'Urgent'
end
@@ -3296,7 +3163,6 @@ class IssuesControllerTest < Redmine::ControllerTest
@request.session[:user_id] = 2
get :edit, :id => 1
assert_response :success
- assert_template 'edit'
assert_select 'select[name=?][multiple=multiple]', 'issue[custom_field_values][1][]' do
assert_select 'option', 3
@@ -3315,27 +3181,16 @@ class IssuesControllerTest < Redmine::ControllerTest
:priority_id => 5}
assert_response :success
assert_equal 'text/javascript', response.content_type
- assert_template 'edit'
- assert_template :partial => '_form'
- issue = assigns(:issue)
- assert_kind_of Issue, issue
- assert_equal 1, issue.id
- assert_equal 1, issue.project_id
- assert_equal 2, issue.tracker_id
- assert_equal 'This is the test_new issue', issue.subject
+ assert_include 'This is the test_new issue', response.body
end
def test_update_form_for_existing_issue_should_keep_issue_author
@request.session[:user_id] = 3
- xhr :patch, :edit, :id => 1, :issue => {:subject => 'Changed'}
+ patch :edit, :id => 1, :issue => {:subject => 'Changed'}
assert_response :success
- assert_equal 'text/javascript', response.content_type
- issue = assigns(:issue)
- assert_equal User.find(2), issue.author
- assert_equal 2, issue.author_id
- assert_not_equal User.current, issue.author
+ assert_equal User.find(2), Issue.find(1).author
end
def test_update_form_for_existing_issue_should_propose_transitions_based_on_initial_status
@@ -3345,32 +3200,35 @@ class IssuesControllerTest < Redmine::ControllerTest
WorkflowTransition.create!(:role_id => 1, :tracker_id => 2, :old_status_id => 2, :new_status_id => 5)
WorkflowTransition.create!(:role_id => 1, :tracker_id => 2, :old_status_id => 5, :new_status_id => 4)
- xhr :patch, :edit, :id => 2,
- :issue => {:tracker_id => 2,
- :status_id => 5,
- :subject => 'This is an issue'}
+ patch :edit, :id => 2,
+ :issue => {:tracker_id => 2,
+ :status_id => 5,
+ :subject => 'This is an issue'}
- assert_equal 5, assigns(:issue).status_id
- assert_equal [1,2,5], assigns(:allowed_statuses).map(&:id).sort
+ assert_select 'select[name=?]', 'issue[status_id]' do
+ assert_select 'option[value="1"]'
+ assert_select 'option[value="2"]'
+ assert_select 'option[value="5"][selected=selected]'
+ assert_select 'option', 3
+ end
end
def test_update_form_for_existing_issue_with_project_change
@request.session[:user_id] = 2
- xhr :patch, :edit, :id => 1,
- :issue => {:project_id => 2,
- :tracker_id => 2,
- :subject => 'This is the test_new issue',
- :description => 'This is the description',
- :priority_id => 5}
+ patch :edit, :id => 1,
+ :issue => {:project_id => 2,
+ :tracker_id => 2,
+ :subject => 'This is the test_new issue',
+ :description => 'This is the description',
+ :priority_id => 5}
assert_response :success
- assert_template :partial => '_form'
-
- issue = assigns(:issue)
- assert_kind_of Issue, issue
- assert_equal 1, issue.id
- assert_equal 2, issue.project_id
- assert_equal 2, issue.tracker_id
- assert_equal 'This is the test_new issue', issue.subject
+ assert_select 'select[name=?]', 'issue[project_id]' do
+ assert_select 'option[value="2"][selected=selected]'
+ end
+ assert_select 'select[name=?]', 'issue[tracker_id]' do
+ assert_select 'option[value="2"][selected=selected]'
+ end
+ assert_select 'input[name=?][value=?]', 'issue[subject]', 'This is the test_new issue'
end
def test_update_form_should_keep_category_with_same_when_changing_project
@@ -3382,11 +3240,12 @@ class IssuesControllerTest < Redmine::ControllerTest
@request.session[:user_id] = 1
patch :edit, :id => issue.id,
- :issue => {:project_id => target.id, :category_id => source_category.id}
+ :issue => {:project_id => target.id, :category_id => source_category.id}
assert_response :success
- issue = assigns(:issue)
- assert_equal target_category, issue.category
+ assert_select 'select[name=?]', 'issue[category_id]' do
+ assert_select 'option[value=?][selected=selected]', target_category.id.to_s
+ end
end
def test_update_form_should_propose_default_status_for_existing_issue
@@ -3394,9 +3253,13 @@ class IssuesControllerTest < Redmine::ControllerTest
WorkflowTransition.delete_all
WorkflowTransition.create!(:role_id => 1, :tracker_id => 2, :old_status_id => 2, :new_status_id => 3)
- xhr :patch, :edit, :id => 2
+ patch :edit, :id => 2
assert_response :success
- assert_equal [2,3], assigns(:allowed_statuses).map(&:id).sort
+ assert_select 'select[name=?]', 'issue[status_id]' do
+ assert_select 'option[value="2"]'
+ assert_select 'option[value="3"]'
+ assert_select 'option', 2
+ end
end
def test_put_update_without_custom_fields_param
@@ -3691,7 +3554,6 @@ class IssuesControllerTest < Redmine::ControllerTest
:issue => { :subject => '' },
:attachments => {'1' => {'file' => uploaded_test_file('testfile.txt', 'text/plain'), 'description' => 'test file'}}
assert_response :success
- assert_template 'edit'
end
end
@@ -3715,7 +3577,6 @@ class IssuesControllerTest < Redmine::ControllerTest
:issue => { :subject => '' },
:attachments => {'p0' => {'token' => attachment.token}}
assert_response :success
- assert_template 'edit'
end
end
@@ -3842,7 +3703,6 @@ class IssuesControllerTest < Redmine::ControllerTest
:time_entry => {"comments"=>"", "activity_id"=>"", "hours"=>"2z"}
end
assert_response :success
- assert_template 'edit'
assert_select_error /Activity cannot be blank/
assert_select 'textarea[name=?]', 'issue[notes]', :text => notes
@@ -3860,7 +3720,6 @@ class IssuesControllerTest < Redmine::ControllerTest
:time_entry => {"comments"=>"this is my comment", "activity_id"=>"", "hours"=>""}
end
assert_response :success
- assert_template 'edit'
assert_select_error /Activity cannot be blank/
assert_select_error /Hours cannot be blank/
@@ -3955,7 +3814,6 @@ class IssuesControllerTest < Redmine::ControllerTest
@request.session[:user_id] = 2
get :bulk_edit, :ids => [1, 3]
assert_response :success
- assert_template 'bulk_edit'
assert_select 'ul#bulk-selection' do
assert_select 'li', 2
@@ -3991,7 +3849,6 @@ class IssuesControllerTest < Redmine::ControllerTest
@request.session[:user_id] = 2
get :bulk_edit, :ids => [1, 2, 6]
assert_response :success
- assert_template 'bulk_edit'
# Can not set issues from different projects as children of an issue
assert_select 'input[name=?]', 'issue[parent_issue_id]', 0
@@ -4009,7 +3866,6 @@ class IssuesControllerTest < Redmine::ControllerTest
@request.session[:user_id] = 2
get :bulk_edit, :ids => [1, 2]
assert_response :success
- assert_template 'bulk_edit'
assert_select 'select.user_cf[name=?]', "issue[custom_field_values][#{field.id}]" do
assert_select 'option', Project.find(1).users.count + 2 # "no change" + "none" options
@@ -4022,7 +3878,6 @@ class IssuesControllerTest < Redmine::ControllerTest
@request.session[:user_id] = 2
get :bulk_edit, :ids => [1, 2]
assert_response :success
- assert_template 'bulk_edit'
assert_select 'select.version_cf[name=?]', "issue[custom_field_values][#{field.id}]" do
assert_select 'option', Project.find(1).shared_versions.count + 2 # "no change" + "none" options
@@ -4036,7 +3891,6 @@ class IssuesControllerTest < Redmine::ControllerTest
@request.session[:user_id] = 2
get :bulk_edit, :ids => [1, 3]
assert_response :success
- assert_template 'bulk_edit'
assert_select 'select[name=?]', 'issue[custom_field_values][1][]' do
assert_select 'option', field.possible_values.size + 1 # "none" options
@@ -4046,6 +3900,8 @@ class IssuesControllerTest < Redmine::ControllerTest
def test_bulk_edit_should_propose_to_clear_text_custom_fields
@request.session[:user_id] = 2
get :bulk_edit, :ids => [1, 3]
+ assert_response :success
+
assert_select 'input[name=?][value=?]', 'issue[custom_field_values][2]', '__none__'
end
@@ -4066,12 +3922,10 @@ class IssuesControllerTest < Redmine::ControllerTest
@request.session[:user_id] = 2
get :bulk_edit, :ids => [1, 2]
- assert_response :success
- statuses = assigns(:available_statuses)
- assert_not_nil statuses
- assert_equal [1, 3], statuses.map(&:id).sort
-
assert_select 'select[name=?]', 'issue[status_id]' do
+ assert_select 'option[value=""]'
+ assert_select 'option[value="1"]'
+ assert_select 'option[value="3"]'
assert_select 'option', 3 # 2 statuses + "no change" option
end
end
@@ -4080,11 +3934,16 @@ class IssuesControllerTest < Redmine::ControllerTest
@request.session[:user_id] = 2
post :bulk_edit, :ids => [1, 2, 6], :issue => {:project_id => 1}
assert_response :success
- assert_template 'bulk_edit'
- assert_equal Project.find(1).shared_versions.open.to_a.sort, assigns(:versions).sort
+
+ expected_versions = Project.find(1).shared_versions.open.to_a.sort
assert_select 'select[name=?]', 'issue[fixed_version_id]' do
- assert_select 'option', :text => '2.0'
+ expected_versions.each do |version|
+ assert_select 'option[value=?]', version.id.to_s
+ end
+ assert_select 'option[value=""]'
+ assert_select 'option[value="none"]'
+ assert_select 'option', expected_versions.size + 2
end
end
@@ -4092,23 +3951,31 @@ class IssuesControllerTest < Redmine::ControllerTest
@request.session[:user_id] = 2
post :bulk_edit, :ids => [1, 2, 6], :issue => {:project_id => 1}
assert_response :success
- assert_template 'bulk_edit'
- assert_equal Project.find(1).issue_categories.sort, assigns(:categories).sort
+
+ expected_categories = Project.find(1).issue_categories.sort
assert_select 'select[name=?]', 'issue[category_id]' do
- assert_select 'option', :text => 'Recipes'
+ expected_categories.each do |category|
+ assert_select 'option[value=?]', category.id.to_s
+ end
+ assert_select 'option[value=""]'
+ assert_select 'option[value="none"]'
+ assert_select 'option', expected_categories.size + 2
end
end
def test_bulk_edit_should_only_propose_issues_trackers_custom_fields
IssueCustomField.delete_all
- field = IssueCustomField.generate!(:tracker_ids => [1], :is_for_all => true)
- IssueCustomField.generate!(:tracker_ids => [2], :is_for_all => true)
+ field1 = IssueCustomField.generate!(:tracker_ids => [1], :is_for_all => true)
+ field2 = IssueCustomField.generate!(:tracker_ids => [2], :is_for_all => true)
@request.session[:user_id] = 2
issue_ids = Issue.where(:project_id => 1, :tracker_id => 1).limit(2).ids
get :bulk_edit, :ids => issue_ids
- assert_equal [field], assigns(:custom_fields)
+ assert_response :success
+
+ assert_select 'input[name=?]', "issue[custom_field_values][#{field1.id}]"
+ assert_select 'input[name=?]', "issue[custom_field_values][#{field2.id}]", 0
end
def test_bulk_update
@@ -4389,13 +4256,10 @@ class IssuesControllerTest < Redmine::ControllerTest
def test_bulk_update_with_all_failures_should_show_errors
@request.session[:user_id] = 2
post :bulk_update, :ids => [1, 2], :issue => {:start_date => 'foo'}
-
assert_response :success
- assert_template 'bulk_edit'
+
assert_select '#errorExplanation span', :text => 'Failed to save 2 issue(s) on 2 selected: #1, #2.'
assert_select '#errorExplanation ul li', :text => 'Start date is not a valid date: #1, #2'
-
- assert_equal [1, 2], assigns[:issues].map(&:id)
end
def test_bulk_update_with_some_failures_should_show_errors
@@ -4406,20 +4270,20 @@ class IssuesControllerTest < Redmine::ControllerTest
post :bulk_update, :ids => [issue1.id, issue2.id, issue3.id],
:issue => {:due_date => '2013-05-01'}
assert_response :success
- assert_template 'bulk_edit'
+
assert_select '#errorExplanation span',
:text => "Failed to save 2 issue(s) on 3 selected: ##{issue1.id}, ##{issue2.id}."
assert_select '#errorExplanation ul li',
:text => "Due date must be greater than start date: ##{issue1.id}, ##{issue2.id}"
- assert_equal [issue1.id, issue2.id], assigns[:issues].map(&:id)
+
+ assert_select '#bulk-selection li', 2
end
def test_bulk_update_with_failure_should_preserved_form_values
@request.session[:user_id] = 2
post :bulk_update, :ids => [1, 2], :issue => {:tracker_id => '2', :start_date => 'foo'}
-
assert_response :success
- assert_template 'bulk_edit'
+
assert_select 'select[name=?]', 'issue[tracker_id]' do
assert_select 'option[value="2"][selected=selected]'
end
@@ -4430,11 +4294,8 @@ class IssuesControllerTest < Redmine::ControllerTest
@request.session[:user_id] = 2
get :bulk_edit, :ids => [1, 2, 3], :copy => '1'
assert_response :success
- assert_template 'bulk_edit'
- issues = assigns(:issues)
- assert_not_nil issues
- assert_equal [1, 2, 3], issues.map(&:id).sort
+ assert_select '#bulk-selection li', 3
assert_select 'select[name=?]', 'issue[project_id]' do
assert_select 'option[value=""]'
@@ -4448,7 +4309,6 @@ class IssuesControllerTest < Redmine::ControllerTest
get :bulk_edit, :ids => [1, 2, 3], :copy => '1'
assert_response :success
- assert_template 'bulk_edit'
assert_select 'select[name=?]', 'issue[project_id]' do
assert_select 'option[value=""]', 0
@@ -4688,9 +4548,6 @@ class IssuesControllerTest < Redmine::ControllerTest
delete :destroy, :ids => [1, 3]
end
assert_response :success
- assert_template 'destroy'
- assert_not_nil assigns(:hours)
- assert Issue.find_by_id(1) && Issue.find_by_id(3)
assert_select 'form' do
assert_select 'input[name=_method][value=delete]'
@@ -4748,7 +4605,6 @@ class IssuesControllerTest < Redmine::ControllerTest
end
end
assert_response :success
- assert_template 'destroy'
end
def test_destroy_issues_from_different_projects
diff --git a/test/functional/issues_controller_transaction_test.rb b/test/functional/issues_controller_transaction_test.rb
index d7e9c4cb5..161ce8bc2 100644
--- a/test/functional/issues_controller_transaction_test.rb
+++ b/test/functional/issues_controller_transaction_test.rb
@@ -68,7 +68,6 @@ class IssuesControllerTransactionTest < Redmine::ControllerTest
end
assert_response :success
- assert_template 'edit'
assert_select 'div.conflict'
assert_select 'input[name=?][value=?]', 'conflict_resolution', 'overwrite'
@@ -101,7 +100,7 @@ class IssuesControllerTransactionTest < Redmine::ControllerTest
end
assert_response :success
- assert_template 'edit'
+
attachment = Attachment.order('id DESC').first
assert_select 'input[name=?][value=?]', 'attachments[p0][token]', attachment.token
assert_select 'input[name=?][value=?]', 'attachments[p0][filename]', 'testfile.txt'
@@ -117,6 +116,7 @@ class IssuesControllerTransactionTest < Redmine::ControllerTest
:notes => '',
:lock_version => (issue.lock_version - 1)
}
+ assert_response :success
assert_select 'div.conflict'
assert_select 'input[name=conflict_resolution][value=overwrite]'
@@ -134,11 +134,9 @@ class IssuesControllerTransactionTest < Redmine::ControllerTest
:lock_version => 2
},
:last_journal_id => 1
+ assert_response :success
- assert_not_nil assigns(:conflict_journals)
- assert_equal 1, assigns(:conflict_journals).size
- assert_equal 2, assigns(:conflict_journals).first.id
-
+ assert_select '.conflict-journal', 1
assert_select 'div.conflict', :text => /Some notes with Redmine links/
end
@@ -152,9 +150,9 @@ class IssuesControllerTransactionTest < Redmine::ControllerTest
:lock_version => 2
},
:last_journal_id => ''
+ assert_response :success
- assert_not_nil assigns(:conflict_journals)
- assert_equal 2, assigns(:conflict_journals).size
+ assert_select '.conflict-journal', 2
assert_select 'div.conflict', :text => /Some notes with Redmine links/
assert_select 'div.conflict', :text => /Journal notes/
end
@@ -164,11 +162,13 @@ class IssuesControllerTransactionTest < Redmine::ControllerTest
@request.session[:user_id] = 2
put :update, :id => 1, :issue => {:fixed_version_id => 4, :lock_version => 2}, :last_journal_id => ''
- assert_include journal, assigns(:conflict_journals)
+ assert_response :success
+ assert_select '.conflict-journal', :text => /Privates notes/
Role.find(1).remove_permission! :view_private_notes
put :update, :id => 1, :issue => {:fixed_version_id => 4, :lock_version => 2}, :last_journal_id => ''
- assert_not_include journal, assigns(:conflict_journals)
+ assert_response :success
+ assert_select '.conflict-journal', :text => /Privates notes/, :count => 0
end
def test_update_stale_issue_with_overwrite_conflict_resolution_should_update
diff --git a/test/functional/issues_custom_fields_visibility_test.rb b/test/functional/issues_custom_fields_visibility_test.rb
index 5eafc6232..6ebe0c48f 100644
--- a/test/functional/issues_custom_fields_visibility_test.rb
+++ b/test/functional/issues_custom_fields_visibility_test.rb
@@ -213,14 +213,14 @@ class IssuesCustomFieldsVisibilityTest < Redmine::ControllerTest
get :index, :sort => "cf_#{@field2.id}"
# ValueB is not visible to user and ignored while sorting
- assert_equal %w(ValueB ValueA ValueC), assigns(:issues).map{|i| i.custom_field_value(@field2)}
+ assert_equal %w(ValueB ValueA ValueC), issues_in_list.map{|i| i.custom_field_value(@field2)}
get :index, :set_filter => '1', "cf_#{@field2.id}" => '*'
- assert_equal %w(ValueA ValueC), assigns(:issues).map{|i| i.custom_field_value(@field2)}
+ assert_equal %w(ValueA ValueC), issues_in_list.map{|i| i.custom_field_value(@field2)}
CustomField.update_all(:field_format => 'list')
get :index, :group => "cf_#{@field2.id}"
- assert_equal %w(ValueA ValueC), assigns(:issues).map{|i| i.custom_field_value(@field2)}
+ assert_equal %w(ValueA ValueC), issues_in_list.map{|i| i.custom_field_value(@field2)}
end
def test_create_should_send_notifications_according_custom_fields_visibility
diff --git a/test/functional/journals_controller_test.rb b/test/functional/journals_controller_test.rb
index 5e930eba0..446cdcc83 100644
--- a/test/functional/journals_controller_test.rb
+++ b/test/functional/journals_controller_test.rb
@@ -28,7 +28,6 @@ class JournalsControllerTest < Redmine::ControllerTest
def test_index
get :index, :project_id => 1
assert_response :success
- assert_not_nil assigns(:journals)
assert_equal 'application/atom+xml', @response.content_type
end
@@ -43,12 +42,12 @@ class JournalsControllerTest < Redmine::ControllerTest
get :index, :project_id => 1
assert_response :success
- assert_include journal, assigns(:journals)
+ assert_select 'entry>id', :text => "http://test.host/issues/2?journal_id=#{journal.id}"
Role.find(1).remove_permission! :view_private_notes
get :index, :project_id => 1
assert_response :success
- assert_not_include journal, assigns(:journals)
+ assert_select 'entry>id', :text => "http://test.host/issues/2?journal_id=#{journal.id}", :count => 0
end
def test_index_should_show_visible_custom_fields_only
@@ -94,7 +93,6 @@ class JournalsControllerTest < Redmine::ControllerTest
def test_diff_for_description_change
get :diff, :id => 3, :detail_id => 4
assert_response :success
- assert_template 'diff'
assert_select 'span.diff_out', :text => /removed/
assert_select 'span.diff_in', :text => /added/
@@ -108,7 +106,6 @@ class JournalsControllerTest < Redmine::ControllerTest
get :diff, :id => journal.id, :detail_id => detail.id
assert_response :success
- assert_template 'diff'
assert_select 'span.diff_out', :text => /Foo/
assert_select 'span.diff_in', :text => /Bar/
@@ -127,7 +124,6 @@ class JournalsControllerTest < Redmine::ControllerTest
def test_diff_should_default_to_description_diff
get :diff, :id => 3
assert_response :success
- assert_template 'diff'
assert_select 'span.diff_out', :text => /removed/
assert_select 'span.diff_in', :text => /added/
@@ -137,7 +133,7 @@ class JournalsControllerTest < Redmine::ControllerTest
@request.session[:user_id] = 2
xhr :get, :new, :id => 6
assert_response :success
- assert_template 'new'
+
assert_equal 'text/javascript', response.content_type
assert_include '> This is an issue', response.body
end
@@ -152,7 +148,6 @@ class JournalsControllerTest < Redmine::ControllerTest
@request.session[:user_id] = 2
xhr :get, :new, :id => 6, :journal_id => 4
assert_response :success
- assert_template 'new'
assert_equal 'text/javascript', response.content_type
assert_include '> A comment with a private version', response.body
end
@@ -163,7 +158,6 @@ class JournalsControllerTest < Redmine::ControllerTest
xhr :get, :new, :id => 2, :journal_id => journal.id
assert_response :success
- assert_template 'new'
assert_equal 'text/javascript', response.content_type
assert_include '> Privates notes', response.body
@@ -176,7 +170,6 @@ class JournalsControllerTest < Redmine::ControllerTest
@request.session[:user_id] = 1
xhr :get, :edit, :id => 2
assert_response :success
- assert_template 'edit'
assert_equal 'text/javascript', response.content_type
assert_include 'textarea', response.body
end
@@ -188,7 +181,6 @@ class JournalsControllerTest < Redmine::ControllerTest
xhr :get, :edit, :id => journal.id
assert_response :success
- assert_template 'edit'
assert_equal 'text/javascript', response.content_type
assert_include 'textarea', response.body
@@ -201,7 +193,6 @@ class JournalsControllerTest < Redmine::ControllerTest
@request.session[:user_id] = 1
xhr :post, :update, :id => 2, :journal => {:notes => 'Updated notes'}
assert_response :success
- assert_template 'update'
assert_equal 'text/javascript', response.content_type
assert_equal 'Updated notes', Journal.find(2).notes
assert_include 'journal-2-notes', response.body
@@ -211,7 +202,6 @@ class JournalsControllerTest < Redmine::ControllerTest
@request.session[:user_id] = 1
xhr :post, :update, :id => 2, :journal => {:private_notes => '1'}
assert_response :success
- assert_template 'update'
assert_equal 'text/javascript', response.content_type
assert_equal true, Journal.find(2).private_notes
assert_include 'change-2', response.body
@@ -223,7 +213,6 @@ class JournalsControllerTest < Redmine::ControllerTest
@request.session[:user_id] = 1
xhr :post, :update, :id => 2, :journal => {:private_notes => '0'}
assert_response :success
- assert_template 'update'
assert_equal 'text/javascript', response.content_type
assert_equal false, Journal.find(2).private_notes
assert_include 'change-2', response.body
@@ -246,7 +235,6 @@ class JournalsControllerTest < Redmine::ControllerTest
assert_difference 'Journal.count', -1 do
xhr :post, :update, :id => 2, :journal => {:notes => ''}
assert_response :success
- assert_template 'update'
assert_equal 'text/javascript', response.content_type
end
assert_nil Journal.find_by_id(2)
diff --git a/test/functional/members_controller_test.rb b/test/functional/members_controller_test.rb
index 0e6d7b0a8..c9337e210 100644
--- a/test/functional/members_controller_test.rb
+++ b/test/functional/members_controller_test.rb
@@ -93,7 +93,6 @@ class MembersControllerTest < Redmine::ControllerTest
assert_difference 'Member.count', 3 do
xhr :post, :create, :project_id => 1, :membership => {:role_ids => [1], :user_ids => [7, 8, 9]}
assert_response :success
- assert_template 'create'
assert_equal 'text/javascript', response.content_type
end
assert User.find(7).member_of?(Project.find(1))
@@ -106,7 +105,6 @@ class MembersControllerTest < Redmine::ControllerTest
assert_no_difference 'Member.count' do
xhr :post, :create, :project_id => 1, :membership => {:role_ids => [], :user_ids => [7, 8, 9]}
assert_response :success
- assert_template 'create'
assert_equal 'text/javascript', response.content_type
end
assert_match /alert/, response.body, "Alert message not sent"
@@ -143,7 +141,6 @@ class MembersControllerTest < Redmine::ControllerTest
assert_no_difference 'Member.count' do
xhr :put, :update, :id => 2, :membership => {:role_ids => [1], :user_id => 3}
assert_response :success
- assert_template 'update'
assert_equal 'text/javascript', response.content_type
end
member = Member.find(2)
@@ -186,7 +183,6 @@ class MembersControllerTest < Redmine::ControllerTest
assert_difference 'Member.count', -1 do
xhr :delete, :destroy, :id => 2
assert_response :success
- assert_template 'destroy'
assert_equal 'text/javascript', response.content_type
end
assert_nil Member.find_by_id(2)
diff --git a/test/test_helper.rb b/test/test_helper.rb
index 2572495df..0be4d42ae 100644
--- a/test/test_helper.rb
+++ b/test/test_helper.rb
@@ -282,6 +282,29 @@ module Redmine
end
class ControllerTest < ActionController::TestCase
+ # Returns the issues that are displayed in the list in the same order
+ def issues_in_list
+ ids = css_select('tr.issue td.id').map(&:text).map(&:to_i)
+ Issue.where(:id => ids).sort_by {|issue| ids.index(issue.id)}
+ end
+
+ # Return the columns that are displayed in the list
+ def columns_in_issues_list
+ css_select('table.issues thead th:not(.checkbox)').map(&:text)
+ end
+
+ # Verifies that the query filters match the expected filters
+ def assert_query_filters(expected_filters)
+ response.body =~ /initFilters\(\);\s*((addFilter\(.+\);\s*)*)/
+ filter_init = $1.to_s
+
+ expected_filters.each do |field, operator, values|
+ s = "addFilter(#{field.to_json}, #{operator.to_json}, #{Array(values).to_json});"
+ assert_include s, filter_init
+ end
+ assert_equal expected_filters.size, filter_init.scan("addFilter").size, "filters counts don't match"
+ end
+
def process(method, path, parameters={}, session={}, flash={})
if parameters.key?(:params) || parameters.key?(:session)
raise ArgumentError if session.present?