Chris@154
|
1 # Redmine - project management software
|
Chris@154
|
2 # Copyright (C) 2008 Jean-Philippe Lang
|
Chris@154
|
3 #
|
Chris@154
|
4 # This program is free software; you can redistribute it and/or
|
Chris@154
|
5 # modify it under the terms of the GNU General Public License
|
Chris@154
|
6 # as published by the Free Software Foundation; either version 2
|
Chris@154
|
7 # of the License, or (at your option) any later version.
|
Chris@154
|
8 #
|
Chris@154
|
9 # This program is distributed in the hope that it will be useful,
|
Chris@154
|
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
|
Chris@154
|
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
Chris@154
|
12 # GNU General Public License for more details.
|
Chris@154
|
13 #
|
Chris@154
|
14 # You should have received a copy of the GNU General Public License
|
Chris@154
|
15 # along with this program; if not, write to the Free Software
|
Chris@154
|
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
Chris@154
|
17
|
Chris@154
|
18 require File.dirname(__FILE__) + '/../test_helper'
|
Chris@154
|
19
|
Chris@154
|
20 class EmbeddedControllerTest < ActionController::TestCase
|
Chris@154
|
21 fixtures :projects, :enabled_modules, :users, :roles, :members
|
Chris@154
|
22
|
Chris@154
|
23 def setup
|
Chris@154
|
24 fixtures_path = File.dirname(__FILE__) + '/../fixtures/html'
|
Chris@154
|
25
|
Chris@154
|
26 Setting.plugin_embedded = { 'path' => fixtures_path,
|
Chris@154
|
27 'index' => 'main.html overview-summary.html index.html',
|
Chris@154
|
28 'extensions' => 'html png gif',
|
Chris@154
|
29 'template' => '',
|
Chris@154
|
30 'encoding' => '',
|
Chris@154
|
31 'menu' => 'Embedded' }
|
Chris@154
|
32
|
Chris@154
|
33 Project.find(1).enabled_modules << EnabledModule.new(:name => 'embedded')
|
Chris@154
|
34
|
Chris@154
|
35 anonymous = Role.anonymous
|
Chris@154
|
36 anonymous.permissions += [:view_embedded_doc]
|
Chris@154
|
37 assert anonymous.save
|
Chris@154
|
38 end
|
Chris@154
|
39
|
Chris@154
|
40 def test_get_root_should_redirect_to_index_file
|
Chris@154
|
41 get :index, :id => 'ecookbook'
|
Chris@154
|
42 assert_redirected_to :path => ['index.html']
|
Chris@154
|
43 end
|
Chris@154
|
44
|
Chris@154
|
45 def test_get_index_file
|
Chris@154
|
46 get :index, :id => 'ecookbook', :path => ['index.html']
|
Chris@154
|
47 assert_response :success
|
Chris@154
|
48 assert_template 'index'
|
Chris@154
|
49 assert_tag :h3, :content => 'C0 code coverage information'
|
Chris@154
|
50 end
|
Chris@154
|
51
|
Chris@154
|
52 def test_get_subdirectory_file
|
Chris@154
|
53 get :index, :id => 'ecookbook', :path => ['misc', 'misc.html']
|
Chris@154
|
54 assert_response :success
|
Chris@154
|
55 assert_template 'index'
|
Chris@154
|
56 assert_tag :b, :content => 'Misc file'
|
Chris@154
|
57 end
|
Chris@154
|
58
|
Chris@154
|
59 def test_get_invalid_extension_should_be_denied
|
Chris@154
|
60 get :index, :id => 'ecookbook', :path => ['misc', 'misc.txt']
|
Chris@154
|
61 assert_response 500
|
Chris@154
|
62 end
|
Chris@154
|
63 end
|