Sha256: 17f3d290e982c050a4eaf7d11237587c39a706d6427fcfe3af209499c765ae47

Contents?: true

Size: 709 Bytes

Versions: 6

Compression:

Stored size: 709 Bytes

Contents

require 'spec_helper'

require 'upsert/active_record_upsert'

describe Upsert do
  describe 'the optional active_record extension' do
    describe :upsert do
      it "is easy to use" do
        assert_creates(Pet,[{:name => 'Jerry', :good => true}]) do
          Pet.upsert({:name => 'Jerry'}, :good => false)
          Pet.upsert({:name => 'Jerry'}, :good => true)
        end
      end

      it "doesn't fail inside a transaction" do
        Upsert.clear_database_functions(Pet.connection)
        expect {
          Pet.transaction do
            Pet.upsert({name: 'Simba'}, good: true)
          end
        }.to_not raise_error
        expect(Pet.first.name).to eq('Simba')
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
upsert-2.9.10-java spec/active_record_upsert_spec.rb
upsert-2.9.10 spec/active_record_upsert_spec.rb
upsert-2.9.9-universal-java-11 spec/active_record_upsert_spec.rb
upsert-2.9.9 spec/active_record_upsert_spec.rb
upsert-2.2.1 spec/active_record_upsert_spec.rb
upsert-2.2.0 spec/active_record_upsert_spec.rb