##// END OF EJS Templates
fix ProjectsHelperTest fails when config.threadsafe! is enabled (#12097)...
Toshi MARUYAMA -
r12895:bbaccc347b08
parent child
Show More
@@ -1,77 +1,78
1 # Redmine - project management software
1 # Redmine - project management software
2 # Copyright (C) 2006-2014 Jean-Philippe Lang
2 # Copyright (C) 2006-2014 Jean-Philippe Lang
3 #
3 #
4 # This program is free software; you can redistribute it and/or
4 # This program is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU General Public License
5 # modify it under the terms of the GNU General Public License
6 # as published by the Free Software Foundation; either version 2
6 # as published by the Free Software Foundation; either version 2
7 # of the License, or (at your option) any later version.
7 # of the License, or (at your option) any later version.
8 #
8 #
9 # This program is distributed in the hope that it will be useful,
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
12 # GNU General Public License for more details.
13 #
13 #
14 # You should have received a copy of the GNU General Public License
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the Free Software
15 # along with this program; if not, write to the Free Software
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17
17
18 require File.expand_path('../../../test_helper', __FILE__)
18 require File.expand_path('../../../test_helper', __FILE__)
19
19
20 class ProjectsHelperTest < ActionView::TestCase
20 class ProjectsHelperTest < ActionView::TestCase
21 include ApplicationHelper
21 include ApplicationHelper
22 include ProjectsHelper
22 include ProjectsHelper
23 include Redmine::I18n
23 include Redmine::I18n
24 include ERB::Util
24 include ERB::Util
25 include Rails.application.routes.url_helpers
25
26
26 fixtures :projects, :trackers, :issue_statuses, :issues,
27 fixtures :projects, :trackers, :issue_statuses, :issues,
27 :enumerations, :users, :issue_categories,
28 :enumerations, :users, :issue_categories,
28 :versions,
29 :versions,
29 :projects_trackers,
30 :projects_trackers,
30 :member_roles,
31 :member_roles,
31 :members,
32 :members,
32 :groups_users,
33 :groups_users,
33 :enabled_modules
34 :enabled_modules
34
35
35 def setup
36 def setup
36 super
37 super
37 set_language_if_valid('en')
38 set_language_if_valid('en')
38 User.current = nil
39 User.current = nil
39 end
40 end
40
41
41 def test_link_to_version_within_project
42 def test_link_to_version_within_project
42 @project = Project.find(2)
43 @project = Project.find(2)
43 User.current = User.find(1)
44 User.current = User.find(1)
44 assert_equal '<a href="/versions/5">Alpha</a>', link_to_version(Version.find(5))
45 assert_equal '<a href="/versions/5">Alpha</a>', link_to_version(Version.find(5))
45 end
46 end
46
47
47 def test_link_to_version
48 def test_link_to_version
48 User.current = User.find(1)
49 User.current = User.find(1)
49 assert_equal '<a href="/versions/5">OnlineStore - Alpha</a>', link_to_version(Version.find(5))
50 assert_equal '<a href="/versions/5">OnlineStore - Alpha</a>', link_to_version(Version.find(5))
50 end
51 end
51
52
52 def test_link_to_private_version
53 def test_link_to_private_version
53 assert_equal 'OnlineStore - Alpha', link_to_version(Version.find(5))
54 assert_equal 'OnlineStore - Alpha', link_to_version(Version.find(5))
54 end
55 end
55
56
56 def test_link_to_version_invalid_version
57 def test_link_to_version_invalid_version
57 assert_equal '', link_to_version(Object)
58 assert_equal '', link_to_version(Object)
58 end
59 end
59
60
60 def test_format_version_name_within_project
61 def test_format_version_name_within_project
61 @project = Project.find(1)
62 @project = Project.find(1)
62 assert_equal "0.1", format_version_name(Version.find(1))
63 assert_equal "0.1", format_version_name(Version.find(1))
63 end
64 end
64
65
65 def test_format_version_name
66 def test_format_version_name
66 assert_equal "eCookbook - 0.1", format_version_name(Version.find(1))
67 assert_equal "eCookbook - 0.1", format_version_name(Version.find(1))
67 end
68 end
68
69
69 def test_format_version_name_for_system_version
70 def test_format_version_name_for_system_version
70 assert_equal "OnlineStore - Systemwide visible version", format_version_name(Version.find(7))
71 assert_equal "OnlineStore - Systemwide visible version", format_version_name(Version.find(7))
71 end
72 end
72
73
73 def test_version_options_for_select_with_no_versions
74 def test_version_options_for_select_with_no_versions
74 assert_equal '', version_options_for_select([])
75 assert_equal '', version_options_for_select([])
75 assert_equal '', version_options_for_select([], Version.find(1))
76 assert_equal '', version_options_for_select([], Version.find(1))
76 end
77 end
77 end
78 end
General Comments 0
You need to be logged in to leave comments. Login now