Sha256: 83173e0c1e761b3afd326496b3c1486313268e0a81e948db950c7a2aa7fe0dc7

Contents?: true

Size: 1.89 KB

Versions: 22

Compression:

Stored size: 1.89 KB

Contents

shared_examples_for "Guest role" do

  it 'should allow :read of all Articles' do
    user.should be_allowed_to(:read, Article)
  end

  it 'should allow :read of all Posts' do
    user.should be_allowed_to(:read, Post)
  end

  it 'should allow :read of all Comments' do
    user.should be_allowed_to(:read, Comment)
  end
end

shared_examples_for "User role" do
  it_should_behave_like "Guest role" do
  end

  it 'should allow :management of own Articles' do
    user.should be_allowed_to(:manage, own_article)
  end

  it 'should allow :management of own Posts' do
    user.should be_allowed_to(:manage, own_post)
  end

  it 'should allow :management of own Comments' do
    user.should be_allowed_to(:manage, own_comment)
  end

  it 'should not allow :management not-own Articles' do
    user.should_not be_allowed_to(:manage, Article.create!)
  end

  it 'should allow :write of not-own Articles' do
    user.should be_allowed_to(:write, Article.create!)
  end
end

shared_examples_for "Editor role" do
  it_should_behave_like "Guest role" do
  end

  it 'should allow :write of Comments' do
    user.should be_allowed_to(:write, Comment)
  end

  it 'should allow :write of Article' do
    user.should be_allowed_to(:write, Article)
  end

  it 'should allow :write of Post' do
    user.should be_allowed_to(:write, Post)
  end
end


shared_examples_for "User + Editor roles" do
  it_should_behave_like "User role" do
  end

  it_should_behave_like "Editor role" do
  end
end

shared_examples_for "Admin role" do

  it 'should allow :management of everything' do
    user.should be_allowed_to(:manage, :all)
  end

  it 'should allow :management of all Articles' do
    user.should be_allowed_to(:manage, Article)
  end

  it 'should allow :management of all Posts' do
    user.should be_allowed_to(:manage, Post)
  end

  it 'should allow :management of all Comments' do
    user.should be_allowed_to(:manage, Comment)
  end
end

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
cantango-0.8.5.1 spec/active_record/scenarios/shared/examples/users.rb
cantango-0.8.0 spec/active_record/scenarios/shared/examples/users.rb