mongoid_rails_migrations 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore CHANGED
@@ -1 +1,3 @@
1
- .DS_Store
1
+ .bundle
2
+ .DS_Store
3
+ .rvmrc
data/Gemfile CHANGED
@@ -1,6 +1,6 @@
1
1
  # Use `bundle install` in order to install these gems
2
2
  # Use `bundle exec rake` in order to run the specs using the bundle
3
- source "http://gemcutter.org"
3
+ source :rubygems
4
4
 
5
5
  gem "rails", ">=3.0.0.beta3"
6
6
  gem "railties", ">=3.0.0.beta3"
@@ -55,7 +55,7 @@ module Mongoid #:nodoc
55
55
  # If you'd prefer to use numeric prefixes, you can turn timestamped migrations
56
56
  # off by setting:
57
57
  #
58
- # config.mongoid.timestamped_migrations = false
58
+ # Mongoid.config.timestamped_migrations = false
59
59
  #
60
60
  # In environment.rb.
61
61
  #
@@ -1,8 +1,12 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  module Mongoid #:nodoc
4
- class << self
4
+ class Config #:nodoc
5
5
  # Specify whether or not to use timestamps for migration versions
6
- cattr_accessor(:timestamped_migrations , :instance_writer => true) {|timestamped_migrations| timestamped_migrations = true }
6
+ attr_accessor :timestamped_migrations
7
+
8
+ def reset
9
+ @timestamped_migrations = true
10
+ end
7
11
  end
8
12
  end
@@ -1,3 +1,4 @@
1
+ require 'rails/generators/named_base'
1
2
  require 'rails/generators/migration'
2
3
 
3
4
  module Mongoid #:nodoc:
@@ -14,7 +15,7 @@ module Mongoid #:nodoc:
14
15
  # Implement the required interface for Rails::Generators::Migration.
15
16
  def self.next_migration_number(dirname) #:nodoc:
16
17
  next_migration_number = current_migration_number(dirname) + 1
17
- if Mongoid.timestamped_migrations
18
+ if Mongoid.config.timestamped_migrations
18
19
  [Time.now.utc.strftime("%Y%m%d%H%M%S"), "%.14d" % next_migration_number].max
19
20
  else
20
21
  "%.3d" % next_migration_number
@@ -1,7 +1,7 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.platform = Gem::Platform::RUBY
3
3
  s.name = 'mongoid_rails_migrations'
4
- s.version = '0.0.3'
4
+ s.version = '0.0.4'
5
5
  s.summary = 'Data migrations for Mongoid in Active Record style, minus column input.'
6
6
  s.description = 'Sometimes you just need to migrate data.'
7
7
 
data/test/config.rb CHANGED
@@ -1,4 +1,5 @@
1
1
  require File.dirname(__FILE__) + '/../lib/mongoid_rails_migrations'
2
+ require File.dirname(__FILE__) + '/../lib/rails/generators/mongoid/mongoid_generator'
2
3
 
3
4
  Mongoid.configure do |config|
4
5
  name = "mongoid_test"
@@ -18,12 +18,11 @@ module Mongoid
18
18
  end
19
19
 
20
20
  def teardown
21
- Mongoid.master.collections.each(&:drop)
21
+ Mongoid.master.collections.reject { |c| c.name == 'system.indexes' }.each(&:drop)
22
22
  end
23
23
 
24
24
  def test_finds_migrations
25
25
  assert Mongoid::Migrator.new(:up, MIGRATIONS_ROOT + "/valid").migrations.size == 2
26
-
27
26
  assert_equal 2, Mongoid::Migrator.new(:up, MIGRATIONS_ROOT + "/valid").pending_migrations.size
28
27
  end
29
28
 
@@ -117,6 +116,12 @@ module Mongoid
117
116
  Mongoid::Migrator.migrate(MIGRATIONS_ROOT + "/valid", 500)
118
117
  end
119
118
  end
120
-
119
+
120
+ def test_turning_off_timestamped_migrations
121
+ Mongoid.config.timestamped_migrations = false
122
+ next_number = Mongoid::Generators::Base.next_migration_number(MIGRATIONS_ROOT + "/valid")
123
+ assert_equal "20100513063903", next_number
124
+ end
125
+
121
126
  end
122
127
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mongoid_rails_migrations
3
3
  version: !ruby/object:Gem::Version
4
- hash: 25
4
+ hash: 23
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 3
10
- version: 0.0.3
9
+ - 4
10
+ version: 0.0.4
11
11
  platform: ruby
12
12
  authors:
13
13
  - Alan Da Costa
@@ -42,7 +42,7 @@ dependencies:
42
42
  requirements:
43
43
  - - ">="
44
44
  - !ruby/object:Gem::Version
45
- hash: 725565327
45
+ hash: -2012828558
46
46
  segments:
47
47
  - 2
48
48
  - 0
@@ -59,7 +59,7 @@ dependencies:
59
59
  requirements:
60
60
  - - ">="
61
61
  - !ruby/object:Gem::Version
62
- hash: 1725185761
62
+ hash: 275995622
63
63
  segments:
64
64
  - 3
65
65
  - 0
@@ -76,7 +76,7 @@ dependencies:
76
76
  requirements:
77
77
  - - ">="
78
78
  - !ruby/object:Gem::Version
79
- hash: 1725185761
79
+ hash: 275995622
80
80
  segments:
81
81
  - 3
82
82
  - 0
@@ -93,7 +93,7 @@ dependencies:
93
93
  requirements:
94
94
  - - ">="
95
95
  - !ruby/object:Gem::Version
96
- hash: 1725185761
96
+ hash: 275995622
97
97
  segments:
98
98
  - 3
99
99
  - 0