mongoid-versioning 1.2.0 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +20 -0
- data/.travis.yml +4 -1
- data/README.md +3 -3
- data/lib/mongoid/core_ext/errors/versioning_not_on_root.rb +1 -3
- data/lib/mongoid/core_ext/relations/cascading.rb +4 -5
- data/lib/mongoid/core_ext/relations/metadata.rb +16 -16
- data/lib/mongoid/core_ext/threaded/lifecycle.rb +4 -3
- data/lib/mongoid/core_ext/versioning.rb +19 -20
- data/lib/mongoid/versioning.rb +14 -14
- data/lib/mongoid/versioning/version.rb +1 -1
- data/mongoid-versioning.gemspec +4 -4
- data/spec/app/models/address.rb +9 -8
- data/spec/app/models/paranoid_post.rb +2 -2
- data/spec/app/models/tag.rb +1 -1
- data/spec/app/models/wiki_page.rb +2 -2
- data/spec/mongoid/errors/versioning_not_on_root_spec.rb +8 -10
- data/spec/mongoid/relations/macros_spec.rb +6 -6
- data/spec/mongoid/relations/metadata_spec.rb +8 -12
- data/spec/mongoid/versioning_spec.rb +129 -171
- data/spec/spec_helper.rb +19 -22
- metadata +8 -5
- data/CHANGELOG.md +0 -9
data/spec/spec_helper.rb
CHANGED
@@ -1,44 +1,42 @@
|
|
1
1
|
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
2
|
-
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__),
|
2
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
3
3
|
|
4
|
-
MODELS = File.join(File.dirname(__FILE__),
|
4
|
+
MODELS = File.join(File.dirname(__FILE__), 'app/models')
|
5
5
|
$LOAD_PATH.unshift(MODELS)
|
6
6
|
|
7
|
-
require
|
8
|
-
require
|
7
|
+
require 'mongoid'
|
8
|
+
require 'rspec'
|
9
9
|
|
10
|
-
require
|
10
|
+
require 'mongoid/versioning'
|
11
11
|
|
12
12
|
# These environment variables can be set if wanting to test against a database
|
13
13
|
# that is not on the local machine.
|
14
|
-
ENV[
|
15
|
-
ENV[
|
14
|
+
ENV['MONGOID_SPEC_HOST'] ||= 'localhost'
|
15
|
+
ENV['MONGOID_SPEC_PORT'] ||= '27017'
|
16
16
|
|
17
17
|
# These are used when creating any connection in the test suite.
|
18
|
-
HOST = ENV[
|
19
|
-
PORT = ENV[
|
18
|
+
HOST = ENV['MONGOID_SPEC_HOST']
|
19
|
+
PORT = ENV['MONGOID_SPEC_PORT'].to_i
|
20
20
|
|
21
21
|
# Moped.logger.level = Logger::DEBUG # TODO Remove Mongoid 4 support.
|
22
22
|
# Mongoid.logger.level = Logger::DEBUG
|
23
|
-
if defined?(Mongo)
|
24
|
-
Mongo::Logger.logger.level = Logger::WARN
|
25
|
-
end
|
23
|
+
Mongo::Logger.logger.level = Logger::WARN if defined?(Mongo)
|
26
24
|
|
27
25
|
# When testing locally we use the database named mongoid_test. However when
|
28
26
|
# tests are running in parallel on Travis we need to use different database
|
29
27
|
# names for each process running since we do not have transactions and want a
|
30
28
|
# clean slate before each spec run.
|
31
29
|
def database_id
|
32
|
-
|
30
|
+
'mongoid_test'
|
33
31
|
end
|
34
32
|
|
35
33
|
def database_id_alt
|
36
|
-
|
34
|
+
'mongoid_test_alt'
|
37
35
|
end
|
38
36
|
|
39
37
|
# Can we connect to MongoHQ from this box?
|
40
38
|
def mongohq_connectable?
|
41
|
-
ENV[
|
39
|
+
ENV['MONGOHQ_REPL_PASS'].present?
|
42
40
|
end
|
43
41
|
|
44
42
|
# Set the database that the spec suite connects to.
|
@@ -47,8 +45,8 @@ Mongoid.configure do |config|
|
|
47
45
|
end
|
48
46
|
|
49
47
|
# Autoload every model for the test suite that sits in spec/app/models.
|
50
|
-
Dir[
|
51
|
-
name = File.basename(file,
|
48
|
+
Dir[File.join(MODELS, '*.rb')].sort.each do |file|
|
49
|
+
name = File.basename(file, '.rb')
|
52
50
|
autoload name.camelize.to_sym, name
|
53
51
|
end
|
54
52
|
|
@@ -63,7 +61,6 @@ module MyApp
|
|
63
61
|
end
|
64
62
|
|
65
63
|
RSpec.configure do |config|
|
66
|
-
|
67
64
|
# Drop all collections before each spec.
|
68
65
|
config.before(:each) do
|
69
66
|
Mongoid.purge!
|
@@ -72,7 +69,7 @@ RSpec.configure do |config|
|
|
72
69
|
# On travis we are creating many different databases on each test run. We
|
73
70
|
# drop the database after the suite.
|
74
71
|
config.after(:suite) do
|
75
|
-
if ENV[
|
72
|
+
if ENV['CI']
|
76
73
|
if defined?(Mongo)
|
77
74
|
Mongo::Client.new(["#{HOST}:#{PORT}"], database: database_id).database.drop
|
78
75
|
Mongo::Client.new(["#{HOST}:#{PORT}"], database: database_id_alt).database.drop
|
@@ -83,11 +80,11 @@ RSpec.configure do |config|
|
|
83
80
|
end
|
84
81
|
|
85
82
|
# Filter out MongoHQ specs if we can't connect to it.
|
86
|
-
config.filter_run_excluding(config:
|
83
|
+
config.filter_run_excluding(config: lambda do |value|
|
87
84
|
return true if value == :mongohq && !mongohq_connectable?
|
88
|
-
|
85
|
+
end)
|
89
86
|
end
|
90
87
|
|
91
88
|
ActiveSupport::Inflector.inflections do |inflect|
|
92
|
-
inflect.singular(
|
89
|
+
inflect.singular('address_components', 'address_component')
|
93
90
|
end
|
metadata
CHANGED
@@ -1,14 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mongoid-versioning
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
|
+
- Durran Jordan
|
7
8
|
- Mario Uher
|
8
9
|
autorequire:
|
9
10
|
bindir: bin
|
10
11
|
cert_chain: []
|
11
|
-
date:
|
12
|
+
date: 2016-03-17 00:00:00.000000000 Z
|
12
13
|
dependencies:
|
13
14
|
- !ruby/object:Gem::Dependency
|
14
15
|
name: activesupport
|
@@ -94,14 +95,16 @@ dependencies:
|
|
94
95
|
version: '3'
|
95
96
|
description: Mongoid supports simple versioning through inclusion of the Mongoid::Versioning
|
96
97
|
module.
|
97
|
-
email:
|
98
|
+
email:
|
99
|
+
- durran@gmail.com
|
100
|
+
- uher.mario@gmail.com
|
98
101
|
executables: []
|
99
102
|
extensions: []
|
100
103
|
extra_rdoc_files: []
|
101
104
|
files:
|
102
105
|
- ".gitignore"
|
106
|
+
- ".rubocop.yml"
|
103
107
|
- ".travis.yml"
|
104
|
-
- CHANGELOG.md
|
105
108
|
- Gemfile
|
106
109
|
- README.md
|
107
110
|
- Rakefile
|
@@ -158,7 +161,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
158
161
|
version: '0'
|
159
162
|
requirements: []
|
160
163
|
rubyforge_project:
|
161
|
-
rubygems_version: 2.
|
164
|
+
rubygems_version: 2.4.5.1
|
162
165
|
signing_key:
|
163
166
|
specification_version: 4
|
164
167
|
summary: Extraction of mongoid-versioning into its own gem.
|