Skip to content
This repository has been archived by the owner on Sep 13, 2022. It is now read-only.

Commit

Permalink
Browse files Browse the repository at this point in the history
Renaming LiveValidations::Adapter to LiveValidations::AdapterBase. It…
… just makes more sense that way.
  • Loading branch information
augustl committed May 1, 2009
1 parent 7f898eb commit 6ec09f9
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 18 deletions.
@@ -1,6 +1,6 @@
module LiveValidations
# The base class of an adapter.
class Adapter
class AdapterBase
attr_reader :data, :active_record_instance, :rendered_attributes

def initialize(active_record_instance)
Expand Down
@@ -1,5 +1,5 @@
module LiveValidations
class Adapter
class AdapterBase
# The internal representation of each of the 'validates' blocks in the adapter implementation.
class ValidationHook
attr_reader :data, :callback, :prefix, :adapter_instance
Expand Down
@@ -1,5 +1,5 @@
module LiveValidations
class Adapter
class AdapterBase
class ValidationResponse
attr_reader :params
def initialize(&block)
Expand Down
2 changes: 1 addition & 1 deletion lib/live_validations/adapters/jquery_validations.rb
@@ -1,7 +1,7 @@
module LiveValidations
module Adapters
# Adapter for http://bassistance.de/jquery-plugins/jquery-plugin-validation/
class JqueryValidations < LiveValidations::Adapter
class JqueryValidations < LiveValidations::AdapterBase
setup do |v|
v[:validators] = Hash.new {|hash, key| hash[key] = {} }
v[:messages] = Hash.new {|hash, key| hash[key] = {} }
Expand Down
2 changes: 1 addition & 1 deletion lib/live_validations/adapters/livevalidation_dot_com.rb
@@ -1,7 +1,7 @@
module LiveValidations
module Adapters
# Adapter for http://www.livevalidation.com/ (d'oh)
class LivevalidationDotCom < LiveValidations::Adapter
class LivevalidationDotCom < LiveValidations::AdapterBase
setup do |v|
v[:validators] = Hash.new {|hash, key| hash[key] = {} }
end
Expand Down
2 changes: 1 addition & 1 deletion lib/live_validations/adapters/validatious.rb
@@ -1,7 +1,7 @@
module LiveValidations
module Adapters
# Adapter for http://www.validatious.org/
class Validatious < LiveValidations::Adapter
class Validatious < LiveValidations::AdapterBase
def alters_tag_attributes?
true
end
Expand Down
24 changes: 12 additions & 12 deletions test/general_adapter_test.rb
Expand Up @@ -5,7 +5,7 @@ def setup
reset_database
reset_callbacks Post
@post = Post.new
@hook = LiveValidations::Adapter::ValidationHook.new
@hook = LiveValidations::AdapterBase::ValidationHook.new
end

def teardown
Expand All @@ -32,29 +32,29 @@ def test_message_for_without_custom_message
end

def test_utilizes_inline_javascript_with_data_and_proc
LiveValidations::Adapter.expects(:setup_proc).returns(Proc.new {})
LiveValidations::Adapter.expects(:inline_javascript_proc).returns(Proc.new {})
LiveValidations::AdapterBase.expects(:setup_proc).returns(Proc.new {})
LiveValidations::AdapterBase.expects(:inline_javascript_proc).returns(Proc.new {})

adapter = LiveValidations::Adapter.new(@post)
adapter = LiveValidations::AdapterBase.new(@post)
adapter.expects(:data).returns({:not => "blank"})
assert adapter.utilizes_inline_javascript?
end

def test_utilizes_inline_javascript_with_blank_data_and_proc
LiveValidations::Adapter.expects(:setup_proc).returns(Proc.new {})
LiveValidations::Adapter.expects(:inline_javascript_proc).returns(Proc.new {})
LiveValidations::AdapterBase.expects(:setup_proc).returns(Proc.new {})
LiveValidations::AdapterBase.expects(:inline_javascript_proc).returns(Proc.new {})

adapter = LiveValidations::Adapter.new(@post)
adapter = LiveValidations::AdapterBase.new(@post)
adapter.expects(:data).returns({})
assert !adapter.utilizes_inline_javascript?
end

def test_utilizes_inline_javascript_without_json_proc
LiveValidations::Adapter.expects(:setup_proc).returns(Proc.new {})
LiveValidations::Adapter.expects(:inline_javascript_proc).returns(nil)
LiveValidations::AdapterBase.expects(:setup_proc).returns(Proc.new {})
LiveValidations::AdapterBase.expects(:inline_javascript_proc).returns(nil)
# No point in mocking .json or .data, because it'll never get called anyway.

adapter = LiveValidations::Adapter.new(@post)
adapter = LiveValidations::AdapterBase.new(@post)
assert !adapter.utilizes_inline_javascript?
end

Expand Down Expand Up @@ -97,8 +97,8 @@ def test_specifying_invalid_adapter_as_symbol
def test_with_validation_that_has_no_attribute
Post.validate {|r| }

LiveValidations::Adapter.expects(:setup_proc).returns(Proc.new {})
adapter = LiveValidations::Adapter.new(@post)
LiveValidations::AdapterBase.expects(:setup_proc).returns(Proc.new {})
adapter = LiveValidations::AdapterBase.new(@post)

# This test should probably be improved. The plugin used to raise an error when
# the model had attribute-less validations, which is what this tests tries to
Expand Down

0 comments on commit 6ec09f9

Please sign in to comment.