Sha256: 351aed7cf416ec88a35a1b4d8a381c1fe7c0894a3ba04361ca773bafa78887df

Contents?: true

Size: 1.41 KB

Versions: 11

Compression:

Stored size: 1.41 KB

Contents

require 'rails_helper'
require 'byebug'

RSpec.describe User, type: :model do
  let(:keppler_user) { create(:user) }

  context 'database' do
    context 'columns' do
      it { should have_db_column(:name).of_type(:string) }
      it { should have_db_column(:username).of_type(:string) }
      it { should have_db_column(:email).of_type(:string) }
      it { should have_db_column(:encrypted_password).of_type(:string) }
      it { should have_db_column(:deleted_at).of_type(:datetime) }
    end

    context 'validates' do
      it 'validate name' do
        user = build(:user, name: nil)
        expect(user).to be_invalid
      end

      it 'validate email' do
        user = build(:user, email: nil)
        expect(user).to be_invalid
      end

      it 'validate role_ids' do
        user = build(:user, role_ids: nil)
        expect(user).to be_invalid
      end
    end
  end

  context 'class fuctions' do
    it { expect(User.search_field).to eq(:name_or_username_or_email_cont) }

    it 'user filter by role keppler_admin' do
      query = User.all.order(created_at: :desc).page(1)
      users = User.filter_by_role(query, 'keppler_admin')
      expect(users.shuffle.first.rol).to eq('keppler_admin')
    end
  end

  context 'instance fuctions' do
    it { expect(keppler_user.rol).to eq('keppler_admin') }
    it { expect(keppler_user.keppler_admin?).to eq(true) }
    it { expect(keppler_user.permalink?).to eq(true) }
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
keppler-2.1.22 installer/core/spec/models/user_spec.rb
keppler-2.1.21 installer/core/spec/models/user_spec.rb
keppler-2.1.20 installer/core/spec/models/user_spec.rb
keppler-2.1.19 installer/core/spec/models/user_spec.rb
keppler-2.1.18 installer/core/spec/models/user_spec.rb
keppler-2.1.17 installer/core/spec/models/user_spec.rb
keppler-2.1.16 installer/core/spec/models/user_spec.rb
keppler-2.1.15 installer/core/spec/models/user_spec.rb
keppler-2.1.14 installer/core/spec/models/user_spec.rb
keppler-2.1.13 installer/core/spec/models/user_spec.rb
keppler-2.1.12 installer/core/spec/models/user_spec.rb