From 7c541b4a2fef9c201c164a05f1519b190f667a5f Mon Sep 17 00:00:00 2001 From: Victor Costa Date: Mon, 19 Jan 2015 14:58:55 -0300 Subject: [PATCH] Base controller for plugins administration --- app/controllers/admin/plugin_admin_controller.rb | 5 +++++ test/functional/plugin_admin_controller_test.rb | 25 +++++++++++++++++++++++++ 2 files changed, 30 insertions(+), 0 deletions(-) create mode 100644 app/controllers/admin/plugin_admin_controller.rb create mode 100644 test/functional/plugin_admin_controller_test.rb diff --git a/app/controllers/admin/plugin_admin_controller.rb b/app/controllers/admin/plugin_admin_controller.rb new file mode 100644 index 0000000..7b3a8ec --- /dev/null +++ b/app/controllers/admin/plugin_admin_controller.rb @@ -0,0 +1,5 @@ +class PluginAdminController < AdminController + + protect 'edit_environment_features', :environment + +end diff --git a/test/functional/plugin_admin_controller_test.rb b/test/functional/plugin_admin_controller_test.rb new file mode 100644 index 0000000..88eacef --- /dev/null +++ b/test/functional/plugin_admin_controller_test.rb @@ -0,0 +1,25 @@ +require File.dirname(__FILE__) + '/../test_helper' + +class PluginAdminController + def index + render :text => 'ok' + end +end + +class PluginAdminControllerTest < ActionController::TestCase + + should 'allow user with the required permission to access plugin administration page' do + create_user_with_permission('testuser', 'edit_environment_features', Environment.default) + login_as('testuser') + get :index + assert_response :success + end + + should 'forbid access to users that did not have the required permission' do + create_user('testuser') + login_as('testuser') + get :index + assert_response :forbidden + end + +end -- libgit2 0.21.2