Working on getting tests to work for new design doc checkcodes

This commit is contained in:
Sam Lown 2011-04-13 19:04:09 +02:00
parent 221e5a5470
commit da93fda815
9 changed files with 15 additions and 109 deletions

View file

@ -103,12 +103,6 @@ module CouchRest
design_doc
end
# Return true if the two views match
def compare_views(orig, repl)
return false if orig.nil? or repl.nil?
(orig['map'].to_s.strip == repl['map'].to_s.strip) && (orig['reduce'].to_s.strip == repl['reduce'].to_s.strip)
end
end # module ClassMethods
end

View file

@ -1,19 +0,0 @@
module CouchRest
class Database
alias :delete_orig! :delete!
def delete!
clear_model_fresh_cache
delete_orig!
end
# If the database is deleted, ensure that the design docs will be refreshed.
def clear_model_fresh_cache
::CouchRest::Model::Base.subclasses.each{|klass| klass.req_design_doc_refresh if klass.respond_to?(:req_design_doc_refresh)}
end
end
end

View file

@ -15,8 +15,8 @@ CouchRest::Design.class_eval do
base.delete('_rev')
result = nil
flatten =
lambda{|v|
v.is_a?(Hash) ? v.flatten.map{|v| flatten.call(v)}.flatten : v
lambda {|v|
v.is_a?(Hash) ? v.flatten.map{|v| flatten.call(v)}.flatten : v.to_s
}
Digest::MD5.hexdigest(flatten.call(base).sort.join(''))
end

View file

@ -2,7 +2,7 @@ module CouchRest
module Model
module Views
extend ActiveSupport::Concern
module ClassMethods
# Define a CouchDB view. The name of the view will be the concatenation
# of <tt>by</tt> and the keys joined by <tt>_and_</tt>