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/animal.rb
DELETED
@@ -1,25 +0,0 @@
|
|
1
|
-
class Animal
|
2
|
-
include Mongoid::Document
|
3
|
-
|
4
|
-
field :_id, type: String, default: ->{ name.try(:parameterize) }
|
5
|
-
|
6
|
-
field :name
|
7
|
-
field :height, type: Integer
|
8
|
-
field :weight, type: Integer
|
9
|
-
field :tags, type: Array
|
10
|
-
|
11
|
-
embedded_in :person
|
12
|
-
embedded_in :circus
|
13
|
-
|
14
|
-
validates_format_of :name, without: /\$\$\$/
|
15
|
-
|
16
|
-
accepts_nested_attributes_for :person
|
17
|
-
|
18
|
-
def tag_list
|
19
|
-
tags.join(", ")
|
20
|
-
end
|
21
|
-
|
22
|
-
def tag_list=(_tag_list)
|
23
|
-
self.tags = _tag_list.split(",").map(&:strip)
|
24
|
-
end
|
25
|
-
end
|
data/spec/app/models/answer.rb
DELETED
data/spec/app/models/article.rb
DELETED
@@ -1,10 +0,0 @@
|
|
1
|
-
class Article
|
2
|
-
include Mongoid::Document
|
3
|
-
|
4
|
-
field :title, type: String
|
5
|
-
field :is_rss, type: Boolean, default: false
|
6
|
-
field :user_login, type: String
|
7
|
-
|
8
|
-
has_and_belongs_to_many :tags, validate: false
|
9
|
-
has_and_belongs_to_many :preferences, inverse_of: nil, validate: false
|
10
|
-
end
|
data/spec/app/models/artist.rb
DELETED
@@ -1,66 +0,0 @@
|
|
1
|
-
class Artist
|
2
|
-
include Mongoid::Document
|
3
|
-
|
4
|
-
attr_accessor :before_add_called, :after_add_called, :before_add_referenced_called, :after_add_referenced_called, :before_remove_embedded_called, :after_remove_embedded_called, :before_remove_referenced_called, :after_remove_referenced_called
|
5
|
-
|
6
|
-
field :name, type: String
|
7
|
-
|
8
|
-
embeds_many :songs, before_add: [ :before_add_song, Proc.new { |artist, song| song.before_add_called = true } ], before_remove: :before_remove_song
|
9
|
-
embeds_many :labels, after_add: :after_add_label, after_remove: :after_remove_label
|
10
|
-
has_many :albums, dependent: :destroy, before_add: [:before_add_album, Proc.new { |artist, album| album.before_add_called = true} ], after_add: :after_add_album, before_remove: :before_remove_album, after_remove: :after_remove_album
|
11
|
-
|
12
|
-
before_create :before_create_stub
|
13
|
-
after_create :create_songs
|
14
|
-
before_save :before_save_stub
|
15
|
-
before_destroy :before_destroy_stub
|
16
|
-
|
17
|
-
protected
|
18
|
-
def before_create_stub
|
19
|
-
true
|
20
|
-
end
|
21
|
-
|
22
|
-
def before_save_stub
|
23
|
-
true
|
24
|
-
end
|
25
|
-
|
26
|
-
def before_destroy_stub
|
27
|
-
true
|
28
|
-
end
|
29
|
-
|
30
|
-
def create_songs
|
31
|
-
2.times { |n| songs.create!(title: "#{n}") }
|
32
|
-
end
|
33
|
-
|
34
|
-
def before_add_song(song)
|
35
|
-
@before_add_called = true
|
36
|
-
end
|
37
|
-
|
38
|
-
def after_add_label(label)
|
39
|
-
@after_add_called = true
|
40
|
-
end
|
41
|
-
|
42
|
-
def before_add_album(album)
|
43
|
-
@before_add_referenced_called = true
|
44
|
-
end
|
45
|
-
|
46
|
-
def after_add_album(album)
|
47
|
-
@after_add_referenced_called = true
|
48
|
-
end
|
49
|
-
|
50
|
-
def before_remove_song(song)
|
51
|
-
@before_remove_embedded_called = true
|
52
|
-
end
|
53
|
-
|
54
|
-
def after_remove_label(label)
|
55
|
-
@after_remove_embedded_called = true
|
56
|
-
end
|
57
|
-
|
58
|
-
def before_remove_album(album)
|
59
|
-
@before_remove_referenced_called = true
|
60
|
-
end
|
61
|
-
|
62
|
-
def after_remove_album(album)
|
63
|
-
@after_remove_referenced_called = true
|
64
|
-
end
|
65
|
-
|
66
|
-
end
|
data/spec/app/models/artwork.rb
DELETED
data/spec/app/models/band.rb
DELETED
@@ -1,25 +0,0 @@
|
|
1
|
-
class Band
|
2
|
-
include Mongoid::Document
|
3
|
-
field :name, type: String
|
4
|
-
field :active, type: Boolean, default: true
|
5
|
-
field :origin, type: String
|
6
|
-
field :genres, type: Array
|
7
|
-
field :member_count, type: Integer
|
8
|
-
field :mems, as: :members, type: Array
|
9
|
-
field :likes, type: Integer
|
10
|
-
field :views, type: Integer
|
11
|
-
field :rating, type: Float
|
12
|
-
field :upserted, type: Boolean, default: false
|
13
|
-
field :created, type: DateTime
|
14
|
-
field :sales, type: BigDecimal
|
15
|
-
field :y, as: :years, type: Integer
|
16
|
-
field :founded, type: Date
|
17
|
-
|
18
|
-
embeds_many :records, cascade_callbacks: true
|
19
|
-
embeds_many :notes, as: :noteable, cascade_callbacks: true, validate: false
|
20
|
-
embeds_one :label, cascade_callbacks: true
|
21
|
-
|
22
|
-
after_upsert do |doc|
|
23
|
-
doc.upserted = true
|
24
|
-
end
|
25
|
-
end
|
data/spec/app/models/bar.rb
DELETED
data/spec/app/models/basic.rb
DELETED
data/spec/app/models/bed.rb
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
class Bed; end
|
data/spec/app/models/birthday.rb
DELETED
@@ -1,13 +0,0 @@
|
|
1
|
-
class Birthday
|
2
|
-
include Mongoid::Document
|
3
|
-
field :title
|
4
|
-
field :date, type: Date
|
5
|
-
embedded_in :owner, inverse_of: :birthdays
|
6
|
-
|
7
|
-
def self.each_day(start_date, end_date)
|
8
|
-
groups = only(:date).asc(:date).where(:date.gte => start_date, :date.lte => end_date).group
|
9
|
-
groups.each do |date, group|
|
10
|
-
yield(date, group)
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|
data/spec/app/models/book.rb
DELETED
@@ -1,12 +0,0 @@
|
|
1
|
-
class Book
|
2
|
-
include Mongoid::Document
|
3
|
-
field :title, type: String
|
4
|
-
field :chapters, type: Integer
|
5
|
-
belongs_to :series
|
6
|
-
belongs_to :person, autobuild: true
|
7
|
-
has_one :rating, as: :ratable, dependent: :nullify
|
8
|
-
|
9
|
-
after_initialize do |doc|
|
10
|
-
doc.chapters = 5
|
11
|
-
end
|
12
|
-
end
|
data/spec/app/models/breed.rb
DELETED
data/spec/app/models/browser.rb
DELETED
data/spec/app/models/building.rb
DELETED
data/spec/app/models/bus.rb
DELETED
data/spec/app/models/business.rb
DELETED
@@ -1,25 +0,0 @@
|
|
1
|
-
class CallbackRecorder < Mongoid::Observer
|
2
|
-
observe :actor
|
3
|
-
|
4
|
-
attr_reader :last_callback, :call_count, :last_record
|
5
|
-
|
6
|
-
def initialize
|
7
|
-
reset
|
8
|
-
super
|
9
|
-
end
|
10
|
-
|
11
|
-
def reset
|
12
|
-
@last_callback = nil
|
13
|
-
@call_count = Hash.new(0)
|
14
|
-
@last_record = {}
|
15
|
-
end
|
16
|
-
|
17
|
-
Mongoid::Callbacks.observables.each do |callback|
|
18
|
-
define_method(callback) do |record, &block|
|
19
|
-
@last_callback = callback
|
20
|
-
@call_count[callback] += 1
|
21
|
-
@last_record[callback] = record
|
22
|
-
block ? block.call : true
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
data/spec/app/models/canvas.rb
DELETED
@@ -1,25 +0,0 @@
|
|
1
|
-
class Canvas
|
2
|
-
include Mongoid::Document
|
3
|
-
field :name
|
4
|
-
embeds_many :shapes
|
5
|
-
embeds_one :writer
|
6
|
-
embeds_one :palette
|
7
|
-
|
8
|
-
field :foo, type: String, default: ->{ "original" }
|
9
|
-
|
10
|
-
has_many :comments, as: :commentable
|
11
|
-
|
12
|
-
accepts_nested_attributes_for :shapes
|
13
|
-
accepts_nested_attributes_for :writer
|
14
|
-
|
15
|
-
def render
|
16
|
-
shapes.each { |shape| render }
|
17
|
-
end
|
18
|
-
|
19
|
-
class Test < Canvas
|
20
|
-
|
21
|
-
field :foo, type: String, default: ->{ "overridden" }
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
require "app/models/browser"
|
data/spec/app/models/car.rb
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
class Car < Vehicle; end
|
data/spec/app/models/cat.rb
DELETED
data/spec/app/models/category.rb
DELETED
data/spec/app/models/child.rb
DELETED
@@ -1,22 +0,0 @@
|
|
1
|
-
class ChildDoc
|
2
|
-
include Mongoid::Document
|
3
|
-
|
4
|
-
embedded_in :parent_doc
|
5
|
-
|
6
|
-
attr_writer :position
|
7
|
-
|
8
|
-
after_save :update_position
|
9
|
-
|
10
|
-
def position
|
11
|
-
exsited_position = parent_doc.children_order.index(id)
|
12
|
-
exsited_position ? exsited_position + 1 : parent_doc.aspects.size
|
13
|
-
end
|
14
|
-
|
15
|
-
def update_position
|
16
|
-
if @position && (@position.to_i > 0)
|
17
|
-
parent_doc.children_order.delete(id)
|
18
|
-
parent_doc.children_order.insert(@position.to_i - 1, id)
|
19
|
-
parent_doc.save
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
data/spec/app/models/church.rb
DELETED
data/spec/app/models/circle.rb
DELETED
data/spec/app/models/circuit.rb
DELETED
data/spec/app/models/circus.rb
DELETED
data/spec/app/models/code.rb
DELETED
data/spec/app/models/cookie.rb
DELETED
@@ -1,10 +0,0 @@
|
|
1
|
-
class Dictionary
|
2
|
-
include Mongoid::Document
|
3
|
-
field :name, type: String
|
4
|
-
field :publisher, type: String
|
5
|
-
field :year, type: Integer
|
6
|
-
field :published, type: Time
|
7
|
-
field :description, type: String, localize: true
|
8
|
-
field :l, type: String, as: :language
|
9
|
-
has_many :words, validate: false
|
10
|
-
end
|
data/spec/app/models/division.rb
DELETED
data/spec/app/models/doctor.rb
DELETED
data/spec/app/models/dog.rb
DELETED
data/spec/app/models/dokument.rb
DELETED
data/spec/app/models/driver.rb
DELETED
data/spec/app/models/drug.rb
DELETED
data/spec/app/models/email.rb
DELETED
data/spec/app/models/employer.rb
DELETED
data/spec/app/models/entry.rb
DELETED
data/spec/app/models/eraser.rb
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
class Eraser < Tool; end
|
data/spec/app/models/event.rb
DELETED
@@ -1,22 +0,0 @@
|
|
1
|
-
class Event
|
2
|
-
include Mongoid::Document
|
3
|
-
|
4
|
-
field :title
|
5
|
-
field :date, type: Date
|
6
|
-
has_and_belongs_to_many \
|
7
|
-
:administrators,
|
8
|
-
class_name: 'Person',
|
9
|
-
inverse_of: :administrated_events,
|
10
|
-
dependent: :nullify
|
11
|
-
belongs_to :owner
|
12
|
-
|
13
|
-
def self.each_day(start_date, end_date)
|
14
|
-
groups = only(:date).asc(:date).where(:date.gte => start_date, :date.lte => end_date).group
|
15
|
-
groups.each do |hash|
|
16
|
-
yield(hash["date"], hash["group"])
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
scope :best, ->{ where(:kind.in => [ "party", "concert" ]) }
|
21
|
-
scope :by_kind, ->(kind){ where(:kind.in => [kind]) }
|
22
|
-
end
|
data/spec/app/models/eye.rb
DELETED
data/spec/app/models/eye_bowl.rb
DELETED
data/spec/app/models/face.rb
DELETED
data/spec/app/models/favorite.rb
DELETED
data/spec/app/models/firefox.rb
DELETED
data/spec/app/models/fish.rb
DELETED