Sha256: 8cf296bcbd3fde194d72cba3408a21a460c47a339d64352d1de06910310863e1

Contents?: true

Size: 676 Bytes

Versions: 3

Compression:

Stored size: 676 Bytes

Contents

require 'spec_helper'

unless RUBY_PLATFORM == 'opal'
  class Fridge < Volt::Model
    validate :name, unique: true
  end

  describe 'unique spec' do
    it 'should reject save if there are records with existing attributes already' do
      store._fridges << { name: 'swift' }
      fridge = store._fridges.buffer name: 'swift'
      fridge.save!.then do
        expect(false).to be_true
      end.fail do
        expect(true).to be_true
      end
    end

    it 'should not increase count of the total records in the store' do
      store._fridges << { name: 'swift' }
      store._fridges << { name: 'swift' }
      expect(store._fridges.count).to eq(1)
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
volt-0.9.3.pre2 spec/models/validators/unique_validator_spec.rb
volt-0.9.3.pre1 spec/models/validators/unique_validator_spec.rb
volt-0.9.2 spec/models/validators/unique_validator_spec.rb