mirror of
https://github.com/redmine/redmine.git
synced 2025-11-02 11:25:55 +01:00
Removes calls to #assert_template and #assigns in functional tests.
git-svn-id: http://svn.redmine.org/redmine/trunk@15715 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
@@ -33,10 +33,6 @@ class ProjectsControllerTest < Redmine::ControllerTest
|
||||
def test_index_by_anonymous_should_not_show_private_projects
|
||||
get :index
|
||||
assert_response :success
|
||||
assert_template 'index'
|
||||
projects = assigns(:projects)
|
||||
assert_not_nil projects
|
||||
assert projects.all?(&:is_public?)
|
||||
|
||||
assert_select 'ul' do
|
||||
assert_select 'li' do
|
||||
@@ -52,7 +48,6 @@ class ProjectsControllerTest < Redmine::ControllerTest
|
||||
def test_index_atom
|
||||
get :index, :format => 'atom'
|
||||
assert_response :success
|
||||
assert_template 'common/feed'
|
||||
assert_select 'feed>title', :text => 'Redmine: Latest projects'
|
||||
assert_select 'feed>entry', :count => Project.visible(User.current).count
|
||||
end
|
||||
@@ -60,7 +55,6 @@ class ProjectsControllerTest < Redmine::ControllerTest
|
||||
test "#index by non-admin user with view_time_entries permission should show overall spent time link" do
|
||||
@request.session[:user_id] = 3
|
||||
get :index
|
||||
assert_template 'index'
|
||||
assert_select 'a[href=?]', '/time_entries'
|
||||
end
|
||||
|
||||
@@ -71,15 +65,14 @@ class ProjectsControllerTest < Redmine::ControllerTest
|
||||
@request.session[:user_id] = 3
|
||||
|
||||
get :index
|
||||
assert_template 'index'
|
||||
assert_select 'a[href=?]', '/time_entries', 0
|
||||
end
|
||||
|
||||
test "#index by non-admin user with permission should show add project link" do
|
||||
Role.find(1).add_permission! :add_project
|
||||
@request.session[:user_id] = 2
|
||||
|
||||
get :index
|
||||
assert_template 'index'
|
||||
assert_select 'a[href=?]', '/projects/new'
|
||||
end
|
||||
|
||||
@@ -88,7 +81,8 @@ class ProjectsControllerTest < Redmine::ControllerTest
|
||||
|
||||
get :new
|
||||
assert_response :success
|
||||
assert_template 'new'
|
||||
assert_select 'input[name=?]', 'project[name]'
|
||||
assert_select 'select[name=?]', 'project[parent_id]'
|
||||
end
|
||||
|
||||
test "#new by non-admin user with add_project permission should accept get" do
|
||||
@@ -97,7 +91,7 @@ class ProjectsControllerTest < Redmine::ControllerTest
|
||||
|
||||
get :new
|
||||
assert_response :success
|
||||
assert_template 'new'
|
||||
assert_select 'input[name=?]', 'project[name]'
|
||||
assert_select 'select[name=?]', 'project[parent_id]', 0
|
||||
end
|
||||
|
||||
@@ -108,7 +102,6 @@ class ProjectsControllerTest < Redmine::ControllerTest
|
||||
|
||||
get :new, :parent_id => 'ecookbook'
|
||||
assert_response :success
|
||||
assert_template 'new'
|
||||
|
||||
assert_select 'select[name=?]', 'project[parent_id]' do
|
||||
# parent project selected
|
||||
@@ -215,6 +208,7 @@ class ProjectsControllerTest < Redmine::ControllerTest
|
||||
|
||||
test "#create by non-admin user with add_project permission should fail with parent_id" do
|
||||
Role.non_member.add_permission! :add_project
|
||||
User.find(9).update! :language => 'en'
|
||||
@request.session[:user_id] = 9
|
||||
|
||||
assert_no_difference 'Project.count' do
|
||||
@@ -227,9 +221,7 @@ class ProjectsControllerTest < Redmine::ControllerTest
|
||||
}
|
||||
end
|
||||
assert_response :success
|
||||
project = assigns(:project)
|
||||
assert_kind_of Project, project
|
||||
assert_not_equal [], project.errors[:parent_id]
|
||||
assert_select_error /Subproject of is invalid/
|
||||
end
|
||||
|
||||
test "#create by non-admin user with add_subprojects permission should create a project with a parent_id" do
|
||||
@@ -246,6 +238,7 @@ class ProjectsControllerTest < Redmine::ControllerTest
|
||||
}
|
||||
assert_redirected_to '/projects/blog/settings'
|
||||
project = Project.find_by_name('blog')
|
||||
assert_equal 1, project.parent_id
|
||||
end
|
||||
|
||||
test "#create by non-admin user with add_subprojects permission should fail without parent_id" do
|
||||
@@ -262,9 +255,7 @@ class ProjectsControllerTest < Redmine::ControllerTest
|
||||
}
|
||||
end
|
||||
assert_response :success
|
||||
project = assigns(:project)
|
||||
assert_kind_of Project, project
|
||||
assert_not_equal [], project.errors[:parent_id]
|
||||
assert_select_error /Subproject of is invalid/
|
||||
end
|
||||
|
||||
test "#create by non-admin user with add_subprojects permission should fail with unauthorized parent_id" do
|
||||
@@ -283,9 +274,7 @@ class ProjectsControllerTest < Redmine::ControllerTest
|
||||
}
|
||||
end
|
||||
assert_response :success
|
||||
project = assigns(:project)
|
||||
assert_kind_of Project, project
|
||||
assert_not_equal [], project.errors[:parent_id]
|
||||
assert_select_error /Subproject of is invalid/
|
||||
end
|
||||
|
||||
def test_create_subproject_with_inherit_members_should_inherit_members
|
||||
@@ -318,26 +307,23 @@ class ProjectsControllerTest < Redmine::ControllerTest
|
||||
}
|
||||
end
|
||||
assert_response :success
|
||||
project = assigns(:project)
|
||||
assert_equal %w(issue_tracking news), project.enabled_module_names.sort
|
||||
%w(issue_tracking news).each do |mod|
|
||||
assert_select 'input[name=?][value=?][checked=checked]', 'project[enabled_module_names][]', mod
|
||||
end
|
||||
assert_select 'input[name=?][checked=checked]', 'project[enabled_module_names][]', :count => 2
|
||||
end
|
||||
end
|
||||
|
||||
def test_show_by_id
|
||||
get :show, :id => 1
|
||||
assert_response :success
|
||||
assert_template 'show'
|
||||
assert_not_nil assigns(:project)
|
||||
assert_select '#header h1', :text => "eCookbook"
|
||||
end
|
||||
|
||||
def test_show_by_identifier
|
||||
get :show, :id => 'ecookbook'
|
||||
assert_response :success
|
||||
assert_template 'show'
|
||||
assert_not_nil assigns(:project)
|
||||
assert_equal Project.find_by_identifier('ecookbook'), assigns(:project)
|
||||
|
||||
assert_select 'li', :text => /Development status/
|
||||
assert_select '#header h1', :text => "eCookbook"
|
||||
end
|
||||
|
||||
def test_show_should_not_display_empty_sidebar
|
||||
@@ -350,12 +336,18 @@ class ProjectsControllerTest < Redmine::ControllerTest
|
||||
assert_select '#main.nosidebar'
|
||||
end
|
||||
|
||||
def test_show_should_display_visible_custom_fields
|
||||
ProjectCustomField.find_by_name('Development status').update_attribute :visible, true
|
||||
get :show, :id => 'ecookbook'
|
||||
assert_response :success
|
||||
|
||||
assert_select 'li', :text => /Development status/
|
||||
end
|
||||
|
||||
def test_show_should_not_display_hidden_custom_fields
|
||||
ProjectCustomField.find_by_name('Development status').update_attribute :visible, false
|
||||
get :show, :id => 'ecookbook'
|
||||
assert_response :success
|
||||
assert_template 'show'
|
||||
assert_not_nil assigns(:project)
|
||||
|
||||
assert_select 'li', :text => /Development status/, :count => 0
|
||||
end
|
||||
@@ -386,9 +378,6 @@ class ProjectsControllerTest < Redmine::ControllerTest
|
||||
project.custom_values.first.update_attribute(:value, nil)
|
||||
get :show, :id => 'ecookbook'
|
||||
assert_response :success
|
||||
assert_template 'show'
|
||||
assert_not_nil assigns(:project)
|
||||
assert_equal Project.find_by_identifier('ecookbook'), assigns(:project)
|
||||
end
|
||||
|
||||
def show_archived_project_should_be_denied
|
||||
@@ -397,14 +386,13 @@ class ProjectsControllerTest < Redmine::ControllerTest
|
||||
|
||||
get :show, :id => 'ecookbook'
|
||||
assert_response 403
|
||||
assert_nil assigns(:project)
|
||||
assert_select 'p', :text => /archived/
|
||||
assert_not_include project.name, response.body
|
||||
end
|
||||
|
||||
def test_show_should_not_show_private_subprojects_that_are_not_visible
|
||||
get :show, :id => 'ecookbook'
|
||||
assert_response :success
|
||||
assert_template 'show'
|
||||
assert_select 'a', :text => /Private child/, :count => 0
|
||||
end
|
||||
|
||||
@@ -412,7 +400,6 @@ class ProjectsControllerTest < Redmine::ControllerTest
|
||||
@request.session[:user_id] = 2 # manager who is a member of the private subproject
|
||||
get :show, :id => 'ecookbook'
|
||||
assert_response :success
|
||||
assert_template 'show'
|
||||
assert_select 'a', :text => /Private child/
|
||||
end
|
||||
|
||||
@@ -420,14 +407,14 @@ class ProjectsControllerTest < Redmine::ControllerTest
|
||||
@request.session[:user_id] = 2 # manager
|
||||
get :settings, :id => 1
|
||||
assert_response :success
|
||||
assert_template 'settings'
|
||||
|
||||
assert_select 'input[name=?]', 'project[name]'
|
||||
end
|
||||
|
||||
def test_settings_of_subproject
|
||||
@request.session[:user_id] = 2
|
||||
get :settings, :id => 'private-child'
|
||||
assert_response :success
|
||||
assert_template 'settings'
|
||||
|
||||
assert_select 'input[type=checkbox][name=?]', 'project[inherit_members]'
|
||||
end
|
||||
@@ -454,7 +441,6 @@ class ProjectsControllerTest < Redmine::ControllerTest
|
||||
|
||||
get :settings, :id => 1
|
||||
assert_response :success
|
||||
assert_template 'settings'
|
||||
|
||||
assert_select 'form[action=?]', '/projects/ecookbook/wiki' do
|
||||
assert_select 'input[name=?]', 'wiki[start_page]'
|
||||
@@ -474,7 +460,6 @@ class ProjectsControllerTest < Redmine::ControllerTest
|
||||
@request.session[:user_id] = 2 # manager
|
||||
post :update, :id => 1, :project => {:name => ''}
|
||||
assert_response :success
|
||||
assert_template 'settings'
|
||||
assert_select_error /name cannot be blank/i
|
||||
end
|
||||
|
||||
@@ -521,8 +506,8 @@ class ProjectsControllerTest < Redmine::ControllerTest
|
||||
assert_no_difference 'Project.count' do
|
||||
delete :destroy, :id => 2
|
||||
assert_response :success
|
||||
assert_template 'destroy'
|
||||
end
|
||||
assert_select '.warning', :text => /Are you sure you want to delete this project/
|
||||
end
|
||||
|
||||
def test_destroy_without_confirmation_should_show_confirmation_with_subprojects
|
||||
@@ -531,7 +516,6 @@ class ProjectsControllerTest < Redmine::ControllerTest
|
||||
assert_no_difference 'Project.count' do
|
||||
delete :destroy, :id => 1
|
||||
assert_response :success
|
||||
assert_template 'destroy'
|
||||
end
|
||||
assert_select 'strong',
|
||||
:text => ['Private child of eCookbook',
|
||||
@@ -603,13 +587,12 @@ class ProjectsControllerTest < Redmine::ControllerTest
|
||||
|
||||
def test_get_copy
|
||||
@request.session[:user_id] = 1 # admin
|
||||
get :copy, :id => 1
|
||||
assert_response :success
|
||||
assert_template 'copy'
|
||||
assert assigns(:project)
|
||||
assert_equal Project.find(1).description, assigns(:project).description
|
||||
assert_nil assigns(:project).id
|
||||
orig = Project.find(1)
|
||||
|
||||
get :copy, :id => orig.id
|
||||
assert_response :success
|
||||
|
||||
assert_select 'textarea[name=?]', 'project[description]', :text => orig.description
|
||||
assert_select 'input[name=?][value=?]', 'project[enabled_module_names][]', 'issue_tracking', 1
|
||||
end
|
||||
|
||||
@@ -667,7 +650,7 @@ class ProjectsControllerTest < Redmine::ControllerTest
|
||||
@request.session[:user_id] = 1
|
||||
post :copy, :id => 1, :project => {:name => 'Copy', :identifier => ''}
|
||||
assert_response :success
|
||||
assert_template 'copy'
|
||||
assert_select_error /Identifier cannot be blank/
|
||||
end
|
||||
|
||||
def test_jump_should_redirect_to_active_tab
|
||||
@@ -678,13 +661,11 @@ class ProjectsControllerTest < Redmine::ControllerTest
|
||||
def test_jump_should_not_redirect_to_inactive_tab
|
||||
get :show, :id => 3, :jump => 'documents'
|
||||
assert_response :success
|
||||
assert_template 'show'
|
||||
end
|
||||
|
||||
def test_jump_should_not_redirect_to_unknown_tab
|
||||
get :show, :id => 3, :jump => 'foobar'
|
||||
assert_response :success
|
||||
assert_template 'show'
|
||||
end
|
||||
|
||||
def test_body_should_have_project_css_class
|
||||
|
||||
Reference in New Issue
Block a user