Sha256: 0bf53727979c0c89fb5946af66614e773b8b4328d5d9ef13f5fff8911930fdea

Contents?: true

Size: 649 Bytes

Versions: 15

Compression:

Stored size: 649 Bytes

Contents

require "spec_helper"

describe BazaModels::Validators::UniquenessValidator do
  include DatabaseHelper

  before do
    User.create!(email: "test@example.com", organization_id: 1)
  end

  it "doesnt accept users with the same email" do
    user2 = User.new(email: "test@example.com", organization_id: 1)
    user2.validate_uniqueness = true

    expect(user2.valid?).to eq false
    expect(user2.errors.full_messages).to eq ["Email isn't unique"]
  end

  it "accepts users from other scope" do
    user2 = User.new(email: "test@example.com", organization_id: 2)
    user2.validate_uniqueness = true

    expect(user2.valid?).to eq true
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
baza_models-0.0.15 spec/baza_models/validators/uniqueness_validator_spec.rb
baza_models-0.0.14 spec/baza_models/validators/uniqueness_validator_spec.rb
baza_models-0.0.13 spec/baza_models/validators/uniqueness_validator_spec.rb
baza_models-0.0.12 spec/baza_models/validators/uniqueness_validator_spec.rb
baza_models-0.0.11 spec/baza_models/validators/uniqueness_validator_spec.rb
baza_models-0.0.10 spec/baza_models/validators/uniqueness_validator_spec.rb
baza_models-0.0.9 spec/baza_models/validators/uniqueness_validator_spec.rb
baza_models-0.0.8 spec/baza_models/validators/uniqueness_validator_spec.rb
baza_models-0.0.7 spec/baza_models/validators/uniqueness_validator_spec.rb
baza_models-0.0.6 spec/baza_models/validators/uniqueness_validator_spec.rb
baza_models-0.0.5 spec/baza_models/validators/uniqueness_validator_spec.rb
baza_models-0.0.4 spec/baza_models/validators/uniqueness_validator_spec.rb
baza_models-0.0.3 spec/baza_models/validators/uniqueness_validator_spec.rb
baza_models-0.0.2 spec/baza_models/validators/uniqueness_validator_spec.rb
baza_models-0.0.1 spec/baza_models/validators/uniqueness_validator_spec.rb