|
1 | 1 | $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
2 | 2 | $LOAD_PATH.unshift(File.dirname(__FILE__))
|
3 | 3 | require "bundler/setup"
|
| 4 | +require "rails" |
4 | 5 | Bundler.require(:default)
|
| 6 | +require 'action_controller/railtie' |
| 7 | +require 'active_record' |
5 | 8 |
|
6 |
| -require "rails" |
7 |
| -require "nested_form" |
| 9 | +ActiveRecord::Base.establish_connection(:adapter => 'sqlite3', :database => ':memory:') |
| 10 | +ActiveRecord::Migration.verbose = false |
8 | 11 |
|
9 | 12 | # a fake app for initializing the railtie
|
10 | 13 | app = Class.new(Rails::Application)
|
11 | 14 | app.config.secret_token = "token"
|
12 | 15 | app.config.session_store :cookie_store, :key => "_myapp_session"
|
13 | 16 | app.config.active_support.deprecation = :log
|
| 17 | +app.config.action_controller.perform_caching = false |
14 | 18 | app.initialize!
|
15 | 19 |
|
16 |
| -require 'action_controller' |
17 |
| -require 'active_record' |
18 | 20 | require 'rspec/rails'
|
19 |
| - |
20 | 21 | RSpec.configure do |config|
|
21 | 22 | config.mock_with :mocha
|
22 | 23 | end
|
23 | 24 |
|
24 |
| -class TablelessModel < ActiveRecord::Base |
25 |
| - def self.columns() @columns ||= []; end |
26 |
| - |
27 |
| - def self.column(name, sql_type = nil, default = nil, null = true) |
28 |
| - columns << ActiveRecord::ConnectionAdapters::Column.new(name.to_s, default, sql_type.to_s, null) |
29 |
| - end |
30 |
| - |
31 |
| - def self.quoted_table_name |
32 |
| - name.pluralize.underscore |
33 |
| - end |
34 |
| - |
35 |
| - def quoted_id |
36 |
| - "0" |
| 25 | +ActiveRecord::Schema.define do |
| 26 | + create_table :projects, :force => true do |t| |
| 27 | + t.string :name |
37 | 28 | end
|
38 | 29 | end
|
39 |
| - |
40 |
| -class Project < TablelessModel |
41 |
| - column :name, :string |
| 30 | +class Project < ActiveRecord::Base |
| 31 | + # column :name, :string |
42 | 32 | has_many :tasks
|
43 | 33 | accepts_nested_attributes_for :tasks
|
44 | 34 | end
|
45 | 35 |
|
46 |
| -class Task < TablelessModel |
47 |
| - column :project_id, :integer |
48 |
| - column :name, :string |
| 36 | +ActiveRecord::Schema.define do |
| 37 | + create_table :tasks, :force => true do |t| |
| 38 | + t.integer :project_id |
| 39 | + t.string :name |
| 40 | + end |
| 41 | +end |
| 42 | +class Task < ActiveRecord::Base |
| 43 | + # column :project_id, :integer |
| 44 | + # column :name, :string |
49 | 45 | belongs_to :project
|
50 | 46 | end
|
51 | 47 |
|
52 |
| -class Milestone < TablelessModel |
53 |
| - column :task_id, :integer |
54 |
| - column :name, :string |
| 48 | +ActiveRecord::Schema.define do |
| 49 | + create_table :milestones, :force => true do |t| |
| 50 | + t.integer :task_id |
| 51 | + t.string :name |
| 52 | + end |
| 53 | +end |
| 54 | +class Milestone < ActiveRecord::Base |
| 55 | + # column :task_id, :integer |
| 56 | + # column :name, :string |
55 | 57 | belongs_to :task
|
56 | 58 | end
|
0 commit comments