Sha256: 4eb0db7583bc0dd403142533115685eac391dd4a156c3cf37a7e799ff578810a

Contents?: true

Size: 973 Bytes

Versions: 8

Compression:

Stored size: 973 Bytes

Contents

require 'spec_helper'
require 'cancan/matchers'

describe Sufia::Ability do


  describe "a user with no roles" do
    let(:user) { nil }
    subject { Ability.new(user) }
    it { should_not be_able_to(:create, GenericFile) }
    it { should_not be_able_to(:create, TinymceAsset) }
    it { should_not be_able_to(:update, ContentBlock) }
  end

  describe "a registered user" do
    let(:user) { FactoryGirl.create(:user) }
    subject { Ability.new(user) }
    it { should be_able_to(:create, GenericFile) }
    it { should_not be_able_to(:create, TinymceAsset) }
    it { should_not be_able_to(:update, ContentBlock) }
  end

  describe "a user in the admin group" do
    let(:user) { FactoryGirl.create(:user) }
    before { user.stub(groups: ['admin', 'registered']) }
    subject { Ability.new(user) }
    it { should be_able_to(:create, GenericFile) }
    it { should be_able_to(:create, TinymceAsset) }
    it { should be_able_to(:update, ContentBlock) }
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
sufia-4.0.1 spec/models/ability_spec.rb
sufia-4.0.0 spec/models/ability_spec.rb
sufia-4.0.0.rc2 spec/models/ability_spec.rb
sufia-4.0.0.rc1 spec/models/ability_spec.rb
sufia-4.0.0.beta4 spec/models/ability_spec.rb
sufia-4.0.0.beta3 spec/models/ability_spec.rb
sufia-4.0.0.beta2 spec/models/ability_spec.rb
sufia-4.0.0.beta1 spec/models/ability_spec.rb