File: helper.rb

package info (click to toggle)
ruby-rails-observers 0.1.1-1~bpo70%2B1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy-backports
  • size: 272 kB
  • sloc: ruby: 1,522; makefile: 2
file content (74 lines) | stat: -rw-r--r-- 1,666 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
require 'minitest/autorun'
require 'active_record'

require 'rails/observers/activerecord/active_record'

FIXTURES_ROOT = File.expand_path(File.dirname(__FILE__)) + "/fixtures"

class ActiveSupport::TestCase
  include ActiveRecord::TestFixtures

  self.fixture_path = FIXTURES_ROOT
  self.use_instantiated_fixtures  = false
  self.use_transactional_fixtures = true
end

ActiveRecord::Base.configurations = { "test" => { adapter: 'sqlite3', database: ':memory:' } }
ActiveRecord::Base.establish_connection(:test)

ActiveRecord::Schema.verbose = false
ActiveRecord::Schema.define do
  create_table :topics do |t|
    t.string   :title
    t.string   :author_name
    t.string   :author_email_address
    t.datetime :written_on
    t.time     :bonus_time
    t.date     :last_read
    t.text     :content
    t.text     :important
    t.boolean  :approved, :default => true
    t.integer  :replies_count, :default => 0
    t.integer  :parent_id
    t.string   :parent_title
    t.string   :type
    t.string   :group
    t.timestamps
  end

  create_table :comments do |t|
    t.string :title
  end

  create_table :minimalistics do |t|
  end

  create_table :developers do |t|
    t.string :name
    t.integer :salary
  end
end

class Topic < ActiveRecord::Base
  has_many :replies, dependent: :destroy, foreign_key: "parent_id"
end

class Reply < Topic
  belongs_to :topic, :foreign_key => "parent_id", :counter_cache => true
end

class Comment < ActiveRecord::Base
  def self.lol
    "lol"
  end
end

class Developer < ActiveRecord::Base
end

class Minimalistic < ActiveRecord::Base
end

ActiveSupport::Deprecation.silence do
  require 'active_record/test_case'
end