Merged Rails 2.2 branch. Redmine now requires Rails 2.2.2.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@2493 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
@@ -22,6 +22,8 @@ require 'application'
|
||||
class ApplicationController; def rescue_action(e) raise e end; end
|
||||
|
||||
class ApplicationControllerTest < Test::Unit::TestCase
|
||||
include Redmine::I18n
|
||||
|
||||
def setup
|
||||
@controller = ApplicationController.new
|
||||
@request = ActionController::TestRequest.new
|
||||
@@ -30,9 +32,9 @@ class ApplicationControllerTest < Test::Unit::TestCase
|
||||
|
||||
# check that all language files are valid
|
||||
def test_localization
|
||||
lang_files_count = Dir["#{RAILS_ROOT}/lang/*.yml"].size
|
||||
assert_equal lang_files_count, GLoc.valid_languages.size
|
||||
GLoc.valid_languages.each do |lang|
|
||||
lang_files_count = Dir["#{RAILS_ROOT}/config/locales/*.yml"].size
|
||||
assert_equal lang_files_count, valid_languages.size
|
||||
valid_languages.each do |lang|
|
||||
assert set_language_if_valid(lang)
|
||||
end
|
||||
set_language_if_valid('en')
|
||||
|
||||
@@ -86,7 +86,7 @@ class AttachmentsControllerTest < Test::Unit::TestCase
|
||||
post :destroy, :id => 1
|
||||
end
|
||||
# no referrer
|
||||
assert_redirected_to 'projects/show/ecookbook'
|
||||
assert_redirected_to 'projects/ecookbook'
|
||||
assert_nil Attachment.find_by_id(1)
|
||||
j = issue.journals.find(:first, :order => 'created_on DESC')
|
||||
assert_equal 'attachment', j.details.first.property
|
||||
|
||||
@@ -47,7 +47,7 @@ class CustomFieldsControllerTest < Test::Unit::TestCase
|
||||
:field_format => "list",
|
||||
:tracker_ids => ["1", ""]}
|
||||
end
|
||||
assert_redirected_to '/custom_fields'
|
||||
assert_redirected_to '/custom_fields?tab=IssueCustomField'
|
||||
field = IssueCustomField.find_by_name('test_post_new_list')
|
||||
assert_not_nil field
|
||||
assert_equal ["0.1", "0.2"], field.possible_values
|
||||
|
||||
@@ -445,7 +445,7 @@ class IssuesControllerTest < Test::Unit::TestCase
|
||||
assert_template 'new'
|
||||
issue = assigns(:issue)
|
||||
assert_not_nil issue
|
||||
assert_equal 'activerecord_error_invalid', issue.errors.on(:custom_values)
|
||||
assert_equal I18n.translate('activerecord.errors.messages.invalid'), issue.errors.on(:custom_values)
|
||||
end
|
||||
|
||||
def test_post_new_with_watchers
|
||||
|
||||
@@ -87,9 +87,9 @@ class MessagesControllerTest < Test::Unit::TestCase
|
||||
post :new, :board_id => 1,
|
||||
:message => { :subject => 'Test created message',
|
||||
:content => 'Message body'}
|
||||
assert_redirected_to 'messages/show'
|
||||
message = Message.find_by_subject('Test created message')
|
||||
assert_not_nil message
|
||||
assert_redirected_to "boards/1/topics/#{message.to_param}"
|
||||
assert_equal 'Message body', message.content
|
||||
assert_equal 2, message.author_id
|
||||
assert_equal 1, message.board_id
|
||||
@@ -127,7 +127,7 @@ class MessagesControllerTest < Test::Unit::TestCase
|
||||
post :edit, :board_id => 1, :id => 1,
|
||||
:message => { :subject => 'New subject',
|
||||
:content => 'New body'}
|
||||
assert_redirected_to 'messages/show'
|
||||
assert_redirected_to 'boards/1/topics/1'
|
||||
message = Message.find(1)
|
||||
assert_equal 'New subject', message.subject
|
||||
assert_equal 'New body', message.content
|
||||
@@ -143,7 +143,7 @@ class MessagesControllerTest < Test::Unit::TestCase
|
||||
def test_reply
|
||||
@request.session[:user_id] = 2
|
||||
post :reply, :board_id => 1, :id => 1, :reply => { :content => 'This is a test reply', :subject => 'Test reply' }
|
||||
assert_redirected_to 'messages/show'
|
||||
assert_redirected_to 'boards/1/topics/1'
|
||||
assert Message.find_by_subject('Test reply')
|
||||
end
|
||||
|
||||
@@ -157,7 +157,7 @@ class MessagesControllerTest < Test::Unit::TestCase
|
||||
def test_destroy_topic
|
||||
@request.session[:user_id] = 2
|
||||
post :destroy, :board_id => 1, :id => 1
|
||||
assert_redirected_to 'boards/show'
|
||||
assert_redirected_to 'projects/ecookbook/boards/1'
|
||||
assert_nil Message.find_by_id(1)
|
||||
end
|
||||
|
||||
|
||||
@@ -146,7 +146,7 @@ class NewsControllerTest < Test::Unit::TestCase
|
||||
def test_post_edit
|
||||
@request.session[:user_id] = 2
|
||||
post :edit, :id => 1, :news => { :description => 'Description changed by test_post_edit' }
|
||||
assert_redirected_to 'news/show/1'
|
||||
assert_redirected_to 'news/1'
|
||||
news = News.find(1)
|
||||
assert_equal 'Description changed by test_post_edit', news.description
|
||||
end
|
||||
@@ -167,7 +167,7 @@ class NewsControllerTest < Test::Unit::TestCase
|
||||
def test_add_comment
|
||||
@request.session[:user_id] = 2
|
||||
post :add_comment, :id => 1, :comment => { :comments => 'This is a NewsControllerTest comment' }
|
||||
assert_redirected_to 'news/show/1'
|
||||
assert_redirected_to 'news/1'
|
||||
|
||||
comment = News.find(1).comments.find(:first, :order => 'created_on DESC')
|
||||
assert_not_nil comment
|
||||
@@ -179,7 +179,7 @@ class NewsControllerTest < Test::Unit::TestCase
|
||||
comments_count = News.find(1).comments.size
|
||||
@request.session[:user_id] = 2
|
||||
post :destroy_comment, :id => 1, :comment_id => 2
|
||||
assert_redirected_to 'news/show/1'
|
||||
assert_redirected_to 'news/1'
|
||||
assert_nil Comment.find_by_id(2)
|
||||
assert_equal comments_count - 1, News.find(1).comments.size
|
||||
end
|
||||
|
||||
@@ -148,7 +148,7 @@ class ProjectsControllerTest < Test::Unit::TestCase
|
||||
@request.session[:user_id] = 2 # manager
|
||||
post :edit, :id => 1, :project => {:name => 'Test changed name',
|
||||
:issue_custom_field_ids => ['']}
|
||||
assert_redirected_to 'projects/settings/ecookbook'
|
||||
assert_redirected_to 'projects/ecookbook/settings'
|
||||
project = Project.find(1)
|
||||
assert_equal 'Test changed name', project.name
|
||||
end
|
||||
@@ -214,7 +214,7 @@ class ProjectsControllerTest < Test::Unit::TestCase
|
||||
post :add_file, :id => 1, :version_id => '',
|
||||
:attachments => {'1' => {'file' => test_uploaded_file('testfile.txt', 'text/plain')}}
|
||||
end
|
||||
assert_redirected_to 'projects/list_files/ecookbook'
|
||||
assert_redirected_to 'projects/ecookbook/files'
|
||||
a = Attachment.find(:first, :order => 'created_on DESC')
|
||||
assert_equal 'testfile.txt', a.filename
|
||||
assert_equal Project.find(1), a.container
|
||||
@@ -245,7 +245,7 @@ class ProjectsControllerTest < Test::Unit::TestCase
|
||||
post :add_file, :id => 1, :version_id => '2',
|
||||
:attachments => {'1' => {'file' => test_uploaded_file('testfile.txt', 'text/plain')}}
|
||||
end
|
||||
assert_redirected_to 'projects/list_files/ecookbook'
|
||||
assert_redirected_to 'projects/ecookbook/files'
|
||||
a = Attachment.find(:first, :order => 'created_on DESC')
|
||||
assert_equal 'testfile.txt', a.filename
|
||||
assert_equal Version.find(2), a.container
|
||||
@@ -483,7 +483,7 @@ class ProjectsControllerTest < Test::Unit::TestCase
|
||||
def test_project_menu
|
||||
assert_no_difference 'Redmine::MenuManager.items(:project_menu).size' do
|
||||
Redmine::MenuManager.map :project_menu do |menu|
|
||||
menu.push :foo, { :controller => 'projects', :action => 'show' }, :cation => 'Foo'
|
||||
menu.push :foo, { :controller => 'projects', :action => 'show' }, :caption => 'Foo'
|
||||
menu.push :bar, { :controller => 'projects', :action => 'show' }, :before => :activity
|
||||
menu.push :hello, { :controller => 'projects', :action => 'show' }, :caption => Proc.new {|p| p.name.upcase }, :after => :bar
|
||||
end
|
||||
|
||||
@@ -200,7 +200,7 @@ class RepositoriesControllerTest < Test::Unit::TestCase
|
||||
|
||||
assert_no_difference "Changeset.count(:conditions => 'user_id = 3')" do
|
||||
post :committers, :id => 1, :committers => { '0' => ['foo', '2'], '1' => ['dlopper', '3']}
|
||||
assert_redirected_to '/repositories/committers/ecookbook'
|
||||
assert_redirected_to 'projects/ecookbook/repository/committers'
|
||||
assert_equal User.find(2), c.reload.user
|
||||
end
|
||||
end
|
||||
|
||||
@@ -126,7 +126,7 @@ class SearchControllerTest < Test::Unit::TestCase
|
||||
def test_quick_jump_to_issue
|
||||
# issue of a public project
|
||||
get :index, :q => "3"
|
||||
assert_redirected_to 'issues/show/3'
|
||||
assert_redirected_to 'issues/3'
|
||||
|
||||
# issue of a private project
|
||||
get :index, :q => "4"
|
||||
|
||||
@@ -377,6 +377,7 @@ class TimelogControllerTest < Test::Unit::TestCase
|
||||
end
|
||||
|
||||
def test_details_all_projects_csv_export
|
||||
Setting.date_format = '%m/%d/%Y'
|
||||
get :details, :format => 'csv'
|
||||
assert_response :success
|
||||
assert_equal 'text/csv', @response.content_type
|
||||
@@ -385,6 +386,7 @@ class TimelogControllerTest < Test::Unit::TestCase
|
||||
end
|
||||
|
||||
def test_details_csv_export
|
||||
Setting.date_format = '%m/%d/%Y'
|
||||
get :details, :project_id => 1, :format => 'csv'
|
||||
assert_response :success
|
||||
assert_equal 'text/csv', @response.content_type
|
||||
|
||||
@@ -51,7 +51,7 @@ class WelcomeControllerTest < Test::Unit::TestCase
|
||||
Setting.default_language = 'en'
|
||||
@request.env['HTTP_ACCEPT_LANGUAGE'] = 'zh-TW'
|
||||
get :index
|
||||
assert_equal :"zh-tw", @controller.current_language
|
||||
assert_equal :"zh-TW", @controller.current_language
|
||||
end
|
||||
|
||||
def test_browser_language_alternate_not_valid
|
||||
|
||||
@@ -63,7 +63,7 @@ class WikisControllerTest < Test::Unit::TestCase
|
||||
def test_destroy
|
||||
@request.session[:user_id] = 1
|
||||
post :destroy, :id => 1, :confirm => 1
|
||||
assert_redirected_to :action => 'settings', :id => 'ecookbook', :tab => 'wiki'
|
||||
assert_redirected_to :controller => 'projects', :action => 'settings', :id => 'ecookbook', :tab => 'wiki'
|
||||
assert_nil Project.find(1).wiki
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user