summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2014-12-03 20:21:03 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2014-12-03 20:21:03 +0000
commit5222650d952390d3435848397a46d8aa1dbda09e (patch)
tree6ef084faa30f3bba0d0d1e361247f86c1f4da21d /test
parent1059f9a99ec41a8e320d4d66684e65d183270920 (diff)
downloadredmine-5222650d952390d3435848397a46d8aa1dbda09e.tar.gz
redmine-5222650d952390d3435848397a46d8aa1dbda09e.zip
Adds a few tests.
git-svn-id: http://svn.redmine.org/redmine/trunk@13695 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'test')
-rw-r--r--test/functional/issues_controller_test.rb19
-rw-r--r--test/functional/projects_controller_test.rb8
-rw-r--r--test/functional/users_controller_test.rb11
-rw-r--r--test/functional/wiki_controller_test.rb8
-rw-r--r--test/functional/workflows_controller_test.rb7
-rw-r--r--test/integration/api_test/users_test.rb20
-rw-r--r--test/unit/group_test.rb26
-rw-r--r--test/unit/project_test.rb25
-rw-r--r--test/unit/version_test.rb6
9 files changed, 127 insertions, 3 deletions
diff --git a/test/functional/issues_controller_test.rb b/test/functional/issues_controller_test.rb
index 2eccb9074..876a63732 100644
--- a/test/functional/issues_controller_test.rb
+++ b/test/functional/issues_controller_test.rb
@@ -1741,6 +1741,12 @@ class IssuesControllerTest < ActionController::TestCase
assert_select_error /No tracker/
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
@request.session[:user_id] = 2
xhr :post, :update_form, :project_id => 1,
@@ -4032,6 +4038,19 @@ class IssuesControllerTest < ActionController::TestCase
assert_equal 2, TimeEntry.find(2).issue_id
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
@request.session[:user_id] = 2
diff --git a/test/functional/projects_controller_test.rb b/test/functional/projects_controller_test.rb
index 4a7f0d498..83fcf160e 100644
--- a/test/functional/projects_controller_test.rb
+++ b/test/functional/projects_controller_test.rb
@@ -75,6 +75,14 @@ class ProjectsControllerTest < ActionController::TestCase
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
+
test "#new by admin user should accept get" do
@request.session[:user_id] = 1
diff --git a/test/functional/users_controller_test.rb b/test/functional/users_controller_test.rb
index 3306e2fad..56a0292f6 100644
--- a/test/functional/users_controller_test.rb
+++ b/test/functional/users_controller_test.rb
@@ -239,6 +239,17 @@ class UsersControllerTest < ActionController::TestCase
assert user.check_password?(password)
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
assert_no_difference 'User.count' do
post :create, :user => {}
diff --git a/test/functional/wiki_controller_test.rb b/test/functional/wiki_controller_test.rb
index ebebf343d..5e1b19034 100644
--- a/test/functional/wiki_controller_test.rb
+++ b/test/functional/wiki_controller_test.rb
@@ -320,12 +320,14 @@ class WikiControllerTest < ActionController::TestCase
:id => 'Another_page',
:content => {
:comments => 'a' * 300, # failure here, comment is too long
- :text => 'edited',
- :version => 1
+ :text => 'edited'
+ },
+ :wiki_page => {
+ :parent_id => ""
}
- end
end
end
+ end
assert_response :success
assert_template 'edit'
diff --git a/test/functional/workflows_controller_test.rb b/test/functional/workflows_controller_test.rb
index 10d68bf15..7a21972cb 100644
--- a/test/functional/workflows_controller_test.rb
+++ b/test/functional/workflows_controller_test.rb
@@ -61,6 +61,13 @@ class WorkflowsControllerTest < ActionController::TestCase
assert_select 'input[type=checkbox][name=?]', 'transitions[1][1][always]', 0
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
WorkflowTransition.delete_all
diff --git a/test/integration/api_test/users_test.rb b/test/integration/api_test/users_test.rb
index 22b6abeff..beadc54c6 100644
--- a/test/integration/api_test/users_test.rb
+++ b/test/integration/api_test/users_test.rb
@@ -20,6 +20,26 @@ require File.expand_path('../../../test_helper', __FILE__)
class Redmine::ApiTest::UsersTest < Redmine::ApiTest::Base
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
get '/users/2.xml'
diff --git a/test/unit/group_test.rb b/test/unit/group_test.rb
index d2f09f9a7..6989680ec 100644
--- a/test/unit/group_test.rb
+++ b/test/unit/group_test.rb
@@ -132,4 +132,30 @@ class GroupTest < ActiveSupport::TestCase
assert_equal nil, Issue.find(1).assigned_to_id
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
diff --git a/test/unit/project_test.rb b/test/unit/project_test.rb
index 4723b4638..02bcfccbd 100644
--- a/test/unit/project_test.rb
+++ b/test/unit/project_test.rb
@@ -647,6 +647,12 @@ class ProjectTest < ActiveSupport::TestCase
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
@project = Project.find(1)
# Remove one module
@@ -947,4 +953,23 @@ class ProjectTest < ActiveSupport::TestCase
assert_equal [Role.anonymous], project.override_roles(Role.anonymous)
assert_equal [Role.non_member], project.override_roles(Role.non_member)
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
diff --git a/test/unit/version_test.rb b/test/unit/version_test.rb
index a1dddd905..85c1079d5 100644
--- a/test/unit/version_test.rb
+++ b/test/unit/version_test.rb
@@ -127,6 +127,12 @@ class VersionTest < ActiveSupport::TestCase
assert_equal [v5, v3, v1, v2, v4], Version.sorted.to_a
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
version = Version.create!(:project_id => 1, :effective_date => Date.today, :name => 'Due today')
assert_equal false, version.completed?