Index: ruby/branches/0.5/lib/open_ehr/rm/common/change_control.rb
===================================================================
--- ruby/branches/0.5/lib/open_ehr/rm/common/change_control.rb	(revision 331)
+++ ruby/branches/0.5/lib/open_ehr/rm/common/change_control.rb	(revision 332)
@@ -156,6 +156,5 @@
 
           def is_merged?
-# Java implementation has is_merged attribute, Eiffel implementation does
-# nothing
+            return !other_input_version_uids.nil?
           end
         end
Index: ruby/branches/0.5/spec/lib/open_ehr/rm/common/change_control/original_version_spec.rb
===================================================================
--- ruby/branches/0.5/spec/lib/open_ehr/rm/common/change_control/original_version_spec.rb	(revision 332)
+++ ruby/branches/0.5/spec/lib/open_ehr/rm/common/change_control/original_version_spec.rb	(revision 332)
@@ -0,0 +1,57 @@
+require File.dirname(__FILE__) + '/../../../../../spec_helper'
+include OpenEHR::RM::Common::ChangeControl
+include OpenEHR::RM::DataTypes::Text
+
+describe OriginalVersion do
+  before(:each) do
+    uid = ObjectVersionID.new(:value => 'ABC::DEF::1')
+    defining_code = stub(CodePhrase, :code_string => '532')
+    lifecycle_state = stub(DvCodedText, :defining_code => defining_code)
+    object_id = stub(ObjectID, :value => 'unique')
+    contribution = ObjectRef.new(:namespace => 'local',
+                                 :type => 'CONTRIBUTION',
+                                 :id => object_id)
+    commit_audit = stub(AuditDetails, :committer => 'UNKNOWN', :empty? => false)
+    attestations = stub(Array, :empty? => false, :size => 12)
+    other_input_version_uids = stub(Set, :empty? => false, :size => 5)
+    @original_version = OriginalVersion.new(:uid => uid,
+                                            :lifecycle_state => lifecycle_state,
+                                            :attestations => attestations,
+                                            :commit_audit => commit_audit,
+                                            :contribution => contribution,
+                                            :other_input_version_uids => other_input_version_uids)
+  end
+
+  it 'should be an isntance of OriginalVersion' do
+    @original_version.should be_an_instance_of OriginalVersion
+  end
+
+  it 'attestation size should be 12' do
+    @original_version.attestations.size.should == 12
+  end
+
+  it 'other_version_input_uids size should be 5' do
+    @original_version.other_input_version_uids.size.should == 5
+  end
+
+  it 'is_merged? should be true when other_input_version_uids is nil' do
+    @original_version.is_merged?.should be_true
+  end
+
+  it 'is_merged? should not be true when other_input_version_uids is not nil' do
+    @original_version.other_input_version_uids = nil
+    @original_version.is_merged?.should be_false
+  end
+
+  it 'should raise ArgumentError when attestations is nil' do
+    lambda {
+      @original_version.attestations = nil
+    }.should raise_error ArgumentError
+  end
+
+  it 'should raise ArgumentError when other_input_version_uids is empty' do
+    lambda {
+      @original_version.other_input_version_uids = Set.new
+    }.should raise_error ArgumentError
+  end
+end
Index: ruby/branches/0.5/spec/lib/open_ehr/rm/common/change_control/version_spec.rb
===================================================================
--- ruby/branches/0.5/spec/lib/open_ehr/rm/common/change_control/version_spec.rb	(revision 332)
+++ ruby/branches/0.5/spec/lib/open_ehr/rm/common/change_control/version_spec.rb	(revision 332)
@@ -0,0 +1,89 @@
+require File.dirname(__FILE__) + '/../../../../../spec_helper'
+include OpenEHR::RM::Common::ChangeControl
+include OpenEHR::RM::Common::Generic
+include OpenEHR::RM::DataTypes::Text
+
+describe Version do
+  before(:each) do
+    uid = ObjectVersionID.new(:value => 'ABCD::EFG::2')
+    preceding_version_uid = ObjectVersionID.new(:value =>'HIJ::KLM::1')
+    commit_audit = stub(AuditDetails, :committer => 'UNKNOWN', :empty? => false)
+    object_id = stub(ObjectID, :value => 'unique')
+    contribution = ObjectRef.new(:namespace => 'local',
+                                 :type => 'CONTRIBUTION',
+                                 :id => object_id)
+    defining_code = stub(CodePhrase, :code_string => '532')
+    lifecycle_state = stub(DvCodedText, :defining_code => defining_code)
+    signature = '4760271533c2866579dde347ad28dd79e4aad933'
+    @version = Version.new(:uid => uid,
+                           :preceding_version_uid => preceding_version_uid,
+                           :data => 'data',
+                           :contribution => contribution,
+                           :lifecycle_state => lifecycle_state,
+                           :commit_audit => commit_audit,
+                           :signature => signature)
+  end
+
+  it 'should be an instance of Version' do
+    @version.should be_an_instance_of Version
+  end
+
+  it 'uid value should be ABCD::EFG::1' do
+    @version.uid.value.should == 'ABCD::EFG::2'
+  end
+
+  it 'commit_audit.committer.should be UNKNOWN' do
+    @version.commit_audit.committer.should == 'UNKNOWN'
+  end
+
+  it 'lifecycle_state should be 532' do
+    @version.lifecycle_state.defining_code.code_string.should == '532'
+  end
+
+  it 'contribution namespece should be local' do
+    @version.contribution.namespace.should == 'local'
+  end
+
+  it 'contribution type should be CONTRIBUTION' do
+    contribution = @version.contribution
+    contribution.type = 'PARTY'
+    lambda {
+      @version.contribution = contribution
+    }.should raise_error ArgumentError
+  end
+
+  it 'signature should be 4760271533c2866579dde347ad28dd79e4aad933' do
+    @version.signature.should == '4760271533c2866579dde347ad28dd79e4aad933'
+  end
+
+  it 'should not be a branch' do
+    @version.is_branch?.should_not be true
+  end
+
+  it 'should be a branch' do
+    @version.uid.value = 'ABCD::EFG::1.2.3'
+    @version.is_branch?.should be true
+  end
+
+  it 'data should be data' do
+    @version.data.should == 'data'
+  end
+
+  it 'owner_id value should be ABCD::EFG::2' do
+    @version.owner_id.value.should == 'ABCD::EFG::2'
+  end
+
+  it 'canonical form is not well determined' do
+    lambda {
+      @version.canonical_form
+    }.should raise_error NotImplementedError
+  end
+
+  it 'should raise ArgumentError when preceding version id exists and uid version tree is first' do
+    @version.uid.value = 'ABC::DEF::1'
+    preceding_version_uid = ObjectVersionID.new(:value => 'GHI::JKL::2')
+    lambda {
+      @version.preceding_version_uid = preceding_version_uid
+    }.should raise_error ArgumentError
+  end
+end
