Sha256: 47c52ac3d9f8271664ad464919b9b16616f339eca70923443ae24c99a8eb4241

Contents?: true

Size: 1.26 KB

Versions: 2

Compression:

Stored size: 1.26 KB

Contents

require File.dirname(__FILE__) + '/test_helper.rb'

class AnnotationVersionTest < ActiveSupport::TestCase
  
  def test_annotation_version_class_loaded
    assert_kind_of Annotation::Version, Annotation::Version.new
  end
  
  def test_versioning_on_update
    ann = annotations(:bh_title_1)
    orig_value_id = ann.value_id
    orig_content = ann.value_content
    new_content = "Harry Potter IIIIIII"
    
    # Check number of versions
    assert_equal 1, ann.versions.length
    
    # Update the value and check that a version has been created
    
    ann.value = new_content
    ann.version_creator = users(:john)

    assert ann.valid?
    
    assert ann.save
    
    assert_equal 2, ann.versions.length
    assert_equal new_content, ann.value_content
    assert_equal 2, ann.versions.latest.version
    assert_equal new_content, ann.versions.latest.value_content
    assert_equal 1, ann.versions.latest.previous.version
    assert_equal orig_content, ann.versions.latest.previous.value_content
    assert_equal orig_value_id, ann.versions.latest.previous.value_id
    assert_equal users(:john).id, ann.version_creator_id
    assert_equal users(:john).id, ann.versions.latest.version_creator_id
    assert_equal nil, ann.versions.latest.previous.version_creator_id
  end
  
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
my_annotations-0.6.0 test/annotation_version_test.rb
my_annotations-0.5.1 test/annotation_version_test.rb