diff options
Diffstat (limited to 'test/functional/admin/templates_controller_test.rb')
-rw-r--r-- | test/functional/admin/templates_controller_test.rb | 29 |
1 files changed, 18 insertions, 11 deletions
diff --git a/test/functional/admin/templates_controller_test.rb b/test/functional/admin/templates_controller_test.rb index 8e8f991..37b8680 100644 --- a/test/functional/admin/templates_controller_test.rb +++ b/test/functional/admin/templates_controller_test.rb @@ -2,13 +2,20 @@ require 'test_helper' class Admin::TemplatesControllerTest < ActionController::TestCase setup do - @admin_template = admin_templates(:one) + @template = templates(:one) + @request.env['HTTP_AUTHORIZATION'] = basic_auth_creds('admin', GLSAMAKER_DEVEL_PASSWORD) + end + + test "should not grant access to regular users" do + @request.env['HTTP_AUTHORIZATION'] = basic_auth_creds('test', GLSAMAKER_DEVEL_PASSWORD) + get :index + assert_redirected_to :controller => '/index', :action => 'error', :type => 'access' end test "should get index" do get :index assert_response :success - assert_not_nil assigns(:admin_templates) + assert_not_nil assigns(:templates) end test "should get new" do @@ -17,31 +24,31 @@ class Admin::TemplatesControllerTest < ActionController::TestCase end test "should create admin_template" do - assert_difference('Admin::Template.count') do - post :create, :admin_template => @admin_template.attributes + assert_difference('Template.count') do + post :create, :admin_template => @template.attributes end - assert_redirected_to admin_template_path(assigns(:admin_template)) + assert_redirected_to admin_template_path(assigns(:template)) end test "should show admin_template" do - get :show, :id => @admin_template.to_param + get :show, :id => @template.to_param assert_response :success end test "should get edit" do - get :edit, :id => @admin_template.to_param + get :edit, :id => @template.to_param assert_response :success end test "should update admin_template" do - put :update, :id => @admin_template.to_param, :admin_template => @admin_template.attributes - assert_redirected_to admin_template_path(assigns(:admin_template)) + put :update, :id => @template.to_param, :template => @template.attributes + assert_redirected_to admin_template_path(assigns(:template)) end test "should destroy admin_template" do - assert_difference('Admin::Template.count', -1) do - delete :destroy, :id => @admin_template.to_param + assert_difference('Template.count', -1) do + delete :destroy, :id => @template.to_param end assert_redirected_to admin_templates_path |