Sha256: 9ae87a59e2ee6bc4521b74bc1f1bfd106cde5d4704f39d1cd1a380d56e8b9564

Contents?: true

Size: 1.21 KB

Versions: 6

Compression:

Stored size: 1.21 KB

Contents

require 'spec_helper'

describe User do
  describe '#role?' do
    let(:user) { create(:user) }

    it 'returns true for admin role' do
      user.admin = true
      expect(user.role?(:admin)).to be true
    end

    it 'returns false for non-admin role' do
      user.admin = false
      expect(user.role?(:admin)).to be false
    end
  end

  describe '#password_complexity' do
    let(:user) { build(:user) }

    it 'is valid with a complex password' do
      user.password = 'ComplexPass1!'
      expect(user).to be_valid
    end

    it 'is invalid with a simple password' do
      user.password = 'simple'
      user.valid?
      expect(user.errors[:password]).to include('Complexity requirement not met. Length should be 12 characters and include: 1 uppercase, 1 lowercase, 1 digit and 1 special character.')
    end
  end

  describe '#password_required?' do
    let(:user) { build(:user) }

    it 'returns false if skip_password_validation is true' do
      user.skip_password_validation = true
      expect(user.password_required?).to be false
    end

    it 'returns true if skip_password_validation is false' do
      user.skip_password_validation = false
      expect(user.password_required?).to be true
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
trusty-cms-7.0.8 spec/models/user_spec.rb
trusty-cms-7.0.7 spec/models/user_spec.rb
trusty-cms-7.0.6 spec/models/user_spec.rb
trusty-cms-7.0.5 spec/models/user_spec.rb
trusty-cms-7.0.4 spec/models/user_spec.rb
trusty-cms-7.0.3 spec/models/user_spec.rb