Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Added RCOV, minor change to primary_key_format

  • Loading branch information...
commit bb6d920b25e7ef7117f7db7eebaf80514fd04580 1 parent c410dcf
@stefankroes authored
Showing with 14 additions and 4 deletions.
  1. +2 −1  .gitignore
  2. +10 −0 Rakefile
  3. +2 −3 lib/ancestry/has_ancestry.rb
View
3  .gitignore
@@ -2,4 +2,5 @@ doc
*.gem
**/*.log
**/*.db
-test/database.yml
+test/database.yml
+coverage
View
10 Rakefile
@@ -1,6 +1,7 @@
require 'rake'
require 'rake/testtask'
require 'rake/rdoctask'
+require 'rcov/rcovtask'
desc 'Default: run unit tests.'
task :default => :test
@@ -12,6 +13,15 @@ Rake::TestTask.new(:test) do |t|
t.verbose = true
end
+desc 'Determine test code coverage for the ancestry plugin.'
+Rcov::RcovTask.new(:coverage) do |t|
+ t.libs << 'lib'
+ t.test_files = FileList['test/**/*_test.rb']
+ t.verbose = true
+ t.output_dir = "test/coverage"
+ t.rcov_opts << "-x /gems/,/library/"
+end
+
desc 'Generate documentation for the ancestry plugin.'
Rake::RDocTask.new(:rdoc) do |rdoc|
rdoc.rdoc_dir = 'doc'
View
5 lib/ancestry/has_ancestry.rb
@@ -31,8 +31,8 @@ def has_ancestry options = {}
self.base_class = self
# Validate format of ancestry column value
- key_format = options[:primary_key_format] || /[0-9]+/
- validates_format_of ancestry_column, :with => /\A#{key_format.source}(\/#{key_format.source})*\Z/, :allow_nil => true
+ primary_key_format = options[:primary_key_format] || /[0-9]+/
+ validates_format_of ancestry_column, :with => /\A#{primary_key_format.source}(\/#{primary_key_format.source})*\Z/, :allow_nil => true
# Validate that the ancestor ids don't include own id
validate :ancestry_exclude_self
@@ -44,7 +44,6 @@ def has_ancestry options = {}
# Workaround to support Rails 2
scope_method = if rails_3 then :scope else :named_scope end
-
# Named scopes
send scope_method, :roots, :conditions => {ancestry_column => nil}
send scope_method, :ancestors_of, lambda { |object| {:conditions => to_node(object).ancestor_conditions} }

0 comments on commit bb6d920

Please sign in to comment.
Something went wrong with that request. Please try again.