import awesome_nested_set 2.1.6

64cc8bc8cf

git-svn-id: http://svn.redmine.org/redmine/trunk@12687 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Toshi MARUYAMA
2014-01-21 07:54:42 +00:00
parent bdfcfb35a3
commit 3f6a676622
13 changed files with 119 additions and 59 deletions

View File

@@ -1,4 +1,5 @@
require 'spec_helper'
require 'awesome_nested_set/helper'
describe "Helper" do
include CollectiveIdea::Acts::NestedSet::Helper

View File

@@ -1006,6 +1006,12 @@ describe "AwesomeNestedSet" do
end
end
describe 'rebuilding tree with a default scope ordering' do
it "doesn't throw exception" do
expect { Position.rebuild! }.not_to raise_error
end
end
describe 'creating roots with a default scope ordering' do
it "assigns rgt and lft correctly" do
alpha = Order.create(:name => 'Alpha')

View File

@@ -6,20 +6,22 @@ sqlite3mem:
database: ":memory:"
postgresql:
adapter: postgresql
encoding: unicode
database: awesome_nested_set_plugin_test
pool: 5
username: postgres
password: postgres
database: awesome_nested_set_plugin_test
min_messages: ERROR
min_messages: warning
mysql:
adapter: mysql2
host: localhost
username: root
password:
password:
database: awesome_nested_set_plugin_test
## Add DB Configuration to run Oracle tests
oracle:
adapter: oracle_enhanced
host: localhost
username: awesome_nested_set_dev
password:
password:
database: xe

View File

@@ -56,6 +56,15 @@ ActiveRecord::Schema.define(:version => 0) do
t.column :depth, :integer
end
create_table :positions, :force => true do |t|
t.column :name, :string
t.column :parent_id, :integer
t.column :lft, :integer
t.column :rgt, :integer
t.column :depth, :integer
t.column :position, :integer
end
create_table :no_depths, :force => true do |t|
t.column :name, :string
t.column :parent_id, :integer

View File

@@ -1,32 +1,33 @@
$:.unshift(File.dirname(__FILE__) + '/../lib')
plugin_test_dir = File.dirname(__FILE__)
require 'rubygems'
require 'bundler/setup'
require 'rspec'
require 'logger'
require 'active_support'
require 'active_model'
require 'active_record'
require 'action_controller'
require 'awesome_nested_set'
ActiveRecord::Base.logger = Logger.new(plugin_test_dir + "/debug.log")
require 'yaml'
require 'erb'
ActiveRecord::Base.configurations = YAML::load(ERB.new(IO.read(plugin_test_dir + "/db/database.yml")).result)
ActiveRecord::Base.establish_connection(ENV["DB"] || "sqlite3mem")
ActiveRecord::Base.establish_connection(ENV["DB"] ||= "sqlite3mem")
ActiveRecord::Migration.verbose = false
require 'combustion/database'
Combustion::Database.create_database(ActiveRecord::Base.configurations[ENV["DB"]])
load(File.join(plugin_test_dir, "db", "schema.rb"))
require 'awesome_nested_set'
require 'support/models'
require 'action_controller'
require 'rspec/rails'
RSpec.configure do |config|
config.fixture_path = "#{plugin_test_dir}/fixtures"
config.use_transactional_fixtures = true
config.after(:suite) do
unless /sqlite/ === ENV['DB']
Combustion::Database.drop_database(ActiveRecord::Base.configurations[ENV['DB']])
end
end
end

View File

@@ -85,6 +85,12 @@ class Order < ActiveRecord::Base
default_scope order(:name)
end
class Position < ActiveRecord::Base
acts_as_nested_set
default_scope order(:position)
end
class NoDepth < ActiveRecord::Base
acts_as_nested_set
end