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.
- checksums.yaml +4 -4
- data/.travis.yml +3 -8
- data/README.md +1 -1
- data/gemfiles/Mongoid_4.gemfile +4 -0
- data/gemfiles/Mongoid_5.gemfile +4 -0
- data/lib/mongoid/core_ext/fields/validators/macro.rb +1 -3
- data/lib/mongoid/core_ext/relations/options.rb +1 -3
- data/lib/mongoid/core_ext/versioning.rb +12 -3
- data/lib/mongoid/versioning/version.rb +1 -1
- data/mongoid-versioning.gemspec +3 -3
- data/spec/app/models/comment.rb +4 -4
- data/spec/mongoid/versioning_spec.rb +9 -5
- data/spec/spec_helper.rb +14 -2
- metadata +26 -187
- data/spec/app/models/account.rb +0 -28
- data/spec/app/models/acolyte.rb +0 -16
- data/spec/app/models/actor.rb +0 -19
- data/spec/app/models/actor_observer.rb +0 -15
- data/spec/app/models/actress.rb +0 -2
- data/spec/app/models/address_number.rb +0 -6
- data/spec/app/models/agency.rb +0 -5
- data/spec/app/models/agent.rb +0 -12
- data/spec/app/models/album.rb +0 -14
- data/spec/app/models/alert.rb +0 -5
- data/spec/app/models/animal.rb +0 -25
- data/spec/app/models/answer.rb +0 -4
- data/spec/app/models/appointment.rb +0 -7
- data/spec/app/models/article.rb +0 -10
- data/spec/app/models/artist.rb +0 -66
- data/spec/app/models/artwork.rb +0 -4
- data/spec/app/models/augmentation.rb +0 -11
- data/spec/app/models/band.rb +0 -25
- data/spec/app/models/bar.rb +0 -9
- data/spec/app/models/basic.rb +0 -6
- data/spec/app/models/bed.rb +0 -1
- data/spec/app/models/big_palette.rb +0 -2
- data/spec/app/models/birthday.rb +0 -13
- data/spec/app/models/book.rb +0 -12
- data/spec/app/models/breed.rb +0 -4
- data/spec/app/models/browser.rb +0 -6
- data/spec/app/models/building.rb +0 -5
- data/spec/app/models/building_address.rb +0 -5
- data/spec/app/models/bus.rb +0 -7
- data/spec/app/models/business.rb +0 -5
- data/spec/app/models/callback_recorder.rb +0 -25
- data/spec/app/models/callback_test.rb +0 -9
- data/spec/app/models/canvas.rb +0 -25
- data/spec/app/models/car.rb +0 -1
- data/spec/app/models/cat.rb +0 -8
- data/spec/app/models/category.rb +0 -8
- data/spec/app/models/child.rb +0 -4
- data/spec/app/models/child_doc.rb +0 -22
- data/spec/app/models/church.rb +0 -4
- data/spec/app/models/circle.rb +0 -3
- data/spec/app/models/circuit.rb +0 -4
- data/spec/app/models/circus.rb +0 -7
- data/spec/app/models/code.rb +0 -5
- data/spec/app/models/contractor.rb +0 -5
- data/spec/app/models/cookie.rb +0 -6
- data/spec/app/models/country_code.rb +0 -8
- data/spec/app/models/definition.rb +0 -7
- data/spec/app/models/description.rb +0 -11
- data/spec/app/models/dictionary.rb +0 -10
- data/spec/app/models/division.rb +0 -10
- data/spec/app/models/doctor.rb +0 -12
- data/spec/app/models/dog.rb +0 -6
- data/spec/app/models/dokument.rb +0 -5
- data/spec/app/models/driver.rb +0 -7
- data/spec/app/models/drug.rb +0 -6
- data/spec/app/models/email.rb +0 -6
- data/spec/app/models/employer.rb +0 -5
- data/spec/app/models/entry.rb +0 -6
- data/spec/app/models/eraser.rb +0 -1
- data/spec/app/models/event.rb +0 -22
- data/spec/app/models/exhibition.rb +0 -4
- data/spec/app/models/exhibitor.rb +0 -5
- data/spec/app/models/eye.rb +0 -9
- data/spec/app/models/eye_bowl.rb +0 -9
- data/spec/app/models/face.rb +0 -8
- data/spec/app/models/favorite.rb +0 -6
- data/spec/app/models/filesystem.rb +0 -4
- data/spec/app/models/firefox.rb +0 -4
- data/spec/app/models/fish.rb +0 -8
- data/spec/app/models/folder.rb +0 -7
- data/spec/app/models/folder_item.rb +0 -9
- data/spec/app/models/fruits.rb +0 -28
- data/spec/app/models/game.rb +0 -19
- data/spec/app/models/ghost.rb +0 -7
- data/spec/app/models/home.rb +0 -4
- data/spec/app/models/house.rb +0 -7
- data/spec/app/models/html_writer.rb +0 -3
- data/spec/app/models/image.rb +0 -22
- data/spec/app/models/implant.rb +0 -16
- data/spec/app/models/item.rb +0 -8
- data/spec/app/models/jar.rb +0 -7
- data/spec/app/models/label.rb +0 -40
- data/spec/app/models/language.rb +0 -5
- data/spec/app/models/lat_lng.rb +0 -15
- data/spec/app/models/league.rb +0 -11
- data/spec/app/models/learner.rb +0 -2
- data/spec/app/models/line_item.rb +0 -6
- data/spec/app/models/location.rb +0 -8
- data/spec/app/models/login.rb +0 -8
- data/spec/app/models/manufacturer.rb +0 -7
- data/spec/app/models/meat.rb +0 -4
- data/spec/app/models/membership.rb +0 -4
- data/spec/app/models/mixed_drink.rb +0 -4
- data/spec/app/models/movie.rb +0 -12
- data/spec/app/models/my_hash.rb +0 -2
- data/spec/app/models/name.rb +0 -21
- data/spec/app/models/node.rb +0 -5
- data/spec/app/models/note.rb +0 -12
- data/spec/app/models/ordered_post.rb +0 -6
- data/spec/app/models/ordered_preference.rb +0 -6
- data/spec/app/models/oscar.rb +0 -15
- data/spec/app/models/override.rb +0 -16
- data/spec/app/models/ownable.rb +0 -6
- data/spec/app/models/owner.rb +0 -6
- data/spec/app/models/page.rb +0 -5
- data/spec/app/models/page_question.rb +0 -4
- data/spec/app/models/palette.rb +0 -7
- data/spec/app/models/paranoid_phone.rb +0 -27
- data/spec/app/models/parent.rb +0 -5
- data/spec/app/models/parent_doc.rb +0 -6
- data/spec/app/models/passport.rb +0 -5
- data/spec/app/models/patient.rb +0 -9
- data/spec/app/models/pdf_writer.rb +0 -3
- data/spec/app/models/pencil.rb +0 -1
- data/spec/app/models/person.rb +0 -198
- data/spec/app/models/pet.rb +0 -23
- data/spec/app/models/pet_owner.rb +0 -6
- data/spec/app/models/phone.rb +0 -11
- data/spec/app/models/phone_observer.rb +0 -6
- data/spec/app/models/pizza.rb +0 -7
- data/spec/app/models/player.rb +0 -35
- data/spec/app/models/post.rb +0 -42
- data/spec/app/models/powerup.rb +0 -11
- data/spec/app/models/preference.rb +0 -9
- data/spec/app/models/princess.rb +0 -8
- data/spec/app/models/product.rb +0 -15
- data/spec/app/models/profile.rb +0 -5
- data/spec/app/models/pronunciation.rb +0 -5
- data/spec/app/models/purchase.rb +0 -4
- data/spec/app/models/question.rb +0 -8
- data/spec/app/models/quiz.rb +0 -7
- data/spec/app/models/rating.rb +0 -8
- data/spec/app/models/record.rb +0 -46
- data/spec/app/models/registry.rb +0 -4
- data/spec/app/models/role.rb +0 -5
- data/spec/app/models/root_category.rb +0 -4
- data/spec/app/models/sandwich.rb +0 -4
- data/spec/app/models/scheduler.rb +0 -7
- data/spec/app/models/seo.rb +0 -7
- data/spec/app/models/series.rb +0 -4
- data/spec/app/models/server.rb +0 -13
- data/spec/app/models/service.rb +0 -22
- data/spec/app/models/shape.rb +0 -12
- data/spec/app/models/shelf.rb +0 -5
- data/spec/app/models/shipping_container.rb +0 -5
- data/spec/app/models/shop.rb +0 -6
- data/spec/app/models/short_agent.rb +0 -4
- data/spec/app/models/short_quiz.rb +0 -5
- data/spec/app/models/slave.rb +0 -6
- data/spec/app/models/song.rb +0 -8
- data/spec/app/models/square.rb +0 -4
- data/spec/app/models/strategy.rb +0 -3
- data/spec/app/models/sub_item.rb +0 -3
- data/spec/app/models/survey.rb +0 -5
- data/spec/app/models/symptom.rb +0 -6
- data/spec/app/models/target.rb +0 -5
- data/spec/app/models/template.rb +0 -5
- data/spec/app/models/thing.rb +0 -9
- data/spec/app/models/tool.rb +0 -8
- data/spec/app/models/topping.rb +0 -5
- data/spec/app/models/track.rb +0 -38
- data/spec/app/models/translation.rb +0 -5
- data/spec/app/models/tree.rb +0 -9
- data/spec/app/models/truck.rb +0 -3
- data/spec/app/models/user.rb +0 -20
- data/spec/app/models/user_account.rb +0 -10
- data/spec/app/models/validation_callback.rb +0 -10
- data/spec/app/models/vehicle.rb +0 -11
- data/spec/app/models/version.rb +0 -5
- data/spec/app/models/vet_visit.rb +0 -5
- data/spec/app/models/video.rb +0 -13
- data/spec/app/models/weapon.rb +0 -11
- data/spec/app/models/word.rb +0 -12
- data/spec/app/models/word_origin.rb +0 -11
- data/spec/app/models/writer.rb +0 -11
data/spec/app/models/fruits.rb
DELETED
@@ -1,28 +0,0 @@
|
|
1
|
-
module Fruits
|
2
|
-
class Apple
|
3
|
-
include Mongoid::Document
|
4
|
-
has_many :bananas, class_name: "Fruits::Banana"
|
5
|
-
recursively_embeds_many
|
6
|
-
end
|
7
|
-
|
8
|
-
class Banana
|
9
|
-
include Mongoid::Document
|
10
|
-
belongs_to :apple, class_name: "Fruits::Apple"
|
11
|
-
end
|
12
|
-
|
13
|
-
class Pineapple
|
14
|
-
include Mongoid::Document
|
15
|
-
recursively_embeds_many cascade_callbacks: true
|
16
|
-
end
|
17
|
-
|
18
|
-
class Mango
|
19
|
-
include Mongoid::Document
|
20
|
-
recursively_embeds_one cascade_callbacks: true
|
21
|
-
end
|
22
|
-
|
23
|
-
module Big
|
24
|
-
class Ananas
|
25
|
-
include Mongoid::Document
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
data/spec/app/models/game.rb
DELETED
@@ -1,19 +0,0 @@
|
|
1
|
-
class Game
|
2
|
-
include Mongoid::Document
|
3
|
-
|
4
|
-
field :high_score, type: Integer, default: 500
|
5
|
-
field :score, type: Integer, default: 0
|
6
|
-
field :name
|
7
|
-
|
8
|
-
belongs_to :person, index: true, validate: true
|
9
|
-
belongs_to :parent, class_name: "Game", foreign_key: "parent-id"
|
10
|
-
has_one :video, validate: false
|
11
|
-
has_many :ratings, as: :ratable, dependent: :nullify
|
12
|
-
accepts_nested_attributes_for :person
|
13
|
-
|
14
|
-
validates_format_of :name, without: /\$\$\$/
|
15
|
-
|
16
|
-
set_callback(:initialize, :after) do |document|
|
17
|
-
write_attribute("name", "Testing") unless name
|
18
|
-
end
|
19
|
-
end
|
data/spec/app/models/ghost.rb
DELETED
data/spec/app/models/home.rb
DELETED
data/spec/app/models/house.rb
DELETED
data/spec/app/models/image.rb
DELETED
@@ -1,22 +0,0 @@
|
|
1
|
-
class Image
|
2
|
-
attr_reader :name
|
3
|
-
|
4
|
-
def initialize(name)
|
5
|
-
@name = name
|
6
|
-
end
|
7
|
-
|
8
|
-
def self.demongoize(value)
|
9
|
-
Image.new(value)
|
10
|
-
end
|
11
|
-
|
12
|
-
def mongoize
|
13
|
-
name
|
14
|
-
end
|
15
|
-
|
16
|
-
def hash_is_hash
|
17
|
-
{}.is_a?(Hash)
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
class Thumbnail < Image
|
22
|
-
end
|
data/spec/app/models/implant.rb
DELETED
@@ -1,16 +0,0 @@
|
|
1
|
-
class Implant
|
2
|
-
include Mongoid::Document
|
3
|
-
|
4
|
-
field :name
|
5
|
-
field :impressions, type: Integer, default: 0
|
6
|
-
|
7
|
-
embedded_in :player, inverse_of: :implants
|
8
|
-
|
9
|
-
after_build do |doc|
|
10
|
-
doc.name = "Cochlear Implant (#{player.frags})"
|
11
|
-
end
|
12
|
-
|
13
|
-
after_find do |doc|
|
14
|
-
doc.impressions += 1
|
15
|
-
end
|
16
|
-
end
|
data/spec/app/models/item.rb
DELETED
data/spec/app/models/jar.rb
DELETED
data/spec/app/models/label.rb
DELETED
@@ -1,40 +0,0 @@
|
|
1
|
-
class Label
|
2
|
-
include Mongoid::Document
|
3
|
-
include Mongoid::Timestamps::Updated::Short
|
4
|
-
|
5
|
-
field :name, type: String
|
6
|
-
field :after_create_called, type: Boolean, default: false
|
7
|
-
field :after_save_called, type: Boolean, default: false
|
8
|
-
field :after_update_called, type: Boolean, default: false
|
9
|
-
field :after_validation_called, type: Boolean, default: false
|
10
|
-
|
11
|
-
embedded_in :artist
|
12
|
-
embedded_in :band
|
13
|
-
|
14
|
-
after_create :after_create_stub
|
15
|
-
after_save :after_save_stub
|
16
|
-
after_update :after_update_stub
|
17
|
-
after_validation :after_validation_stub
|
18
|
-
before_validation :cleanup
|
19
|
-
|
20
|
-
def after_create_stub
|
21
|
-
self.after_create_called = true
|
22
|
-
end
|
23
|
-
|
24
|
-
def after_save_stub
|
25
|
-
self.after_save_called = true
|
26
|
-
end
|
27
|
-
|
28
|
-
def after_update_stub
|
29
|
-
self.after_update_called = true
|
30
|
-
end
|
31
|
-
|
32
|
-
def after_validation_stub
|
33
|
-
self.after_validation_called = true
|
34
|
-
end
|
35
|
-
|
36
|
-
private
|
37
|
-
def cleanup
|
38
|
-
self.name = self.name.downcase.capitalize
|
39
|
-
end
|
40
|
-
end
|
data/spec/app/models/language.rb
DELETED
data/spec/app/models/lat_lng.rb
DELETED
data/spec/app/models/league.rb
DELETED
data/spec/app/models/learner.rb
DELETED
data/spec/app/models/location.rb
DELETED
data/spec/app/models/login.rb
DELETED
data/spec/app/models/meat.rb
DELETED
data/spec/app/models/movie.rb
DELETED
data/spec/app/models/my_hash.rb
DELETED
data/spec/app/models/name.rb
DELETED
@@ -1,21 +0,0 @@
|
|
1
|
-
class Name
|
2
|
-
include Mongoid::Document
|
3
|
-
|
4
|
-
field :_id, type: String, default: ->{
|
5
|
-
"#{first_name}-#{last_name}"
|
6
|
-
}
|
7
|
-
|
8
|
-
field :first_name, type: String
|
9
|
-
field :last_name, type: String
|
10
|
-
field :parent_title, type: String
|
11
|
-
|
12
|
-
embeds_many :translations, validate: false
|
13
|
-
embeds_one :language, as: :translatable, validate: false
|
14
|
-
embedded_in :namable, polymorphic: true
|
15
|
-
|
16
|
-
accepts_nested_attributes_for :language
|
17
|
-
|
18
|
-
def set_parent=(set = false)
|
19
|
-
self.parent_title = namable.title if set
|
20
|
-
end
|
21
|
-
end
|
data/spec/app/models/node.rb
DELETED
data/spec/app/models/note.rb
DELETED
data/spec/app/models/oscar.rb
DELETED
data/spec/app/models/override.rb
DELETED
data/spec/app/models/ownable.rb
DELETED
data/spec/app/models/owner.rb
DELETED
data/spec/app/models/page.rb
DELETED
data/spec/app/models/palette.rb
DELETED
@@ -1,27 +0,0 @@
|
|
1
|
-
require 'mongoid/paranoia'
|
2
|
-
|
3
|
-
class ParanoidPhone
|
4
|
-
include Mongoid::Document
|
5
|
-
include Mongoid::Paranoia
|
6
|
-
|
7
|
-
attr_accessor :after_destroy_called, :before_destroy_called
|
8
|
-
|
9
|
-
field :number, type: String
|
10
|
-
|
11
|
-
embedded_in :person
|
12
|
-
|
13
|
-
before_destroy :before_destroy_stub, :halt_me
|
14
|
-
after_destroy :after_destroy_stub
|
15
|
-
|
16
|
-
def before_destroy_stub
|
17
|
-
self.before_destroy_called = true
|
18
|
-
end
|
19
|
-
|
20
|
-
def after_destroy_stub
|
21
|
-
self.after_destroy_called = true
|
22
|
-
end
|
23
|
-
|
24
|
-
def halt_me
|
25
|
-
person.age == 42 ? false : true
|
26
|
-
end
|
27
|
-
end
|
data/spec/app/models/parent.rb
DELETED
data/spec/app/models/passport.rb
DELETED
data/spec/app/models/patient.rb
DELETED
data/spec/app/models/pencil.rb
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
class Pencil < Tool; end
|