spec/spec_helper.rb in datts_right-0.0.15 vs spec/spec_helper.rb in datts_right-0.0.16
- old
+ new
@@ -4,10 +4,11 @@
require 'active_record'
require 'active_record/errors'
require 'rspec'
require 'datts_right'
require 'datts_right/page'
+require 'datts_right/category'
# Allow to connect to SQLite
root = File.expand_path(File.join(File.dirname(__FILE__), '..'))
Dir.mkdir("db") unless File.directory?("db")
ActiveRecord::Base.establish_connection(
@@ -22,23 +23,32 @@
RSpec.configure do |config|
end
def reset_database
- %W(pages dynamic_attributes).each do |table_name|
+ %W(pages categories dynamic_attributes dynamic_attribute_definitions).each do |table_name|
ActiveRecord::Base.connection.execute("DROP TABLE IF EXISTS '#{table_name}'")
end
ActiveRecord::Base.connection.create_table(:pages) do |t|
t.string :name, :default => "My name"
+ t.integer :category_id
end
ActiveRecord::Base.connection.create_table(:dynamic_attributes) do |t|
- t.string :name, :null => false
+ t.integer :dynamic_attribute_definition_id
t.string :attr_key, :null => false
t.string :object_type, :null => false
t.string :attributable_type, :null => false
t.integer :attributable_id, :null => false
%w(integer string boolean text float).each do |type|
t.send(type, "#{type}_value".to_sym)
end
+ end
+ ActiveRecord::Base.connection.create_table(:dynamic_attribute_definitions) do |t|
+ t.text :definition
+ t.string :attribute_defineable_type, :null => false
+ t.integer :attribute_defineable_id, :null => false
+ end
+ ActiveRecord::Base.connection.create_table(:categories) do |t|
+ t.string :name
end
end