mirror of
https://github.com/redmine/redmine.git
synced 2025-11-11 07:46:02 +01:00
Adds a few tests.
git-svn-id: http://svn.redmine.org/redmine/trunk@13695 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
@@ -1741,6 +1741,12 @@ class IssuesControllerTest < ActionController::TestCase
|
|||||||
assert_select_error /No tracker/
|
assert_select_error /No tracker/
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_new_with_invalid_project_id
|
||||||
|
@request.session[:user_id] = 1
|
||||||
|
get :new, :project_id => 'invalid'
|
||||||
|
assert_response 404
|
||||||
|
end
|
||||||
|
|
||||||
def test_update_form_for_new_issue
|
def test_update_form_for_new_issue
|
||||||
@request.session[:user_id] = 2
|
@request.session[:user_id] = 2
|
||||||
xhr :post, :update_form, :project_id => 1,
|
xhr :post, :update_form, :project_id => 1,
|
||||||
@@ -4032,6 +4038,19 @@ class IssuesControllerTest < ActionController::TestCase
|
|||||||
assert_equal 2, TimeEntry.find(2).issue_id
|
assert_equal 2, TimeEntry.find(2).issue_id
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_destroy_issues_and_reassign_time_entries_to_an_invalid_issue_should_fail
|
||||||
|
@request.session[:user_id] = 2
|
||||||
|
|
||||||
|
assert_no_difference 'Issue.count' do
|
||||||
|
assert_no_difference 'TimeEntry.count' do
|
||||||
|
# try to reassign time to an issue of another project
|
||||||
|
delete :destroy, :ids => [1, 3], :todo => 'reassign', :reassign_to_id => 4
|
||||||
|
end
|
||||||
|
end
|
||||||
|
assert_response :success
|
||||||
|
assert_template 'destroy'
|
||||||
|
end
|
||||||
|
|
||||||
def test_destroy_issues_from_different_projects
|
def test_destroy_issues_from_different_projects
|
||||||
@request.session[:user_id] = 2
|
@request.session[:user_id] = 2
|
||||||
|
|
||||||
|
|||||||
@@ -75,6 +75,14 @@ class ProjectsControllerTest < ActionController::TestCase
|
|||||||
assert_select 'a[href=?]', '/time_entries', 0
|
assert_select 'a[href=?]', '/time_entries', 0
|
||||||
end
|
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
|
||||||
|
|
||||||
test "#new by admin user should accept get" do
|
test "#new by admin user should accept get" do
|
||||||
@request.session[:user_id] = 1
|
@request.session[:user_id] = 1
|
||||||
|
|
||||||
|
|||||||
@@ -239,6 +239,17 @@ class UsersControllerTest < ActionController::TestCase
|
|||||||
assert user.check_password?(password)
|
assert user.check_password?(password)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_create_and_continue
|
||||||
|
post :create, :user => {
|
||||||
|
:login => 'randompass',
|
||||||
|
:firstname => 'Random',
|
||||||
|
:lastname => 'Pass',
|
||||||
|
:mail => 'randompass@example.net',
|
||||||
|
:generate_password => '1'
|
||||||
|
}, :continue => '1'
|
||||||
|
assert_redirected_to '/users/new?user%5Bgenerate_password%5D=1'
|
||||||
|
end
|
||||||
|
|
||||||
def test_create_with_failure
|
def test_create_with_failure
|
||||||
assert_no_difference 'User.count' do
|
assert_no_difference 'User.count' do
|
||||||
post :create, :user => {}
|
post :create, :user => {}
|
||||||
|
|||||||
@@ -320,8 +320,10 @@ class WikiControllerTest < ActionController::TestCase
|
|||||||
:id => 'Another_page',
|
:id => 'Another_page',
|
||||||
:content => {
|
:content => {
|
||||||
:comments => 'a' * 300, # failure here, comment is too long
|
:comments => 'a' * 300, # failure here, comment is too long
|
||||||
:text => 'edited',
|
:text => 'edited'
|
||||||
:version => 1
|
},
|
||||||
|
:wiki_page => {
|
||||||
|
:parent_id => ""
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -61,6 +61,13 @@ class WorkflowsControllerTest < ActionController::TestCase
|
|||||||
assert_select 'input[type=checkbox][name=?]', 'transitions[1][1][always]', 0
|
assert_select 'input[type=checkbox][name=?]', 'transitions[1][1][always]', 0
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_get_edit_with_all_roles_and_all_trackers
|
||||||
|
get :edit, :role_id => 'all', :tracker_id => 'all'
|
||||||
|
assert_response :success
|
||||||
|
assert_equal Role.sorted.to_a, assigns(:roles)
|
||||||
|
assert_equal Tracker.sorted.to_a, assigns(:trackers)
|
||||||
|
end
|
||||||
|
|
||||||
def test_get_edit_with_role_and_tracker_and_all_statuses
|
def test_get_edit_with_role_and_tracker_and_all_statuses
|
||||||
WorkflowTransition.delete_all
|
WorkflowTransition.delete_all
|
||||||
|
|
||||||
|
|||||||
@@ -20,6 +20,26 @@ require File.expand_path('../../../test_helper', __FILE__)
|
|||||||
class Redmine::ApiTest::UsersTest < Redmine::ApiTest::Base
|
class Redmine::ApiTest::UsersTest < Redmine::ApiTest::Base
|
||||||
fixtures :users, :members, :member_roles, :roles, :projects
|
fixtures :users, :members, :member_roles, :roles, :projects
|
||||||
|
|
||||||
|
test "GET /users.xml should return users" do
|
||||||
|
get '/users.xml', {}, credentials('admin')
|
||||||
|
|
||||||
|
assert_response :success
|
||||||
|
assert_equal 'application/xml', response.content_type
|
||||||
|
assert_select 'users' do
|
||||||
|
assert_select 'user', assigns(:users).size
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
test "GET /users.json should return users" do
|
||||||
|
get '/users.json', {}, credentials('admin')
|
||||||
|
|
||||||
|
assert_response :success
|
||||||
|
assert_equal 'application/json', response.content_type
|
||||||
|
json = ActiveSupport::JSON.decode(response.body)
|
||||||
|
assert json.key?('users')
|
||||||
|
assert_equal assigns(:users).size, json['users'].size
|
||||||
|
end
|
||||||
|
|
||||||
test "GET /users/:id.xml should return the user" do
|
test "GET /users/:id.xml should return the user" do
|
||||||
get '/users/2.xml'
|
get '/users/2.xml'
|
||||||
|
|
||||||
|
|||||||
@@ -132,4 +132,30 @@ class GroupTest < ActiveSupport::TestCase
|
|||||||
|
|
||||||
assert_equal nil, Issue.find(1).assigned_to_id
|
assert_equal nil, Issue.find(1).assigned_to_id
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_builtin_groups_should_be_created_if_missing
|
||||||
|
Group.delete_all
|
||||||
|
|
||||||
|
assert_difference 'Group.count', 2 do
|
||||||
|
group = Group.anonymous
|
||||||
|
assert_equal GroupAnonymous, group.class
|
||||||
|
|
||||||
|
group = Group.non_member
|
||||||
|
assert_equal GroupNonMember, group.class
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_builtin_in_group_should_be_uniq
|
||||||
|
group = GroupAnonymous.new
|
||||||
|
group.name = 'Foo'
|
||||||
|
assert !group.save
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_builtin_in_group_should_not_accept_users
|
||||||
|
group = Group.anonymous
|
||||||
|
assert_raise RuntimeError do
|
||||||
|
group.users << User.find(1)
|
||||||
|
end
|
||||||
|
assert_equal 0, group.reload.users.count
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -647,6 +647,12 @@ class ProjectTest < ActiveSupport::TestCase
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_enabled_modules_names_with_nil_should_clear_modules
|
||||||
|
p = Project.find(1)
|
||||||
|
p.enabled_module_names = nil
|
||||||
|
assert_equal [], p.enabled_modules
|
||||||
|
end
|
||||||
|
|
||||||
test "enabled_modules should define module by names and preserve ids" do
|
test "enabled_modules should define module by names and preserve ids" do
|
||||||
@project = Project.find(1)
|
@project = Project.find(1)
|
||||||
# Remove one module
|
# Remove one module
|
||||||
@@ -947,4 +953,23 @@ class ProjectTest < ActiveSupport::TestCase
|
|||||||
assert_equal [Role.anonymous], project.override_roles(Role.anonymous)
|
assert_equal [Role.anonymous], project.override_roles(Role.anonymous)
|
||||||
assert_equal [Role.non_member], project.override_roles(Role.non_member)
|
assert_equal [Role.non_member], project.override_roles(Role.non_member)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_css_classes
|
||||||
|
p = Project.new
|
||||||
|
assert_kind_of String, p.css_classes
|
||||||
|
assert_not_include 'archived', p.css_classes.split
|
||||||
|
assert_not_include 'closed', p.css_classes.split
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_css_classes_for_archived_project
|
||||||
|
p = Project.new
|
||||||
|
p.status = Project::STATUS_ARCHIVED
|
||||||
|
assert_include 'archived', p.css_classes.split
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_css_classes_for_closed_project
|
||||||
|
p = Project.new
|
||||||
|
p.status = Project::STATUS_CLOSED
|
||||||
|
assert_include 'closed', p.css_classes.split
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -127,6 +127,12 @@ class VersionTest < ActiveSupport::TestCase
|
|||||||
assert_equal [v5, v3, v1, v2, v4], Version.sorted.to_a
|
assert_equal [v5, v3, v1, v2, v4], Version.sorted.to_a
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_should_sort_versions_with_same_date_by_name
|
||||||
|
v1 = Version.new(:effective_date => '2014-12-03', :name => 'v2')
|
||||||
|
v2 = Version.new(:effective_date => '2014-12-03', :name => 'v1')
|
||||||
|
assert_equal [v2, v1], [v1, v2].sort
|
||||||
|
end
|
||||||
|
|
||||||
def test_completed_should_be_false_when_due_today
|
def test_completed_should_be_false_when_due_today
|
||||||
version = Version.create!(:project_id => 1, :effective_date => Date.today, :name => 'Due today')
|
version = Version.create!(:project_id => 1, :effective_date => Date.today, :name => 'Due today')
|
||||||
assert_equal false, version.completed?
|
assert_equal false, version.completed?
|
||||||
|
|||||||
Reference in New Issue
Block a user