summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorAlex Legler <alex@a3li.li>2011-08-26 18:04:41 +0200
committerAlex Legler <alex@a3li.li>2011-08-26 18:04:41 +0200
commit791a882c049b9f7ed3d39cdf54d6a0a2976acc12 (patch)
tree2c6d0abc6547e2d4fa6c5400cfa966aa2ca275da /test
parentUse proper CamelCase for all CVE related models to adhere to rails standards (diff)
downloadglsamaker-791a882c049b9f7ed3d39cdf54d6a0a2976acc12.tar.gz
glsamaker-791a882c049b9f7ed3d39cdf54d6a0a2976acc12.tar.bz2
glsamaker-791a882c049b9f7ed3d39cdf54d6a0a2976acc12.zip
Migrate tests to rails 3
Diffstat (limited to 'test')
-rw-r--r--test/functional/bugs_controller_test.rb20
-rw-r--r--test/functional/comments_controller_test.rb20
-rw-r--r--test/test_helper.rb8
-rw-r--r--test/test_helper.rb.rails240
-rw-r--r--test/unit/glsa_test.rb4
-rw-r--r--test/unit/user_test.rb6
6 files changed, 12 insertions, 86 deletions
diff --git a/test/functional/bugs_controller_test.rb b/test/functional/bugs_controller_test.rb
index 4637e04..428da4c 100644
--- a/test/functional/bugs_controller_test.rb
+++ b/test/functional/bugs_controller_test.rb
@@ -1,24 +1,4 @@
require 'test_helper'
class BugsControllerTest < ActionController::TestCase
- test "should get new" do
- get :new
- assert_response :success
- end
-
- test "should get create" do
- get :create
- assert_response :success
- end
-
- test "should get destroy" do
- get :destroy
- assert_response :success
- end
-
- test "should get show" do
- get :show
- assert_response :success
- end
-
end
diff --git a/test/functional/comments_controller_test.rb b/test/functional/comments_controller_test.rb
index fd4d589..b4c996b 100644
--- a/test/functional/comments_controller_test.rb
+++ b/test/functional/comments_controller_test.rb
@@ -1,24 +1,4 @@
require 'test_helper'
class CommentsControllerTest < ActionController::TestCase
- test "should get new" do
- get :new
- assert_response :success
- end
-
- test "should get create" do
- get :create
- assert_response :success
- end
-
- test "should get show" do
- get :show
- assert_response :success
- end
-
- test "should get destroy" do
- get :destroy
- assert_response :success
- end
-
end
diff --git a/test/test_helper.rb b/test/test_helper.rb
index 8bf1192..a1bccc0 100644
--- a/test/test_helper.rb
+++ b/test/test_helper.rb
@@ -7,7 +7,13 @@ class ActiveSupport::TestCase
#
# Note: You'll currently still have to declare fixtures explicitly in integration tests
# -- they do not yet inherit this setting
+ set_fixture_class :cves => 'Cve'
+
fixtures :all
# Add more helper methods to be used by all tests here...
-end
+
+ def basic_auth_creds(user, password)
+ "Basic #{ActiveSupport::Base64.encode64("#{username}:#{password}")}"
+ end
+end \ No newline at end of file
diff --git a/test/test_helper.rb.rails2 b/test/test_helper.rb.rails2
deleted file mode 100644
index c91a0c6..0000000
--- a/test/test_helper.rb.rails2
+++ /dev/null
@@ -1,40 +0,0 @@
-ENV["RAILS_ENV"] = "test"
-require File.expand_path(File.dirname(__FILE__) + "/../config/environment")
-require 'test_help'
-
-class ActiveSupport::TestCase
- # Transactional fixtures accelerate your tests by wrapping each test method
- # in a transaction that's rolled back on completion. This ensures that the
- # test database remains unchanged so your fixtures don't have to be reloaded
- # between every test method. Fewer database queries means faster tests.
- #
- # Read Mike Clark's excellent walkthrough at
- # http://clarkware.com/cgi/blosxom/2005/10/24#Rails10FastTesting
- #
- # Every Active Record database supports transactions except MyISAM tables
- # in MySQL. Turn off transactional fixtures in this case; however, if you
- # don't care one way or the other, switching from MyISAM to InnoDB tables
- # is recommended.
- #
- # The only drawback to using transactional fixtures is when you actually
- # need to test transactions. Since your test is bracketed by a transaction,
- # any transactions started in your code will be automatically rolled back.
- self.use_transactional_fixtures = true
-
- # Instantiated fixtures are slow, but give you @david where otherwise you
- # would need people(:david). If you don't want to migrate your existing
- # test cases which use the @david style and don't mind the speed hit (each
- # instantiated fixtures translates to a database query per test method),
- # then set this back to true.
- self.use_instantiated_fixtures = false
-
- set_fixture_class :cves => 'CVE'
-
- # Setup all fixtures in test/fixtures/*.(yml|csv) for all tests in alphabetical order.
- #
- # Note: You'll currently still have to declare fixtures explicitly in integration tests
- # -- they do not yet inherit this setting
- fixtures :all
-
- # Add more helper methods to be used by all tests here...
-end
diff --git a/test/unit/glsa_test.rb b/test/unit/glsa_test.rb
index a8222bf..8d3948c 100644
--- a/test/unit/glsa_test.rb
+++ b/test/unit/glsa_test.rb
@@ -1,13 +1,13 @@
require 'test_helper'
-class GLSATest < ActiveSupport::TestCase
+class GlsaTest < ActiveSupport::TestCase
fixtures :glsas, :users
test "uniqueness" do
glsa = Glsa.new(:glsa_id => glsas(:glsa_one).glsa_id)
assert !glsa.save
- assert glsa.errors.invalid?(:glsa_id)
+ assert glsa.invalid?(:glsa_id)
end
test "successful creation" do
diff --git a/test/unit/user_test.rb b/test/unit/user_test.rb
index 582ccee..8ca01c5 100644
--- a/test/unit/user_test.rb
+++ b/test/unit/user_test.rb
@@ -15,7 +15,7 @@ class UserTest < ActiveSupport::TestCase
test "invalid user name" do
user = User.new
assert !user.valid?
- assert user.errors.invalid?(:login)
+ assert user.invalid?(:login)
end
test "unique user name" do
@@ -24,7 +24,7 @@ class UserTest < ActiveSupport::TestCase
:email => "foo@gentoo.org")
assert !user.save
- assert_equal "User name must be unique", user.errors.on(:login)
+ assert_equal ["User name must be unique"], user.errors[:login]
end
test "invalid email" do
@@ -33,7 +33,7 @@ class UserTest < ActiveSupport::TestCase
:email => 'THIScouldNEVERbeAvalidEMAIL@ADDRESS')
assert !user.valid?
- assert user.errors.invalid?(:email)
+ assert user.invalid?(:email)
end
test "successful creation" do