2019-03-16 15:03:47 +00:00
|
|
|
# frozen_string_literal: true
|
2019-03-15 01:32:57 +00:00
|
|
|
|
2009-12-06 10:28:20 +00:00
|
|
|
# Redmine - project management software
|
2022-01-02 05:29:10 +00:00
|
|
|
# Copyright (C) 2006-2022 Jean-Philippe Lang
|
2009-12-06 10:28:20 +00:00
|
|
|
#
|
|
|
|
|
# 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.
|
2011-08-22 07:09:10 +00:00
|
|
|
#
|
2009-12-06 10:28:20 +00:00
|
|
|
# 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.
|
2011-08-22 07:09:10 +00:00
|
|
|
#
|
2009-12-06 10:28:20 +00:00
|
|
|
# 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.
|
|
|
|
|
|
2017-07-30 18:23:06 +00:00
|
|
|
require File.expand_path('../../test_helper', __FILE__)
|
2009-12-06 10:28:20 +00:00
|
|
|
|
2016-07-16 11:36:57 +00:00
|
|
|
class ProjectsHelperTest < Redmine::HelperTest
|
2009-12-06 10:28:20 +00:00
|
|
|
include ApplicationHelper
|
|
|
|
|
include ProjectsHelper
|
2012-03-04 13:53:38 +00:00
|
|
|
include ERB::Util
|
2014-05-25 14:38:12 +00:00
|
|
|
include Rails.application.routes.url_helpers
|
2011-08-22 07:09:10 +00:00
|
|
|
|
2011-09-23 23:57:36 +00:00
|
|
|
fixtures :projects, :trackers, :issue_statuses, :issues,
|
|
|
|
|
:enumerations, :users, :issue_categories,
|
|
|
|
|
:versions,
|
|
|
|
|
:projects_trackers,
|
|
|
|
|
:member_roles,
|
|
|
|
|
:members,
|
|
|
|
|
:groups_users,
|
2013-02-03 14:27:19 +00:00
|
|
|
:enabled_modules
|
2009-12-06 10:28:20 +00:00
|
|
|
|
|
|
|
|
def test_link_to_version_within_project
|
|
|
|
|
@project = Project.find(2)
|
|
|
|
|
User.current = User.find(1)
|
2015-01-17 17:02:55 +00:00
|
|
|
assert_equal '<a title="07/01/2006" href="/versions/5">Alpha</a>', link_to_version(Version.find(5))
|
2009-12-06 10:28:20 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def test_link_to_version
|
|
|
|
|
User.current = User.find(1)
|
2015-03-15 14:05:29 +00:00
|
|
|
assert_equal '<a title="07/01/2006" href="/versions/5">OnlineStore - Alpha</a>', link_to_version(Version.find(5))
|
2014-10-24 18:41:35 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def test_link_to_version_without_effective_date
|
|
|
|
|
User.current = User.find(1)
|
|
|
|
|
version = Version.find(5)
|
|
|
|
|
version.effective_date = nil
|
2015-03-15 14:05:29 +00:00
|
|
|
assert_equal '<a href="/versions/5">OnlineStore - Alpha</a>', link_to_version(version)
|
2009-12-06 10:28:20 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def test_link_to_private_version
|
2015-03-15 14:05:29 +00:00
|
|
|
assert_equal 'OnlineStore - Alpha', link_to_version(Version.find(5))
|
2009-12-06 10:28:20 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def test_link_to_version_invalid_version
|
|
|
|
|
assert_equal '', link_to_version(Object)
|
|
|
|
|
end
|
2011-08-22 07:09:10 +00:00
|
|
|
|
2009-12-06 10:28:20 +00:00
|
|
|
def test_format_version_name_within_project
|
|
|
|
|
@project = Project.find(1)
|
|
|
|
|
assert_equal "0.1", format_version_name(Version.find(1))
|
|
|
|
|
end
|
2011-08-22 07:09:10 +00:00
|
|
|
|
2009-12-06 10:28:20 +00:00
|
|
|
def test_format_version_name
|
2015-03-15 14:05:29 +00:00
|
|
|
assert_equal "eCookbook - 0.1", format_version_name(Version.find(1))
|
2009-12-06 10:28:20 +00:00
|
|
|
end
|
|
|
|
|
|
2015-03-15 14:05:29 +00:00
|
|
|
def test_format_version_name_for_system_version
|
|
|
|
|
assert_equal "OnlineStore - Systemwide visible version", format_version_name(Version.find(7))
|
2009-12-06 10:28:20 +00:00
|
|
|
end
|
2011-08-22 07:09:10 +00:00
|
|
|
|
2009-12-09 09:22:16 +00:00
|
|
|
def test_version_options_for_select_with_no_versions
|
|
|
|
|
assert_equal '', version_options_for_select([])
|
2012-07-27 19:41:36 +00:00
|
|
|
assert_equal '', version_options_for_select([], Version.find(1))
|
2009-12-09 09:22:16 +00:00
|
|
|
end
|
2009-12-06 10:28:20 +00:00
|
|
|
end
|