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:
@@ -18,6 +18,7 @@
|
||||
require File.dirname(__FILE__) + '/../test_helper'
|
||||
|
||||
class DefaultDataTest < Test::Unit::TestCase
|
||||
include Redmine::I18n
|
||||
fixtures :roles
|
||||
|
||||
def test_no_data
|
||||
@@ -30,7 +31,7 @@ class DefaultDataTest < Test::Unit::TestCase
|
||||
end
|
||||
|
||||
def test_load
|
||||
GLoc.valid_languages.each do |lang|
|
||||
valid_languages.each do |lang|
|
||||
begin
|
||||
Role.delete_all("builtin = 0")
|
||||
Tracker.delete_all
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
# redMine - project management software
|
||||
# Copyright (C) 2006-2007 Jean-Philippe Lang
|
||||
# Redmine - project management software
|
||||
# Copyright (C) 2006-2009 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
|
||||
@@ -20,6 +20,8 @@ require File.dirname(__FILE__) + '/../../test_helper'
|
||||
class ApplicationHelperTest < HelperTestCase
|
||||
include ApplicationHelper
|
||||
include ActionView::Helpers::TextHelper
|
||||
include ActionView::Helpers::DateHelper
|
||||
|
||||
fixtures :projects, :roles, :enabled_modules, :users,
|
||||
:repositories, :changesets,
|
||||
:trackers, :issue_statuses, :issues, :versions, :documents,
|
||||
@@ -390,50 +392,14 @@ EXPECTED
|
||||
Setting.text_formatting = 'textile'
|
||||
end
|
||||
|
||||
def test_date_format_default
|
||||
today = Date.today
|
||||
Setting.date_format = ''
|
||||
assert_equal l_date(today), format_date(today)
|
||||
end
|
||||
|
||||
def test_date_format
|
||||
today = Date.today
|
||||
Setting.date_format = '%d %m %Y'
|
||||
assert_equal today.strftime('%d %m %Y'), format_date(today)
|
||||
end
|
||||
|
||||
def test_time_format_default
|
||||
now = Time.now
|
||||
Setting.date_format = ''
|
||||
Setting.time_format = ''
|
||||
assert_equal l_datetime(now), format_time(now)
|
||||
assert_equal l_time(now), format_time(now, false)
|
||||
end
|
||||
|
||||
def test_time_format
|
||||
now = Time.now
|
||||
Setting.date_format = '%d %m %Y'
|
||||
Setting.time_format = '%H %M'
|
||||
assert_equal now.strftime('%d %m %Y %H %M'), format_time(now)
|
||||
assert_equal now.strftime('%H %M'), format_time(now, false)
|
||||
end
|
||||
|
||||
def test_utc_time_format
|
||||
now = Time.now.utc
|
||||
Setting.date_format = '%d %m %Y'
|
||||
Setting.time_format = '%H %M'
|
||||
assert_equal Time.now.strftime('%d %m %Y %H %M'), format_time(now)
|
||||
assert_equal Time.now.strftime('%H %M'), format_time(now, false)
|
||||
end
|
||||
|
||||
def test_due_date_distance_in_words
|
||||
to_test = { Date.today => 'Due in 0 days',
|
||||
Date.today + 1 => 'Due in 1 day',
|
||||
Date.today + 100 => 'Due in 100 days',
|
||||
Date.today + 20000 => 'Due in 20000 days',
|
||||
Date.today + 100 => 'Due in about 3 months',
|
||||
Date.today + 20000 => 'Due in over 55 years',
|
||||
Date.today - 1 => '1 day late',
|
||||
Date.today - 100 => '100 days late',
|
||||
Date.today - 20000 => '20000 days late',
|
||||
Date.today - 100 => 'about 3 months late',
|
||||
Date.today - 20000 => 'over 55 years late',
|
||||
}
|
||||
to_test.each do |date, expected|
|
||||
assert_equal expected, due_date_distance_in_words(date)
|
||||
|
||||
@@ -47,15 +47,15 @@ class IssueTest < Test::Unit::TestCase
|
||||
assert issue.available_custom_fields.include?(field)
|
||||
# No value for the custom field
|
||||
assert !issue.save
|
||||
assert_equal 'activerecord_error_invalid', issue.errors.on(:custom_values)
|
||||
assert_equal I18n.translate('activerecord.errors.messages.invalid'), issue.errors.on(:custom_values)
|
||||
# Blank value
|
||||
issue.custom_field_values = { field.id => '' }
|
||||
assert !issue.save
|
||||
assert_equal 'activerecord_error_invalid', issue.errors.on(:custom_values)
|
||||
assert_equal I18n.translate('activerecord.errors.messages.invalid'), issue.errors.on(:custom_values)
|
||||
# Invalid value
|
||||
issue.custom_field_values = { field.id => 'SQLServer' }
|
||||
assert !issue.save
|
||||
assert_equal 'activerecord_error_invalid', issue.errors.on(:custom_values)
|
||||
assert_equal I18n.translate('activerecord.errors.messages.invalid'), issue.errors.on(:custom_values)
|
||||
# Valid value
|
||||
issue.custom_field_values = { field.id => 'PostgreSQL' }
|
||||
assert issue.save
|
||||
|
||||
@@ -0,0 +1,100 @@
|
||||
# Redmine - project management software
|
||||
# Copyright (C) 2006-2009 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 Redmine::I18nTest < Test::Unit::TestCase
|
||||
include Redmine::I18n
|
||||
|
||||
def setup
|
||||
@hook_module = Redmine::Hook
|
||||
end
|
||||
|
||||
def test_date_format_default
|
||||
set_language_if_valid 'en'
|
||||
today = Date.today
|
||||
Setting.date_format = ''
|
||||
assert_equal I18n.l(today), format_date(today)
|
||||
end
|
||||
|
||||
def test_date_format
|
||||
set_language_if_valid 'en'
|
||||
today = Date.today
|
||||
Setting.date_format = '%d %m %Y'
|
||||
assert_equal today.strftime('%d %m %Y'), format_date(today)
|
||||
end
|
||||
|
||||
def test_date_and_time_for_each_language
|
||||
Setting.date_format = ''
|
||||
valid_languages.each do |lang|
|
||||
set_language_if_valid lang
|
||||
assert_nothing_raised "#{lang} failure" do
|
||||
format_date(Date.today)
|
||||
format_time(Time.now)
|
||||
format_time(Time.now, false)
|
||||
end
|
||||
assert l('date.day_names').is_a?(Array)
|
||||
assert_equal 7, l('date.day_names').size
|
||||
|
||||
assert l('date.month_names').is_a?(Array)
|
||||
assert_equal 13, l('date.month_names').size
|
||||
end
|
||||
end
|
||||
|
||||
def test_time_format_default
|
||||
set_language_if_valid 'en'
|
||||
now = Time.now
|
||||
Setting.date_format = ''
|
||||
Setting.time_format = ''
|
||||
assert_equal I18n.l(now), format_time(now)
|
||||
assert_equal I18n.l(now, :format => :time), format_time(now, false)
|
||||
end
|
||||
|
||||
def test_time_format
|
||||
set_language_if_valid 'en'
|
||||
now = Time.now
|
||||
Setting.date_format = '%d %m %Y'
|
||||
Setting.time_format = '%H %M'
|
||||
assert_equal now.strftime('%d %m %Y %H %M'), format_time(now)
|
||||
assert_equal now.strftime('%H %M'), format_time(now, false)
|
||||
end
|
||||
|
||||
def test_utc_time_format
|
||||
set_language_if_valid 'en'
|
||||
now = Time.now.utc
|
||||
Setting.date_format = '%d %m %Y'
|
||||
Setting.time_format = '%H %M'
|
||||
assert_equal Time.now.strftime('%d %m %Y %H %M'), format_time(now)
|
||||
assert_equal Time.now.strftime('%H %M'), format_time(now, false)
|
||||
end
|
||||
|
||||
def test_valid_languages
|
||||
assert valid_languages.is_a?(Array)
|
||||
assert valid_languages.first.is_a?(Symbol)
|
||||
end
|
||||
|
||||
def test_valid_language
|
||||
to_test = {'fr' => :fr,
|
||||
'Fr' => :fr,
|
||||
'zh' => :zh,
|
||||
'zh-tw' => :"zh-TW",
|
||||
'zh-TW' => :"zh-TW",
|
||||
'zh-ZZ' => nil }
|
||||
|
||||
to_test.each {|lang, expected| assert_equal expected, find_language(lang)}
|
||||
end
|
||||
end
|
||||
@@ -18,6 +18,7 @@
|
||||
require File.dirname(__FILE__) + '/../test_helper'
|
||||
|
||||
class MailerTest < Test::Unit::TestCase
|
||||
include Redmine::I18n
|
||||
fixtures :projects, :issues, :users, :members, :documents, :attachments, :news, :tokens, :journals, :journal_details, :changesets, :trackers, :issue_statuses, :enumerations, :messages, :boards, :repositories
|
||||
|
||||
def test_generated_links_in_emails
|
||||
@@ -138,7 +139,7 @@ class MailerTest < Test::Unit::TestCase
|
||||
# test mailer methods for each language
|
||||
def test_issue_add
|
||||
issue = Issue.find(1)
|
||||
GLoc.valid_languages.each do |lang|
|
||||
valid_languages.each do |lang|
|
||||
Setting.default_language = lang.to_s
|
||||
assert Mailer.deliver_issue_add(issue)
|
||||
end
|
||||
@@ -146,7 +147,7 @@ class MailerTest < Test::Unit::TestCase
|
||||
|
||||
def test_issue_edit
|
||||
journal = Journal.find(1)
|
||||
GLoc.valid_languages.each do |lang|
|
||||
valid_languages.each do |lang|
|
||||
Setting.default_language = lang.to_s
|
||||
assert Mailer.deliver_issue_edit(journal)
|
||||
end
|
||||
@@ -154,7 +155,7 @@ class MailerTest < Test::Unit::TestCase
|
||||
|
||||
def test_document_added
|
||||
document = Document.find(1)
|
||||
GLoc.valid_languages.each do |lang|
|
||||
valid_languages.each do |lang|
|
||||
Setting.default_language = lang.to_s
|
||||
assert Mailer.deliver_document_added(document)
|
||||
end
|
||||
@@ -162,7 +163,7 @@ class MailerTest < Test::Unit::TestCase
|
||||
|
||||
def test_attachments_added
|
||||
attachements = [ Attachment.find_by_container_type('Document') ]
|
||||
GLoc.valid_languages.each do |lang|
|
||||
valid_languages.each do |lang|
|
||||
Setting.default_language = lang.to_s
|
||||
assert Mailer.deliver_attachments_added(attachements)
|
||||
end
|
||||
@@ -170,7 +171,7 @@ class MailerTest < Test::Unit::TestCase
|
||||
|
||||
def test_news_added
|
||||
news = News.find(:first)
|
||||
GLoc.valid_languages.each do |lang|
|
||||
valid_languages.each do |lang|
|
||||
Setting.default_language = lang.to_s
|
||||
assert Mailer.deliver_news_added(news)
|
||||
end
|
||||
@@ -180,7 +181,7 @@ class MailerTest < Test::Unit::TestCase
|
||||
message = Message.find(:first)
|
||||
recipients = ([message.root] + message.root.children).collect {|m| m.author.mail if m.author}
|
||||
recipients = recipients.compact.uniq
|
||||
GLoc.valid_languages.each do |lang|
|
||||
valid_languages.each do |lang|
|
||||
Setting.default_language = lang.to_s
|
||||
assert Mailer.deliver_message_posted(message, recipients)
|
||||
end
|
||||
@@ -188,7 +189,7 @@ class MailerTest < Test::Unit::TestCase
|
||||
|
||||
def test_account_information
|
||||
user = User.find(:first)
|
||||
GLoc.valid_languages.each do |lang|
|
||||
valid_languages.each do |lang|
|
||||
user.update_attribute :language, lang.to_s
|
||||
user.reload
|
||||
assert Mailer.deliver_account_information(user, 'pAsswORd')
|
||||
@@ -197,7 +198,7 @@ class MailerTest < Test::Unit::TestCase
|
||||
|
||||
def test_lost_password
|
||||
token = Token.find(2)
|
||||
GLoc.valid_languages.each do |lang|
|
||||
valid_languages.each do |lang|
|
||||
token.user.update_attribute :language, lang.to_s
|
||||
token.reload
|
||||
assert Mailer.deliver_lost_password(token)
|
||||
@@ -206,7 +207,7 @@ class MailerTest < Test::Unit::TestCase
|
||||
|
||||
def test_register
|
||||
token = Token.find(1)
|
||||
GLoc.valid_languages.each do |lang|
|
||||
valid_languages.each do |lang|
|
||||
token.user.update_attribute :language, lang.to_s
|
||||
token.reload
|
||||
assert Mailer.deliver_register(token)
|
||||
|
||||
@@ -44,7 +44,7 @@ class ProjectTest < Test::Unit::TestCase
|
||||
@ecookbook.name = ""
|
||||
assert !@ecookbook.save
|
||||
assert_equal 1, @ecookbook.errors.count
|
||||
assert_equal "activerecord_error_blank", @ecookbook.errors.on(:name)
|
||||
assert_equal I18n.translate('activerecord.errors.messages.blank'), @ecookbook.errors.on(:name)
|
||||
end
|
||||
|
||||
def test_archive
|
||||
@@ -191,7 +191,7 @@ class ProjectTest < Test::Unit::TestCase
|
||||
child = parent.children.find(3)
|
||||
|
||||
assert_equal [1, 2], parent.tracker_ids
|
||||
assert_equal [2, 3], child.tracker_ids
|
||||
assert_equal [2, 3], child.trackers.collect(&:id)
|
||||
|
||||
assert_kind_of Tracker, parent.rolled_up_trackers.first
|
||||
assert_equal Tracker.find(1), parent.rolled_up_trackers.first
|
||||
|
||||
@@ -60,7 +60,7 @@ class RepositoryTest < Test::Unit::TestCase
|
||||
Setting.enabled_scm = ['Darcs', 'Git']
|
||||
repository = Repository::Subversion.new(:project => Project.find(3), :url => "svn://localhost")
|
||||
assert !repository.save
|
||||
assert_equal :activerecord_error_invalid, repository.errors.on(:type)
|
||||
assert_equal I18n.translate('activerecord.errors.messages.invalid'), repository.errors.on(:type)
|
||||
# re-enable Subversion for following tests
|
||||
Setting.delete_all
|
||||
end
|
||||
|
||||
@@ -59,7 +59,7 @@ class UserTest < Test::Unit::TestCase
|
||||
u.login = 'newuser2'
|
||||
u.password, u.password_confirmation = "password", "password"
|
||||
assert !u.save
|
||||
assert_equal 'activerecord_error_taken', u.errors.on(:mail)
|
||||
assert_equal I18n.translate('activerecord.errors.messages.taken'), u.errors.on(:mail)
|
||||
end
|
||||
|
||||
def test_update
|
||||
|
||||
@@ -31,7 +31,7 @@ class VersionTest < Test::Unit::TestCase
|
||||
def test_invalid_effective_date_validation
|
||||
v = Version.new(:project => Project.find(1), :name => '1.1', :effective_date => '99999-01-01')
|
||||
assert !v.save
|
||||
assert_equal 'activerecord_error_not_a_date', v.errors.on(:effective_date)
|
||||
assert_equal I18n.translate('activerecord.errors.messages.not_a_date'), v.errors.on(:effective_date)
|
||||
end
|
||||
|
||||
def test_progress_should_be_0_with_no_assigned_issues
|
||||
|
||||
@@ -78,15 +78,15 @@ class WikiPageTest < Test::Unit::TestCase
|
||||
# A page that doesn't exist
|
||||
page.parent_title = 'Unknown title'
|
||||
assert !page.save
|
||||
assert_equal :activerecord_error_invalid, page.errors.on(:parent_title)
|
||||
assert_equal I18n.translate('activerecord.errors.messages.invalid'), page.errors.on(:parent_title)
|
||||
# A child page
|
||||
page.parent_title = 'Page_with_an_inline_image'
|
||||
assert !page.save
|
||||
assert_equal :activerecord_error_circular_dependency, page.errors.on(:parent_title)
|
||||
assert_equal I18n.translate('activerecord.errors.messages.circular_dependency'), page.errors.on(:parent_title)
|
||||
# The page itself
|
||||
page.parent_title = 'CookBook_documentation'
|
||||
assert !page.save
|
||||
assert_equal :activerecord_error_circular_dependency, page.errors.on(:parent_title)
|
||||
assert_equal I18n.translate('activerecord.errors.messages.circular_dependency'), page.errors.on(:parent_title)
|
||||
|
||||
page.parent_title = 'Another_page'
|
||||
assert page.save
|
||||
|
||||
Reference in New Issue
Block a user