mongoid-versioning 1.0.0 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (189) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +3 -8
  3. data/README.md +1 -1
  4. data/gemfiles/Mongoid_4.gemfile +4 -0
  5. data/gemfiles/Mongoid_5.gemfile +4 -0
  6. data/lib/mongoid/core_ext/fields/validators/macro.rb +1 -3
  7. data/lib/mongoid/core_ext/relations/options.rb +1 -3
  8. data/lib/mongoid/core_ext/versioning.rb +12 -3
  9. data/lib/mongoid/versioning/version.rb +1 -1
  10. data/mongoid-versioning.gemspec +3 -3
  11. data/spec/app/models/comment.rb +4 -4
  12. data/spec/mongoid/versioning_spec.rb +9 -5
  13. data/spec/spec_helper.rb +14 -2
  14. metadata +26 -187
  15. data/spec/app/models/account.rb +0 -28
  16. data/spec/app/models/acolyte.rb +0 -16
  17. data/spec/app/models/actor.rb +0 -19
  18. data/spec/app/models/actor_observer.rb +0 -15
  19. data/spec/app/models/actress.rb +0 -2
  20. data/spec/app/models/address_number.rb +0 -6
  21. data/spec/app/models/agency.rb +0 -5
  22. data/spec/app/models/agent.rb +0 -12
  23. data/spec/app/models/album.rb +0 -14
  24. data/spec/app/models/alert.rb +0 -5
  25. data/spec/app/models/animal.rb +0 -25
  26. data/spec/app/models/answer.rb +0 -4
  27. data/spec/app/models/appointment.rb +0 -7
  28. data/spec/app/models/article.rb +0 -10
  29. data/spec/app/models/artist.rb +0 -66
  30. data/spec/app/models/artwork.rb +0 -4
  31. data/spec/app/models/augmentation.rb +0 -11
  32. data/spec/app/models/band.rb +0 -25
  33. data/spec/app/models/bar.rb +0 -9
  34. data/spec/app/models/basic.rb +0 -6
  35. data/spec/app/models/bed.rb +0 -1
  36. data/spec/app/models/big_palette.rb +0 -2
  37. data/spec/app/models/birthday.rb +0 -13
  38. data/spec/app/models/book.rb +0 -12
  39. data/spec/app/models/breed.rb +0 -4
  40. data/spec/app/models/browser.rb +0 -6
  41. data/spec/app/models/building.rb +0 -5
  42. data/spec/app/models/building_address.rb +0 -5
  43. data/spec/app/models/bus.rb +0 -7
  44. data/spec/app/models/business.rb +0 -5
  45. data/spec/app/models/callback_recorder.rb +0 -25
  46. data/spec/app/models/callback_test.rb +0 -9
  47. data/spec/app/models/canvas.rb +0 -25
  48. data/spec/app/models/car.rb +0 -1
  49. data/spec/app/models/cat.rb +0 -8
  50. data/spec/app/models/category.rb +0 -8
  51. data/spec/app/models/child.rb +0 -4
  52. data/spec/app/models/child_doc.rb +0 -22
  53. data/spec/app/models/church.rb +0 -4
  54. data/spec/app/models/circle.rb +0 -3
  55. data/spec/app/models/circuit.rb +0 -4
  56. data/spec/app/models/circus.rb +0 -7
  57. data/spec/app/models/code.rb +0 -5
  58. data/spec/app/models/contractor.rb +0 -5
  59. data/spec/app/models/cookie.rb +0 -6
  60. data/spec/app/models/country_code.rb +0 -8
  61. data/spec/app/models/definition.rb +0 -7
  62. data/spec/app/models/description.rb +0 -11
  63. data/spec/app/models/dictionary.rb +0 -10
  64. data/spec/app/models/division.rb +0 -10
  65. data/spec/app/models/doctor.rb +0 -12
  66. data/spec/app/models/dog.rb +0 -6
  67. data/spec/app/models/dokument.rb +0 -5
  68. data/spec/app/models/driver.rb +0 -7
  69. data/spec/app/models/drug.rb +0 -6
  70. data/spec/app/models/email.rb +0 -6
  71. data/spec/app/models/employer.rb +0 -5
  72. data/spec/app/models/entry.rb +0 -6
  73. data/spec/app/models/eraser.rb +0 -1
  74. data/spec/app/models/event.rb +0 -22
  75. data/spec/app/models/exhibition.rb +0 -4
  76. data/spec/app/models/exhibitor.rb +0 -5
  77. data/spec/app/models/eye.rb +0 -9
  78. data/spec/app/models/eye_bowl.rb +0 -9
  79. data/spec/app/models/face.rb +0 -8
  80. data/spec/app/models/favorite.rb +0 -6
  81. data/spec/app/models/filesystem.rb +0 -4
  82. data/spec/app/models/firefox.rb +0 -4
  83. data/spec/app/models/fish.rb +0 -8
  84. data/spec/app/models/folder.rb +0 -7
  85. data/spec/app/models/folder_item.rb +0 -9
  86. data/spec/app/models/fruits.rb +0 -28
  87. data/spec/app/models/game.rb +0 -19
  88. data/spec/app/models/ghost.rb +0 -7
  89. data/spec/app/models/home.rb +0 -4
  90. data/spec/app/models/house.rb +0 -7
  91. data/spec/app/models/html_writer.rb +0 -3
  92. data/spec/app/models/image.rb +0 -22
  93. data/spec/app/models/implant.rb +0 -16
  94. data/spec/app/models/item.rb +0 -8
  95. data/spec/app/models/jar.rb +0 -7
  96. data/spec/app/models/label.rb +0 -40
  97. data/spec/app/models/language.rb +0 -5
  98. data/spec/app/models/lat_lng.rb +0 -15
  99. data/spec/app/models/league.rb +0 -11
  100. data/spec/app/models/learner.rb +0 -2
  101. data/spec/app/models/line_item.rb +0 -6
  102. data/spec/app/models/location.rb +0 -8
  103. data/spec/app/models/login.rb +0 -8
  104. data/spec/app/models/manufacturer.rb +0 -7
  105. data/spec/app/models/meat.rb +0 -4
  106. data/spec/app/models/membership.rb +0 -4
  107. data/spec/app/models/mixed_drink.rb +0 -4
  108. data/spec/app/models/movie.rb +0 -12
  109. data/spec/app/models/my_hash.rb +0 -2
  110. data/spec/app/models/name.rb +0 -21
  111. data/spec/app/models/node.rb +0 -5
  112. data/spec/app/models/note.rb +0 -12
  113. data/spec/app/models/ordered_post.rb +0 -6
  114. data/spec/app/models/ordered_preference.rb +0 -6
  115. data/spec/app/models/oscar.rb +0 -15
  116. data/spec/app/models/override.rb +0 -16
  117. data/spec/app/models/ownable.rb +0 -6
  118. data/spec/app/models/owner.rb +0 -6
  119. data/spec/app/models/page.rb +0 -5
  120. data/spec/app/models/page_question.rb +0 -4
  121. data/spec/app/models/palette.rb +0 -7
  122. data/spec/app/models/paranoid_phone.rb +0 -27
  123. data/spec/app/models/parent.rb +0 -5
  124. data/spec/app/models/parent_doc.rb +0 -6
  125. data/spec/app/models/passport.rb +0 -5
  126. data/spec/app/models/patient.rb +0 -9
  127. data/spec/app/models/pdf_writer.rb +0 -3
  128. data/spec/app/models/pencil.rb +0 -1
  129. data/spec/app/models/person.rb +0 -198
  130. data/spec/app/models/pet.rb +0 -23
  131. data/spec/app/models/pet_owner.rb +0 -6
  132. data/spec/app/models/phone.rb +0 -11
  133. data/spec/app/models/phone_observer.rb +0 -6
  134. data/spec/app/models/pizza.rb +0 -7
  135. data/spec/app/models/player.rb +0 -35
  136. data/spec/app/models/post.rb +0 -42
  137. data/spec/app/models/powerup.rb +0 -11
  138. data/spec/app/models/preference.rb +0 -9
  139. data/spec/app/models/princess.rb +0 -8
  140. data/spec/app/models/product.rb +0 -15
  141. data/spec/app/models/profile.rb +0 -5
  142. data/spec/app/models/pronunciation.rb +0 -5
  143. data/spec/app/models/purchase.rb +0 -4
  144. data/spec/app/models/question.rb +0 -8
  145. data/spec/app/models/quiz.rb +0 -7
  146. data/spec/app/models/rating.rb +0 -8
  147. data/spec/app/models/record.rb +0 -46
  148. data/spec/app/models/registry.rb +0 -4
  149. data/spec/app/models/role.rb +0 -5
  150. data/spec/app/models/root_category.rb +0 -4
  151. data/spec/app/models/sandwich.rb +0 -4
  152. data/spec/app/models/scheduler.rb +0 -7
  153. data/spec/app/models/seo.rb +0 -7
  154. data/spec/app/models/series.rb +0 -4
  155. data/spec/app/models/server.rb +0 -13
  156. data/spec/app/models/service.rb +0 -22
  157. data/spec/app/models/shape.rb +0 -12
  158. data/spec/app/models/shelf.rb +0 -5
  159. data/spec/app/models/shipping_container.rb +0 -5
  160. data/spec/app/models/shop.rb +0 -6
  161. data/spec/app/models/short_agent.rb +0 -4
  162. data/spec/app/models/short_quiz.rb +0 -5
  163. data/spec/app/models/slave.rb +0 -6
  164. data/spec/app/models/song.rb +0 -8
  165. data/spec/app/models/square.rb +0 -4
  166. data/spec/app/models/strategy.rb +0 -3
  167. data/spec/app/models/sub_item.rb +0 -3
  168. data/spec/app/models/survey.rb +0 -5
  169. data/spec/app/models/symptom.rb +0 -6
  170. data/spec/app/models/target.rb +0 -5
  171. data/spec/app/models/template.rb +0 -5
  172. data/spec/app/models/thing.rb +0 -9
  173. data/spec/app/models/tool.rb +0 -8
  174. data/spec/app/models/topping.rb +0 -5
  175. data/spec/app/models/track.rb +0 -38
  176. data/spec/app/models/translation.rb +0 -5
  177. data/spec/app/models/tree.rb +0 -9
  178. data/spec/app/models/truck.rb +0 -3
  179. data/spec/app/models/user.rb +0 -20
  180. data/spec/app/models/user_account.rb +0 -10
  181. data/spec/app/models/validation_callback.rb +0 -10
  182. data/spec/app/models/vehicle.rb +0 -11
  183. data/spec/app/models/version.rb +0 -5
  184. data/spec/app/models/vet_visit.rb +0 -5
  185. data/spec/app/models/video.rb +0 -13
  186. data/spec/app/models/weapon.rb +0 -11
  187. data/spec/app/models/word.rb +0 -12
  188. data/spec/app/models/word_origin.rb +0 -11
  189. data/spec/app/models/writer.rb +0 -11
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c10b11219197ec4a9edab2416c8b528926d80d11
4
- data.tar.gz: 8929e8ec1f9c17f0dc5dfcc63637ca57e9ca932f
3
+ metadata.gz: d194ed93d293b70ecc4c7fe0b2995877faf0835f
4
+ data.tar.gz: 14878b0db059da4ffc434aef035c67562d7d0595
5
5
  SHA512:
6
- metadata.gz: c488e4919506c1911a8a9c042f6adca6e0b2b7f76c67747051122af7ff76bd440b1f3cb5f7ef97aec500689386127abdf5f74ceccc64abf1da9476e05e5a3cdc
7
- data.tar.gz: 9eeb198e4a72ddc568d3aa99c81b24af2dde5ecef16ef5ced06c7dd17ac89e0c734ce48d966d0dc9298238a8ee6ce12b65ee2479a59b6a4019d3e6e20f72ed09
6
+ metadata.gz: 6230dbde5a463fafe0b96533dbb0c902ab80f00e2aebfddabfe48e172b3e52aeb9a193ef33aed01e7b093609c20d200f03de51b8f839cc82adae5afeed50e4a3
7
+ data.tar.gz: 76d4b005b89900ca07995148070f1a789a07fd5c9bd790531d7a0ca3b0b0fb712a9f90a0738b61369b97b9d9010d46b7550fb88466743cf9effd3259747df24a
data/.travis.yml CHANGED
@@ -5,14 +5,9 @@ rvm:
5
5
  - 1.9.3
6
6
  - 2.0.0
7
7
  - 2.1.0
8
+ - 2.2.0
8
9
 
9
10
  gemfile:
10
11
  - Gemfile
11
-
12
- branches:
13
- only:
14
- - master
15
-
16
- matrix:
17
- allow_failures:
18
- - rvm: ruby-head
12
+ - gemfiles/Mongoid_4.gemfile
13
+ - gemfiles/Mongoid_5.gemfile
data/README.md CHANGED
@@ -58,7 +58,7 @@ end
58
58
 
59
59
  (The MIT license)
60
60
 
61
- Copyright (c) 2013-2014 Mario Uher
61
+ Copyright (c) 2013-2015 Mario Uher
62
62
 
63
63
  Permission is hereby granted, free of charge, to any person obtaining
64
64
  a copy of this software and associated documentation files (the
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+ gemspec path: '../'
3
+
4
+ gem 'mongoid', '~> 4.0'
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+ gemspec path: '../'
3
+
4
+ gem 'mongoid', '~> 5.0'
@@ -2,9 +2,7 @@ module Mongoid
2
2
  module Fields
3
3
  module Validators
4
4
  module Macro
5
- options = OPTIONS
6
- send :remove_const, :OPTIONS
7
- send :const_set, :OPTIONS, options + [:versioned]
5
+ OPTIONS << :versioned
8
6
  end
9
7
  end
10
8
  end
@@ -1,9 +1,7 @@
1
1
  module Mongoid
2
2
  module Relations
3
3
  module Options
4
- common = COMMON
5
- send :remove_const, :COMMON
6
- send :const_set, :COMMON, common + [:versioned]
4
+ COMMON << :versioned
7
5
  end
8
6
  end
9
7
  end
@@ -32,6 +32,7 @@ module Mongoid
32
32
  # @example Revise the document.
33
33
  # person.revise
34
34
  #
35
+ # @todo Remove Mongoid 4 support.
35
36
  # @since 1.0.0
36
37
  def revise
37
38
  previous = previous_revision
@@ -44,8 +45,11 @@ module Mongoid
44
45
  deleted = versions.first
45
46
  if deleted.respond_to?(:paranoid?) && deleted.paranoid?
46
47
  versions.delete_one(deleted)
47
- collection.find(atomic_selector).
48
- update({ "$pull" => { "versions" => { "version" => deleted.version }}})
48
+
49
+ query = collection.find(atomic_selector)
50
+ query.respond_to?(:update_one) ?
51
+ query.update_one({ "$pull" => { "versions" => { "version" => deleted.version }}}) :
52
+ query.update({ "$pull" => { "versions" => { "version" => deleted.version }}})
49
53
  else
50
54
  versions.delete(deleted)
51
55
  end
@@ -127,11 +131,16 @@ module Mongoid
127
131
  #
128
132
  # @return [ Document, nil ] The previously saved document.
129
133
  #
134
+ # @todo Remove Mongoid 4 support.
130
135
  # @since 2.0.0
131
136
  def previous_revision
137
+ options = self.respond_to?(:mongo_client) ?
138
+ self.mongo_client.options.symbolize_keys :
139
+ self.mongo_session.options
140
+
132
141
  _loading_revision do
133
142
  self.class.unscoped.
134
- with(self.mongo_session.options).
143
+ with(options).
135
144
  where(_id: id).
136
145
  any_of({ version: version }, { version: nil }).first
137
146
  end
@@ -1,5 +1,5 @@
1
1
  module Mongoid
2
2
  module Versioning
3
- VERSION = '1.0.0'
3
+ VERSION = '1.1.0'
4
4
  end
5
5
  end
@@ -13,9 +13,9 @@ Gem::Specification.new do |gem|
13
13
  gem.files = `git ls-files`.split("\n")
14
14
  gem.require_path = 'lib'
15
15
 
16
- gem.add_dependency 'activesupport'
17
- gem.add_dependency 'mongoid', '~> 4.0.0'
18
- gem.add_development_dependency 'mongoid-paranoia', '1.0.0'
16
+ gem.add_dependency 'activesupport', '~> 4.0'
17
+ gem.add_dependency 'mongoid', '>= 4.0.0', '<= 6.0.0'
18
+ gem.add_development_dependency 'mongoid-paranoia', '~> 1.1', '>= 1.1.0'
19
19
  gem.add_development_dependency 'rake'
20
20
  gem.add_development_dependency 'rspec', '~> 3'
21
21
  end
@@ -4,13 +4,13 @@ class Comment
4
4
  field :title, type: String
5
5
  field :text, type: String
6
6
 
7
- belongs_to :account
8
- belongs_to :movie
9
- belongs_to :rating
7
+ # belongs_to :account
8
+ # belongs_to :movie
9
+ # belongs_to :rating
10
10
  belongs_to :wiki_page
11
11
 
12
12
  belongs_to :commentable, polymorphic: true
13
13
 
14
14
  validates :title, presence: true
15
- validates :movie, :rating, associated: true
15
+ # validates :movie, :rating, associated: true
16
16
  end
@@ -194,7 +194,7 @@ describe Mongoid::Versioning do
194
194
  let(:title) { "my new wiki" }
195
195
 
196
196
  let!(:page) do
197
- WikiPage.with(database: "mongoid_test_alt").create!(description: "1",title: title)
197
+ WikiPage.with(database: database_id_alt).create!(description: "1",title: title)
198
198
  end
199
199
 
200
200
  context "when the document is persisted once" do
@@ -210,14 +210,14 @@ describe Mongoid::Versioning do
210
210
  end
211
211
 
212
212
  it "persists to specified database" do
213
- expect(WikiPage.with(database: "mongoid_test_alt").find_by(title: title)).not_to be_nil
213
+ expect(WikiPage.with(database: database_id_alt).find_by(title: title)).not_to be_nil
214
214
  end
215
215
  end
216
216
 
217
217
  context "when the document is persisted more than once" do
218
218
 
219
219
  before do
220
- 3.times { |n| page.with(database: "mongoid_test_alt").update_attribute(:description, "#{n}") }
220
+ 3.times { |n| page.with(database: database_id_alt).update_attribute(:description, "#{n}") }
221
221
  end
222
222
 
223
223
  it "returns the number of versions" do
@@ -225,13 +225,17 @@ describe Mongoid::Versioning do
225
225
  end
226
226
 
227
227
  it "persists to specified database" do
228
- expect(WikiPage.with(database: "mongoid_test_alt").find_by(:title => title)).not_to be_nil
228
+ expect(WikiPage.with(database: database_id_alt).find_by(:title => title)).not_to be_nil
229
229
  end
230
230
 
231
231
  it "persists the versions to specified database" do
232
- expect(WikiPage.with(database: "mongoid_test_alt").find_by(:title => title).version).to eq(4)
232
+ expect(WikiPage.with(database: database_id_alt).find_by(:title => title).version).to eq(4)
233
233
  end
234
234
  end
235
+
236
+ after do
237
+ WikiPage.with(database: database_id_alt).delete_all
238
+ end
235
239
  end
236
240
  end
237
241
 
data/spec/spec_helper.rb CHANGED
@@ -18,8 +18,11 @@ ENV["MONGOID_SPEC_PORT"] ||= "27017"
18
18
  HOST = ENV["MONGOID_SPEC_HOST"]
19
19
  PORT = ENV["MONGOID_SPEC_PORT"].to_i
20
20
 
21
- # Moped.logger.level = Logger::DEBUG
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
26
 
24
27
  # When testing locally we use the database named mongoid_test. However when
25
28
  # tests are running in parallel on Travis we need to use different database
@@ -29,6 +32,10 @@ def database_id
29
32
  "mongoid_test"
30
33
  end
31
34
 
35
+ def database_id_alt
36
+ "mongoid_test_alt"
37
+ end
38
+
32
39
  # Can we connect to MongoHQ from this box?
33
40
  def mongohq_connectable?
34
41
  ENV["MONGOHQ_REPL_PASS"].present?
@@ -66,7 +73,12 @@ RSpec.configure do |config|
66
73
  # drop the database after the suite.
67
74
  config.after(:suite) do
68
75
  if ENV["CI"]
69
- Mongoid::Threaded.sessions[:default].drop
76
+ if defined?(Mongo)
77
+ Mongo::Client.new(["#{HOST}:#{PORT}"], database: database_id).database.drop
78
+ Mongo::Client.new(["#{HOST}:#{PORT}"], database: database_id_alt).database.drop
79
+ else
80
+ Mongoid::Threaded.sessions[:default].drop
81
+ end
70
82
  end
71
83
  end
72
84
 
metadata CHANGED
@@ -1,57 +1,69 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mongoid-versioning
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mario Uher
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-06-24 00:00:00.000000000 Z
11
+ date: 2015-10-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ">="
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '0'
19
+ version: '4.0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ">="
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '0'
26
+ version: '4.0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: mongoid
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - "~>"
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
33
  version: 4.0.0
34
+ - - "<="
35
+ - !ruby/object:Gem::Version
36
+ version: 6.0.0
34
37
  type: :runtime
35
38
  prerelease: false
36
39
  version_requirements: !ruby/object:Gem::Requirement
37
40
  requirements:
38
- - - "~>"
41
+ - - ">="
39
42
  - !ruby/object:Gem::Version
40
43
  version: 4.0.0
44
+ - - "<="
45
+ - !ruby/object:Gem::Version
46
+ version: 6.0.0
41
47
  - !ruby/object:Gem::Dependency
42
48
  name: mongoid-paranoia
43
49
  requirement: !ruby/object:Gem::Requirement
44
50
  requirements:
45
- - - '='
51
+ - - "~>"
46
52
  - !ruby/object:Gem::Version
47
- version: 1.0.0
53
+ version: '1.1'
54
+ - - ">="
55
+ - !ruby/object:Gem::Version
56
+ version: 1.1.0
48
57
  type: :development
49
58
  prerelease: false
50
59
  version_requirements: !ruby/object:Gem::Requirement
51
60
  requirements:
52
- - - '='
61
+ - - "~>"
62
+ - !ruby/object:Gem::Version
63
+ version: '1.1'
64
+ - - ">="
53
65
  - !ruby/object:Gem::Version
54
- version: 1.0.0
66
+ version: 1.1.0
55
67
  - !ruby/object:Gem::Dependency
56
68
  name: rake
57
69
  requirement: !ruby/object:Gem::Requirement
@@ -93,6 +105,8 @@ files:
93
105
  - Gemfile
94
106
  - README.md
95
107
  - Rakefile
108
+ - gemfiles/Mongoid_4.gemfile
109
+ - gemfiles/Mongoid_5.gemfile
96
110
  - lib/mongoid/config/locales/en.yml
97
111
  - lib/mongoid/core_ext/errors/versioning_not_on_root.rb
98
112
  - lib/mongoid/core_ext/fields/standard.rb
@@ -110,189 +124,14 @@ files:
110
124
  - lib/mongoid/versioning.rb
111
125
  - lib/mongoid/versioning/version.rb
112
126
  - mongoid-versioning.gemspec
113
- - spec/app/models/account.rb
114
- - spec/app/models/acolyte.rb
115
- - spec/app/models/actor.rb
116
- - spec/app/models/actor_observer.rb
117
- - spec/app/models/actress.rb
118
127
  - spec/app/models/address.rb
119
128
  - spec/app/models/address_component.rb
120
- - spec/app/models/address_number.rb
121
- - spec/app/models/agency.rb
122
- - spec/app/models/agent.rb
123
- - spec/app/models/album.rb
124
- - spec/app/models/alert.rb
125
- - spec/app/models/animal.rb
126
- - spec/app/models/answer.rb
127
- - spec/app/models/appointment.rb
128
- - spec/app/models/article.rb
129
- - spec/app/models/artist.rb
130
- - spec/app/models/artwork.rb
131
- - spec/app/models/augmentation.rb
132
129
  - spec/app/models/author.rb
133
- - spec/app/models/band.rb
134
- - spec/app/models/bar.rb
135
- - spec/app/models/basic.rb
136
- - spec/app/models/bed.rb
137
- - spec/app/models/big_palette.rb
138
- - spec/app/models/birthday.rb
139
- - spec/app/models/book.rb
140
- - spec/app/models/breed.rb
141
- - spec/app/models/browser.rb
142
- - spec/app/models/building.rb
143
- - spec/app/models/building_address.rb
144
- - spec/app/models/bus.rb
145
- - spec/app/models/business.rb
146
- - spec/app/models/callback_recorder.rb
147
- - spec/app/models/callback_test.rb
148
- - spec/app/models/canvas.rb
149
- - spec/app/models/car.rb
150
- - spec/app/models/cat.rb
151
- - spec/app/models/category.rb
152
- - spec/app/models/child.rb
153
- - spec/app/models/child_doc.rb
154
- - spec/app/models/church.rb
155
- - spec/app/models/circle.rb
156
- - spec/app/models/circuit.rb
157
- - spec/app/models/circus.rb
158
- - spec/app/models/code.rb
159
130
  - spec/app/models/comment.rb
160
- - spec/app/models/contractor.rb
161
- - spec/app/models/cookie.rb
162
- - spec/app/models/country_code.rb
163
- - spec/app/models/definition.rb
164
- - spec/app/models/description.rb
165
- - spec/app/models/dictionary.rb
166
- - spec/app/models/division.rb
167
- - spec/app/models/doctor.rb
168
- - spec/app/models/dog.rb
169
- - spec/app/models/dokument.rb
170
- - spec/app/models/driver.rb
171
- - spec/app/models/drug.rb
172
- - spec/app/models/email.rb
173
- - spec/app/models/employer.rb
174
- - spec/app/models/entry.rb
175
- - spec/app/models/eraser.rb
176
- - spec/app/models/event.rb
177
- - spec/app/models/exhibition.rb
178
- - spec/app/models/exhibitor.rb
179
- - spec/app/models/eye.rb
180
- - spec/app/models/eye_bowl.rb
181
- - spec/app/models/face.rb
182
- - spec/app/models/favorite.rb
183
- - spec/app/models/filesystem.rb
184
- - spec/app/models/firefox.rb
185
- - spec/app/models/fish.rb
186
- - spec/app/models/folder.rb
187
- - spec/app/models/folder_item.rb
188
- - spec/app/models/fruits.rb
189
- - spec/app/models/game.rb
190
- - spec/app/models/ghost.rb
191
- - spec/app/models/home.rb
192
- - spec/app/models/house.rb
193
- - spec/app/models/html_writer.rb
194
- - spec/app/models/image.rb
195
- - spec/app/models/implant.rb
196
- - spec/app/models/item.rb
197
- - spec/app/models/jar.rb
198
- - spec/app/models/label.rb
199
- - spec/app/models/language.rb
200
- - spec/app/models/lat_lng.rb
201
- - spec/app/models/league.rb
202
- - spec/app/models/learner.rb
203
- - spec/app/models/line_item.rb
204
- - spec/app/models/location.rb
205
- - spec/app/models/login.rb
206
- - spec/app/models/manufacturer.rb
207
- - spec/app/models/meat.rb
208
- - spec/app/models/membership.rb
209
- - spec/app/models/mixed_drink.rb
210
- - spec/app/models/movie.rb
211
- - spec/app/models/my_hash.rb
212
- - spec/app/models/name.rb
213
- - spec/app/models/node.rb
214
- - spec/app/models/note.rb
215
- - spec/app/models/ordered_post.rb
216
- - spec/app/models/ordered_preference.rb
217
- - spec/app/models/oscar.rb
218
- - spec/app/models/override.rb
219
- - spec/app/models/ownable.rb
220
- - spec/app/models/owner.rb
221
- - spec/app/models/page.rb
222
- - spec/app/models/page_question.rb
223
- - spec/app/models/palette.rb
224
- - spec/app/models/paranoid_phone.rb
225
131
  - spec/app/models/paranoid_post.rb
226
- - spec/app/models/parent.rb
227
- - spec/app/models/parent_doc.rb
228
- - spec/app/models/passport.rb
229
- - spec/app/models/patient.rb
230
- - spec/app/models/pdf_writer.rb
231
- - spec/app/models/pencil.rb
232
- - spec/app/models/person.rb
233
- - spec/app/models/pet.rb
234
- - spec/app/models/pet_owner.rb
235
- - spec/app/models/phone.rb
236
- - spec/app/models/phone_observer.rb
237
- - spec/app/models/pizza.rb
238
- - spec/app/models/player.rb
239
- - spec/app/models/post.rb
240
- - spec/app/models/powerup.rb
241
- - spec/app/models/preference.rb
242
- - spec/app/models/princess.rb
243
- - spec/app/models/product.rb
244
- - spec/app/models/profile.rb
245
- - spec/app/models/pronunciation.rb
246
- - spec/app/models/purchase.rb
247
- - spec/app/models/question.rb
248
- - spec/app/models/quiz.rb
249
- - spec/app/models/rating.rb
250
- - spec/app/models/record.rb
251
- - spec/app/models/registry.rb
252
- - spec/app/models/role.rb
253
- - spec/app/models/root_category.rb
254
- - spec/app/models/sandwich.rb
255
- - spec/app/models/scheduler.rb
256
- - spec/app/models/seo.rb
257
- - spec/app/models/series.rb
258
- - spec/app/models/server.rb
259
- - spec/app/models/service.rb
260
- - spec/app/models/shape.rb
261
- - spec/app/models/shelf.rb
262
- - spec/app/models/shipping_container.rb
263
- - spec/app/models/shop.rb
264
- - spec/app/models/short_agent.rb
265
- - spec/app/models/short_quiz.rb
266
- - spec/app/models/slave.rb
267
- - spec/app/models/song.rb
268
- - spec/app/models/square.rb
269
- - spec/app/models/strategy.rb
270
- - spec/app/models/sub_item.rb
271
- - spec/app/models/survey.rb
272
- - spec/app/models/symptom.rb
273
132
  - spec/app/models/tag.rb
274
- - spec/app/models/target.rb
275
- - spec/app/models/template.rb
276
- - spec/app/models/thing.rb
277
133
  - spec/app/models/title.rb
278
- - spec/app/models/tool.rb
279
- - spec/app/models/topping.rb
280
- - spec/app/models/track.rb
281
- - spec/app/models/translation.rb
282
- - spec/app/models/tree.rb
283
- - spec/app/models/truck.rb
284
- - spec/app/models/user.rb
285
- - spec/app/models/user_account.rb
286
- - spec/app/models/validation_callback.rb
287
- - spec/app/models/vehicle.rb
288
- - spec/app/models/version.rb
289
- - spec/app/models/vet_visit.rb
290
- - spec/app/models/video.rb
291
- - spec/app/models/weapon.rb
292
134
  - spec/app/models/wiki_page.rb
293
- - spec/app/models/word.rb
294
- - spec/app/models/word_origin.rb
295
- - spec/app/models/writer.rb
296
135
  - spec/config/mongoid.yml
297
136
  - spec/mongoid/errors/versioning_not_on_root_spec.rb
298
137
  - spec/mongoid/relations/macros_spec.rb
@@ -1,28 +0,0 @@
1
- class Account
2
- include Mongoid::Document
3
-
4
- field :_id, type: String, default: ->{ name.try(:parameterize) }
5
-
6
- field :number, type: String
7
- field :balance, type: String
8
- field :nickname, type: String
9
- field :name, type: String
10
- field :balanced, type: Boolean, default: ->{ balance? ? true : false }
11
-
12
- field :overridden, type: String
13
-
14
- embeds_many :memberships
15
- belongs_to :creator, class_name: "User", foreign_key: :creator_id
16
- belongs_to :person
17
- has_many :alerts
18
- has_and_belongs_to_many :agents
19
- has_one :comment, validate: false
20
-
21
- validates_presence_of :name
22
- validates_presence_of :nickname, on: :upsert
23
- validates_length_of :name, maximum: 10, on: :create
24
-
25
- def overridden
26
- self[:overridden] = "not recommended"
27
- end
28
- end
@@ -1,16 +0,0 @@
1
- class Acolyte
2
- include Mongoid::Document
3
- field :status
4
- field :name
5
-
6
- embeds_many :versions, as: :memorable
7
- belongs_to :church
8
-
9
- default_scope ->{ asc(:name) }
10
- scope :active, ->{ where(status: "active") }
11
- scope :named, ->{ where(:name.exists => true) }
12
-
13
- def callback_test?
14
- name == "callback-test"
15
- end
16
- end
@@ -1,19 +0,0 @@
1
- class Actor
2
- include Mongoid::Document
3
- field :name
4
- field :after_custom_count, type: Integer, default: 0
5
- has_and_belongs_to_many :tags
6
- embeds_many :things, validate: false, cascade_callbacks: true
7
- accepts_nested_attributes_for :things, allow_destroy: true
8
-
9
- define_model_callbacks :custom
10
- observable :custom
11
-
12
- def do_something
13
- run_callbacks(:custom) do
14
- self.name = "custom"
15
- end
16
- end
17
- end
18
-
19
- require "app/models/actress"
@@ -1,15 +0,0 @@
1
- class ActorObserver < Mongoid::Observer
2
- attr_reader :last_after_create_record
3
-
4
- def after_create(record)
5
- @last_after_create_record = record
6
- end
7
-
8
- def after_custom(record)
9
- record.after_custom_count += 1
10
- end
11
-
12
- def before_custom(record)
13
- @after_custom_called = true
14
- end
15
- end
@@ -1,2 +0,0 @@
1
- class Actress < Actor
2
- end
@@ -1,6 +0,0 @@
1
- class AddressNumber
2
- include Mongoid::Document
3
- field :country_code, type: Integer, default: 1
4
- field :number
5
- embedded_in :slave
6
- end
@@ -1,5 +0,0 @@
1
- class Agency
2
- include Mongoid::Document
3
- include Mongoid::Timestamps::Updated
4
- has_many :agents, validate: false
5
- end
@@ -1,12 +0,0 @@
1
- class Agent
2
- include Mongoid::Document
3
- include Mongoid::Timestamps::Updated
4
- field :title, type: String
5
- field :number, type: String
6
- field :dob, type: Time
7
- embeds_many :names, as: :namable
8
- belongs_to :game
9
- belongs_to :agency, touch: true, autobuild: true
10
-
11
- has_and_belongs_to_many :accounts
12
- end
@@ -1,14 +0,0 @@
1
- class Album
2
- include Mongoid::Document
3
-
4
- belongs_to :artist
5
- before_destroy :set_parent_name
6
-
7
- attr_accessor :before_add_called
8
-
9
- private
10
-
11
- def set_parent_name
12
- artist.name = "destroyed"
13
- end
14
- end
@@ -1,5 +0,0 @@
1
- class Alert
2
- include Mongoid::Document
3
- field :message, type: String
4
- belongs_to :account
5
- end