Chris@154: # Redmine - project management software Chris@154: # Copyright (C) 2008 Jean-Philippe Lang Chris@154: # Chris@154: # This program is free software; you can redistribute it and/or Chris@154: # modify it under the terms of the GNU General Public License Chris@154: # as published by the Free Software Foundation; either version 2 Chris@154: # of the License, or (at your option) any later version. Chris@154: # Chris@154: # This program is distributed in the hope that it will be useful, Chris@154: # but WITHOUT ANY WARRANTY; without even the implied warranty of Chris@154: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the Chris@154: # GNU General Public License for more details. Chris@154: # Chris@154: # You should have received a copy of the GNU General Public License Chris@154: # along with this program; if not, write to the Free Software Chris@154: # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Chris@154: Chris@154: require File.dirname(__FILE__) + '/../test_helper' Chris@154: Chris@154: class EmbeddedControllerTest < ActionController::TestCase Chris@154: fixtures :projects, :enabled_modules, :users, :roles, :members Chris@154: Chris@154: def setup Chris@154: fixtures_path = File.dirname(__FILE__) + '/../fixtures/html' Chris@154: Chris@154: Setting.plugin_embedded = { 'path' => fixtures_path, Chris@154: 'index' => 'main.html overview-summary.html index.html', Chris@154: 'extensions' => 'html png gif', Chris@154: 'template' => '', Chris@154: 'encoding' => '', Chris@154: 'menu' => 'Embedded' } Chris@154: Chris@154: Project.find(1).enabled_modules << EnabledModule.new(:name => 'embedded') Chris@154: Chris@154: anonymous = Role.anonymous Chris@154: anonymous.permissions += [:view_embedded_doc] Chris@154: assert anonymous.save Chris@154: end Chris@154: Chris@154: def test_get_root_should_redirect_to_index_file Chris@154: get :index, :id => 'ecookbook' Chris@154: assert_redirected_to :path => ['index.html'] Chris@154: end Chris@154: Chris@154: def test_get_index_file Chris@154: get :index, :id => 'ecookbook', :path => ['index.html'] Chris@154: assert_response :success Chris@154: assert_template 'index' Chris@154: assert_tag :h3, :content => 'C0 code coverage information' Chris@154: end Chris@154: Chris@154: def test_get_subdirectory_file Chris@154: get :index, :id => 'ecookbook', :path => ['misc', 'misc.html'] Chris@154: assert_response :success Chris@154: assert_template 'index' Chris@154: assert_tag :b, :content => 'Misc file' Chris@154: end Chris@154: Chris@154: def test_get_invalid_extension_should_be_denied Chris@154: get :index, :id => 'ecookbook', :path => ['misc', 'misc.txt'] Chris@154: assert_response 500 Chris@154: end Chris@154: end