I am testing an existent Rails test suite by creating a new functional test, but am seeing the following test failures that just do not make sense. Note that I have done extensive research here and across the interwebs, so I'm posting this as a last resort:
Justins-MacBook-Pro-4:custserv-web_rake justinfox$ rake test
TEST=test/functional/auth_zones_controller_test.rb --trace
rake/rdoctask is deprecated. Use rdoc/task instead (in RDoc 2.4.2+)
** Invoke test (first_time)
** Execute test
** Invoke test:units (first_time)
** Invoke db:test:prepare (first_time)
** Invoke db:abort_if_pending_migrations (first_time)
** Invoke environment (first_time)
** Execute environment
*******************************************************************
* config.breakpoint_server has been deprecated and has no effect. *
*******************************************************************
** Execute db:abort_if_pending_migrations
** Execute db:test:prepare
** Invoke db:test:load (first_time)
** Invoke db:test:purge (first_time)
** Invoke environment
** Execute db:test:purge
** Execute db:test:load
** Invoke db:schema:load (first_time)
** Invoke environment
** Execute db:schema:load
** Execute test:units
/Users/justinfox/.rvm/rubies/jruby-1.5.5/bin/jruby -I"lib:test" -
I"/Users/justinfox/.rvm/gems/jruby-1.5.5@rails2.3.2/gems/rake-0.9.2/lib"
"/Users/justinfox/.rvm/gems/jruby-1.5.5@rails2.3.2/gems/rake-
0.9.2/lib/rake/rake_test_loader.rb" "test/functional/auth_zones_controller_test.rb"
/Users/justinfox/.rvm/gems/jruby-1.5.5@rails2.3.2/gems/rails-
2.3.2/lib/rails/gem_dependency.rb:99:Warning: Gem::Dependency#version_requirements is
deprecated and will be removed on or after August 2010. Use #requirement
*******************************************************************
* config.breakpoint_server has been deprecated and has no effect. *
*******************************************************************
/Users/justinfox/.rvm/gems/jruby-1.5.5@rails2.3.2/gems/ruby-debug-base-0.10.3.2-
java/lib/ruby-debug-base.rb:214 warning: tracing (e.g. set_trace_func) will not capture all
events without --debug flag
Loaded suite /Users/justinfox/.rvm/gems/jruby-1.5.5@rails2.3.2/gems/rake-
0.9.2/lib/rake/rake_test_loader
Started
access_denied params: --- !map:HashWithIndifferentAccess
user: quentin
action: login_as
controller: auth_zones
in store location for /auth_zones/login_as?user=quentin
Eaccess_denied params: --- !map:HashWithIndifferentAccess
user: quentin
action: login_as
controller: auth_zones
in store location for /auth_zones/login_as?user=quentin
access_denied params: --- !map:HashWithIndifferentAccess
user: quentin
action: index
controller: auth_zones
in store location for /auth_zones/login_as?user=quentin
F
Finished in 0.245 seconds.
1) Error:
test_should_delete_auth_zone(AuthZonesControllerTest):
TypeError: nil is not a string
lib/authenticated_test_helper.rb:43:in `assert_difference'
test/functional/auth_zones_controller_test.rb:19:in `test_should_delete_auth_zone'
2) Failure:
test_should_get_index(AuthZonesControllerTest) [test/functional/auth_zones_controller_test.rb:14]:
<nil> expected to not be nil.
2 tests, 2 assertions, 1 failures, 1 errors
Errors running test:units, test:functionals, and test:integration!
Following are all relevant files:
auth_zone_controller_test.rb
require File.dirname(__FILE__) + '/../test_helper'
require File.dirname(__FILE__) + '/../../app/controllers/account_controller'
require File.dirname(__FILE__) + '/../../app/controllers/auth_zones_controller'
class AuthZonesControllerTest < ActionController::TestCase
include AuthenticatedTestHelper
fixtures :auth_zone, :users
test "should get index" do
post :login_as, :user => 'quentin'
get :index
assert_response :redirect
assert_not_nil assigns(:auth_zones)
end
test "should delete auth zone" do
post :login_as, :user => 'quentin'
assert_difference 'AuthZone.count' do
delete :delete_auth_zone, :id => auth_zone(:one).param
end
assert_response :redirect
end
end
account_controller.rb
def login
logger.info("session: #{session.to_yaml}")
if request.post?
logger.info("in account login (post); session[:return_to] = #{session[:return_to]}")
self.current_user = User.authenticate(params[:email], params[:password])
if logged_in?
if current_user.isCustomerType()
reset_session
end
redirect_back_or_default(url_for(:controller => :home, :action => :index))
#redirect_to :controller => :home, :action => :index
else
flash[:heading] = "Login Error"
flash[:notice] = "The email address and password do not match a SAM Connect account.<br/>
<br/>Please try again or contact a SAMC Administrator."
redirect_to :action => :login
return
end
elsif request.get?
logger.info("in account login (get); session[:return_to] = #{session[:return_to]}")
if logged_in?
session[:return_to] = nil
redirect_to(:controller => :home, :action => :index)
end
end
end
Relevant methods in auth_zone_controller.rb
def index
@auth_zones = AuthZone.find(:all)
end
# Delete an auth zone
def delete_auth_zone
auth_zone_code = AuthZone.find(params[:id]).code
AuthZone.destroy(params[:id])
flash[:notice] = auth_zone_code + " Auth Zone has been deleted"
redirect_to(:action => :index)
end
auth_zone.yml
test_zone_1:
id: 1
created_at: <%= 2.days.ago.to_s :db %>
updated_at: <%= 1.days.ago.to_s :db %>
code: TESTZONE1
desc: "Test Zone 1"
url: "https://testzone1.com"
test_zone_2:
id: 2
created_at: <%= 2.days.ago.to_s :db %>
updated_at: <%= 1.days.ago.to_s :db %>
code: TESTZONE2
desc: "Test Zone 2"
url: "https://testzone2.com"
users.yml (fixture)
quentin:
id: 1
email: quentin@example.com
salt: 7e3041ebc2fc05a40c60028e2c4901a81035d3cd
crypted_password: 00742970dc9e6319f8019fd54864d3ea740f04b1 # test
#crypted_password: "ce2/iFrNtQ8=\n" # quentin, use only if you're using 2-way encryption
created_at: <%= 5.days.ago.to_s :db %>
# activated_at: <%= 5.days.ago.to_s :db %> # only if you're activating new signups
aaron:
id: 2
email: aaron@example.com
salt: 7e3041ebc2fc05a40c60028e2c4901a81035d3cd
crypted_password: 00742970dc9e6319f8019fd54864d3ea740f04b1 # test
# activation_code: aaronscode # only if you're activating new signups
created_at: <%= 1.days.ago.to_s :db %>
Gem list:
*** LOCAL GEMS ***
actionmailer (3.2.2)
actionpack (3.2.2)
activemodel (3.2.2)
activerecord (3.2.2)
activerecord-jdbc-adapter (1.3.11, 1.2.2.1, 1.2.2)
activerecord-jdbcmysql-adapter (1.3.11, 1.2.2.1, 1.2.2)
activeresource (3.2.2)
activesupport (3.2.2)
ansi (1.4.2)
arel (3.0.2)
awesome_nested_set (2.1.5, 2.1.4, 2.1.3)
bouncy-castle-java (1.5.0146.1)
builder (3.0.4, 3.0.2, 3.0.0)
bundler (1.1.4 ruby)
coffee-rails (3.2.2)
coffee-script (2.2.0)
coffee-script-source (1.4.0, 1.3.3)
erubis (2.7.0)
execjs (1.4.0)
fastercsv (1.5.5)
gon (3.0.4, 2.3.0)
hike (1.2.1)
httparty (0.9.0, 0.8.3)
i18n (0.6.11, 0.6.1, 0.6.0)
jdbc-mysql (5.1.33, 5.1.13)
journey (1.0.4, 1.0.3)
jquery-rails (2.1.4, 2.1.2, 2.0.2)
jruby-jars (1.6.8, 1.6.7.2)
jruby-launcher (1.0.14 java)
jruby-openssl (0.7.7)
jruby-rack (1.1.12, 1.1.10, 1.1.6)
json (1.8.1 java, 1.7.6 java, 1.7.5 java, 1.7.3 java)
mail (2.4.4)
mime-types (1.19, 1.18)
minitest (5.4.3)
multi_json (1.5.0, 1.3.6)
multi_xml (0.5.1)
polyglot (0.3.3)
rack (1.4.3, 1.4.1)
rack-cache (1.2)
rack-ssl (1.3.2)
rack-test (0.6.2, 0.6.1)
rails (3.2.2)
rails_sql_views (0.8.0)
railties (3.2.2)
rake (10.0.3, 0.9.2.2, 0.9.2, 0.8.7 ruby)
rdoc (3.12)
ruby-debug-ide (0.4.22)
rubyzip (0.9.9)
sass (3.2.5, 3.2.1, 3.1.19)
sass-rails (3.2.5)
sources (0.0.1)
sprockets (2.1.3)
therubyrhino (2.0.2, 2.0.1, 1.73.4)
therubyrhino_jar (1.7.4)
thor (0.14.6)
thread_safe (0.3.4 java)
tilt (1.3.3)
treetop (1.4.12, 1.4.10)
turn (0.8.2)
tzinfo (1.2.2, 0.3.35, 0.3.33)
uglifier (1.3.0, 1.2.4)
warbler (1.3.6)
Aucun commentaire:
Enregistrer un commentaire