Skip to content
This repository
Browse code

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
@@ -2,91 +2,103 @@ PATH
2 2 remote: .
3 3 specs:
4 4 mongoid_rails_migrations (0.0.14)
5   - activesupport (>= 3.0.0)
  5 + activesupport (>= 3.2.0)
6 6 bundler (>= 1.0.0)
7   - rails (>= 3.0.0)
8   - railties (>= 3.0.0)
  7 + rails (>= 3.2.0)
  8 + railties (>= 3.2.0)
9 9
10 10 GEM
11 11 remote: http://rubygems.org/
12 12 specs:
13   - abstract (1.0.0)
14   - actionmailer (3.0.9)
15   - actionpack (= 3.0.9)
16   - mail (~> 2.2.19)
17   - actionpack (3.0.9)
18   - activemodel (= 3.0.9)
19   - activesupport (= 3.0.9)
20   - builder (~> 2.1.2)
21   - erubis (~> 2.6.6)
22   - i18n (~> 0.5.0)
23   - rack (~> 1.2.1)
24   - rack-mount (~> 0.6.14)
25   - rack-test (~> 0.5.7)
26   - tzinfo (~> 0.3.23)
27   - activemodel (3.0.9)
28   - activesupport (= 3.0.9)
29   - builder (~> 2.1.2)
30   - i18n (~> 0.5.0)
31   - activerecord (3.0.9)
32   - activemodel (= 3.0.9)
33   - activesupport (= 3.0.9)
34   - arel (~> 2.0.10)
35   - tzinfo (~> 0.3.23)
36   - activeresource (3.0.9)
37   - activemodel (= 3.0.9)
38   - activesupport (= 3.0.9)
39   - activesupport (3.0.9)
40   - arel (2.0.10)
41   - bson (1.3.1)
42   - builder (2.1.2)
43   - erubis (2.6.6)
44   - abstract (>= 1.0.0)
45   - i18n (0.5.0)
46   - mail (2.2.19)
47   - activesupport (>= 2.3.6)
  13 + actionmailer (3.2.8)
  14 + actionpack (= 3.2.8)
  15 + mail (~> 2.4.4)
  16 + actionpack (3.2.8)
  17 + activemodel (= 3.2.8)
  18 + activesupport (= 3.2.8)
  19 + builder (~> 3.0.0)
  20 + erubis (~> 2.7.0)
  21 + journey (~> 1.0.4)
  22 + rack (~> 1.4.0)
  23 + rack-cache (~> 1.2)
  24 + rack-test (~> 0.6.1)
  25 + sprockets (~> 2.1.3)
  26 + activemodel (3.2.8)
  27 + activesupport (= 3.2.8)
  28 + builder (~> 3.0.0)
  29 + activerecord (3.2.8)
  30 + activemodel (= 3.2.8)
  31 + activesupport (= 3.2.8)
  32 + arel (~> 3.0.2)
  33 + tzinfo (~> 0.3.29)
  34 + activeresource (3.2.8)
  35 + activemodel (= 3.2.8)
  36 + activesupport (= 3.2.8)
  37 + activesupport (3.2.8)
  38 + i18n (~> 0.6)
  39 + multi_json (~> 1.0)
  40 + arel (3.0.2)
  41 + builder (3.0.0)
  42 + erubis (2.7.0)
  43 + hike (1.2.1)
  44 + i18n (0.6.0)
  45 + journey (1.0.4)
  46 + json (1.7.5)
  47 + mail (2.4.4)
48 48 i18n (>= 0.4.0)
49 49 mime-types (~> 1.16)
50 50 treetop (~> 1.4.8)
51   - mime-types (1.16)
52   - mongo (1.3.1)
53   - bson (>= 1.3.1)
54   - mongoid (2.0.2)
55   - activemodel (~> 3.0)
56   - mongo (~> 1.3)
  51 + mime-types (1.19)
  52 + mongoid (3.0.4)
  53 + activemodel (~> 3.1)
  54 + moped (~> 1.1)
  55 + origin (~> 1.0)
57 56 tzinfo (~> 0.3.22)
58   - polyglot (0.3.1)
59   - rack (1.2.3)
60   - rack-mount (0.6.14)
61   - rack (>= 1.0.0)
62   - rack-test (0.5.7)
  57 + moped (1.2.0)
  58 + multi_json (1.3.6)
  59 + origin (1.0.6)
  60 + polyglot (0.3.3)
  61 + rack (1.4.1)
  62 + rack-cache (1.2)
  63 + rack (>= 0.4)
  64 + rack-ssl (1.3.2)
  65 + rack
  66 + rack-test (0.6.1)
63 67 rack (>= 1.0)
64   - rails (3.0.9)
65   - actionmailer (= 3.0.9)
66   - actionpack (= 3.0.9)
67   - activerecord (= 3.0.9)
68   - activeresource (= 3.0.9)
69   - activesupport (= 3.0.9)
  68 + rails (3.2.8)
  69 + actionmailer (= 3.2.8)
  70 + actionpack (= 3.2.8)
  71 + activerecord (= 3.2.8)
  72 + activeresource (= 3.2.8)
  73 + activesupport (= 3.2.8)
70 74 bundler (~> 1.0)
71   - railties (= 3.0.9)
72   - railties (3.0.9)
73   - actionpack (= 3.0.9)
74   - activesupport (= 3.0.9)
  75 + railties (= 3.2.8)
  76 + railties (3.2.8)
  77 + actionpack (= 3.2.8)
  78 + activesupport (= 3.2.8)
  79 + rack-ssl (~> 1.3.2)
75 80 rake (>= 0.8.7)
76 81 rdoc (~> 3.4)
77   - thor (~> 0.14.4)
78   - rake (0.9.2)
79   - rdoc (3.6.1)
  82 + thor (>= 0.14.6, < 2.0)
  83 + rake (0.9.2.2)
  84 + rdoc (3.12)
  85 + json (~> 1.4)
  86 + sprockets (2.1.3)
  87 + hike (~> 1.2)
  88 + rack (~> 1.0)
  89 + tilt (~> 1.1, != 1.3.0)
80 90 test-unit (2.5.1)
81   - thor (0.14.6)
82   - treetop (1.4.9)
  91 + thor (0.16.0)
  92 + tilt (1.3.3)
  93 + treetop (1.4.10)
  94 + polyglot
83 95 polyglot (>= 0.3.1)
84   - tzinfo (0.3.28)
  96 + tzinfo (0.3.33)
85 97
86 98 PLATFORMS
87 99 ruby
88 100
89 101 DEPENDENCIES
90   - mongoid (>= 2.0.0)
  102 + mongoid (>= 3.0.0)
91 103 mongoid_rails_migrations!
92 104 test-unit (>= 2.5.0)
6 README.rdoc
Source Rendered
... ... @@ -1,5 +1,5 @@
1 1 == RELEASE NOTES
2   -* Rails 3.1 compatible
  2 +* Rails 3.2 compatible
3 3
4 4 == SYNOPSIS
5 5 * Data migrations for Mongoid.
@@ -9,8 +9,8 @@
9 9 * The migrating is good
10 10
11 11 == REQUIREMENTS
12   -* rails ~> 3.0.0
13   -* mongoid ~> 2.0.0 (this isn't currently enforced)
  12 +* rails ~> 3.2.0
  13 +* mongoid ~> 3.0.0 (this isn't currently enforced)
14 14
15 15 == INSTALL
16 16 * gem install mongoid_rails_migrations
2  lib/mongoid_rails_migrations/active_record_ext/migrations.rb
@@ -144,7 +144,7 @@ def suppress_messages
144 144
145 145 def connection
146 146 # ActiveRecord::Base.connection
147   - Mongoid.database
  147 + ::Mongoid.default_session
148 148 end
149 149
150 150 def method_missing(method, *arguments, &block)
11 lib/rails/generators/mongoid/mongoid_generator.rb
... ... @@ -1,5 +1,4 @@
1   -require 'rails/generators/named_base'
2   -require 'rails/generators/migration'
  1 +require 'rails/generators'
3 2
4 3 module Mongoid #:nodoc:
5 4 module Generators #:nodoc:
@@ -11,17 +10,17 @@ class Base < ::Rails::Generators::NamedBase #:nodoc:
11 10 def self.source_root
12 11 File.expand_path("../../#{base_name}/#{generator_name}/templates", __FILE__)
13 12 end
14   -
  13 +
15 14 # Implement the required interface for Rails::Generators::Migration.
16 15 def self.next_migration_number(dirname) #:nodoc:
17 16 next_migration_number = current_migration_number(dirname) + 1
18   - if Mongoid.config.timestamped_migrations
  17 + if Mongoid.configure.timestamped_migrations
19 18 [Time.now.utc.strftime("%Y%m%d%H%M%S"), "%.14d" % next_migration_number].max
20 19 else
21 20 "%.3d" % next_migration_number
22 21 end
23 22 end
24   -
  23 +
25 24 end
26   - end
  25 + end
27 26 end
8 mongoid_rails_migrations.gemspec
@@ -7,7 +7,7 @@ Gem::Specification.new do |s|
7 7
8 8 # only tested with 1.9.1, but let's go for it
9 9 s.required_ruby_version = '>= 1.8.6'
10   - s.required_rubygems_version = ">= 1.3.6"
  10 + s.required_rubygems_version = '>= 1.3.6'
11 11
12 12 s.author = 'Alan Da Costa'
13 13 s.email = 'alandacosta@gmail.com.com'
@@ -19,12 +19,12 @@ Gem::Specification.new do |s|
19 19 s.test_files = Dir['test/**/*']
20 20 s.has_rdoc = false
21 21
22   - rails_version = '>= 3.0.0'
  22 + rails_version = '>= 3.2.0'
23 23
24 24 s.add_dependency('bundler', '>= 1.0.0')
25 25 s.add_dependency('rails', rails_version)
26 26 s.add_dependency('railties', rails_version)
27 27 s.add_dependency('activesupport', rails_version)
28   - s.add_development_dependency('mongoid', '>= 2.0.0')
  28 + s.add_development_dependency('mongoid', '>= 3.0.0')
29 29 s.add_development_dependency('test-unit', '>= 2.5.0')
30   -end
  30 +end
8 test/config.rb
... ... @@ -1,13 +1,9 @@
1 1 require File.join(File.dirname(__FILE__), '..', 'lib', 'mongoid_rails_migrations')
2 2 require File.join(File.dirname(__FILE__), '..', 'lib', 'rails', 'generators', 'mongoid', 'mongoid_generator')
3 3
4   -Mongoid.configure do |config|
5   - name = "mongoid_test"
6   - host = "localhost"
7   - config.master = Mongo::Connection.new.db(name)
8   -end
  4 +Mongoid.configure.connect_to('mongoid_test')
9 5
10 6 # require all models
11   -Dir[ File.join(File.dirname(__FILE__), 'models', '*.rb') ].each {|file| require file }
  7 +Dir[File.join(File.dirname(__FILE__), 'models', '*.rb')].each { |file| require file }
12 8
13 9 MIGRATIONS_ROOT = File.join(File.dirname(__FILE__), 'migrations')
3  test/helper.rb
@@ -31,6 +31,3 @@ class Application < Rails::Application; end
31 31
32 32 # TestMongoidRailsMigrations::Application.initialize!
33 33 TestMongoidRailsMigrations::Application.load_tasks
34   -
35   -# test overrides (dummy path); Rails is really looking for the app environment.rb
36   -Rails.configuration.paths.config.environment = 'test/config.rb'
7 test/migration_test.rb
@@ -3,6 +3,7 @@
3 3 class Mongoid::Migration
4 4 class <<self
5 5 attr_accessor :message_count
  6 +
6 7 def puts(text="")
7 8 self.message_count ||= 0
8 9 self.message_count += 1
@@ -16,7 +17,7 @@ class TestCase < ActiveSupport::TestCase #:nodoc:
16 17 def setup
17 18 Mongoid::Migration.verbose = true
18 19 # same as db:drop command in lib/mongoid_rails_migrations/mongoid_ext/railties/database.rake
19   - Mongoid.master.collections.each {|col| col.drop_indexes && col.drop unless ['system.indexes', 'system.users'].include?(col.name) }
  20 + Mongoid.default_session.drop
20 21 end
21 22
22 23 def teardown; end
@@ -122,7 +123,7 @@ def test_migrator_with_missing_version_numbers
122 123 end
123 124
124 125 def test_default_state_of_timestamped_migrations
125   - assert Mongoid.config.timestamped_migrations, "Mongoid.config.timestamped_migrations should default to true"
  126 + assert Mongoid.configure.timestamped_migrations, "Mongoid.configure.timestamped_migrations should default to true"
126 127 end
127 128
128 129 def test_timestamped_migrations_generates_non_sequential_next_number
@@ -131,7 +132,7 @@ def test_timestamped_migrations_generates_non_sequential_next_number
131 132 end
132 133
133 134 def test_turning_off_timestamped_migrations
134   - Mongoid.config.timestamped_migrations = false
  135 + Mongoid.configure.timestamped_migrations = false
135 136 next_number = Mongoid::Generators::Base.next_migration_number(MIGRATIONS_ROOT + "/valid")
136 137 assert_equal "20100513063903", next_number
137 138 end

0 comments on commit 65b11a6

Please sign in to comment.
Something went wrong with that request. Please try again.