spec_helper.rb
2.65 KB
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
require 'rubygems'
require "active_record"
require 'active_support'
require 'sqlite3'
require 'active_record/fixtures'
require 'debugger'
$LOAD_PATH.unshift(File.dirname(__FILE__))
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'rails'))
require "init"
require "rails/railtie"
# ActiveRecord::Base.logger = Logger.new(STDOUT)
ActiveRecord::Base.establish_connection(:adapter => "sqlite3", :database => ":memory:")
# ActiveRecord::Base.configurations = true
ActiveRecord::Schema.verbose = false
ActiveRecord::Schema.define do
create_table "users", :force => true do |t|
t.column "name", :text
t.column "account_id", :integer
end
create_table "accounts", :force => true do |t|
t.column "name", :text
end
create_table "people", :force => true do |t|
t.column "name", :text
end
# Has Magic Columns migration generator output
create_table :magic_fields do |t|
t.column :name, :string
t.column :pretty_name, :string
t.column :datatype, :string, :default => "string"
t.column :default, :string
t.column :is_required, :boolean, :default => false
t.column :include_blank, :boolean, :default => false
t.column :allow_other, :boolean, :default => true
t.column :created_at, :datetime
t.column :updated_at, :datetime
end
create_table :magic_attributes do |t|
t.column :magic_field_id, :integer
t.column :magic_option_id, :integer
t.column :value, :string
t.column :created_at, :datetime
t.column :updated_at, :datetime
end
create_table :magic_options do |t|
t.column :magic_field_id, :integer
t.column :value, :string
t.column :synonym, :string
t.column :created_at, :datetime
t.column :updated_at, :datetime
end
create_table :magic_field_relationships do |t|
t.column :magic_field_id, :integer
t.column :owner_id, :integer
t.column :owner_type, :string
t.column :created_at, :datetime
t.column :updated_at, :datetime
end
create_table :magic_attribute_relationships do |t|
t.column :magic_attribute_id, :integer
t.column :owner_id, :integer
t.column :owner_type, :string
end
end
RSpec.configure do |config|
config.before(:all) do
class Account < ActiveRecord::Base
include HasMagicFields::Extend
has_many :users
has_magic_fields
end
class Person < ActiveRecord::Base
include HasMagicFields::Extend
has_magic_fields
end
class User < ActiveRecord::Base
include HasMagicFields::Extend
belongs_to :account
has_magic_fields :through => :account
end
end
config.after(:all) do
end
end