Sha256: 4fd93aad796d8c75ff17f5f67ae96162e90e7e8b7099b727c125d6647fc36f24

Contents?: true

Size: 827 Bytes

Versions: 2

Compression:

Stored size: 827 Bytes

Contents

require 'spec_helper'
require 'models/account'
require 'models/user'

describe AutoIncrement do
  before :all do
    @account1 = Account.create name: 'My Account'
    @account2 = Account.create name: 'Another Account', code: 50

    @user_account1 = @account1.users.create name: 'Felipe', letter_code: 'Z'
    @user_account2 = @account2.users.create name: 'Daniel'
  end

  describe 'initial' do
    it { expect(@account1.code).to eq 1 }
    it { expect(@user_account1.letter_code).to eq 'A' }
  end

  describe "do not increment outside scope" do
    it { expect(@user_account2.letter_code).to eq 'A' }
  end

  describe "not set column if is already set" do
    it { expect(@account2.code).to eq 50 }
  end

  describe "set column if option force is used" do
    it { expect(@user_account1.letter_code).to eq 'A' }
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
auto_increment-1.1.1 spec/lib/active_record_spec.rb
auto_increment-1.1.0 spec/lib/active_record_spec.rb