Sha256: ed3de84113ae0724c675280d53230e5f1ed13fa71a4ce51de6b7bcd21ea58a7f
Contents?: true
Size: 1.71 KB
Versions: 5
Compression:
Stored size: 1.71 KB
Contents
require 'spec_helper_models' describe Gaku::User do describe 'associations' do it { should have_many :user_roles } it { should have_many(:roles).through(:user_roles) } end describe 'validations' do it { should validate_presence_of :username } it { should validate_uniqueness_of :username } end it { should respond_to :login } it { should respond_to :login= } describe 'mixins' do let!(:modules) { described_class.included_modules } it 'includes devise modules' do expect(modules).to include(Devise::Models::Authenticatable) expect(modules).to include(Devise::Models::DatabaseAuthenticatable) expect(modules).to include(Devise::Models::Registerable) expect(modules).to include(Devise::Models::Recoverable) expect(modules).to include(Devise::Models::Rememberable) expect(modules).to include(Devise::Models::Trackable) expect(modules).to include(Devise::Models::Validatable) end end describe 'scopes' do describe '.admin' do before do @admin = create(:admin_user) @student = create(:student_user) end it 'returns users with role admin' do expect(described_class.admin).to eq([@admin]) end end end describe '#to_s' do let(:user) { described_class.new(username: 'ruby') } it 'returns username' do expect(user.to_s).to eq 'ruby' end end describe '#role?' do let!(:user) { create(:admin_user) } context 'when role is matched' do it 'returns true' do expect(user.role?(:admin)).to eq true end end context 'when role is not matched' do it 'returns false' do expect(user.role?(:student)).to eq false end end end end
Version data entries
5 entries across 5 versions & 1 rubygems