parent
1468f4a8df
commit
421d47a687
File diff suppressed because it is too large
Load Diff
@ -1,51 +1,51 @@
|
||||
# Redmine - project management software
|
||||
# Copyright (C) 2006-2013 Jean-Philippe Lang
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
# as published by the Free Software Foundation; either version 2
|
||||
# of the License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
require File.expand_path('../../test_helper', __FILE__)
|
||||
|
||||
class ProjectsTest < ActionController::IntegrationTest
|
||||
fixtures :projects, :users, :members, :enabled_modules
|
||||
|
||||
def test_archive_project
|
||||
subproject = Project.find(1).children.first
|
||||
log_user("admin", "admin")
|
||||
get "admin/projects"
|
||||
assert_response :success
|
||||
assert_template "admin/projects"
|
||||
post "projects/1/archive"
|
||||
assert_redirected_to "/admin/projects"
|
||||
assert !Project.find(1).active?
|
||||
|
||||
get 'projects/1'
|
||||
assert_response 403
|
||||
get "projects/#{subproject.id}"
|
||||
assert_response 403
|
||||
|
||||
post "projects/1/unarchive"
|
||||
assert_redirected_to "/admin/projects"
|
||||
assert Project.find(1).active?
|
||||
get "projects/1"
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
def test_modules_should_not_allow_get
|
||||
assert_no_difference 'EnabledModule.count' do
|
||||
get '/projects/1/modules', {:enabled_module_names => ['']}, credentials('jsmith')
|
||||
assert_response 404
|
||||
end
|
||||
end
|
||||
end
|
||||
# Redmine - project management software
|
||||
# Copyright (C) 2006-2013 Jean-Philippe Lang
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
# as published by the Free Software Foundation; either version 2
|
||||
# of the License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
require File.expand_path('../../test_helper', __FILE__)
|
||||
|
||||
class ProjectsTest < ActionController::IntegrationTest
|
||||
fixtures :projects, :users, :members, :enabled_modules
|
||||
|
||||
def test_archive_project
|
||||
subproject = Project.find(1).children.first
|
||||
log_user("admin", "admin")
|
||||
get "admin/projects"
|
||||
assert_response :success
|
||||
assert_template "admin/projects"
|
||||
post "projects/1/archive"
|
||||
assert_redirected_to "/admin/projects"
|
||||
assert !Project.find(1).active?
|
||||
|
||||
get 'projects/1'
|
||||
assert_response 403
|
||||
get "projects/#{subproject.id}"
|
||||
assert_response 403
|
||||
|
||||
post "projects/1/unarchive"
|
||||
assert_redirected_to "/admin/projects"
|
||||
assert Project.find(1).active?
|
||||
get "projects/1"
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
def test_modules_should_not_allow_get
|
||||
assert_no_difference 'EnabledModule.count' do
|
||||
get '/projects/1/modules', {:enabled_module_names => ['']}, credentials('jsmith')
|
||||
assert_response 404
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@ -1,50 +1,50 @@
|
||||
# Redmine - project management software
|
||||
# Copyright (C) 2006-2013 Jean-Philippe Lang
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
# as published by the Free Software Foundation; either version 2
|
||||
# of the License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
require File.expand_path('../../test_helper', __FILE__)
|
||||
|
||||
class RepositoriesGitTest < ActionController::IntegrationTest
|
||||
fixtures :projects, :users, :roles, :members, :member_roles,
|
||||
:repositories, :enabled_modules
|
||||
|
||||
REPOSITORY_PATH = Rails.root.join('tmp/test/git_repository').to_s
|
||||
REPOSITORY_PATH.gsub!(/\//, "\\") if Redmine::Platform.mswin?
|
||||
PRJ_ID = 3
|
||||
|
||||
def setup
|
||||
User.current = nil
|
||||
@project = Project.find(PRJ_ID)
|
||||
@repository = Repository::Git.create(
|
||||
:project => @project,
|
||||
:url => REPOSITORY_PATH,
|
||||
:path_encoding => 'ISO-8859-1'
|
||||
)
|
||||
assert @repository
|
||||
end
|
||||
|
||||
if File.directory?(REPOSITORY_PATH)
|
||||
def test_index
|
||||
get '/projects/subproject1/repository/'
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
def test_diff_two_revs
|
||||
get '/projects/subproject1/repository/diff?rev=61b685fbe&rev_to=2f9c0091'
|
||||
assert_response :success
|
||||
end
|
||||
end
|
||||
end
|
||||
# Redmine - project management software
|
||||
# Copyright (C) 2006-2013 Jean-Philippe Lang
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
# as published by the Free Software Foundation; either version 2
|
||||
# of the License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
require File.expand_path('../../test_helper', __FILE__)
|
||||
|
||||
class RepositoriesGitTest < ActionController::IntegrationTest
|
||||
fixtures :projects, :users, :roles, :members, :member_roles,
|
||||
:repositories, :enabled_modules
|
||||
|
||||
REPOSITORY_PATH = Rails.root.join('tmp/test/git_repository').to_s
|
||||
REPOSITORY_PATH.gsub!(/\//, "\\") if Redmine::Platform.mswin?
|
||||
PRJ_ID = 3
|
||||
|
||||
def setup
|
||||
User.current = nil
|
||||
@project = Project.find(PRJ_ID)
|
||||
@repository = Repository::Git.create(
|
||||
:project => @project,
|
||||
:url => REPOSITORY_PATH,
|
||||
:path_encoding => 'ISO-8859-1'
|
||||
)
|
||||
assert @repository
|
||||
end
|
||||
|
||||
if File.directory?(REPOSITORY_PATH)
|
||||
def test_index
|
||||
get '/projects/subproject1/repository/'
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
def test_diff_two_revs
|
||||
get '/projects/subproject1/repository/diff?rev=61b685fbe&rev_to=2f9c0091'
|
||||
assert_response :success
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@ -1,96 +1,96 @@
|
||||
# Redmine - project management software
|
||||
# Copyright (C) 2006-2013 Jean-Philippe Lang
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
# as published by the Free Software Foundation; either version 2
|
||||
# of the License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
require File.expand_path('../../../test_helper', __FILE__)
|
||||
|
||||
class RoutingProjectsTest < ActionController::IntegrationTest
|
||||
def test_courses
|
||||
assert_routing(
|
||||
{ :method => 'get', :path => "/courses" },
|
||||
{ :controller => 'courses', :action => 'index' }
|
||||
)
|
||||
end
|
||||
def test_courses_search
|
||||
assert_routing(
|
||||
"/courses/search",
|
||||
{controller: 'courses', action: 'search'}
|
||||
)
|
||||
end
|
||||
|
||||
def test_courses_item
|
||||
assert_routing(
|
||||
'courses/233',
|
||||
{controller: 'courses', action: 'show', id: '233'}
|
||||
)
|
||||
# id eq str
|
||||
assert_routing(
|
||||
'courses/timestypo',
|
||||
{controller: 'courses', action: 'show', id: 'timestypo'}
|
||||
)
|
||||
end
|
||||
|
||||
def test_course_setting
|
||||
assert_routing(
|
||||
'courses/233/settings',
|
||||
{controller: 'courses', action: 'settings', id: '233'}
|
||||
)
|
||||
end
|
||||
|
||||
def test_course_homework
|
||||
assert_routing(
|
||||
'courses/233/homework',
|
||||
{controller: 'courses', action: 'homework', id: '233'}
|
||||
)
|
||||
assert_routing(
|
||||
'courses/233/new_homework',
|
||||
{controller: 'courses', action: 'new_homework', id: '233'}
|
||||
)
|
||||
end
|
||||
|
||||
def test_course_file
|
||||
assert_routing(
|
||||
'courses/233/file',
|
||||
{controller: 'courses', action: 'file', id: '233'}
|
||||
)
|
||||
end
|
||||
|
||||
def test_course_feedback
|
||||
assert_routing(
|
||||
'courses/233/feedback',
|
||||
{controller: 'courses', action: 'feedback', id: '233'}
|
||||
)
|
||||
end
|
||||
|
||||
def test_course_member
|
||||
assert_routing(
|
||||
'courses/233/member',
|
||||
{controller: 'courses', action: 'member', id: '233'}
|
||||
)
|
||||
end
|
||||
|
||||
def test_course_finish_restart_course
|
||||
assert_routing(
|
||||
{path: 'courses/233/finishcourse', method: :post},
|
||||
{controller: 'courses', action: 'finishcourse', id: '233'}
|
||||
)
|
||||
assert_routing(
|
||||
{path: 'courses/233/restartcourse', method: :post},
|
||||
{controller: 'courses', action: 'restartcourse', id: '233'}
|
||||
)
|
||||
end
|
||||
|
||||
end
|
||||
# Redmine - project management software
|
||||
# Copyright (C) 2006-2013 Jean-Philippe Lang
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
# as published by the Free Software Foundation; either version 2
|
||||
# of the License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
require File.expand_path('../../../test_helper', __FILE__)
|
||||
|
||||
class RoutingProjectsTest < ActionController::IntegrationTest
|
||||
def test_courses
|
||||
assert_routing(
|
||||
{ :method => 'get', :path => "/courses" },
|
||||
{ :controller => 'courses', :action => 'index' }
|
||||
)
|
||||
end
|
||||
def test_courses_search
|
||||
assert_routing(
|
||||
"/courses/search",
|
||||
{controller: 'courses', action: 'search'}
|
||||
)
|
||||
end
|
||||
|
||||
def test_courses_item
|
||||
assert_routing(
|
||||
'courses/233',
|
||||
{controller: 'courses', action: 'show', id: '233'}
|
||||
)
|
||||
# id eq str
|
||||
assert_routing(
|
||||
'courses/timestypo',
|
||||
{controller: 'courses', action: 'show', id: 'timestypo'}
|
||||
)
|
||||
end
|
||||
|
||||
def test_course_setting
|
||||
assert_routing(
|
||||
'courses/233/settings',
|
||||
{controller: 'courses', action: 'settings', id: '233'}
|
||||
)
|
||||
end
|
||||
|
||||
def test_course_homework
|
||||
assert_routing(
|
||||
'courses/233/homework',
|
||||
{controller: 'courses', action: 'homework', id: '233'}
|
||||
)
|
||||
assert_routing(
|
||||
'courses/233/new_homework',
|
||||
{controller: 'courses', action: 'new_homework', id: '233'}
|
||||
)
|
||||
end
|
||||
|
||||
def test_course_file
|
||||
assert_routing(
|
||||
'courses/233/file',
|
||||
{controller: 'courses', action: 'file', id: '233'}
|
||||
)
|
||||
end
|
||||
|
||||
def test_course_feedback
|
||||
assert_routing(
|
||||
'courses/233/feedback',
|
||||
{controller: 'courses', action: 'feedback', id: '233'}
|
||||
)
|
||||
end
|
||||
|
||||
def test_course_member
|
||||
assert_routing(
|
||||
'courses/233/member',
|
||||
{controller: 'courses', action: 'member', id: '233'}
|
||||
)
|
||||
end
|
||||
|
||||
def test_course_finish_restart_course
|
||||
assert_routing(
|
||||
{path: 'courses/233/finishcourse', method: :post},
|
||||
{controller: 'courses', action: 'finishcourse', id: '233'}
|
||||
)
|
||||
assert_routing(
|
||||
{path: 'courses/233/restartcourse', method: :post},
|
||||
{controller: 'courses', action: 'restartcourse', id: '233'}
|
||||
)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@ -1,29 +1,29 @@
|
||||
# Redmine - project management software
|
||||
# Copyright (C) 2006-2013 Jean-Philippe Lang
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
# as published by the Free Software Foundation; either version 2
|
||||
# of the License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
require File.expand_path('../../test_helper', __FILE__)
|
||||
|
||||
class UsersTest < ActionController::IntegrationTest
|
||||
fixtures :users
|
||||
|
||||
def test_destroy_should_not_accept_get_requests
|
||||
assert_no_difference 'User.count' do
|
||||
get '/users/destroy/2', {}, credentials('admin')
|
||||
assert_response 404
|
||||
end
|
||||
end
|
||||
end
|
||||
# Redmine - project management software
|
||||
# Copyright (C) 2006-2013 Jean-Philippe Lang
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
# as published by the Free Software Foundation; either version 2
|
||||
# of the License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
require File.expand_path('../../test_helper', __FILE__)
|
||||
|
||||
class UsersTest < ActionController::IntegrationTest
|
||||
fixtures :users
|
||||
|
||||
def test_destroy_should_not_accept_get_requests
|
||||
assert_no_difference 'User.count' do
|
||||
get '/users/destroy/2', {}, credentials('admin')
|
||||
assert_response 404
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -1,116 +1,116 @@
|
||||
# encoding: utf-8
|
||||
#
|
||||
# Redmine - project management software
|
||||
# Copyright (C) 2006-2013 Jean-Philippe Lang
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
# as published by the Free Software Foundation; either version 2
|
||||
# of the License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
require File.expand_path('../../test_helper', __FILE__)
|
||||
|
||||
class BoardTest < ActiveSupport::TestCase
|
||||
fixtures :projects, :boards, :messages, :attachments, :watchers
|
||||
|
||||
include Redmine::I18n
|
||||
|
||||
def setup
|
||||
@project = Project.find(1)
|
||||
end
|
||||
|
||||
def test_create
|
||||
board = Board.new(:project => @project, :name => 'Test board', :description => 'Test board description')
|
||||
assert board.save
|
||||
board.reload
|
||||
assert_equal 'Test board', board.name
|
||||
assert_equal 'Test board description', board.description
|
||||
assert_equal @project, board.project
|
||||
assert_equal 0, board.topics_count
|
||||
assert_equal 0, board.messages_count
|
||||
assert_nil board.last_message
|
||||
# last position
|
||||
assert_equal @project.boards.size, board.position
|
||||
end
|
||||
|
||||
def test_parent_should_be_in_same_project
|
||||
set_language_if_valid 'en'
|
||||
board = Board.new(:project_id => 3, :name => 'Test', :description => 'Test', :parent_id => 1)
|
||||
assert !board.save
|
||||
assert_include "Parent forum is invalid", board.errors.full_messages
|
||||
end
|
||||
|
||||
def test_valid_parents_should_not_include_self_nor_a_descendant
|
||||
board1 = Board.generate!(:project_id => 3)
|
||||
board2 = Board.generate!(:project_id => 3, :parent => board1)
|
||||
board3 = Board.generate!(:project_id => 3, :parent => board2)
|
||||
board4 = Board.generate!(:project_id => 3)
|
||||
|
||||
assert_equal [board4], board1.reload.valid_parents.sort_by(&:id)
|
||||
assert_equal [board1, board4], board2.reload.valid_parents.sort_by(&:id)
|
||||
assert_equal [board1, board2, board4], board3.reload.valid_parents.sort_by(&:id)
|
||||
assert_equal [board1, board2, board3], board4.reload.valid_parents.sort_by(&:id)
|
||||
end
|
||||
|
||||
def test_position_should_be_assigned_with_parent_scope
|
||||
parent1 = Board.generate!(:project_id => 3)
|
||||
parent2 = Board.generate!(:project_id => 3)
|
||||
child1 = Board.generate!(:project_id => 3, :parent => parent1)
|
||||
child2 = Board.generate!(:project_id => 3, :parent => parent1)
|
||||
|
||||
assert_equal 1, parent1.reload.position
|
||||
assert_equal 1, child1.reload.position
|
||||
assert_equal 2, child2.reload.position
|
||||
assert_equal 2, parent2.reload.position
|
||||
end
|
||||
|
||||
def test_board_tree_should_yield_boards_with_level
|
||||
parent1 = Board.generate!(:project_id => 3)
|
||||
parent2 = Board.generate!(:project_id => 3)
|
||||
child1 = Board.generate!(:project_id => 3, :parent => parent1)
|
||||
child2 = Board.generate!(:project_id => 3, :parent => parent1)
|
||||
child3 = Board.generate!(:project_id => 3, :parent => child1)
|
||||
|
||||
tree = Board.board_tree(Project.find(3).boards)
|
||||
|
||||
assert_equal [
|
||||
[parent1, 0],
|
||||
[child1, 1],
|
||||
[child3, 2],
|
||||
[child2, 1],
|
||||
[parent2, 0]
|
||||
], tree
|
||||
end
|
||||
|
||||
def test_destroy
|
||||
board = Board.find(1)
|
||||
assert_difference 'Message.count', -6 do
|
||||
assert_difference 'Attachment.count', -1 do
|
||||
assert_difference 'Watcher.count', -1 do
|
||||
assert board.destroy
|
||||
end
|
||||
end
|
||||
end
|
||||
assert_equal 0, Message.count(:conditions => {:board_id => 1})
|
||||
end
|
||||
|
||||
def test_destroy_should_nullify_children
|
||||
parent = Board.generate!(:project => @project)
|
||||
child = Board.generate!(:project => @project, :parent => parent)
|
||||
assert_equal parent, child.parent
|
||||
|
||||
assert parent.destroy
|
||||
child.reload
|
||||
assert_nil child.parent
|
||||
assert_nil child.parent_id
|
||||
end
|
||||
end
|
||||
# encoding: utf-8
|
||||
#
|
||||
# Redmine - project management software
|
||||
# Copyright (C) 2006-2013 Jean-Philippe Lang
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
# as published by the Free Software Foundation; either version 2
|
||||
# of the License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
require File.expand_path('../../test_helper', __FILE__)
|
||||
|
||||
class BoardTest < ActiveSupport::TestCase
|
||||
fixtures :projects, :boards, :messages, :attachments, :watchers
|
||||
|
||||
include Redmine::I18n
|
||||
|
||||
def setup
|
||||
@project = Project.find(1)
|
||||
end
|
||||
|
||||
def test_create
|
||||
board = Board.new(:project => @project, :name => 'Test board', :description => 'Test board description')
|
||||
assert board.save
|
||||
board.reload
|
||||
assert_equal 'Test board', board.name
|
||||
assert_equal 'Test board description', board.description
|
||||
assert_equal @project, board.project
|
||||
assert_equal 0, board.topics_count
|
||||
assert_equal 0, board.messages_count
|
||||
assert_nil board.last_message
|
||||
# last position
|
||||
assert_equal @project.boards.size, board.position
|
||||
end
|
||||
|
||||
def test_parent_should_be_in_same_project
|
||||
set_language_if_valid 'en'
|
||||
board = Board.new(:project_id => 3, :name => 'Test', :description => 'Test', :parent_id => 1)
|
||||
assert !board.save
|
||||
assert_include "Parent forum is invalid", board.errors.full_messages
|
||||
end
|
||||
|
||||
def test_valid_parents_should_not_include_self_nor_a_descendant
|
||||
board1 = Board.generate!(:project_id => 3)
|
||||
board2 = Board.generate!(:project_id => 3, :parent => board1)
|
||||
board3 = Board.generate!(:project_id => 3, :parent => board2)
|
||||
board4 = Board.generate!(:project_id => 3)
|
||||
|
||||
assert_equal [board4], board1.reload.valid_parents.sort_by(&:id)
|
||||
assert_equal [board1, board4], board2.reload.valid_parents.sort_by(&:id)
|
||||
assert_equal [board1, board2, board4], board3.reload.valid_parents.sort_by(&:id)
|
||||
assert_equal [board1, board2, board3], board4.reload.valid_parents.sort_by(&:id)
|
||||
end
|
||||
|
||||
def test_position_should_be_assigned_with_parent_scope
|
||||
parent1 = Board.generate!(:project_id => 3)
|
||||
parent2 = Board.generate!(:project_id => 3)
|
||||
child1 = Board.generate!(:project_id => 3, :parent => parent1)
|
||||
child2 = Board.generate!(:project_id => 3, :parent => parent1)
|
||||
|
||||
assert_equal 1, parent1.reload.position
|
||||
assert_equal 1, child1.reload.position
|
||||
assert_equal 2, child2.reload.position
|
||||
assert_equal 2, parent2.reload.position
|
||||
end
|
||||
|
||||
def test_board_tree_should_yield_boards_with_level
|
||||
parent1 = Board.generate!(:project_id => 3)
|
||||
parent2 = Board.generate!(:project_id => 3)
|
||||
child1 = Board.generate!(:project_id => 3, :parent => parent1)
|
||||
child2 = Board.generate!(:project_id => 3, :parent => parent1)
|
||||
child3 = Board.generate!(:project_id => 3, :parent => child1)
|
||||
|
||||
tree = Board.board_tree(Project.find(3).boards)
|
||||
|
||||
assert_equal [
|
||||
[parent1, 0],
|
||||
[child1, 1],
|
||||
[child3, 2],
|
||||
[child2, 1],
|
||||
[parent2, 0]
|
||||
], tree
|
||||
end
|
||||
|
||||
def test_destroy
|
||||
board = Board.find(1)
|
||||
assert_difference 'Message.count', -6 do
|
||||
assert_difference 'Attachment.count', -1 do
|
||||
assert_difference 'Watcher.count', -1 do
|
||||
assert board.destroy
|
||||
end
|
||||
end
|
||||
end
|
||||
assert_equal 0, Message.count(:conditions => {:board_id => 1})
|
||||
end
|
||||
|
||||
def test_destroy_should_nullify_children
|
||||
parent = Board.generate!(:project => @project)
|
||||
child = Board.generate!(:project => @project, :parent => parent)
|
||||
assert_equal parent, child.parent
|
||||
|
||||
assert parent.destroy
|
||||
child.reload
|
||||
assert_nil child.parent
|
||||
assert_nil child.parent_id
|
||||
end
|
||||
end
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -1,57 +1,57 @@
|
||||
# Redmine - project management software
|
||||
# Copyright (C) 2006-2013 Jean-Philippe Lang
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
# as published by the Free Software Foundation; either version 2
|
||||
# of the License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
require File.expand_path('../../test_helper', __FILE__)
|
||||
|
||||
class CommentTest < ActiveSupport::TestCase
|
||||
fixtures :users, :news, :comments, :projects, :enabled_modules
|
||||
|
||||
def setup
|
||||
@jsmith = User.find(2)
|
||||
@news = News.find(1)
|
||||
end
|
||||
|
||||
def test_create
|
||||
comment = Comment.new(:commented => @news, :author => @jsmith, :comments => "my comment")
|
||||
assert comment.save
|
||||
@news.reload
|
||||
assert_equal 2, @news.comments_count
|
||||
end
|
||||
|
||||
def test_create_should_send_notification
|
||||
Watcher.create!(:watchable => @news, :user => @jsmith)
|
||||
|
||||
with_settings :notified_events => %w(news_comment_added) do
|
||||
assert_difference 'ActionMailer::Base.deliveries.size' do
|
||||
Comment.create!(:commented => @news, :author => @jsmith, :comments => "my comment")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def test_validate
|
||||
comment = Comment.new(:commented => @news)
|
||||
assert !comment.save
|
||||
assert_equal 2, comment.errors.count
|
||||
end
|
||||
|
||||
def test_destroy
|
||||
comment = Comment.find(1)
|
||||
assert comment.destroy
|
||||
@news.reload
|
||||
assert_equal 0, @news.comments_count
|
||||
end
|
||||
end
|
||||
# Redmine - project management software
|
||||
# Copyright (C) 2006-2013 Jean-Philippe Lang
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
# as published by the Free Software Foundation; either version 2
|
||||
# of the License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
require File.expand_path('../../test_helper', __FILE__)
|
||||
|
||||
class CommentTest < ActiveSupport::TestCase
|
||||
fixtures :users, :news, :comments, :projects, :enabled_modules
|
||||
|
||||
def setup
|
||||
@jsmith = User.find(2)
|
||||
@news = News.find(1)
|
||||
end
|
||||
|
||||
def test_create
|
||||
comment = Comment.new(:commented => @news, :author => @jsmith, :comments => "my comment")
|
||||
assert comment.save
|
||||
@news.reload
|
||||
assert_equal 2, @news.comments_count
|
||||
end
|
||||
|
||||
def test_create_should_send_notification
|
||||
Watcher.create!(:watchable => @news, :user => @jsmith)
|
||||
|
||||
with_settings :notified_events => %w(news_comment_added) do
|
||||
assert_difference 'ActionMailer::Base.deliveries.size' do
|
||||
Comment.create!(:commented => @news, :author => @jsmith, :comments => "my comment")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def test_validate
|
||||
comment = Comment.new(:commented => @news)
|
||||
assert !comment.save
|
||||
assert_equal 2, comment.errors.count
|
||||
end
|
||||
|
||||
def test_destroy
|
||||
comment = Comment.find(1)
|
||||
assert comment.destroy
|
||||
@news.reload
|
||||
assert_equal 0, @news.comments_count
|
||||
end
|
||||
end
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
require 'test_helper'
|
||||
|
||||
class ContestNotificationTest < ActiveSupport::TestCase
|
||||
# test "the truth" do
|
||||
# assert true
|
||||
# end
|
||||
end
|
||||
require 'test_helper'
|
||||
|
||||
class ContestNotificationTest < ActiveSupport::TestCase
|
||||
# test "the truth" do
|
||||
# assert true
|
||||
# end
|
||||
end
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -1,77 +1,77 @@
|
||||
# Redmine - project management software
|
||||
# Copyright (C) 2006-2013 Jean-Philippe Lang
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
# as published by the Free Software Foundation; either version 2
|
||||
# of the License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
require File.expand_path('../../test_helper', __FILE__)
|
||||
|
||||
class CustomFieldUserFormatTest < ActiveSupport::TestCase
|
||||
fixtures :custom_fields, :projects, :members, :users, :member_roles, :trackers, :issues
|
||||
|
||||
def setup
|
||||
@field = IssueCustomField.create!(:name => 'Tester', :field_format => 'user')
|
||||
end
|
||||
|
||||
def test_possible_values_with_no_arguments
|
||||
assert_equal [], @field.possible_values
|
||||
assert_equal [], @field.possible_values(nil)
|
||||
end
|
||||
|
||||
def test_possible_values_with_project_resource
|
||||
project = Project.find(1)
|
||||
possible_values = @field.possible_values(project.issues.first)
|
||||
assert possible_values.any?
|
||||
assert_equal project.users.sort.collect(&:id).map(&:to_s), possible_values
|
||||
end
|
||||
|
||||
def test_possible_values_with_nil_project_resource
|
||||
project = Project.find(1)
|
||||
assert_equal [], @field.possible_values(Issue.new)
|
||||
end
|
||||
|
||||
def test_possible_values_options_with_no_arguments
|
||||
assert_equal [], @field.possible_values_options
|
||||
assert_equal [], @field.possible_values_options(nil)
|
||||
end
|
||||
|
||||
def test_possible_values_options_with_project_resource
|
||||
project = Project.find(1)
|
||||
possible_values_options = @field.possible_values_options(project.issues.first)
|
||||
assert possible_values_options.any?
|
||||
assert_equal project.users.sort.map {|u| [u.name, u.id.to_s]}, possible_values_options
|
||||
end
|
||||
|
||||
def test_possible_values_options_with_array
|
||||
projects = Project.find([1, 2])
|
||||
possible_values_options = @field.possible_values_options(projects)
|
||||
assert possible_values_options.any?
|
||||
assert_equal (projects.first.users & projects.last.users).sort.map {|u| [u.name, u.id.to_s]}, possible_values_options
|
||||
end
|
||||
|
||||
def test_cast_blank_value
|
||||
assert_equal nil, @field.cast_value(nil)
|
||||
assert_equal nil, @field.cast_value("")
|
||||
end
|
||||
|
||||
def test_cast_valid_value
|
||||
user = @field.cast_value("2")
|
||||
assert_kind_of User, user
|
||||
assert_equal User.find(2), user
|
||||
end
|
||||
|
||||
def test_cast_invalid_value
|
||||
assert_equal nil, @field.cast_value("187")
|
||||
end
|
||||
end
|
||||
# Redmine - project management software
|
||||
# Copyright (C) 2006-2013 Jean-Philippe Lang
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
# as published by the Free Software Foundation; either version 2
|
||||
# of the License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
require File.expand_path('../../test_helper', __FILE__)
|
||||
|
||||
class CustomFieldUserFormatTest < ActiveSupport::TestCase
|
||||
fixtures :custom_fields, :projects, :members, :users, :member_roles, :trackers, :issues
|
||||
|
||||
def setup
|
||||
@field = IssueCustomField.create!(:name => 'Tester', :field_format => 'user')
|
||||
end
|
||||
|
||||
def test_possible_values_with_no_arguments
|
||||
assert_equal [], @field.possible_values
|
||||
assert_equal [], @field.possible_values(nil)
|
||||
end
|
||||
|
||||
def test_possible_values_with_project_resource
|
||||
project = Project.find(1)
|
||||
possible_values = @field.possible_values(project.issues.first)
|
||||
assert possible_values.any?
|
||||
assert_equal project.users.sort.collect(&:id).map(&:to_s), possible_values
|
||||
end
|
||||
|
||||
def test_possible_values_with_nil_project_resource
|
||||
project = Project.find(1)
|
||||
assert_equal [], @field.possible_values(Issue.new)
|
||||
end
|
||||
|
||||
def test_possible_values_options_with_no_arguments
|
||||
assert_equal [], @field.possible_values_options
|
||||
assert_equal [], @field.possible_values_options(nil)
|
||||
end
|
||||
|
||||
def test_possible_values_options_with_project_resource
|
||||
project = Project.find(1)
|
||||
possible_values_options = @field.possible_values_options(project.issues.first)
|
||||
assert possible_values_options.any?
|
||||
assert_equal project.users.sort.map {|u| [u.name, u.id.to_s]}, possible_values_options
|
||||
end
|
||||
|
||||
def test_possible_values_options_with_array
|
||||
projects = Project.find([1, 2])
|
||||
possible_values_options = @field.possible_values_options(projects)
|
||||
assert possible_values_options.any?
|
||||
assert_equal (projects.first.users & projects.last.users).sort.map {|u| [u.name, u.id.to_s]}, possible_values_options
|
||||
end
|
||||
|
||||
def test_cast_blank_value
|
||||
assert_equal nil, @field.cast_value(nil)
|
||||
assert_equal nil, @field.cast_value("")
|
||||
end
|
||||
|
||||
def test_cast_valid_value
|
||||
user = @field.cast_value("2")
|
||||
assert_kind_of User, user
|
||||
assert_equal User.find(2), user
|
||||
end
|
||||
|
||||
def test_cast_invalid_value
|
||||
assert_equal nil, @field.cast_value("187")
|
||||
end
|
||||
end
|
||||
|
||||
@ -1,76 +1,76 @@
|
||||
# Redmine - project management software
|
||||
# Copyright (C) 2006-2013 Jean-Philippe Lang
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
# as published by the Free Software Foundation; either version 2
|
||||
# of the License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
require File.expand_path('../../test_helper', __FILE__)
|
||||
|
||||
class CustomFieldVersionFormatTest < ActiveSupport::TestCase
|
||||
fixtures :custom_fields, :projects, :members, :users, :member_roles, :trackers, :issues, :versions
|
||||
|
||||
def setup
|
||||
@field = IssueCustomField.create!(:name => 'Tester', :field_format => 'version')
|
||||
end
|
||||
|
||||
def test_possible_values_with_no_arguments
|
||||
assert_equal [], @field.possible_values
|
||||
assert_equal [], @field.possible_values(nil)
|
||||
end
|
||||
|
||||
def test_possible_values_with_project_resource
|
||||
project = Project.find(1)
|
||||
possible_values = @field.possible_values(project.issues.first)
|
||||
assert possible_values.any?
|
||||
assert_equal project.shared_versions.sort.collect(&:id).map(&:to_s), possible_values
|
||||
end
|
||||
|
||||
def test_possible_values_with_nil_project_resource
|
||||
assert_equal [], @field.possible_values(Issue.new)
|
||||
end
|
||||
|
||||
def test_possible_values_options_with_no_arguments
|
||||
assert_equal [], @field.possible_values_options
|
||||
assert_equal [], @field.possible_values_options(nil)
|
||||
end
|
||||
|
||||
def test_possible_values_options_with_project_resource
|
||||
project = Project.find(1)
|
||||
possible_values_options = @field.possible_values_options(project.issues.first)
|
||||
assert possible_values_options.any?
|
||||
assert_equal project.shared_versions.sort.map {|u| [u.name, u.id.to_s]}, possible_values_options
|
||||
end
|
||||
|
||||
def test_possible_values_options_with_array
|
||||
projects = Project.find([1, 2])
|
||||
possible_values_options = @field.possible_values_options(projects)
|
||||
assert possible_values_options.any?
|
||||
assert_equal (projects.first.shared_versions & projects.last.shared_versions).sort.map {|u| [u.name, u.id.to_s]}, possible_values_options
|
||||
end
|
||||
|
||||
def test_cast_blank_value
|
||||
assert_equal nil, @field.cast_value(nil)
|
||||
assert_equal nil, @field.cast_value("")
|
||||
end
|
||||
|
||||
def test_cast_valid_value
|
||||
version = @field.cast_value("2")
|
||||
assert_kind_of Version, version
|
||||
assert_equal Version.find(2), version
|
||||
end
|
||||
|
||||
def test_cast_invalid_value
|
||||
assert_equal nil, @field.cast_value("187")
|
||||
end
|
||||
end
|
||||
# Redmine - project management software
|
||||
# Copyright (C) 2006-2013 Jean-Philippe Lang
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
# as published by the Free Software Foundation; either version 2
|
||||
# of the License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
require File.expand_path('../../test_helper', __FILE__)
|
||||
|
||||
class CustomFieldVersionFormatTest < ActiveSupport::TestCase
|
||||
fixtures :custom_fields, :projects, :members, :users, :member_roles, :trackers, :issues, :versions
|
||||
|
||||
def setup
|
||||
@field = IssueCustomField.create!(:name => 'Tester', :field_format => 'version')
|
||||
end
|
||||
|
||||
def test_possible_values_with_no_arguments
|
||||
assert_equal [], @field.possible_values
|
||||
assert_equal [], @field.possible_values(nil)
|
||||
end
|
||||
|
||||
def test_possible_values_with_project_resource
|
||||
project = Project.find(1)
|
||||
possible_values = @field.possible_values(project.issues.first)
|
||||
assert possible_values.any?
|
||||
assert_equal project.shared_versions.sort.collect(&:id).map(&:to_s), possible_values
|
||||
end
|
||||
|
||||
def test_possible_values_with_nil_project_resource
|
||||
assert_equal [], @field.possible_values(Issue.new)
|
||||
end
|
||||
|
||||
def test_possible_values_options_with_no_arguments
|
||||
assert_equal [], @field.possible_values_options
|
||||
assert_equal [], @field.possible_values_options(nil)
|
||||
end
|
||||
|
||||
def test_possible_values_options_with_project_resource
|
||||
project = Project.find(1)
|
||||
possible_values_options = @field.possible_values_options(project.issues.first)
|
||||
assert possible_values_options.any?
|
||||
assert_equal project.shared_versions.sort.map {|u| [u.name, u.id.to_s]}, possible_values_options
|
||||
end
|
||||
|
||||
def test_possible_values_options_with_array
|
||||
projects = Project.find([1, 2])
|
||||
possible_values_options = @field.possible_values_options(projects)
|
||||
assert possible_values_options.any?
|
||||
assert_equal (projects.first.shared_versions & projects.last.shared_versions).sort.map {|u| [u.name, u.id.to_s]}, possible_values_options
|
||||
end
|
||||
|
||||
def test_cast_blank_value
|
||||
assert_equal nil, @field.cast_value(nil)
|
||||
assert_equal nil, @field.cast_value("")
|
||||
end
|
||||
|
||||
def test_cast_valid_value
|
||||
version = @field.cast_value("2")
|
||||
assert_kind_of Version, version
|
||||
assert_equal Version.find(2), version
|
||||
end
|
||||
|
||||
def test_cast_invalid_value
|
||||
assert_equal nil, @field.cast_value("187")
|
||||
end
|
||||
end
|
||||
|
||||
@ -1,39 +1,39 @@
|
||||
# Redmine - project management software
|
||||
# Copyright (C) 2006-2013 Jean-Philippe Lang
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
# as published by the Free Software Foundation; either version 2
|
||||
# of the License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
require File.expand_path('../../test_helper', __FILE__)
|
||||
|
||||
class CustomValueTest < ActiveSupport::TestCase
|
||||
fixtures :custom_fields, :custom_values, :users
|
||||
|
||||
def test_default_value
|
||||
field = CustomField.find_by_default_value('Default string')
|
||||
assert_not_nil field
|
||||
|
||||
v = CustomValue.new(:custom_field => field)
|
||||
assert_equal 'Default string', v.value
|
||||
|
||||
v = CustomValue.new(:custom_field => field, :value => 'Not empty')
|
||||
assert_equal 'Not empty', v.value
|
||||
end
|
||||
|
||||
def test_sti_polymorphic_association
|
||||
# Rails uses top level sti class for polymorphic association. See #3978.
|
||||
assert !User.find(4).custom_values.empty?
|
||||
assert !CustomValue.find(2).customized.nil?
|
||||
end
|
||||
end
|
||||
# Redmine - project management software
|
||||
# Copyright (C) 2006-2013 Jean-Philippe Lang
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
# as published by the Free Software Foundation; either version 2
|
||||
# of the License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
require File.expand_path('../../test_helper', __FILE__)
|
||||
|
||||
class CustomValueTest < ActiveSupport::TestCase
|
||||
fixtures :custom_fields, :custom_values, :users
|
||||
|
||||
def test_default_value
|
||||
field = CustomField.find_by_default_value('Default string')
|
||||
assert_not_nil field
|
||||
|
||||
v = CustomValue.new(:custom_field => field)
|
||||
assert_equal 'Default string', v.value
|
||||
|
||||
v = CustomValue.new(:custom_field => field, :value => 'Not empty')
|
||||
assert_equal 'Not empty', v.value
|
||||
end
|
||||
|
||||
def test_sti_polymorphic_association
|
||||
# Rails uses top level sti class for polymorphic association. See #3978.
|
||||
assert !User.find(4).custom_values.empty?
|
||||
assert !CustomValue.find(2).customized.nil?
|
||||
end
|
||||
end
|
||||
|
||||
@ -1,49 +1,49 @@
|
||||
# Redmine - project management software
|
||||
# Copyright (C) 2006-2013 Jean-Philippe Lang
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
# as published by the Free Software Foundation; either version 2
|
||||
# of the License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
require File.expand_path('../../test_helper', __FILE__)
|
||||
|
||||
class DefaultDataTest < ActiveSupport::TestCase
|
||||
include Redmine::I18n
|
||||
fixtures :roles
|
||||
|
||||
def test_no_data
|
||||
assert !Redmine::DefaultData::Loader::no_data?
|
||||
Role.delete_all("builtin = 0")
|
||||
Tracker.delete_all
|
||||
IssueStatus.delete_all
|
||||
Enumeration.delete_all
|
||||
assert Redmine::DefaultData::Loader::no_data?
|
||||
end
|
||||
|
||||
def test_load
|
||||
valid_languages.each do |lang|
|
||||
begin
|
||||
Role.delete_all("builtin = 0")
|
||||
Tracker.delete_all
|
||||
IssueStatus.delete_all
|
||||
Enumeration.delete_all
|
||||
assert Redmine::DefaultData::Loader::load(lang)
|
||||
assert_not_nil DocumentCategory.first
|
||||
assert_not_nil IssuePriority.first
|
||||
assert_not_nil TimeEntryActivity.first
|
||||
rescue ActiveRecord::RecordInvalid => e
|
||||
assert false, ":#{lang} default data is invalid (#{e.message})."
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
# Redmine - project management software
|
||||
# Copyright (C) 2006-2013 Jean-Philippe Lang
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
# as published by the Free Software Foundation; either version 2
|
||||
# of the License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
require File.expand_path('../../test_helper', __FILE__)
|
||||
|
||||
class DefaultDataTest < ActiveSupport::TestCase
|
||||
include Redmine::I18n
|
||||
fixtures :roles
|
||||
|
||||
def test_no_data
|
||||
assert !Redmine::DefaultData::Loader::no_data?
|
||||
Role.delete_all("builtin = 0")
|
||||
Tracker.delete_all
|
||||
IssueStatus.delete_all
|
||||
Enumeration.delete_all
|
||||
assert Redmine::DefaultData::Loader::no_data?
|
||||
end
|
||||
|
||||
def test_load
|
||||
valid_languages.each do |lang|
|
||||
begin
|
||||
Role.delete_all("builtin = 0")
|
||||
Tracker.delete_all
|
||||
IssueStatus.delete_all
|
||||
Enumeration.delete_all
|
||||
assert Redmine::DefaultData::Loader::load(lang)
|
||||
assert_not_nil DocumentCategory.first
|
||||
assert_not_nil IssuePriority.first
|
||||
assert_not_nil TimeEntryActivity.first
|
||||
rescue ActiveRecord::RecordInvalid => e
|
||||
assert false, ":#{lang} default data is invalid (#{e.message})."
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@ -1,47 +1,47 @@
|
||||
# Redmine - project management software
|
||||
# Copyright (C) 2006-2013 Jean-Philippe Lang
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
# as published by the Free Software Foundation; either version 2
|
||||
# of the License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
require File.expand_path('../../test_helper', __FILE__)
|
||||
|
||||
class DocumentCategoryTest < ActiveSupport::TestCase
|
||||
fixtures :enumerations, :documents, :issues
|
||||
|
||||
def test_should_be_an_enumeration
|
||||
assert DocumentCategory.ancestors.include?(Enumeration)
|
||||
end
|
||||
|
||||
def test_objects_count
|
||||
assert_equal 2, DocumentCategory.find_by_name("Uncategorized").objects_count
|
||||
assert_equal 0, DocumentCategory.find_by_name("User documentation").objects_count
|
||||
end
|
||||
|
||||
def test_option_name
|
||||
assert_equal :enumeration_doc_categories, DocumentCategory.new.option_name
|
||||
end
|
||||
|
||||
def test_default
|
||||
assert_nil DocumentCategory.where(:is_default => true).first
|
||||
e = Enumeration.find_by_name('Technical documentation')
|
||||
e.update_attributes(:is_default => true)
|
||||
assert_equal 3, DocumentCategory.default.id
|
||||
end
|
||||
|
||||
def test_force_default
|
||||
assert_nil DocumentCategory.where(:is_default => true).first
|
||||
assert_equal 1, DocumentCategory.default.id
|
||||
end
|
||||
end
|
||||
# Redmine - project management software
|
||||
# Copyright (C) 2006-2013 Jean-Philippe Lang
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
# as published by the Free Software Foundation; either version 2
|
||||
# of the License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
require File.expand_path('../../test_helper', __FILE__)
|
||||
|
||||
class DocumentCategoryTest < ActiveSupport::TestCase
|
||||
fixtures :enumerations, :documents, :issues
|
||||
|
||||
def test_should_be_an_enumeration
|
||||
assert DocumentCategory.ancestors.include?(Enumeration)
|
||||
end
|
||||
|
||||
def test_objects_count
|
||||
assert_equal 2, DocumentCategory.find_by_name("Uncategorized").objects_count
|
||||
assert_equal 0, DocumentCategory.find_by_name("User documentation").objects_count
|
||||
end
|
||||
|
||||
def test_option_name
|
||||
assert_equal :enumeration_doc_categories, DocumentCategory.new.option_name
|
||||
end
|
||||
|
||||
def test_default
|
||||
assert_nil DocumentCategory.where(:is_default => true).first
|
||||
e = Enumeration.find_by_name('Technical documentation')
|
||||
e.update_attributes(:is_default => true)
|
||||
assert_equal 3, DocumentCategory.default.id
|
||||
end
|
||||
|
||||
def test_force_default
|
||||
assert_nil DocumentCategory.where(:is_default => true).first
|
||||
assert_equal 1, DocumentCategory.default.id
|
||||
end
|
||||
end
|
||||
|
||||
@ -1,62 +1,62 @@
|
||||
# Redmine - project management software
|
||||
# Copyright (C) 2006-2013 Jean-Philippe Lang
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
# as published by the Free Software Foundation; either version 2
|
||||
# of the License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
require File.expand_path('../../test_helper', __FILE__)
|
||||
|
||||
class DocumentTest < ActiveSupport::TestCase
|
||||
fixtures :projects, :enumerations, :documents, :attachments,
|
||||
:enabled_modules,
|
||||
:users, :members, :member_roles, :roles,
|
||||
:groups_users
|
||||
|
||||
def test_create
|
||||
doc = Document.new(:project => Project.find(1), :title => 'New document', :category => Enumeration.find_by_name('User documentation'))
|
||||
assert doc.save
|
||||
end
|
||||
|
||||
def test_create_should_send_email_notification
|
||||
ActionMailer::Base.deliveries.clear
|
||||
|
||||
with_settings :notified_events => %w(document_added) do
|
||||
doc = Document.new(:project => Project.find(1), :title => 'New document', :category => Enumeration.find_by_name('User documentation'))
|
||||
assert doc.save
|
||||
end
|
||||
assert_equal 1, ActionMailer::Base.deliveries.size
|
||||
end
|
||||
|
||||
def test_create_with_default_category
|
||||
# Sets a default category
|
||||
e = Enumeration.find_by_name('Technical documentation')
|
||||
e.update_attributes(:is_default => true)
|
||||
|
||||
doc = Document.new(:project => Project.find(1), :title => 'New document')
|
||||
assert_equal e, doc.category
|
||||
assert doc.save
|
||||
end
|
||||
|
||||
def test_updated_on_with_attachments
|
||||
d = Document.find(1)
|
||||
assert d.attachments.any?
|
||||
assert_equal d.attachments.map(&:created_on).max, d.updated_on
|
||||
end
|
||||
|
||||
def test_updated_on_without_attachments
|
||||
d = Document.find(2)
|
||||
assert d.attachments.empty?
|
||||
assert_equal d.created_on, d.updated_on
|
||||
end
|
||||
end
|
||||
# Redmine - project management software
|
||||
# Copyright (C) 2006-2013 Jean-Philippe Lang
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
# as published by the Free Software Foundation; either version 2
|
||||
# of the License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
require File.expand_path('../../test_helper', __FILE__)
|
||||
|
||||
class DocumentTest < ActiveSupport::TestCase
|
||||
fixtures :projects, :enumerations, :documents, :attachments,
|
||||
:enabled_modules,
|
||||
:users, :members, :member_roles, :roles,
|
||||
:groups_users
|
||||
|
||||
def test_create
|
||||
doc = Document.new(:project => Project.find(1), :title => 'New document', :category => Enumeration.find_by_name('User documentation'))
|
||||
assert doc.save
|
||||
end
|
||||
|
||||
def test_create_should_send_email_notification
|
||||
ActionMailer::Base.deliveries.clear
|
||||
|
||||
with_settings :notified_events => %w(document_added) do
|
||||
doc = Document.new(:project => Project.find(1), :title => 'New document', :category => Enumeration.find_by_name('User documentation'))
|
||||
assert doc.save
|
||||
end
|
||||
assert_equal 1, ActionMailer::Base.deliveries.size
|
||||
end
|
||||
|
||||
def test_create_with_default_category
|
||||
# Sets a default category
|
||||
e = Enumeration.find_by_name('Technical documentation')
|
||||
e.update_attributes(:is_default => true)
|
||||
|
||||
doc = Document.new(:project => Project.find(1), :title => 'New document')
|
||||
assert_equal e, doc.category
|
||||
assert doc.save
|
||||
end
|
||||
|
||||
def test_updated_on_with_attachments
|
||||
d = Document.find(1)
|
||||
assert d.attachments.any?
|
||||
assert_equal d.attachments.map(&:created_on).max, d.updated_on
|
||||
end
|
||||
|
||||
def test_updated_on_without_attachments
|
||||
d = Document.find(2)
|
||||
assert d.attachments.empty?
|
||||
assert_equal d.created_on, d.updated_on
|
||||
end
|
||||
end
|
||||
|
||||
@ -1,43 +1,43 @@
|
||||
# Redmine - project management software
|
||||
# Copyright (C) 2006-2013 Jean-Philippe Lang
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
# as published by the Free Software Foundation; either version 2
|
||||
# of the License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
require File.expand_path('../../test_helper', __FILE__)
|
||||
|
||||
class EnabledModuleTest < ActiveSupport::TestCase
|
||||
fixtures :projects, :wikis
|
||||
|
||||
def test_enabling_wiki_should_create_a_wiki
|
||||
CustomField.delete_all
|
||||
project = Project.create!(:name => 'Project with wiki', :identifier => 'wikiproject')
|
||||
assert_nil project.wiki
|
||||
project.enabled_module_names = ['wiki']
|
||||
project.reload
|
||||
assert_not_nil project.wiki
|
||||
assert_equal 'Wiki', project.wiki.start_page
|
||||
end
|
||||
|
||||
def test_reenabling_wiki_should_not_create_another_wiki
|
||||
project = Project.find(1)
|
||||
assert_not_nil project.wiki
|
||||
project.enabled_module_names = []
|
||||
project.reload
|
||||
assert_no_difference 'Wiki.count' do
|
||||
project.enabled_module_names = ['wiki']
|
||||
end
|
||||
assert_not_nil project.wiki
|
||||
end
|
||||
end
|
||||
# Redmine - project management software
|
||||
# Copyright (C) 2006-2013 Jean-Philippe Lang
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
# as published by the Free Software Foundation; either version 2
|
||||
# of the License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
require File.expand_path('../../test_helper', __FILE__)
|
||||
|
||||
class EnabledModuleTest < ActiveSupport::TestCase
|
||||
fixtures :projects, :wikis
|
||||
|
||||
def test_enabling_wiki_should_create_a_wiki
|
||||
CustomField.delete_all
|
||||
project = Project.create!(:name => 'Project with wiki', :identifier => 'wikiproject')
|
||||
assert_nil project.wiki
|
||||
project.enabled_module_names = ['wiki']
|
||||
project.reload
|
||||
assert_not_nil project.wiki
|
||||
assert_equal 'Wiki', project.wiki.start_page
|
||||
end
|
||||
|
||||
def test_reenabling_wiki_should_not_create_another_wiki
|
||||
project = Project.find(1)
|
||||
assert_not_nil project.wiki
|
||||
project.enabled_module_names = []
|
||||
project.reload
|
||||
assert_no_difference 'Wiki.count' do
|
||||
project.enabled_module_names = ['wiki']
|
||||
end
|
||||
assert_not_nil project.wiki
|
||||
end
|
||||
end
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue