Sha256: a680a0bf16f7eff4529a2cd4da3b0f10920c881423244b464a6444b7c75a2149

Contents?: true

Size: 1.39 KB

Versions: 1

Compression:

Stored size: 1.39 KB

Contents

require 'spec_helper'
require 'cancan/matchers'

describe Spotlight::Ability do
  let(:exhibit) {Spotlight::Exhibit.default}
  let(:search) {FactoryGirl.create(:search)}
  let(:page) {FactoryGirl.create(:feature_page)}

  describe "a user with no roles" do
    subject { Ability.new(nil) }
    it { should_not be_able_to(:create, exhibit) }
    it { should be_able_to(:read, exhibit) }
    it { should be_able_to(:read, page) }
    it { should_not be_able_to(:create, Spotlight::Page) }
    it { should be_able_to(:read, search) }
  end

  describe "a user with admin role" do
    let(:user) { FactoryGirl.create(:exhibit_admin) }
    subject { Ability.new(user) }
    it { should be_able_to(:update, exhibit) }
  end

  describe "a user with curate role" do
    let(:user) { FactoryGirl.create(:exhibit_curator) }
    subject { Ability.new(user) }

    it { should_not be_able_to(:update, exhibit) }
    it { should be_able_to(:curate, exhibit) }
    it { should be_able_to(:read, exhibit) }

    it { should be_able_to(:create, Spotlight::Search) }
    it { should be_able_to(:update_all, Spotlight::Search) }
    it { should be_able_to(:update, search) }
    it { should be_able_to(:destroy, search) }

    it { should be_able_to(:create, Spotlight::Page) }
    it { should be_able_to(:update_all, Spotlight::Page) }
    it { should be_able_to(:update, page) }
    it { should be_able_to(:destroy, page) }
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
blacklight-spotlight-0.0.1 spec/models/spotlight/ability_spec.rb