From 3186130966cea85d842faf5c038006f8fb40bb61 Mon Sep 17 00:00:00 2001 From: Jean-Philippe Lang Date: Mon, 12 Dec 2016 21:36:14 +0000 Subject: [PATCH] Don't use assert_equal nil. git-svn-id: http://svn.redmine.org/redmine/trunk@16064 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- test/fixtures/attachments.yml | 1 + test/functional/issues_controller_test.rb | 6 +++++- test/integration/api_test/issues_test.rb | 4 ++++ test/unit/lib/redmine/i18n_test.rb | 7 +++++-- test/unit/lib/redmine/mime_type_test.rb | 21 +++++++++++++++------ test/unit/tracker_test.rb | 2 +- 6 files changed, 31 insertions(+), 10 deletions(-) diff --git a/test/fixtures/attachments.yml b/test/fixtures/attachments.yml index 6f56c0811..f3b4545e9 100644 --- a/test/fixtures/attachments.yml +++ b/test/fixtures/attachments.yml @@ -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 diff --git a/test/functional/issues_controller_test.rb b/test/functional/issues_controller_test.rb index 444e02171..3e1bfa234 100644 --- a/test/functional/issues_controller_test.rb +++ b/test/functional/issues_controller_test.rb @@ -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 diff --git a/test/integration/api_test/issues_test.rb b/test/integration/api_test/issues_test.rb index 94f42287a..de0a2fd20 100644 --- a/test/integration/api_test/issues_test.rb +++ b/test/integration/api_test/issues_test.rb @@ -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 diff --git a/test/unit/lib/redmine/i18n_test.rb b/test/unit/lib/redmine/i18n_test.rb index 63febffd9..928adb65f 100644 --- a/test/unit/lib/redmine/i18n_test.rb +++ b/test/unit/lib/redmine/i18n_test.rb @@ -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' diff --git a/test/unit/lib/redmine/mime_type_test.rb b/test/unit/lib/redmine/mime_type_test.rb index 3e3d6c626..999b224b5 100644 --- a/test/unit/lib/redmine/mime_type_test.rb +++ b/test/unit/lib/redmine/mime_type_test.rb @@ -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, diff --git a/test/unit/tracker_test.rb b/test/unit/tracker_test.rb index 85d775459..ad842a753 100644 --- a/test/unit/tracker_test.rb +++ b/test/unit/tracker_test.rb @@ -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 -- 2.39.5