Sha256: b524123f88113d2ecc9179764d5df305c1da86ff67b36bf0e3b9940cbd01a20b
Contents?: true
Size: 1.42 KB
Versions: 2
Compression:
Stored size: 1.42 KB
Contents
require "rubygems" require "ruby-debug" gem 'test-unit' require "test/unit" require 'active_support' require 'active_support/test_case' require 'active_record' require 'active_record/fixtures' 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}/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 def destroy_models Post.detonate Tag.detonate Asset.detonate Page.detonate ActsAsJoinable::Relationship.detonate end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
acts-as-joinable-0.0.1.7 | test/test_helper.rb |
acts-as-joinable-0.0.1.6 | test/test_helper.rb |