Sha256: 824fe6b4bab9a6e5ece1db1bb614ebf7adb4527943fa62f4dacf1cbf33b841db

Contents?: true

Size: 1.09 KB

Versions: 7

Compression:

Stored size: 1.09 KB

Contents

ActiveRecord::Base.configurations = YAML::load(IO.read(File.expand_path("database.yml", File.dirname(__FILE__))))

conf = ActiveRecord::Base.configurations['test']
`echo "drop DATABASE if exists #{conf['database']}" | mysql --user=#{conf['username']}`
`echo "create DATABASE #{conf['database']}" | mysql --user=#{conf['username']}`
ActiveRecord::Base.establish_connection('test')
load(File.dirname(__FILE__) + "/schema.rb")

class Comment < ActiveRecord::Base
  belongs_to :post
  has_one :author, :through => :post

  has_kasket_on :post_id
end

class Author < ActiveRecord::Base
  has_many :posts

  has_kasket
end

class Post < ActiveRecord::Base
  belongs_to :blog
  belongs_to :author
  has_many :comments
  belongs_to :poly, :polymorphic => true

  has_kasket
  has_kasket_on :title
  has_kasket_on :blog_id, :id

  def make_dirty!
    self.updated_at = Time.now
    self.connection.execute("UPDATE posts SET updated_at = '#{updated_at.utc.to_s(:db)}' WHERE id = #{id}")
  end

  kasket_dirty_methods :make_dirty!
end

class Blog < ActiveRecord::Base
  has_many :posts
  has_many :comments, :through => :posts
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
kasket-3.1.0 test/test_models.rb
kasket-3.0.0 test/test_models.rb
kasket-2.2.1 test/test_models.rb
kasket-2.2.0 test/test_models.rb
kasket-2.1.2 test/test_models.rb
kasket-2.1.1 test/test_models.rb
kasket-2.1.0 test/test_models.rb