Sha256: fd789eb586366fffd5b9c1eb1f48a2305875c8364e99c35a7de5126ed8ae21fa

Contents?: true

Size: 1002 Bytes

Versions: 1

Compression:

Stored size: 1002 Bytes

Contents

# encoding: utf-8
require 'spec_helper'

#
# The case
#
class Author
  include Mongoid::Document

  field :name, type: String

  has_many :books
end

class Book
  include Mongoid::Document
  include Mongoid::Max::Denormalize

  field :name, type: String

  belongs_to :author

  has_many :reviews
end

class Review
  include Mongoid::Document
  include Mongoid::Max::Denormalize

  belongs_to :book

  field :rating, type: Integer
end

#
# The specs
#
describe "Case: Existing" do

  before do
    @author = Author.create!(name: "Michael Crichton")
    @book = Book.create!(name: "Jurassic Park", author: @author)
    @review_1 = Review.create!(book: @book, rating: 4)
    @review_2 = Review.create!(book: @book, rating: 5)
  end

  context "when defining the denormalization" do
    before do
      Book.denormalize :author, :name
      Book.denormalize :reviews, :rating, :count => true
      Review.denormalize :book, :name
    end

    it "denormalization should be empty" do

    end

  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
mongoid_max_denormalize-0.0.2 spec/cases/existing_spec.rb