Sha256: a58aeeb0eb639142b0d882ed820a512ac54303b693e7d81695655f8032368d9c

Contents?: true

Size: 702 Bytes

Versions: 69

Compression:

Stored size: 702 Bytes

Contents

require File.dirname(__FILE__) + '/../spec_helper'

describe Sequel::Pervasive::DatabaseMethods do

  it "supports transactions" do
    set_fos_db([Trip])
    t = Trip.first
    ### surround with begin/rescue
    begin
      ### testing do_transaction
      r = nil
      Trip.db.do_transaction do |conn|
        # increment the value of fs_visa by one
        r = conn.run(Trip.filter(t.pk_hash).update_sql(:fs_visa=>t.fs_visa.succ))
        raise(Exception, 'testing do_transaction transactions')
      end
      ### end testing do_transaction
    rescue Exception => e
    ensure
      r.drop if r
    end
    # check if the values have changed
    Trip.first.fs_visa.should == t.fs_visa
  end

end

Version data entries

69 entries across 69 versions & 1 rubygems

Version Path
fossil-0.4.15 spec/sequel/pervasive_adapter_spec.rb
fossil-0.4.14 spec/sequel/pervasive_adapter_spec.rb
fossil-0.4.13 spec/sequel/pervasive_adapter_spec.rb
fossil-0.4.12 spec/sequel/pervasive_adapter_spec.rb
fossil-0.4.10 spec/sequel/pervasive_adapter_spec.rb
fossil-0.4.9 spec/sequel/pervasive_adapter_spec.rb
fossil-0.4.8 spec/sequel/pervasive_adapter_spec.rb
fossil-0.4.7 spec/sequel/pervasive_adapter_spec.rb
fossil-0.4.6 spec/sequel/pervasive_adapter_spec.rb