mirror of
https://github.com/redmine/redmine.git
synced 2026-05-07 06:35:55 +02:00
Adds a branch for unlimited project hierarchy.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/work@2148 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
153
nested_projects/test/integration/account_test.rb
Normal file
153
nested_projects/test/integration/account_test.rb
Normal file
@@ -0,0 +1,153 @@
|
||||
# redMine - project management software
|
||||
# Copyright (C) 2006-2007 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.dirname(__FILE__)}/../test_helper"
|
||||
|
||||
begin
|
||||
require 'mocha'
|
||||
rescue
|
||||
# Won't run some tests
|
||||
end
|
||||
|
||||
class AccountTest < ActionController::IntegrationTest
|
||||
fixtures :users
|
||||
|
||||
# Replace this with your real tests.
|
||||
def test_login
|
||||
get "my/page"
|
||||
assert_redirected_to "account/login"
|
||||
log_user('jsmith', 'jsmith')
|
||||
|
||||
get "my/account"
|
||||
assert_response :success
|
||||
assert_template "my/account"
|
||||
end
|
||||
|
||||
def test_lost_password
|
||||
Token.delete_all
|
||||
|
||||
get "account/lost_password"
|
||||
assert_response :success
|
||||
assert_template "account/lost_password"
|
||||
|
||||
post "account/lost_password", :mail => 'jSmith@somenet.foo'
|
||||
assert_redirected_to "account/login"
|
||||
|
||||
token = Token.find(:first)
|
||||
assert_equal 'recovery', token.action
|
||||
assert_equal 'jsmith@somenet.foo', token.user.mail
|
||||
assert !token.expired?
|
||||
|
||||
get "account/lost_password", :token => token.value
|
||||
assert_response :success
|
||||
assert_template "account/password_recovery"
|
||||
|
||||
post "account/lost_password", :token => token.value, :new_password => 'newpass', :new_password_confirmation => 'newpass'
|
||||
assert_redirected_to "account/login"
|
||||
assert_equal 'Password was successfully updated.', flash[:notice]
|
||||
|
||||
log_user('jsmith', 'newpass')
|
||||
assert_equal 0, Token.count
|
||||
end
|
||||
|
||||
def test_register_with_automatic_activation
|
||||
Setting.self_registration = '3'
|
||||
|
||||
get 'account/register'
|
||||
assert_response :success
|
||||
assert_template 'account/register'
|
||||
|
||||
post 'account/register', :user => {:login => "newuser", :language => "en", :firstname => "New", :lastname => "User", :mail => "newuser@foo.bar"},
|
||||
:password => "newpass", :password_confirmation => "newpass"
|
||||
assert_redirected_to 'my/account'
|
||||
follow_redirect!
|
||||
assert_response :success
|
||||
assert_template 'my/account'
|
||||
|
||||
assert User.find_by_login('newuser').active?
|
||||
end
|
||||
|
||||
def test_register_with_manual_activation
|
||||
Setting.self_registration = '2'
|
||||
|
||||
post 'account/register', :user => {:login => "newuser", :language => "en", :firstname => "New", :lastname => "User", :mail => "newuser@foo.bar"},
|
||||
:password => "newpass", :password_confirmation => "newpass"
|
||||
assert_redirected_to 'account/login'
|
||||
assert !User.find_by_login('newuser').active?
|
||||
end
|
||||
|
||||
def test_register_with_email_activation
|
||||
Setting.self_registration = '1'
|
||||
Token.delete_all
|
||||
|
||||
post 'account/register', :user => {:login => "newuser", :language => "en", :firstname => "New", :lastname => "User", :mail => "newuser@foo.bar"},
|
||||
:password => "newpass", :password_confirmation => "newpass"
|
||||
assert_redirected_to 'account/login'
|
||||
assert !User.find_by_login('newuser').active?
|
||||
|
||||
token = Token.find(:first)
|
||||
assert_equal 'register', token.action
|
||||
assert_equal 'newuser@foo.bar', token.user.mail
|
||||
assert !token.expired?
|
||||
|
||||
get 'account/activate', :token => token.value
|
||||
assert_redirected_to 'account/login'
|
||||
log_user('newuser', 'newpass')
|
||||
end
|
||||
|
||||
if Object.const_defined?(:Mocha)
|
||||
|
||||
def test_onthefly_registration
|
||||
# disable registration
|
||||
Setting.self_registration = '0'
|
||||
AuthSource.expects(:authenticate).returns([:login => 'foo', :firstname => 'Foo', :lastname => 'Smith', :mail => 'foo@bar.com', :auth_source_id => 66])
|
||||
|
||||
post 'account/login', :username => 'foo', :password => 'bar'
|
||||
assert_redirected_to 'my/page'
|
||||
|
||||
user = User.find_by_login('foo')
|
||||
assert user.is_a?(User)
|
||||
assert_equal 66, user.auth_source_id
|
||||
assert user.hashed_password.blank?
|
||||
end
|
||||
|
||||
def test_onthefly_registration_with_invalid_attributes
|
||||
# disable registration
|
||||
Setting.self_registration = '0'
|
||||
AuthSource.expects(:authenticate).returns([:login => 'foo', :lastname => 'Smith', :auth_source_id => 66])
|
||||
|
||||
post 'account/login', :username => 'foo', :password => 'bar'
|
||||
assert_response :success
|
||||
assert_template 'account/register'
|
||||
assert_tag :input, :attributes => { :name => 'user[firstname]', :value => '' }
|
||||
assert_tag :input, :attributes => { :name => 'user[lastname]', :value => 'Smith' }
|
||||
assert_no_tag :input, :attributes => { :name => 'user[login]' }
|
||||
assert_no_tag :input, :attributes => { :name => 'user[password]' }
|
||||
|
||||
post 'account/register', :user => {:firstname => 'Foo', :lastname => 'Smith', :mail => 'foo@bar.com'}
|
||||
assert_redirected_to 'my/account'
|
||||
|
||||
user = User.find_by_login('foo')
|
||||
assert user.is_a?(User)
|
||||
assert_equal 66, user.auth_source_id
|
||||
assert user.hashed_password.blank?
|
||||
end
|
||||
|
||||
else
|
||||
puts 'Mocha is missing. Skipping tests.'
|
||||
end
|
||||
end
|
||||
66
nested_projects/test/integration/admin_test.rb
Normal file
66
nested_projects/test/integration/admin_test.rb
Normal file
@@ -0,0 +1,66 @@
|
||||
# redMine - project management software
|
||||
# Copyright (C) 2006 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.dirname(__FILE__)}/../test_helper"
|
||||
|
||||
class AdminTest < ActionController::IntegrationTest
|
||||
fixtures :users
|
||||
|
||||
def test_add_user
|
||||
log_user("admin", "admin")
|
||||
get "/users/add"
|
||||
assert_response :success
|
||||
assert_template "users/add"
|
||||
post "/users/add", :user => { :login => "psmith", :firstname => "Paul", :lastname => "Smith", :mail => "psmith@somenet.foo", :language => "en" }, :password => "psmith09", :password_confirmation => "psmith09"
|
||||
assert_redirected_to "users/list"
|
||||
|
||||
user = User.find_by_login("psmith")
|
||||
assert_kind_of User, user
|
||||
logged_user = User.try_to_login("psmith", "psmith09")
|
||||
assert_kind_of User, logged_user
|
||||
assert_equal "Paul", logged_user.firstname
|
||||
|
||||
post "users/edit", :id => user.id, :user => { :status => User::STATUS_LOCKED }
|
||||
assert_redirected_to "users/list"
|
||||
locked_user = User.try_to_login("psmith", "psmith09")
|
||||
assert_equal nil, locked_user
|
||||
end
|
||||
|
||||
def test_add_project
|
||||
log_user("admin", "admin")
|
||||
get "projects/add"
|
||||
assert_response :success
|
||||
assert_template "projects/add"
|
||||
post "projects/add", :project => { :name => "blog",
|
||||
:description => "weblog",
|
||||
:identifier => "blog",
|
||||
:is_public => 1,
|
||||
:custom_field_values => { '3' => 'Beta' }
|
||||
}
|
||||
assert_redirected_to "admin/projects"
|
||||
assert_equal 'Successful creation.', flash[:notice]
|
||||
|
||||
project = Project.find_by_name("blog")
|
||||
assert_kind_of Project, project
|
||||
assert_equal "weblog", project.description
|
||||
assert_equal true, project.is_public?
|
||||
|
||||
get "admin/projects"
|
||||
assert_response :success
|
||||
assert_template "admin/projects"
|
||||
end
|
||||
end
|
||||
43
nested_projects/test/integration/application_test.rb
Normal file
43
nested_projects/test/integration/application_test.rb
Normal file
@@ -0,0 +1,43 @@
|
||||
# redMine - project management software
|
||||
# Copyright (C) 2006-2008 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.dirname(__FILE__)}/../test_helper"
|
||||
|
||||
class ApplicationTest < ActionController::IntegrationTest
|
||||
fixtures :users
|
||||
|
||||
def test_set_localization
|
||||
Setting.default_language = 'en'
|
||||
|
||||
# a french user
|
||||
get 'projects', { }, 'Accept-Language' => 'fr,fr-fr;q=0.8,en-us;q=0.5,en;q=0.3'
|
||||
assert_response :success
|
||||
assert_tag :tag => 'h2', :content => 'Projets'
|
||||
assert_equal 'fr', User.current.language
|
||||
|
||||
# then an italien user
|
||||
get 'projects', { }, 'Accept-Language' => 'it;q=0.8,en-us;q=0.5,en;q=0.3'
|
||||
assert_response :success
|
||||
assert_tag :tag => 'h2', :content => 'Progetti'
|
||||
assert_equal 'it', User.current.language
|
||||
|
||||
# not a supported language: default language should be used
|
||||
get 'projects', { }, 'Accept-Language' => 'zz'
|
||||
assert_response :success
|
||||
assert_tag :tag => 'h2', :content => 'Projects'
|
||||
end
|
||||
end
|
||||
92
nested_projects/test/integration/issues_test.rb
Normal file
92
nested_projects/test/integration/issues_test.rb
Normal file
@@ -0,0 +1,92 @@
|
||||
# redMine - project management software
|
||||
# Copyright (C) 2006-2008 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.dirname(__FILE__)}/../test_helper"
|
||||
|
||||
class IssuesTest < ActionController::IntegrationTest
|
||||
fixtures :projects,
|
||||
:users,
|
||||
:roles,
|
||||
:members,
|
||||
:trackers,
|
||||
:projects_trackers,
|
||||
:enabled_modules,
|
||||
:issue_statuses,
|
||||
:issues,
|
||||
:enumerations,
|
||||
:custom_fields,
|
||||
:custom_values,
|
||||
:custom_fields_trackers
|
||||
|
||||
# create an issue
|
||||
def test_add_issue
|
||||
log_user('jsmith', 'jsmith')
|
||||
get 'projects/1/issues/new', :tracker_id => '1'
|
||||
assert_response :success
|
||||
assert_template 'issues/new'
|
||||
|
||||
post 'projects/1/issues/new', :tracker_id => "1",
|
||||
:issue => { :start_date => "2006-12-26",
|
||||
:priority_id => "3",
|
||||
:subject => "new test issue",
|
||||
:category_id => "",
|
||||
:description => "new issue",
|
||||
:done_ratio => "0",
|
||||
:due_date => "",
|
||||
:assigned_to_id => "" },
|
||||
:custom_fields => {'2' => 'Value for field 2'}
|
||||
# find created issue
|
||||
issue = Issue.find_by_subject("new test issue")
|
||||
assert_kind_of Issue, issue
|
||||
|
||||
# check redirection
|
||||
assert_redirected_to "issues/show"
|
||||
follow_redirect!
|
||||
assert_equal issue, assigns(:issue)
|
||||
|
||||
# check issue attributes
|
||||
assert_equal 'jsmith', issue.author.login
|
||||
assert_equal 1, issue.project.id
|
||||
assert_equal 1, issue.status.id
|
||||
end
|
||||
|
||||
# add then remove 2 attachments to an issue
|
||||
def test_issue_attachements
|
||||
log_user('jsmith', 'jsmith')
|
||||
set_tmp_attachments_directory
|
||||
|
||||
post 'issues/edit/1',
|
||||
:notes => 'Some notes',
|
||||
:attachments => {'1' => {'file' => test_uploaded_file('testfile.txt', 'text/plain'), 'description' => 'This is an attachment'}}
|
||||
assert_redirected_to "issues/show/1"
|
||||
|
||||
# make sure attachment was saved
|
||||
attachment = Issue.find(1).attachments.find_by_filename("testfile.txt")
|
||||
assert_kind_of Attachment, attachment
|
||||
assert_equal Issue.find(1), attachment.container
|
||||
assert_equal 'This is an attachment', attachment.description
|
||||
# verify the size of the attachment stored in db
|
||||
#assert_equal file_data_1.length, attachment.filesize
|
||||
# verify that the attachment was written to disk
|
||||
assert File.exist?(attachment.diskfile)
|
||||
|
||||
# remove the attachments
|
||||
Issue.find(1).attachments.each(&:destroy)
|
||||
assert_equal 0, Issue.find(1).attachments.length
|
||||
end
|
||||
|
||||
end
|
||||
44
nested_projects/test/integration/projects_test.rb
Normal file
44
nested_projects/test/integration/projects_test.rb
Normal file
@@ -0,0 +1,44 @@
|
||||
# redMine - project management software
|
||||
# Copyright (C) 2006-2007 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.dirname(__FILE__)}/../test_helper"
|
||||
|
||||
class ProjectsTest < ActionController::IntegrationTest
|
||||
fixtures :projects, :users, :members
|
||||
|
||||
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/archive", :id => 1
|
||||
assert_redirected_to "admin/projects"
|
||||
assert !Project.find(1).active?
|
||||
|
||||
get "projects/show", :id => 1
|
||||
assert_response 403
|
||||
get "projects/show", :id => subproject.id
|
||||
assert_response 403
|
||||
|
||||
post "projects/unarchive", :id => 1
|
||||
assert_redirected_to "admin/projects"
|
||||
assert Project.find(1).active?
|
||||
get "projects/show", :id => 1
|
||||
assert_response :success
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user