Skip to content

Commit

Permalink
Prepared helpers tests + fixed bug reported in ror-es
Browse files Browse the repository at this point in the history
  • Loading branch information
porras committed Oct 24, 2007
1 parent 0237960 commit 7e4716a
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 4 deletions.
4 changes: 2 additions & 2 deletions lib/form_helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def text_field_with_live_validations(object_name, method, options = {})
private

def live_validation(object_name, method)
if validations = self.instance_variable_get("@#{object_name.to_s}").class.live_validations[method]
if validations = self.instance_variable_get("@#{object_name.to_s}").class.live_validations[method] rescue false
field_name = "#{object_name}_#{method}"
initialize_validator(field_name) +
validations.map do |type, configuration|
Expand All @@ -35,4 +35,4 @@ def script_tags(js_code = '')
end
end
end
end
end
24 changes: 22 additions & 2 deletions test/form_helpers_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,41 @@
require 'rubygems'
require 'active_record'
require 'action_controller'
require 'action_controller/test_process'
require 'action_view'
require File.dirname(__FILE__) + '/../lib/live_validations'
require File.dirname(__FILE__) + '/../lib/form_helpers'
require File.dirname(__FILE__) + '/../test/resource'

class ResourcesController < ActionController::Base
def without_instance_var
render :inline => "<% form_for(:resource, :url => resources_path) do |f| %><%= f.text_field :name %><% end %>"
end

def rescue_action(e)
raise e
end
end

ActionController::Routing::Routes.draw do |map|
map.resources :resources
map.connect ':controller/:action/:id'
end

class FormHelpersTest < Test::Unit::TestCase

def setup
@controller = ResourcesController.new
@request = ActionController::TestRequest.new
@response = ActionController::TestResponse.new
Resource.class_eval do # reset live validations
@live_validations = {}
end
end

def test_truth
assert true
def test_without_instance_var
get :without_instance_var
assert_response :ok
end

end

0 comments on commit 7e4716a

Please sign in to comment.