Revision 1298:4f746d8966dd .svn/pristine/01
| .svn/pristine/01/011d952bc7773843d5a8219df22dce0959479d6d.svn-base | ||
|---|---|---|
| 1 |
# Redmine - project management software |
|
| 2 |
# Copyright (C) 2006-2011 Jean-Philippe Lang |
|
| 3 |
# |
|
| 4 |
# This program is free software; you can redistribute it and/or |
|
| 5 |
# modify it under the terms of the GNU General Public License |
|
| 6 |
# as published by the Free Software Foundation; either version 2 |
|
| 7 |
# of the License, or (at your option) any later version. |
|
| 8 |
# |
|
| 9 |
# This program is distributed in the hope that it will be useful, |
|
| 10 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
| 11 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
| 12 |
# GNU General Public License for more details. |
|
| 13 |
# |
|
| 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 |
|
| 16 |
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
|
| 17 |
|
|
| 18 |
require File.expand_path('../../test_helper', __FILE__)
|
|
| 19 |
|
|
| 20 |
class DocumentCategoryTest < ActiveSupport::TestCase |
|
| 21 |
fixtures :enumerations, :documents, :issues |
|
| 22 |
|
|
| 23 |
def test_should_be_an_enumeration |
|
| 24 |
assert DocumentCategory.ancestors.include?(Enumeration) |
|
| 25 |
end |
|
| 26 |
|
|
| 27 |
def test_objects_count |
|
| 28 |
assert_equal 2, DocumentCategory.find_by_name("Uncategorized").objects_count
|
|
| 29 |
assert_equal 0, DocumentCategory.find_by_name("User documentation").objects_count
|
|
| 30 |
end |
|
| 31 |
|
|
| 32 |
def test_option_name |
|
| 33 |
assert_equal :enumeration_doc_categories, DocumentCategory.new.option_name |
|
| 34 |
end |
|
| 35 |
end |
|
| .svn/pristine/01/01272907f6842a5e924d61c923ee0994110ab686.svn-base | ||
|---|---|---|
| 1 |
# Redmine - project management software |
|
| 2 |
# Copyright (C) 2006-2011 Jean-Philippe Lang |
|
| 3 |
# |
|
| 4 |
# This program is free software; you can redistribute it and/or |
|
| 5 |
# modify it under the terms of the GNU General Public License |
|
| 6 |
# as published by the Free Software Foundation; either version 2 |
|
| 7 |
# of the License, or (at your option) any later version. |
|
| 8 |
# |
|
| 9 |
# This program is distributed in the hope that it will be useful, |
|
| 10 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
| 11 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
| 12 |
# GNU General Public License for more details. |
|
| 13 |
# |
|
| 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 |
|
| 16 |
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
|
| 17 |
|
|
| 18 |
require File.expand_path('../../../../../test_helper', __FILE__)
|
|
| 19 |
|
|
| 20 |
class Redmine::MenuManager::MenuHelperTest < HelperTestCase |
|
| 21 |
include Redmine::MenuManager::MenuHelper |
|
| 22 |
include ActionController::Assertions::SelectorAssertions |
|
| 23 |
fixtures :users, :members, :projects, :enabled_modules |
|
| 24 |
|
|
| 25 |
# Used by assert_select |
|
| 26 |
def html_document |
|
| 27 |
HTML::Document.new(@response.body) |
|
| 28 |
end |
|
| 29 |
|
|
| 30 |
def setup |
|
| 31 |
super |
|
| 32 |
@response = ActionController::TestResponse.new |
|
| 33 |
# Stub the current menu item in the controller |
|
| 34 |
def current_menu_item |
|
| 35 |
:index |
|
| 36 |
end |
|
| 37 |
end |
|
| 38 |
|
|
| 39 |
|
|
| 40 |
context "MenuManager#current_menu_item" do |
|
| 41 |
should "be tested" |
|
| 42 |
end |
|
| 43 |
|
|
| 44 |
context "MenuManager#render_main_menu" do |
|
| 45 |
should "be tested" |
|
| 46 |
end |
|
| 47 |
|
|
| 48 |
context "MenuManager#render_menu" do |
|
| 49 |
should "be tested" |
|
| 50 |
end |
|
| 51 |
|
|
| 52 |
context "MenuManager#menu_item_and_children" do |
|
| 53 |
should "be tested" |
|
| 54 |
end |
|
| 55 |
|
|
| 56 |
context "MenuManager#extract_node_details" do |
|
| 57 |
should "be tested" |
|
| 58 |
end |
|
| 59 |
|
|
| 60 |
def test_render_single_menu_node |
|
| 61 |
node = Redmine::MenuManager::MenuItem.new(:testing, '/test', { })
|
|
| 62 |
@response.body = render_single_menu_node(node, 'This is a test', node.url, false) |
|
| 63 |
|
|
| 64 |
assert_select("a.testing", "This is a test")
|
|
| 65 |
end |
|
| 66 |
|
|
| 67 |
def test_render_menu_node |
|
| 68 |
single_node = Redmine::MenuManager::MenuItem.new(:single_node, '/test', { })
|
|
| 69 |
@response.body = render_menu_node(single_node, nil) |
|
| 70 |
|
|
| 71 |
assert_select("li") do
|
|
| 72 |
assert_select("a.single-node", "Single node")
|
|
| 73 |
end |
|
| 74 |
end |
|
| 75 |
|
|
| 76 |
def test_render_menu_node_with_nested_items |
|
| 77 |
parent_node = Redmine::MenuManager::MenuItem.new(:parent_node, '/test', { })
|
|
| 78 |
parent_node << Redmine::MenuManager::MenuItem.new(:child_one_node, '/test', { })
|
|
| 79 |
parent_node << Redmine::MenuManager::MenuItem.new(:child_two_node, '/test', { })
|
|
| 80 |
parent_node << |
|
| 81 |
Redmine::MenuManager::MenuItem.new(:child_three_node, '/test', { }) <<
|
|
| 82 |
Redmine::MenuManager::MenuItem.new(:child_three_inner_node, '/test', { })
|
|
| 83 |
|
|
| 84 |
@response.body = render_menu_node(parent_node, nil) |
|
| 85 |
|
|
| 86 |
assert_select("li") do
|
|
| 87 |
assert_select("a.parent-node", "Parent node")
|
|
| 88 |
assert_select("ul") do
|
|
| 89 |
assert_select("li a.child-one-node", "Child one node")
|
|
| 90 |
assert_select("li a.child-two-node", "Child two node")
|
|
| 91 |
assert_select("li") do
|
|
| 92 |
assert_select("a.child-three-node", "Child three node")
|
|
| 93 |
assert_select("ul") do
|
|
| 94 |
assert_select("li a.child-three-inner-node", "Child three inner node")
|
|
| 95 |
end |
|
| 96 |
end |
|
| 97 |
end |
|
| 98 |
end |
|
| 99 |
|
|
| 100 |
end |
|
| 101 |
|
|
| 102 |
def test_render_menu_node_with_children |
|
| 103 |
User.current = User.find(2) |
|
| 104 |
|
|
| 105 |
parent_node = Redmine::MenuManager::MenuItem.new(:parent_node, |
|
| 106 |
'/test', |
|
| 107 |
{
|
|
| 108 |
:children => Proc.new {|p|
|
|
| 109 |
children = [] |
|
| 110 |
3.times do |time| |
|
| 111 |
children << Redmine::MenuManager::MenuItem.new("test_child_#{time}",
|
|
| 112 |
{:controller => 'issues', :action => 'index'},
|
|
| 113 |
{})
|
|
| 114 |
end |
|
| 115 |
children |
|
| 116 |
} |
|
| 117 |
}) |
|
| 118 |
@response.body = render_menu_node(parent_node, Project.find(1)) |
|
| 119 |
|
|
| 120 |
assert_select("li") do
|
|
| 121 |
assert_select("a.parent-node", "Parent node")
|
|
| 122 |
assert_select("ul") do
|
|
| 123 |
assert_select("li a.test-child-0", "Test child 0")
|
|
| 124 |
assert_select("li a.test-child-1", "Test child 1")
|
|
| 125 |
assert_select("li a.test-child-2", "Test child 2")
|
|
| 126 |
end |
|
| 127 |
end |
|
| 128 |
end |
|
| 129 |
|
|
| 130 |
def test_render_menu_node_with_nested_items_and_children |
|
| 131 |
User.current = User.find(2) |
|
| 132 |
|
|
| 133 |
parent_node = Redmine::MenuManager::MenuItem.new(:parent_node, |
|
| 134 |
'/test', |
|
| 135 |
{
|
|
| 136 |
:children => Proc.new {|p|
|
|
| 137 |
children = [] |
|
| 138 |
3.times do |time| |
|
| 139 |
children << Redmine::MenuManager::MenuItem.new("test_child_#{time}", {:controller => 'issues', :action => 'index'}, {})
|
|
| 140 |
end |
|
| 141 |
children |
|
| 142 |
} |
|
| 143 |
}) |
|
| 144 |
|
|
| 145 |
parent_node << Redmine::MenuManager::MenuItem.new(:child_node, |
|
| 146 |
'/test', |
|
| 147 |
{
|
|
| 148 |
:children => Proc.new {|p|
|
|
| 149 |
children = [] |
|
| 150 |
6.times do |time| |
|
| 151 |
children << Redmine::MenuManager::MenuItem.new("test_dynamic_child_#{time}", {:controller => 'issues', :action => 'index'}, {})
|
|
| 152 |
end |
|
| 153 |
children |
|
| 154 |
} |
|
| 155 |
}) |
|
| 156 |
|
|
| 157 |
@response.body = render_menu_node(parent_node, Project.find(1)) |
|
| 158 |
|
|
| 159 |
assert_select("li") do
|
|
| 160 |
assert_select("a.parent-node", "Parent node")
|
|
| 161 |
assert_select("ul") do
|
|
| 162 |
assert_select("li a.child-node", "Child node")
|
|
| 163 |
assert_select("ul") do
|
|
| 164 |
assert_select("li a.test-dynamic-child-0", "Test dynamic child 0")
|
|
| 165 |
assert_select("li a.test-dynamic-child-1", "Test dynamic child 1")
|
|
| 166 |
assert_select("li a.test-dynamic-child-2", "Test dynamic child 2")
|
|
| 167 |
assert_select("li a.test-dynamic-child-3", "Test dynamic child 3")
|
|
| 168 |
assert_select("li a.test-dynamic-child-4", "Test dynamic child 4")
|
|
| 169 |
assert_select("li a.test-dynamic-child-5", "Test dynamic child 5")
|
|
| 170 |
end |
|
| 171 |
assert_select("li a.test-child-0", "Test child 0")
|
|
| 172 |
assert_select("li a.test-child-1", "Test child 1")
|
|
| 173 |
assert_select("li a.test-child-2", "Test child 2")
|
|
| 174 |
end |
|
| 175 |
end |
|
| 176 |
end |
|
| 177 |
|
|
| 178 |
def test_render_menu_node_with_children_without_an_array |
|
| 179 |
parent_node = Redmine::MenuManager::MenuItem.new(:parent_node, |
|
| 180 |
'/test', |
|
| 181 |
{
|
|
| 182 |
:children => Proc.new {|p| Redmine::MenuManager::MenuItem.new("test_child", "/testing", {})}
|
|
| 183 |
}) |
|
| 184 |
|
|
| 185 |
assert_raises Redmine::MenuManager::MenuError, ":children must be an array of MenuItems" do |
|
| 186 |
@response.body = render_menu_node(parent_node, Project.find(1)) |
|
| 187 |
end |
|
| 188 |
end |
|
| 189 |
|
|
| 190 |
def test_render_menu_node_with_incorrect_children |
|
| 191 |
parent_node = Redmine::MenuManager::MenuItem.new(:parent_node, |
|
| 192 |
'/test', |
|
| 193 |
{
|
|
| 194 |
:children => Proc.new {|p| ["a string"] }
|
|
| 195 |
}) |
|
| 196 |
|
|
| 197 |
assert_raises Redmine::MenuManager::MenuError, ":children must be an array of MenuItems" do |
|
| 198 |
@response.body = render_menu_node(parent_node, Project.find(1)) |
|
| 199 |
end |
|
| 200 |
|
|
| 201 |
end |
|
| 202 |
|
|
| 203 |
def test_menu_items_for_should_yield_all_items_if_passed_a_block |
|
| 204 |
menu_name = :test_menu_items_for_should_yield_all_items_if_passed_a_block |
|
| 205 |
Redmine::MenuManager.map menu_name do |menu| |
|
| 206 |
menu.push(:a_menu, '/', { })
|
|
| 207 |
menu.push(:a_menu_2, '/', { })
|
|
| 208 |
menu.push(:a_menu_3, '/', { })
|
|
| 209 |
end |
|
| 210 |
|
|
| 211 |
items_yielded = [] |
|
| 212 |
menu_items_for(menu_name) do |item| |
|
| 213 |
items_yielded << item |
|
| 214 |
end |
|
| 215 |
|
|
| 216 |
assert_equal 3, items_yielded.size |
|
| 217 |
end |
|
| 218 |
|
|
| 219 |
def test_menu_items_for_should_return_all_items |
|
| 220 |
menu_name = :test_menu_items_for_should_return_all_items |
|
| 221 |
Redmine::MenuManager.map menu_name do |menu| |
|
| 222 |
menu.push(:a_menu, '/', { })
|
|
| 223 |
menu.push(:a_menu_2, '/', { })
|
|
| 224 |
menu.push(:a_menu_3, '/', { })
|
|
| 225 |
end |
|
| 226 |
|
|
| 227 |
items = menu_items_for(menu_name) |
|
| 228 |
assert_equal 3, items.size |
|
| 229 |
end |
|
| 230 |
|
|
| 231 |
def test_menu_items_for_should_skip_unallowed_items_on_a_project |
|
| 232 |
menu_name = :test_menu_items_for_should_skip_unallowed_items_on_a_project |
|
| 233 |
Redmine::MenuManager.map menu_name do |menu| |
|
| 234 |
menu.push(:a_menu, {:controller => 'issues', :action => 'index' }, { })
|
|
| 235 |
menu.push(:a_menu_2, {:controller => 'issues', :action => 'index' }, { })
|
|
| 236 |
menu.push(:unallowed, {:controller => 'issues', :action => 'unallowed' }, { })
|
|
| 237 |
end |
|
| 238 |
|
|
| 239 |
User.current = User.find(2) |
|
| 240 |
|
|
| 241 |
items = menu_items_for(menu_name, Project.find(1)) |
|
| 242 |
assert_equal 2, items.size |
|
| 243 |
end |
|
| 244 |
|
|
| 245 |
def test_menu_items_for_should_skip_items_that_fail_the_conditions |
|
| 246 |
menu_name = :test_menu_items_for_should_skip_items_that_fail_the_conditions |
|
| 247 |
Redmine::MenuManager.map menu_name do |menu| |
|
| 248 |
menu.push(:a_menu, {:controller => 'issues', :action => 'index' }, { })
|
|
| 249 |
menu.push(:unallowed, |
|
| 250 |
{:controller => 'issues', :action => 'index' },
|
|
| 251 |
{ :if => Proc.new { false }})
|
|
| 252 |
end |
|
| 253 |
|
|
| 254 |
User.current = User.find(2) |
|
| 255 |
|
|
| 256 |
items = menu_items_for(menu_name, Project.find(1)) |
|
| 257 |
assert_equal 1, items.size |
|
| 258 |
end |
|
| 259 |
|
|
| 260 |
end |
|
| .svn/pristine/01/0154cdd03545376764b58ded20a14138238e65d0.svn-base | ||
|---|---|---|
| 1 |
# Redmine - project management software |
|
| 2 |
# Copyright (C) 2006-2013 Jean-Philippe Lang |
|
| 3 |
# |
|
| 4 |
# This program is free software; you can redistribute it and/or |
|
| 5 |
# modify it under the terms of the GNU General Public License |
|
| 6 |
# as published by the Free Software Foundation; either version 2 |
|
| 7 |
# of the License, or (at your option) any later version. |
|
| 8 |
# |
|
| 9 |
# This program is distributed in the hope that it will be useful, |
|
| 10 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
| 11 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
| 12 |
# GNU General Public License for more details. |
|
| 13 |
# |
|
| 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 |
|
| 16 |
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
|
| 17 |
|
|
| 18 |
require File.expand_path('../../../../test_helper', __FILE__)
|
|
| 19 |
|
|
| 20 |
class Redmine::Hook::ManagerTest < ActionView::TestCase |
|
| 21 |
fixtures :projects, :users, :members, :member_roles, :roles, |
|
| 22 |
:groups_users, |
|
| 23 |
:trackers, :projects_trackers, |
|
| 24 |
:enabled_modules, |
|
| 25 |
:versions, |
|
| 26 |
:issue_statuses, :issue_categories, :issue_relations, |
|
| 27 |
:enumerations, |
|
| 28 |
:issues |
|
| 29 |
|
|
| 30 |
# Some hooks that are manually registered in these tests |
|
| 31 |
class TestHook < Redmine::Hook::ViewListener; end |
|
| 32 |
|
|
| 33 |
class TestHook1 < TestHook |
|
| 34 |
def view_layouts_base_html_head(context) |
|
| 35 |
'Test hook 1 listener.' |
|
| 36 |
end |
|
| 37 |
end |
|
| 38 |
|
|
| 39 |
class TestHook2 < TestHook |
|
| 40 |
def view_layouts_base_html_head(context) |
|
| 41 |
'Test hook 2 listener.' |
|
| 42 |
end |
|
| 43 |
end |
|
| 44 |
|
|
| 45 |
class TestHook3 < TestHook |
|
| 46 |
def view_layouts_base_html_head(context) |
|
| 47 |
"Context keys: #{context.keys.collect(&:to_s).sort.join(', ')}."
|
|
| 48 |
end |
|
| 49 |
end |
|
| 50 |
|
|
| 51 |
class TestLinkToHook < TestHook |
|
| 52 |
def view_layouts_base_html_head(context) |
|
| 53 |
link_to('Issues', :controller => 'issues')
|
|
| 54 |
end |
|
| 55 |
end |
|
| 56 |
|
|
| 57 |
class TestHookHelperController < ActionController::Base |
|
| 58 |
include Redmine::Hook::Helper |
|
| 59 |
end |
|
| 60 |
|
|
| 61 |
class TestHookHelperView < ActionView::Base |
|
| 62 |
include Redmine::Hook::Helper |
|
| 63 |
end |
|
| 64 |
|
|
| 65 |
Redmine::Hook.clear_listeners |
|
| 66 |
|
|
| 67 |
def setup |
|
| 68 |
@hook_module = Redmine::Hook |
|
| 69 |
end |
|
| 70 |
|
|
| 71 |
def teardown |
|
| 72 |
@hook_module.clear_listeners |
|
| 73 |
end |
|
| 74 |
|
|
| 75 |
def test_clear_listeners |
|
| 76 |
assert_equal 0, @hook_module.hook_listeners(:view_layouts_base_html_head).size |
|
| 77 |
@hook_module.add_listener(TestHook1) |
|
| 78 |
@hook_module.add_listener(TestHook2) |
|
| 79 |
assert_equal 2, @hook_module.hook_listeners(:view_layouts_base_html_head).size |
|
| 80 |
|
|
| 81 |
@hook_module.clear_listeners |
|
| 82 |
assert_equal 0, @hook_module.hook_listeners(:view_layouts_base_html_head).size |
|
| 83 |
end |
|
| 84 |
|
|
| 85 |
def test_add_listener |
|
| 86 |
assert_equal 0, @hook_module.hook_listeners(:view_layouts_base_html_head).size |
|
| 87 |
@hook_module.add_listener(TestHook1) |
|
| 88 |
assert_equal 1, @hook_module.hook_listeners(:view_layouts_base_html_head).size |
|
| 89 |
end |
|
| 90 |
|
|
| 91 |
def test_call_hook |
|
| 92 |
@hook_module.add_listener(TestHook1) |
|
| 93 |
assert_equal ['Test hook 1 listener.'], hook_helper.call_hook(:view_layouts_base_html_head) |
|
| 94 |
end |
|
| 95 |
|
|
| 96 |
def test_call_hook_with_context |
|
| 97 |
@hook_module.add_listener(TestHook3) |
|
| 98 |
assert_equal ['Context keys: bar, controller, foo, hook_caller, project, request.'], |
|
| 99 |
hook_helper.call_hook(:view_layouts_base_html_head, :foo => 1, :bar => 'a') |
|
| 100 |
end |
|
| 101 |
|
|
| 102 |
def test_call_hook_with_multiple_listeners |
|
| 103 |
@hook_module.add_listener(TestHook1) |
|
| 104 |
@hook_module.add_listener(TestHook2) |
|
| 105 |
assert_equal ['Test hook 1 listener.', 'Test hook 2 listener.'], hook_helper.call_hook(:view_layouts_base_html_head) |
|
| 106 |
end |
|
| 107 |
|
|
| 108 |
# Context: Redmine::Hook::Helper.call_hook default_url |
|
| 109 |
def test_call_hook_default_url_options |
|
| 110 |
@hook_module.add_listener(TestLinkToHook) |
|
| 111 |
|
|
| 112 |
assert_equal ['<a href="/issues">Issues</a>'], hook_helper.call_hook(:view_layouts_base_html_head) |
|
| 113 |
end |
|
| 114 |
|
|
| 115 |
# Context: Redmine::Hook::Helper.call_hook |
|
| 116 |
def test_call_hook_with_project_added_to_context |
|
| 117 |
@hook_module.add_listener(TestHook3) |
|
| 118 |
assert_match /project/i, hook_helper.call_hook(:view_layouts_base_html_head)[0] |
|
| 119 |
end |
|
| 120 |
|
|
| 121 |
def test_call_hook_from_controller_with_controller_added_to_context |
|
| 122 |
@hook_module.add_listener(TestHook3) |
|
| 123 |
assert_match /controller/i, hook_helper.call_hook(:view_layouts_base_html_head)[0] |
|
| 124 |
end |
|
| 125 |
|
|
| 126 |
def test_call_hook_from_controller_with_request_added_to_context |
|
| 127 |
@hook_module.add_listener(TestHook3) |
|
| 128 |
assert_match /request/i, hook_helper.call_hook(:view_layouts_base_html_head)[0] |
|
| 129 |
end |
|
| 130 |
|
|
| 131 |
def test_call_hook_from_view_with_project_added_to_context |
|
| 132 |
@hook_module.add_listener(TestHook3) |
|
| 133 |
assert_match /project/i, view_hook_helper.call_hook(:view_layouts_base_html_head) |
|
| 134 |
end |
|
| 135 |
|
|
| 136 |
def test_call_hook_from_view_with_controller_added_to_context |
|
| 137 |
@hook_module.add_listener(TestHook3) |
|
| 138 |
assert_match /controller/i, view_hook_helper.call_hook(:view_layouts_base_html_head) |
|
| 139 |
end |
|
| 140 |
|
|
| 141 |
def test_call_hook_from_view_with_request_added_to_context |
|
| 142 |
@hook_module.add_listener(TestHook3) |
|
| 143 |
assert_match /request/i, view_hook_helper.call_hook(:view_layouts_base_html_head) |
|
| 144 |
end |
|
| 145 |
|
|
| 146 |
def test_call_hook_from_view_should_join_responses_with_a_space |
|
| 147 |
@hook_module.add_listener(TestHook1) |
|
| 148 |
@hook_module.add_listener(TestHook2) |
|
| 149 |
assert_equal 'Test hook 1 listener. Test hook 2 listener.', |
|
| 150 |
view_hook_helper.call_hook(:view_layouts_base_html_head) |
|
| 151 |
end |
|
| 152 |
|
|
| 153 |
def test_call_hook_should_not_change_the_default_url_for_email_notifications |
|
| 154 |
issue = Issue.find(1) |
|
| 155 |
|
|
| 156 |
ActionMailer::Base.deliveries.clear |
|
| 157 |
Mailer.issue_add(issue).deliver |
|
| 158 |
mail = ActionMailer::Base.deliveries.last |
|
| 159 |
|
|
| 160 |
@hook_module.add_listener(TestLinkToHook) |
|
| 161 |
hook_helper.call_hook(:view_layouts_base_html_head) |
|
| 162 |
|
|
| 163 |
ActionMailer::Base.deliveries.clear |
|
| 164 |
Mailer.issue_add(issue).deliver |
|
| 165 |
mail2 = ActionMailer::Base.deliveries.last |
|
| 166 |
|
|
| 167 |
assert_equal mail_body(mail), mail_body(mail2) |
|
| 168 |
end |
|
| 169 |
|
|
| 170 |
def hook_helper |
|
| 171 |
@hook_helper ||= TestHookHelperController.new |
|
| 172 |
end |
|
| 173 |
|
|
| 174 |
def view_hook_helper |
|
| 175 |
@view_hook_helper ||= TestHookHelperView.new(Rails.root.to_s + '/app/views') |
|
| 176 |
end |
|
| 177 |
end |
|
| 178 |
|
|
| .svn/pristine/01/01b21d04c9e912327dc0059ef282ceb1a603f54f.svn-base | ||
|---|---|---|
| 1 |
# Redmine - project management software |
|
| 2 |
# Copyright (C) 2006-2013 Jean-Philippe Lang |
|
| 3 |
# |
|
| 4 |
# This program is free software; you can redistribute it and/or |
|
| 5 |
# modify it under the terms of the GNU General Public License |
|
| 6 |
# as published by the Free Software Foundation; either version 2 |
|
| 7 |
# of the License, or (at your option) any later version. |
|
| 8 |
# |
|
| 9 |
# This program is distributed in the hope that it will be useful, |
|
| 10 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
| 11 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
| 12 |
# GNU General Public License for more details. |
|
| 13 |
# |
|
| 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 |
|
| 16 |
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
|
| 17 |
|
|
| 18 |
require File.expand_path('../../test_helper', __FILE__)
|
|
| 19 |
|
|
| 20 |
class AutoCompletesControllerTest < ActionController::TestCase |
|
| 21 |
fixtures :projects, :issues, :issue_statuses, |
|
| 22 |
:enumerations, :users, :issue_categories, |
|
| 23 |
:trackers, |
|
| 24 |
:projects_trackers, |
|
| 25 |
:roles, |
|
| 26 |
:member_roles, |
|
| 27 |
:members, |
|
| 28 |
:enabled_modules, |
|
| 29 |
:journals, :journal_details |
|
| 30 |
|
|
| 31 |
def test_issues_should_not_be_case_sensitive |
|
| 32 |
get :issues, :project_id => 'ecookbook', :q => 'ReCiPe' |
|
| 33 |
assert_response :success |
|
| 34 |
assert_not_nil assigns(:issues) |
|
| 35 |
assert assigns(:issues).detect {|issue| issue.subject.match /recipe/}
|
|
| 36 |
end |
|
| 37 |
|
|
| 38 |
def test_issues_should_accept_term_param |
|
| 39 |
get :issues, :project_id => 'ecookbook', :term => 'ReCiPe' |
|
| 40 |
assert_response :success |
|
| 41 |
assert_not_nil assigns(:issues) |
|
| 42 |
assert assigns(:issues).detect {|issue| issue.subject.match /recipe/}
|
|
| 43 |
end |
|
| 44 |
|
|
| 45 |
def test_issues_should_return_issue_with_given_id |
|
| 46 |
get :issues, :project_id => 'subproject1', :q => '13' |
|
| 47 |
assert_response :success |
|
| 48 |
assert_not_nil assigns(:issues) |
|
| 49 |
assert assigns(:issues).include?(Issue.find(13)) |
|
| 50 |
end |
|
| 51 |
|
|
| 52 |
def test_issues_should_return_issue_with_given_id_preceded_with_hash |
|
| 53 |
get :issues, :project_id => 'subproject1', :q => '#13' |
|
| 54 |
assert_response :success |
|
| 55 |
assert_not_nil assigns(:issues) |
|
| 56 |
assert assigns(:issues).include?(Issue.find(13)) |
|
| 57 |
end |
|
| 58 |
|
|
| 59 |
def test_auto_complete_with_scope_all_should_search_other_projects |
|
| 60 |
get :issues, :project_id => 'ecookbook', :q => '13', :scope => 'all' |
|
| 61 |
assert_response :success |
|
| 62 |
assert_not_nil assigns(:issues) |
|
| 63 |
assert assigns(:issues).include?(Issue.find(13)) |
|
| 64 |
end |
|
| 65 |
|
|
| 66 |
def test_auto_complete_without_project_should_search_all_projects |
|
| 67 |
get :issues, :q => '13' |
|
| 68 |
assert_response :success |
|
| 69 |
assert_not_nil assigns(:issues) |
|
| 70 |
assert assigns(:issues).include?(Issue.find(13)) |
|
| 71 |
end |
|
| 72 |
|
|
| 73 |
def test_auto_complete_without_scope_all_should_not_search_other_projects |
|
| 74 |
get :issues, :project_id => 'ecookbook', :q => '13' |
|
| 75 |
assert_response :success |
|
| 76 |
assert_equal [], assigns(:issues) |
|
| 77 |
end |
|
| 78 |
|
|
| 79 |
def test_issues_should_return_json |
|
| 80 |
get :issues, :project_id => 'subproject1', :q => '13' |
|
| 81 |
assert_response :success |
|
| 82 |
json = ActiveSupport::JSON.decode(response.body) |
|
| 83 |
assert_kind_of Array, json |
|
| 84 |
issue = json.first |
|
| 85 |
assert_kind_of Hash, issue |
|
| 86 |
assert_equal 13, issue['id'] |
|
| 87 |
assert_equal 13, issue['value'] |
|
| 88 |
assert_equal 'Bug #13: Subproject issue two', issue['label'] |
|
| 89 |
end |
|
| 90 |
end |
|
| .svn/pristine/01/01fd40d061a2be270b23a0152d0699de1966efc7.svn-base | ||
|---|---|---|
| 1 |
--- |
|
| 2 |
roles_001: |
|
| 3 |
name: Manager |
|
| 4 |
id: 1 |
|
| 5 |
builtin: 0 |
|
| 6 |
issues_visibility: all |
|
| 7 |
permissions: | |
|
| 8 |
--- |
|
| 9 |
- :add_project |
|
| 10 |
- :edit_project |
|
| 11 |
- :select_project_modules |
|
| 12 |
- :manage_members |
|
| 13 |
- :manage_versions |
|
| 14 |
- :manage_categories |
|
| 15 |
- :view_issues |
|
| 16 |
- :add_issues |
|
| 17 |
- :edit_issues |
|
| 18 |
- :manage_issue_relations |
|
| 19 |
- :manage_subtasks |
|
| 20 |
- :add_issue_notes |
|
| 21 |
- :move_issues |
|
| 22 |
- :delete_issues |
|
| 23 |
- :view_issue_watchers |
|
| 24 |
- :add_issue_watchers |
|
| 25 |
- :set_issues_private |
|
| 26 |
- :delete_issue_watchers |
|
| 27 |
- :manage_public_queries |
|
| 28 |
- :save_queries |
|
| 29 |
- :view_gantt |
|
| 30 |
- :view_calendar |
|
| 31 |
- :log_time |
|
| 32 |
- :view_time_entries |
|
| 33 |
- :edit_time_entries |
|
| 34 |
- :delete_time_entries |
|
| 35 |
- :manage_news |
|
| 36 |
- :comment_news |
|
| 37 |
- :view_documents |
|
| 38 |
- :manage_documents |
|
| 39 |
- :view_wiki_pages |
|
| 40 |
- :export_wiki_pages |
|
| 41 |
- :view_wiki_edits |
|
| 42 |
- :edit_wiki_pages |
|
| 43 |
- :delete_wiki_pages_attachments |
|
| 44 |
- :protect_wiki_pages |
|
| 45 |
- :delete_wiki_pages |
|
| 46 |
- :rename_wiki_pages |
|
| 47 |
- :add_messages |
|
| 48 |
- :edit_messages |
|
| 49 |
- :delete_messages |
|
| 50 |
- :manage_boards |
|
| 51 |
- :view_files |
|
| 52 |
- :manage_files |
|
| 53 |
- :browse_repository |
|
| 54 |
- :manage_repository |
|
| 55 |
- :view_changesets |
|
| 56 |
- :manage_project_activities |
|
| 57 |
|
|
| 58 |
position: 1 |
|
| 59 |
roles_002: |
|
| 60 |
name: Developer |
|
| 61 |
id: 2 |
|
| 62 |
builtin: 0 |
|
| 63 |
issues_visibility: default |
|
| 64 |
permissions: | |
|
| 65 |
--- |
|
| 66 |
- :edit_project |
|
| 67 |
- :manage_members |
|
| 68 |
- :manage_versions |
|
| 69 |
- :manage_categories |
|
| 70 |
- :view_issues |
|
| 71 |
- :add_issues |
|
| 72 |
- :edit_issues |
|
| 73 |
- :manage_issue_relations |
|
| 74 |
- :manage_subtasks |
|
| 75 |
- :add_issue_notes |
|
| 76 |
- :move_issues |
|
| 77 |
- :delete_issues |
|
| 78 |
- :view_issue_watchers |
|
| 79 |
- :save_queries |
|
| 80 |
- :view_gantt |
|
| 81 |
- :view_calendar |
|
| 82 |
- :log_time |
|
| 83 |
- :view_time_entries |
|
| 84 |
- :edit_own_time_entries |
|
| 85 |
- :manage_news |
|
| 86 |
- :comment_news |
|
| 87 |
- :view_documents |
|
| 88 |
- :manage_documents |
|
| 89 |
- :view_wiki_pages |
|
| 90 |
- :view_wiki_edits |
|
| 91 |
- :edit_wiki_pages |
|
| 92 |
- :protect_wiki_pages |
|
| 93 |
- :delete_wiki_pages |
|
| 94 |
- :add_messages |
|
| 95 |
- :edit_own_messages |
|
| 96 |
- :delete_own_messages |
|
| 97 |
- :manage_boards |
|
| 98 |
- :view_files |
|
| 99 |
- :manage_files |
|
| 100 |
- :browse_repository |
|
| 101 |
- :view_changesets |
|
| 102 |
|
|
| 103 |
position: 2 |
|
| 104 |
roles_003: |
|
| 105 |
name: Reporter |
|
| 106 |
id: 3 |
|
| 107 |
builtin: 0 |
|
| 108 |
issues_visibility: default |
|
| 109 |
permissions: | |
|
| 110 |
--- |
|
| 111 |
- :edit_project |
|
| 112 |
- :manage_members |
|
| 113 |
- :manage_versions |
|
| 114 |
- :manage_categories |
|
| 115 |
- :view_issues |
|
| 116 |
- :add_issues |
|
| 117 |
- :edit_issues |
|
| 118 |
- :manage_issue_relations |
|
| 119 |
- :add_issue_notes |
|
| 120 |
- :move_issues |
|
| 121 |
- :view_issue_watchers |
|
| 122 |
- :save_queries |
|
| 123 |
- :view_gantt |
|
| 124 |
- :view_calendar |
|
| 125 |
- :log_time |
|
| 126 |
- :view_time_entries |
|
| 127 |
- :manage_news |
|
| 128 |
- :comment_news |
|
| 129 |
- :view_documents |
|
| 130 |
- :manage_documents |
|
| 131 |
- :view_wiki_pages |
|
| 132 |
- :view_wiki_edits |
|
| 133 |
- :edit_wiki_pages |
|
| 134 |
- :delete_wiki_pages |
|
| 135 |
- :add_messages |
|
| 136 |
- :manage_boards |
|
| 137 |
- :view_files |
|
| 138 |
- :manage_files |
|
| 139 |
- :browse_repository |
|
| 140 |
- :view_changesets |
|
| 141 |
|
|
| 142 |
position: 3 |
|
| 143 |
roles_004: |
|
| 144 |
name: Non member |
|
| 145 |
id: 4 |
|
| 146 |
builtin: 1 |
|
| 147 |
issues_visibility: default |
|
| 148 |
permissions: | |
|
| 149 |
--- |
|
| 150 |
- :view_issues |
|
| 151 |
- :add_issues |
|
| 152 |
- :edit_issues |
|
| 153 |
- :manage_issue_relations |
|
| 154 |
- :add_issue_notes |
|
| 155 |
- :move_issues |
|
| 156 |
- :save_queries |
|
| 157 |
- :view_gantt |
|
| 158 |
- :view_calendar |
|
| 159 |
- :log_time |
|
| 160 |
- :view_time_entries |
|
| 161 |
- :comment_news |
|
| 162 |
- :view_documents |
|
| 163 |
- :manage_documents |
|
| 164 |
- :view_wiki_pages |
|
| 165 |
- :view_wiki_edits |
|
| 166 |
- :edit_wiki_pages |
|
| 167 |
- :add_messages |
|
| 168 |
- :view_files |
|
| 169 |
- :manage_files |
|
| 170 |
- :browse_repository |
|
| 171 |
- :view_changesets |
|
| 172 |
|
|
| 173 |
position: 4 |
|
| 174 |
roles_005: |
|
| 175 |
name: Anonymous |
|
| 176 |
id: 5 |
|
| 177 |
builtin: 2 |
|
| 178 |
issues_visibility: default |
|
| 179 |
permissions: | |
|
| 180 |
--- |
|
| 181 |
- :view_issues |
|
| 182 |
- :add_issue_notes |
|
| 183 |
- :view_gantt |
|
| 184 |
- :view_calendar |
|
| 185 |
- :view_time_entries |
|
| 186 |
- :view_documents |
|
| 187 |
- :view_wiki_pages |
|
| 188 |
- :view_wiki_edits |
|
| 189 |
- :view_files |
|
| 190 |
- :browse_repository |
|
| 191 |
- :view_changesets |
|
| 192 |
|
|
| 193 |
position: 5 |
|
| 194 |
|
|
Also available in: Unified diff