test/test_helper.rb in acts-as-joinable-0.0.1.5 vs test/test_helper.rb in acts-as-joinable-0.0.1.6

- old
+ new

@@ -9,30 +9,48 @@ require 'shoulda' require 'shoulda/active_record' this = File.expand_path(File.dirname(__FILE__)) +# ActiveRecord::Base.logger = Logger.new(STDOUT) + require File.expand_path(File.join(this, '/../lib/acts-as-joinable')) +require File.join(this, "database") -ActsAsJoinable.models = Dir["#{this}/../app/models/*.rb"].collect { |f| File.basename f, '.rb' } +ActsAsJoinable.models = Dir["#{this}/lib/*.rb"].collect { |f| File.basename f, '.rb' } +Dir["#{File.dirname(__FILE__)}/../app/models/*"].each { |c| require c if File.extname(c) == ".rb" } + Dir["#{this}/lib/*"].each { |c| require c if File.extname(c) == ".rb" } ActiveRecord::Base.class_eval do def self.detonate all.map(&:destroy) end end ActiveSupport::TestCase.class_eval do + def create_models(parent = 1, child = 2) + return unless Post.all.empty? parent.times do |i| post = Post.create!(:title => "title-#{i.to_s}") child.times do |j| position = (i + 1) * (j + 1) asset = Asset.create!(:title => "asset-title-#{position.to_s}") tag = Tag.create!(:name => "tag-name-#{position.to_s}") + asset.tags << tag + post.tags << tag + post.assets << asset end end end -end + + def destroy_models + Post.detonate + Tag.detonate + Asset.detonate + Page.detonate + ActsAsJoinable::Relationship.detonate + end +end \ No newline at end of file