Sha256: 347f6faef7f24e52db86485c0621fdff24cff89188189a8b86c6a277d605979e

Contents?: true

Size: 1.66 KB

Versions: 7

Compression:

Stored size: 1.66 KB

Contents

require 'spec_helper'

RSpec.describe Roroacms::Admin, :type => :model do

  let!(:admin) { FactoryGirl.create(:admin) }
  let!(:user) { FactoryGirl.build(:admin) }

  it "has a valid factory" do
    expect(user).to be_valid
  end

  it "is invalid without a username" do
    expect(FactoryGirl.build(:admin, username: nil)).to_not be_valid
  end

  it "is invalid without a unique username" do
    expect(FactoryGirl.build(:admin, username: admin.username)).to_not be_valid
  end

  it "is invalid without a access_level" do
    expect(FactoryGirl.build(:admin, access_level: nil)).to_not be_valid
  end

  it "is invalid without a password" do
    expect(FactoryGirl.build(:admin, password: '')).to_not be_valid
  end

  it "is invalid without a password of a length of 6-128" do
    expect(FactoryGirl.build(:admin, password: '123')).to_not be_valid
  end

  it "is valid with a password of a length between 6-128" do
    expect(FactoryGirl.build(:admin, password: '123123123')).to be_valid
  end

  context "set defaults" do

    it "should return overlord as 'N'" do
      expect(admin.overlord).to eq('N')
    end

    it "should set the profile image" do
      expect(admin.avatar).to_not be_blank
    end

  end

  context "access levels" do 

    let(:levels) { Roroacms::Admin.access_levels }

    it "should return an array" do
      expect(levels).to be_a_kind_of(Array)
    end

    it "should include admin" do 
      expect(levels).to include('admin')
    end

  end

  it "should set the cover image to blank" do
    user.deal_with_cover({ has_cover_image: nil })
    expect(user.cover_picture).to be_blank
  end

end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
roroacms-0.0.6.4 spec/models/roroacms/admin_spec.rb
roroacms-0.0.6.2 spec/models/roroacms/admin_spec.rb
roroacms-0.0.6.1 spec/models/roroacms/admin_spec.rb
roroacms-0.0.6 spec/models/roroacms/admin_spec.rb
roroacms-0.0.5 spec/models/roroacms/admin_spec.rb
roroacms-0.0.4 spec/models/roroacms/admin_spec.rb
roroacms-0.0.3 spec/models/roroacms/admin_spec.rb