aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Legler <alex@a3li.li>2011-08-29 14:54:16 +0200
committerAlex Legler <alex@a3li.li>2011-08-29 14:54:16 +0200
commit586ab347c9adf8b575127ccf28cde7f1099e51f0 (patch)
tree831bf30b4120a4b1a23ce896fa768c008c789ddc
parentAdmin::TemplatesController: Redirect to correct path after updating (diff)
downloadglsamaker-rails3.tar.gz
glsamaker-rails3.tar.bz2
glsamaker-rails3.zip
Fix TemplatesController functional test. Introduce admin user in the fixtures.rails3
-rw-r--r--test/fixtures/templates.yml14
-rw-r--r--test/fixtures/users.yml9
-rw-r--r--test/functional/admin/templates_controller_test.rb29
3 files changed, 33 insertions, 19 deletions
diff --git a/test/fixtures/templates.yml b/test/fixtures/templates.yml
index 4fcb23c..744e493 100644
--- a/test/fixtures/templates.yml
+++ b/test/fixtures/templates.yml
@@ -1,13 +1,13 @@
# Read about fixtures at http://api.rubyonrails.org/classes/Fixtures.html
one:
- name: MyString
- text: MyText
- field: MyString
+ name: DoS
+ text: A remote attacker could exploit these vulnerabilities to cause a Denial of Service condition.
+ target: impact
enabled: false
two:
- name: MyString
- text: MyText
- field: MyString
- enabled: false
+ name: DoS
+ text: Muiltiple vulnerabilities in [Product] allow remote attackers to cause Denial of Service conditions.
+ target: synopsis
+ enabled: true
diff --git a/test/fixtures/users.yml b/test/fixtures/users.yml
index 7c4553f..a4ba4de 100644
--- a/test/fixtures/users.yml
+++ b/test/fixtures/users.yml
@@ -2,4 +2,11 @@ test_user:
id: 1
login: test
name: foo
- email: foo@bar.org \ No newline at end of file
+ email: foo@bar.org
+
+test_admin:
+ id: 2
+ login: admin
+ name: Admin
+ email: ad@min.invalid
+ jefe: true \ No newline at end of file
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