Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fixing to work with Rails 3.2 and Mongoid 3

  • Loading branch information...
commit 65b11a63c2c72856fb70a7db7d96d4cf5bb8c3b4 1 parent 2d04a7a
Navin Peiris navinpeiris authored
144 Gemfile.lock
View
@@ -2,91 +2,103 @@ PATH
remote: .
specs:
mongoid_rails_migrations (0.0.14)
- activesupport (>= 3.0.0)
+ activesupport (>= 3.2.0)
bundler (>= 1.0.0)
- rails (>= 3.0.0)
- railties (>= 3.0.0)
+ rails (>= 3.2.0)
+ railties (>= 3.2.0)
GEM
remote: http://rubygems.org/
specs:
- abstract (1.0.0)
- actionmailer (3.0.9)
- actionpack (= 3.0.9)
- mail (~> 2.2.19)
- actionpack (3.0.9)
- activemodel (= 3.0.9)
- activesupport (= 3.0.9)
- builder (~> 2.1.2)
- erubis (~> 2.6.6)
- i18n (~> 0.5.0)
- rack (~> 1.2.1)
- rack-mount (~> 0.6.14)
- rack-test (~> 0.5.7)
- tzinfo (~> 0.3.23)
- activemodel (3.0.9)
- activesupport (= 3.0.9)
- builder (~> 2.1.2)
- i18n (~> 0.5.0)
- activerecord (3.0.9)
- activemodel (= 3.0.9)
- activesupport (= 3.0.9)
- arel (~> 2.0.10)
- tzinfo (~> 0.3.23)
- activeresource (3.0.9)
- activemodel (= 3.0.9)
- activesupport (= 3.0.9)
- activesupport (3.0.9)
- arel (2.0.10)
- bson (1.3.1)
- builder (2.1.2)
- erubis (2.6.6)
- abstract (>= 1.0.0)
- i18n (0.5.0)
- mail (2.2.19)
- activesupport (>= 2.3.6)
+ actionmailer (3.2.8)
+ actionpack (= 3.2.8)
+ mail (~> 2.4.4)
+ actionpack (3.2.8)
+ activemodel (= 3.2.8)
+ activesupport (= 3.2.8)
+ builder (~> 3.0.0)
+ erubis (~> 2.7.0)
+ journey (~> 1.0.4)
+ rack (~> 1.4.0)
+ rack-cache (~> 1.2)
+ rack-test (~> 0.6.1)
+ sprockets (~> 2.1.3)
+ activemodel (3.2.8)
+ activesupport (= 3.2.8)
+ builder (~> 3.0.0)
+ activerecord (3.2.8)
+ activemodel (= 3.2.8)
+ activesupport (= 3.2.8)
+ arel (~> 3.0.2)
+ tzinfo (~> 0.3.29)
+ activeresource (3.2.8)
+ activemodel (= 3.2.8)
+ activesupport (= 3.2.8)
+ activesupport (3.2.8)
+ i18n (~> 0.6)
+ multi_json (~> 1.0)
+ arel (3.0.2)
+ builder (3.0.0)
+ erubis (2.7.0)
+ hike (1.2.1)
+ i18n (0.6.0)
+ journey (1.0.4)
+ json (1.7.5)
+ mail (2.4.4)
i18n (>= 0.4.0)
mime-types (~> 1.16)
treetop (~> 1.4.8)
- mime-types (1.16)
- mongo (1.3.1)
- bson (>= 1.3.1)
- mongoid (2.0.2)
- activemodel (~> 3.0)
- mongo (~> 1.3)
+ mime-types (1.19)
+ mongoid (3.0.4)
+ activemodel (~> 3.1)
+ moped (~> 1.1)
+ origin (~> 1.0)
tzinfo (~> 0.3.22)
- polyglot (0.3.1)
- rack (1.2.3)
- rack-mount (0.6.14)
- rack (>= 1.0.0)
- rack-test (0.5.7)
+ moped (1.2.0)
+ multi_json (1.3.6)
+ origin (1.0.6)
+ polyglot (0.3.3)
+ rack (1.4.1)
+ rack-cache (1.2)
+ rack (>= 0.4)
+ rack-ssl (1.3.2)
+ rack
+ rack-test (0.6.1)
rack (>= 1.0)
- rails (3.0.9)
- actionmailer (= 3.0.9)
- actionpack (= 3.0.9)
- activerecord (= 3.0.9)
- activeresource (= 3.0.9)
- activesupport (= 3.0.9)
+ rails (3.2.8)
+ actionmailer (= 3.2.8)
+ actionpack (= 3.2.8)
+ activerecord (= 3.2.8)
+ activeresource (= 3.2.8)
+ activesupport (= 3.2.8)
bundler (~> 1.0)
- railties (= 3.0.9)
- railties (3.0.9)
- actionpack (= 3.0.9)
- activesupport (= 3.0.9)
+ railties (= 3.2.8)
+ railties (3.2.8)
+ actionpack (= 3.2.8)
+ activesupport (= 3.2.8)
+ rack-ssl (~> 1.3.2)
rake (>= 0.8.7)
rdoc (~> 3.4)
- thor (~> 0.14.4)
- rake (0.9.2)
- rdoc (3.6.1)
+ thor (>= 0.14.6, < 2.0)
+ rake (0.9.2.2)
+ rdoc (3.12)
+ json (~> 1.4)
+ sprockets (2.1.3)
+ hike (~> 1.2)
+ rack (~> 1.0)
+ tilt (~> 1.1, != 1.3.0)
test-unit (2.5.1)
- thor (0.14.6)
- treetop (1.4.9)
+ thor (0.16.0)
+ tilt (1.3.3)
+ treetop (1.4.10)
+ polyglot
polyglot (>= 0.3.1)
- tzinfo (0.3.28)
+ tzinfo (0.3.33)
PLATFORMS
ruby
DEPENDENCIES
- mongoid (>= 2.0.0)
+ mongoid (>= 3.0.0)
mongoid_rails_migrations!
test-unit (>= 2.5.0)
6 README.rdoc
View
@@ -1,5 +1,5 @@
== RELEASE NOTES
-* Rails 3.1 compatible
+* Rails 3.2 compatible
== SYNOPSIS
* Data migrations for Mongoid.
@@ -9,8 +9,8 @@
* The migrating is good
== REQUIREMENTS
-* rails ~> 3.0.0
-* mongoid ~> 2.0.0 (this isn't currently enforced)
+* rails ~> 3.2.0
+* mongoid ~> 3.0.0 (this isn't currently enforced)
== INSTALL
* gem install mongoid_rails_migrations
2  lib/mongoid_rails_migrations/active_record_ext/migrations.rb
View
@@ -144,7 +144,7 @@ def suppress_messages
def connection
# ActiveRecord::Base.connection
- Mongoid.database
+ ::Mongoid.default_session
end
def method_missing(method, *arguments, &block)
11 lib/rails/generators/mongoid/mongoid_generator.rb
View
@@ -1,5 +1,4 @@
-require 'rails/generators/named_base'
-require 'rails/generators/migration'
+require 'rails/generators'
module Mongoid #:nodoc:
module Generators #:nodoc:
@@ -11,17 +10,17 @@ class Base < ::Rails::Generators::NamedBase #:nodoc:
def self.source_root
File.expand_path("../../#{base_name}/#{generator_name}/templates", __FILE__)
end
-
+
# Implement the required interface for Rails::Generators::Migration.
def self.next_migration_number(dirname) #:nodoc:
next_migration_number = current_migration_number(dirname) + 1
- if Mongoid.config.timestamped_migrations
+ if Mongoid.configure.timestamped_migrations
[Time.now.utc.strftime("%Y%m%d%H%M%S"), "%.14d" % next_migration_number].max
else
"%.3d" % next_migration_number
end
end
-
+
end
- end
+ end
end
8 mongoid_rails_migrations.gemspec
View
@@ -7,7 +7,7 @@ Gem::Specification.new do |s|
# only tested with 1.9.1, but let's go for it
s.required_ruby_version = '>= 1.8.6'
- s.required_rubygems_version = ">= 1.3.6"
+ s.required_rubygems_version = '>= 1.3.6'
s.author = 'Alan Da Costa'
s.email = 'alandacosta@gmail.com.com'
@@ -19,12 +19,12 @@ Gem::Specification.new do |s|
s.test_files = Dir['test/**/*']
s.has_rdoc = false
- rails_version = '>= 3.0.0'
+ rails_version = '>= 3.2.0'
s.add_dependency('bundler', '>= 1.0.0')
s.add_dependency('rails', rails_version)
s.add_dependency('railties', rails_version)
s.add_dependency('activesupport', rails_version)
- s.add_development_dependency('mongoid', '>= 2.0.0')
+ s.add_development_dependency('mongoid', '>= 3.0.0')
s.add_development_dependency('test-unit', '>= 2.5.0')
-end
+end
8 test/config.rb
View
@@ -1,13 +1,9 @@
require File.join(File.dirname(__FILE__), '..', 'lib', 'mongoid_rails_migrations')
require File.join(File.dirname(__FILE__), '..', 'lib', 'rails', 'generators', 'mongoid', 'mongoid_generator')
-Mongoid.configure do |config|
- name = "mongoid_test"
- host = "localhost"
- config.master = Mongo::Connection.new.db(name)
-end
+Mongoid.configure.connect_to('mongoid_test')
# require all models
-Dir[ File.join(File.dirname(__FILE__), 'models', '*.rb') ].each {|file| require file }
+Dir[File.join(File.dirname(__FILE__), 'models', '*.rb')].each { |file| require file }
MIGRATIONS_ROOT = File.join(File.dirname(__FILE__), 'migrations')
3  test/helper.rb
View
@@ -31,6 +31,3 @@ class Application < Rails::Application; end
# TestMongoidRailsMigrations::Application.initialize!
TestMongoidRailsMigrations::Application.load_tasks
-
-# test overrides (dummy path); Rails is really looking for the app environment.rb
-Rails.configuration.paths.config.environment = 'test/config.rb'
7 test/migration_test.rb
View
@@ -3,6 +3,7 @@
class Mongoid::Migration
class <<self
attr_accessor :message_count
+
def puts(text="")
self.message_count ||= 0
self.message_count += 1
@@ -16,7 +17,7 @@ class TestCase < ActiveSupport::TestCase #:nodoc:
def setup
Mongoid::Migration.verbose = true
# same as db:drop command in lib/mongoid_rails_migrations/mongoid_ext/railties/database.rake
- Mongoid.master.collections.each {|col| col.drop_indexes && col.drop unless ['system.indexes', 'system.users'].include?(col.name) }
+ Mongoid.default_session.drop
end
def teardown; end
@@ -122,7 +123,7 @@ def test_migrator_with_missing_version_numbers
end
def test_default_state_of_timestamped_migrations
- assert Mongoid.config.timestamped_migrations, "Mongoid.config.timestamped_migrations should default to true"
+ assert Mongoid.configure.timestamped_migrations, "Mongoid.configure.timestamped_migrations should default to true"
end
def test_timestamped_migrations_generates_non_sequential_next_number
@@ -131,7 +132,7 @@ def test_timestamped_migrations_generates_non_sequential_next_number
end
def test_turning_off_timestamped_migrations
- Mongoid.config.timestamped_migrations = false
+ Mongoid.configure.timestamped_migrations = false
next_number = Mongoid::Generators::Base.next_migration_number(MIGRATIONS_ROOT + "/valid")
assert_equal "20100513063903", next_number
end
Please sign in to comment.
Something went wrong with that request. Please try again.