summaryrefslogtreecommitdiffstats
path: root/test/unit
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2012-04-25 17:17:49 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2012-04-25 17:17:49 +0000
commit5e57a1a9d9478162ac4f27ae96b2ccaf55a1aba7 (patch)
tree93e57765139714bd82dede475725516c448c0d55 /test/unit
parent34e20c4373b7f5a20ab3a132feae3f70f21ec477 (diff)
downloadredmine-5e57a1a9d9478162ac4f27ae96b2ccaf55a1aba7.tar.gz
redmine-5e57a1a9d9478162ac4f27ae96b2ccaf55a1aba7.zip
Merged rails-3.2 branch.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@9528 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'test/unit')
-rw-r--r--test/unit/custom_field_test.rb11
-rw-r--r--test/unit/helpers/application_helper_test.rb2
-rw-r--r--test/unit/issue_test.rb26
-rw-r--r--test/unit/lib/redmine/hook_test.rb2
-rw-r--r--test/unit/lib/redmine/wiki_formatting/macros_test.rb1
-rw-r--r--test/unit/mailer_test.rb32
-rw-r--r--test/unit/user_test.rb2
-rw-r--r--test/unit/watcher_test.rb2
8 files changed, 41 insertions, 37 deletions
diff --git a/test/unit/custom_field_test.rb b/test/unit/custom_field_test.rb
index 529aa699d..4509dc8ed 100644
--- a/test/unit/custom_field_test.rb
+++ b/test/unit/custom_field_test.rb
@@ -75,6 +75,17 @@ class CustomFieldTest < ActiveSupport::TestCase
assert_equal ["One value", "And another one"], field.possible_values
end
+ if "string".respond_to?(:encoding)
+ def test_possible_values_stored_as_binary_should_be_utf8_encoded
+ field = CustomField.find(11)
+ assert_kind_of Array, field.possible_values
+ assert field.possible_values.size > 0
+ field.possible_values.each do |value|
+ assert_equal "UTF-8", value.encoding.name
+ end
+ end
+ end
+
def test_destroy
field = CustomField.find(1)
assert field.destroy
diff --git a/test/unit/helpers/application_helper_test.rb b/test/unit/helpers/application_helper_test.rb
index 7e6c15585..a7a05f3e0 100644
--- a/test/unit/helpers/application_helper_test.rb
+++ b/test/unit/helpers/application_helper_test.rb
@@ -79,7 +79,7 @@ class ApplicationHelperTest < ActionView::TestCase
# two exclamation marks
'http://example.net/path!602815048C7B5C20!302.html' => '<a class="external" href="http://example.net/path!602815048C7B5C20!302.html">http://example.net/path!602815048C7B5C20!302.html</a>',
# escaping
- 'http://foo"bar' => '<a class="external" href="http://foo&quot;bar">http://foo"bar</a>',
+ 'http://foo"bar' => '<a class="external" href="http://foo&quot;bar">http://foo&quot;bar</a>',
# wrap in angle brackets
'<http://foo.bar>' => '&lt;<a class="external" href="http://foo.bar">http://foo.bar</a>&gt;'
}
diff --git a/test/unit/issue_test.rb b/test/unit/issue_test.rb
index 64844edbb..729e7cc54 100644
--- a/test/unit/issue_test.rb
+++ b/test/unit/issue_test.rb
@@ -1033,11 +1033,12 @@ class IssueTest < ActiveSupport::TestCase
assert IssueRelation.create!(:issue_from => Issue.find(2),
:issue_to => Issue.find(3),
:relation_type => IssueRelation::TYPE_PRECEDES)
- # Validation skipping
- assert IssueRelation.new(:issue_from => Issue.find(3),
- :issue_to => Issue.find(1),
- :relation_type => IssueRelation::TYPE_PRECEDES).save(false)
+ r = IssueRelation.create!(:issue_from => Issue.find(3),
+ :issue_to => Issue.find(7),
+ :relation_type => IssueRelation::TYPE_PRECEDES)
+ IssueRelation.update_all("issue_to_id = 1", ["id = ?", r.id])
+
assert_equal [2, 3], Issue.find(1).all_dependent_issues.collect(&:id).sort
end
@@ -1052,13 +1053,16 @@ class IssueTest < ActiveSupport::TestCase
assert IssueRelation.create!(:issue_from => Issue.find(3),
:issue_to => Issue.find(8),
:relation_type => IssueRelation::TYPE_RELATES)
- # Validation skipping
- assert IssueRelation.new(:issue_from => Issue.find(8),
- :issue_to => Issue.find(2),
- :relation_type => IssueRelation::TYPE_RELATES).save(false)
- assert IssueRelation.new(:issue_from => Issue.find(3),
- :issue_to => Issue.find(1),
- :relation_type => IssueRelation::TYPE_RELATES).save(false)
+
+ r = IssueRelation.create!(:issue_from => Issue.find(8),
+ :issue_to => Issue.find(7),
+ :relation_type => IssueRelation::TYPE_RELATES)
+ IssueRelation.update_all("issue_to_id = 2", ["id = ?", r.id])
+
+ r = IssueRelation.create!(:issue_from => Issue.find(3),
+ :issue_to => Issue.find(7),
+ :relation_type => IssueRelation::TYPE_RELATES)
+ IssueRelation.update_all("issue_to_id = 1", ["id = ?", r.id])
assert_equal [2, 3, 8], Issue.find(1).all_dependent_issues.collect(&:id).sort
end
diff --git a/test/unit/lib/redmine/hook_test.rb b/test/unit/lib/redmine/hook_test.rb
index 1b0034c95..07aeb1aff 100644
--- a/test/unit/lib/redmine/hook_test.rb
+++ b/test/unit/lib/redmine/hook_test.rb
@@ -17,7 +17,7 @@
require File.expand_path('../../../../test_helper', __FILE__)
-class Redmine::Hook::ManagerTest < ActiveSupport::TestCase
+class Redmine::Hook::ManagerTest < ActionView::TestCase
fixtures :issues
diff --git a/test/unit/lib/redmine/wiki_formatting/macros_test.rb b/test/unit/lib/redmine/wiki_formatting/macros_test.rb
index 3f4966bbf..7a8eb1170 100644
--- a/test/unit/lib/redmine/wiki_formatting/macros_test.rb
+++ b/test/unit/lib/redmine/wiki_formatting/macros_test.rb
@@ -21,6 +21,7 @@ class Redmine::WikiFormatting::MacrosTest < ActionView::TestCase
include ApplicationHelper
include ActionView::Helpers::TextHelper
include ActionView::Helpers::SanitizeHelper
+ include ERB::Util
extend ActionView::Helpers::SanitizeHelper::ClassMethods
fixtures :projects, :roles, :enabled_modules, :users,
diff --git a/test/unit/mailer_test.rb b/test/unit/mailer_test.rb
index 5607d1636..97516c139 100644
--- a/test/unit/mailer_test.rb
+++ b/test/unit/mailer_test.rb
@@ -19,7 +19,7 @@ require File.expand_path('../../test_helper', __FILE__)
class MailerTest < ActiveSupport::TestCase
include Redmine::I18n
- include ActionController::Assertions::SelectorAssertions
+ include ActionDispatch::Assertions::SelectorAssertions
fixtures :projects, :enabled_modules, :issues, :users, :members,
:member_roles, :roles, :documents, :attachments, :news,
:tokens, :journals, :journal_details, :changesets, :trackers,
@@ -78,7 +78,6 @@ class MailerTest < ActiveSupport::TestCase
relative_url_root = Redmine::Utils.relative_url_root
Setting.host_name = 'mydomain.foo/rdm'
Setting.protocol = 'http'
- Redmine::Utils.relative_url_root = '/rdm'
journal = Journal.find(3)
assert Mailer.deliver_issue_edit(journal)
@@ -111,9 +110,6 @@ class MailerTest < ActiveSupport::TestCase
'http://mydomain.foo/rdm/attachments/download/4/source.rb',
:text => 'source.rb'
end
- ensure
- # restore it
- Redmine::Utils.relative_url_root = relative_url_root
end
def test_generated_links_with_prefix_and_no_relative_url_root
@@ -164,15 +160,15 @@ class MailerTest < ActiveSupport::TestCase
Mailer.deliver_issue_add(issue)
mail = last_email
assert_not_nil mail
- assert_equal 'OOF', mail.header_string('X-Auto-Response-Suppress')
- assert_equal 'auto-generated', mail.header_string('Auto-Submitted')
+ assert_equal 'OOF', mail.header['X-Auto-Response-Suppress'].to_s
+ assert_equal 'auto-generated', mail.header['Auto-Submitted'].to_s
end
def test_email_headers_should_include_sender
issue = Issue.find(1)
Mailer.deliver_issue_add(issue)
mail = last_email
- assert_equal issue.author.login, mail.header_string('X-Redmine-Sender')
+ assert_equal issue.author.login, mail.header['X-Redmine-Sender'].to_s
end
def test_plain_text_mail
@@ -180,7 +176,7 @@ class MailerTest < ActiveSupport::TestCase
journal = Journal.find(2)
Mailer.deliver_issue_edit(journal)
mail = last_email
- assert_equal "text/plain", mail.content_type
+ assert_equal "text/plain; charset=UTF-8", mail.content_type
assert_equal 0, mail.parts.size
assert !mail.encoded.include?('href')
end
@@ -199,7 +195,7 @@ class MailerTest < ActiveSupport::TestCase
Mailer.deliver_test_email(User.find(1))
end
mail = last_email
- assert_equal 'redmine@example.net', mail.from_addrs.first.address
+ assert_equal 'redmine@example.net', mail.from_addrs.first
end
def test_from_header_with_phrase
@@ -207,8 +203,8 @@ class MailerTest < ActiveSupport::TestCase
Mailer.deliver_test_email(User.find(1))
end
mail = last_email
- assert_equal 'redmine@example.net', mail.from_addrs.first.address
- assert_equal 'Redmine app', mail.from_addrs.first.name
+ assert_equal 'redmine@example.net', mail.from_addrs.first
+ assert_equal 'Redmine app <redmine@example.net>', mail.header['From'].to_s
end
def test_should_not_send_email_without_recipient
@@ -245,7 +241,7 @@ class MailerTest < ActiveSupport::TestCase
Mailer.deliver_issue_edit(journal)
mail = last_email
assert_equal Mailer.message_id_for(journal), mail.message_id
- assert_equal Mailer.message_id_for(journal.issue), mail.references.first.to_s
+ assert_include Mailer.message_id_for(journal.issue), mail.references
assert_select_email do
# link to the update
assert_select "a[href=?]",
@@ -272,7 +268,7 @@ class MailerTest < ActiveSupport::TestCase
Mailer.deliver_message_posted(message)
mail = last_email
assert_equal Mailer.message_id_for(message), mail.message_id
- assert_equal Mailer.message_id_for(message.parent), mail.references.first.to_s
+ assert_include Mailer.message_id_for(message.parent), mail.references
assert_select_email do
# link to the reply
assert_select "a[href=?]",
@@ -528,14 +524,6 @@ class MailerTest < ActiveSupport::TestCase
# should restore perform_deliveries
assert ActionMailer::Base.perform_deliveries
end
-
- def test_tmail_to_header_field_should_not_include_blank_lines
- mail = TMail::Mail.new
- mail.to = ["a.user@example.com", "v.user2@example.com", "e.smith@example.com", "info@example.com", "v.pupkin@example.com",
- "b.user@example.com", "w.user2@example.com", "f.smith@example.com", "info2@example.com", "w.pupkin@example.com"]
-
- assert !mail.encoded.strip.split("\r\n").detect(&:blank?), "#{mail.encoded} malformed"
- end
def test_layout_should_include_the_emails_header
with_settings :emails_header => "*Header content*" do
diff --git a/test/unit/user_test.rb b/test/unit/user_test.rb
index 6488bb07e..545edc42b 100644
--- a/test/unit/user_test.rb
+++ b/test/unit/user_test.rb
@@ -141,7 +141,7 @@ class UserTest < ActiveSupport::TestCase
u2 = User.new(:firstname => "new", :lastname => "user", :mail => "newuser2@somenet.foo")
u2.login = 'newuser1'
- assert u2.save(false)
+ assert u2.save(:validate => false)
user = User.find(u2.id)
user.firstname = "firstname"
diff --git a/test/unit/watcher_test.rb b/test/unit/watcher_test.rb
index ed0400a7e..32c93d5fe 100644
--- a/test/unit/watcher_test.rb
+++ b/test/unit/watcher_test.rb
@@ -157,7 +157,7 @@ class WatcherTest < ActiveSupport::TestCase
def test_prune_all
user = User.find(9)
- Watcher.new(:watchable => Issue.find(4), :user => User.find(9)).save(false)
+ Watcher.new(:watchable => Issue.find(4), :user => User.find(9)).save(:validate => false)
assert Watcher.prune > 0
assert !Issue.find(4).watched_by?(user)