Sha256: f96f8648e9a580b03ce7743dddab3238243db2e6f697403e0bcd585e57300058

Contents?: true

Size: 1.09 KB

Versions: 2

Compression:

Stored size: 1.09 KB

Contents

require File.join(File.dirname(__FILE__), '..', 'og', 'CONFIG.rb')

require 'test/unit'

require 'og'
require 'glue/revisable'

class Article
  is Revisable
  property :body, String, :revisable => true
  property :title, String
  
  def initialize(t, b)
    @title, @body = t, b
  end
end

$og = Og.setup($og_config)

class TestOgRevisable < Test::Unit::TestCase # :nodoc: all

  def test_all
    a = Article.create('hello', 'world')
    a.revise do |a|
      a.body = 'wow!'
    end
    a.revise do |a|
      a.body = 'nice'
    end
    a.revise do |a|
      a.body = 'it'
    end
    
    assert_equal 3, a.revisions.count
    
    rev = a.get_revision(2)
    assert_equal 'wow!', rev.body
    
    a.rollback(2)
    assert_equal 'wow!', a.body
    
    a.rollback(1)
    assert_equal 'world', a.body
    
    a.rollback(3)
    assert_equal 'nice', a.body

    assert_equal 6, a.revisions.count
    
    a.revise do |a|
      a.title = 'kicks'
      a.body = 'ass'
    end

    assert_equal 7, a.revisions.count
    
    # The automatically generated class.
    
    assert_equal 7, Article::Revision.count
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
og-0.26.0 test/glue/tc_revisable.rb
og-0.27.0 test/glue/tc_revisable.rb