-
Notifications
You must be signed in to change notification settings - Fork 174
Expand file tree
/
Copy pathtest_helper.rb
More file actions
53 lines (40 loc) · 973 Bytes
/
test_helper.rb
File metadata and controls
53 lines (40 loc) · 973 Bytes
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
require 'active_record'
require 'minitest/autorun'
require 'bourne'
require 'database_cleaner'
unless ENV['CI'] || RUBY_PLATFORM =~ /java/
require 'byebug'
end
require 'dotenv'
Dotenv.load
require 'postgres_ext'
ActiveRecord::Base.establish_connection(ENV['DATABASE_URL'])
class Person < ActiveRecord::Base
has_many :hm_tags, class_name: 'Tag'
has_and_belongs_to_many :habtm_tags, class_name: 'Tag'
def self.wicked_people
includes(:habtm_tags)
.where(:tags => {:categories => ['wicked','awesome']})
end
end
class Tag < ActiveRecord::Base
belongs_to :person
scope :recursive, -> { with.recursive(recursive: Tag.where(tag: 'tag')) }
end
class ParentTag < Tag
end
class ChildTag < Tag
belongs_to :parent_tag, foreign_key: :parent_id
end
DatabaseCleaner.strategy = :deletion
class MiniTest::Spec
class << self
alias :context :describe
end
before do
DatabaseCleaner.start
end
after do
DatabaseCleaner.clean
end
end