Sha256: 16c9f8f616b9a7a61d90b0956b20bafd2c1bcbaa631637defd52627a3dee22f5

Contents?: true

Size: 1.2 KB

Versions: 3

Compression:

Stored size: 1.2 KB

Contents

require File.join(File.dirname(__FILE__), 'spec_helper')

describe "HasManyVersions history" do

  before(:each) do
    Database.reset!
  end
  
  it "should give you a history" do
    Database.reset!(true)
    jasper = Author.new(:name => 'Jasper Fforde')
    
    books = (1..100).collect do |i|
      book = Book.new(:name => "Book #{i}", :id => i)
      book.save!
      book
    end
    jasper.save!
    titles = [[]]
    jasper.books = [Book.find(1), Book.find(10), Book.find(11), Book.find(23), Book.find(99)]
    titles << jasper.books.collect(&:name)
    jasper.books = [Book.find(1), Book.find(10), Book.find(12), Book.find(25), Book.find(94)]
    titles << jasper.books.collect(&:name)
    jasper.books = [Book.find(1), Book.find(10), Book.find(12), Book.find(25), Book.find(94), Book.find(87)]
    titles << jasper.books.collect(&:name)
    jasper.books = [Book.find(2), Book.find(4), Book.find(5)]
    titles << jasper.books.collect(&:name)
    jasper.books = [Book.find(1), Book.find(10), Book.find(11), Book.find(23), Book.find(99)]
    titles << jasper.books.collect(&:name)
    
    jasper.books.history.each do |history|
      history.state.collect(&:name).should == titles.shift
    end
    
  end
  
end

Version data entries

3 entries across 3 versions & 2 rubygems

Version Path
joshbuddy-has_many_versions-0.0.6 spec/history_spec.rb
joshbuddy-has_many_versions-0.0.7 spec/history_spec.rb
has_many_versions-0.0.7 spec/history_spec.rb