Browse files

corrected a check for ActiveModel::Naming, AM::N is not included into…

… the base class but is extended in, so the check has been changed to just make sure model_name has been implemented
  • Loading branch information...
1 parent 509ccf5 commit 25f68c1c212bae9e7b5ddb375c75c85c07bd44af @joshk committed Jul 7, 2011
Showing with 4 additions and 4 deletions.
  1. +3 −3 lib/completeness-fu/active_model_additions.rb
  2. +1 −1 test/test_helper.rb
View
6 lib/completeness-fu/active_model_additions.rb
@@ -8,15 +8,15 @@ module ActiveModelAdditions
def self.included(base)
base.class_eval do
def self.define_completeness_scoring(&checks_block)
- unless self.include?(ActiveModel::Naming)
- raise CompletenessFuError, 'please make sure ActiveModel::Naming is included so completeness_scoring can translate messages correctly'
+ unless self.respond_to?(:model_name)
+ raise CompletenessFuError, 'please make sure ActiveModel::Naming is included so completeness_scoring can translate messages correctly, or that you implement a model_name method.'
end
class_inheritable_array :completeness_checks
cattr_accessor :default_weighting
cattr_accessor :model_weightings
- self.send :extend, ClassMethods
+ self.send :extend, ClassMethods
self.send :include, InstanceMethods
checks_results = CompletenessFu::ScoringBuilder.generate(self, &checks_block)
View
2 test/test_helper.rb
@@ -24,7 +24,7 @@ def rebuild_class(class_name)
klass = Object.const_set(class_name, Class.new)
klass.class_eval do
- include ActiveModel::Naming
+ extend ActiveModel::Naming
include ActiveModel::Validations
include ActiveModel::Validations::Callbacks

0 comments on commit 25f68c1

Please sign in to comment.