]> source.dussan.org Git - redmine.git/commitdiff
Don't use assert_equal nil.
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Mon, 12 Dec 2016 21:36:14 +0000 (21:36 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Mon, 12 Dec 2016 21:36:14 +0000 (21:36 +0000)
git-svn-id: http://svn.redmine.org/redmine/trunk@16064 e93f8b46-1217-0410-a6f0-8f06a7374b81

test/fixtures/attachments.yml
test/functional/issues_controller_test.rb
test/integration/api_test/issues_test.rb
test/unit/lib/redmine/i18n_test.rb
test/unit/lib/redmine/mime_type_test.rb
test/unit/tracker_test.rb

index 6f56c08119de8834b9fe48da92a5ffc5aea22908..f3b4545e92a1d600608637c8853cba849c816c60 100644 (file)
@@ -12,6 +12,7 @@ attachments_001:
   filesize: 28
   filename: error281.txt
   author_id: 2
+  description: An attachment
 attachments_002: 
   created_on: 2007-01-27 15:08:27 +01:00
   downloads: 0
index 444e02171759277f538d69c765823f1b12e966a2..3e1bfa23472cd8398137ba20d913f8e9b62d6f24 100644 (file)
@@ -4457,7 +4457,11 @@ class IssuesControllerTest < Redmine::ControllerTest
       assert_equal orig.project_id, copy.project_id
       assert_equal orig.tracker_id, copy.tracker_id
       assert_equal orig.status_id, copy.status_id
-      assert_equal orig.assigned_to_id, copy.assigned_to_id
+      if orig.assigned_to_id
+        assert_equal orig.assigned_to_id, copy.assigned_to_id
+      else
+        assert_nil copy.assigned_to_id
+      end
       assert_equal orig.priority_id, copy.priority_id
     end
   end
index 94f42287a05b56530c2313653978f44588e76ec0..de0a2fd20d584f3a918699ee0a41ba02c26590f0 100644 (file)
@@ -356,6 +356,7 @@ class Redmine::ApiTest::IssuesTest < Redmine::ApiTest::Base
 
   test "GET /issues/:id.xml should contains total_estimated_hours and total_spent_hours" do
     parent = Issue.find(3)
+    parent.update_columns :estimated_hours => 2.0
     child = Issue.generate!(:parent_issue_id => parent.id, :estimated_hours => 3.0)
     TimeEntry.create!(:project => child.project, :issue => child, :user => child.author, :spent_on => child.author.today,
                       :hours => '2.5', :comments => '', :activity_id => TimeEntryActivity.first.id)
@@ -372,6 +373,7 @@ class Redmine::ApiTest::IssuesTest < Redmine::ApiTest::Base
 
   test "GET /issues/:id.xml should contains total_estimated_hours, and should not contains spent_hours and total_spent_hours when permission does not exists" do
     parent = Issue.find(3)
+    parent.update_columns :estimated_hours => 2.0
     child = Issue.generate!(:parent_issue_id => parent.id, :estimated_hours => 3.0)
     # remove permission!
     Role.anonymous.remove_permission! :view_time_entries
@@ -389,6 +391,7 @@ class Redmine::ApiTest::IssuesTest < Redmine::ApiTest::Base
 
   test "GET /issues/:id.json should contains total_estimated_hours and total_spent_hours" do
     parent = Issue.find(3)
+    parent.update_columns :estimated_hours => 2.0
     child = Issue.generate!(:parent_issue_id => parent.id, :estimated_hours => 3.0)
     TimeEntry.create!(:project => child.project, :issue => child, :user => child.author, :spent_on => child.author.today,
                       :hours => '2.5', :comments => '', :activity_id => TimeEntryActivity.first.id)
@@ -404,6 +407,7 @@ class Redmine::ApiTest::IssuesTest < Redmine::ApiTest::Base
 
   test "GET /issues/:id.json should contains total_estimated_hours, and should not contains spent_hours and total_spent_hours when permission does not exists" do
     parent = Issue.find(3)
+    parent.update_columns :estimated_hours => 2.0
     child = Issue.generate!(:parent_issue_id => parent.id, :estimated_hours => 3.0)
     # remove permission!
     Role.anonymous.remove_permission! :view_time_entries
index 63febffd94280d18ee7f8f9734472461f7b125fc..928adb65f60a826ade18beb035304ddea516cc4e 100644 (file)
@@ -217,11 +217,14 @@ class Redmine::I18nTest < ActiveSupport::TestCase
                'Fr' => :fr,
                'zh' => :zh,
                'zh-tw' => :"zh-TW",
-               'zh-TW' => :"zh-TW",
-               'zh-ZZ' => nil }
+               'zh-TW' => :"zh-TW"}
     to_test.each {|lang, expected| assert_equal expected, find_language(lang)}
   end
 
+  def test_find_language_with_invalid_language_should_return_nil
+    assert_nil find_language('zh-ZZ')
+  end
+
   def test_fallback
     ::I18n.backend.store_translations(:en, {:untranslated => "Untranslated string"})
     ::I18n.locale = 'en'
index 3e3d6c626d0444cdb9d54dd93e9e30e07eb29c81..999b224b58655882acf1987a6e9bf9e8d6f2fffd 100644 (file)
@@ -20,8 +20,7 @@ require File.expand_path('../../../../test_helper', __FILE__)
 class Redmine::MimeTypeTest < ActiveSupport::TestCase
 
   def test_of
-    to_test = {'test.unk' => nil,
-               'test.txt' => 'text/plain',
+    to_test = {'test.txt' => 'text/plain',
                'test.c' => 'text/x-c',
                }
     to_test.each do |name, expected|
@@ -29,9 +28,12 @@ class Redmine::MimeTypeTest < ActiveSupport::TestCase
     end
   end
 
+  def test_of_with_unknown_type
+    assert_nil Redmine::MimeType.of('test.unk')
+  end
+
   def test_css_class_of
-    to_test = {'test.unk' => nil,
-               'test.txt' => 'text-plain',
+    to_test = {'test.txt' => 'text-plain',
                'test.c' => 'text-x-c',
                }
     to_test.each do |name, expected|
@@ -39,9 +41,12 @@ class Redmine::MimeTypeTest < ActiveSupport::TestCase
     end
   end
 
+  def test_css_class_of_with_unknown_type
+    assert_nil Redmine::MimeType.css_class_of('test.unk')
+  end
+
   def test_main_mimetype_of
-    to_test = {'test.unk' => nil,
-               'test.txt' => 'text',
+    to_test = {'test.txt' => 'text',
                'test.c' => 'text',
                }
     to_test.each do |name, expected|
@@ -49,6 +54,10 @@ class Redmine::MimeTypeTest < ActiveSupport::TestCase
     end
   end
 
+  def test_main_mimetype_of_with_unknown_type
+    assert_nil Redmine::MimeType.main_mimetype_of('test.unk')
+  end
+
   def test_is_type
     to_test = {['text', 'test.unk'] => false,
                ['text', 'test.txt'] => true,
index 85d775459eebbb59ea62cc5e1224b8c68b764ada..ad842a753c92c3ed4b11a83b6092d2b0701fadb4 100644 (file)
@@ -25,7 +25,7 @@ class TrackerTest < ActiveSupport::TestCase
   end
 
   def test_named_scope
-    assert_equal Tracker.find_by_name('Feature'), Tracker.named('feature').first
+    assert_equal Tracker.find(2), Tracker.named('feature request').first
   end
 
   def test_visible_scope_chained_with_project_rolled_up_trackers