Sha256: 70d9e09485823988fa4bc1378dceffa6942aee183ebea33ff010a579244884ac

Contents?: true

Size: 941 Bytes

Versions: 5

Compression:

Stored size: 941 Bytes

Contents

require 'active_record/spec_helper'

require_all File.dirname(__FILE__) + "/../shared/" 

describe 'Scenario: users - :guest, :user, :admin' do
  context 'User user (normal user)' do
    before(:each) do
      @user = User.create!(:role => "user")
      @own_todo = Todo.create!
      @own_todo.authors << @user
      @own_todo.save!

    end
  
    it_should_behave_like "User role" do
      let(:current_user) { @user }
      let(:user) { current_user_ability(:user) }
      let(:own_article) { Article.create!(:user_id => @user.id) }
      let(:own_post)    { Post.create(:user_id => @user.id) }
      let(:own_comment) { Comment.create(:user_id => @user.id) }
      let(:own_todo) { @own_todo }
    end
 
    it "should allow :write of own Todos" do
      @user.should be_allowed_to(:write, @own_todo)
    end

    it "should not allow :write of not-own Todos" do
      @user.should_not be_allowed_to(:write, Todo.new)
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
cantango-0.9.4.7 spec/active_record/scenarios/guest_user_admin/user_spec.rb
cantango-0.9.4.6 spec/active_record/scenarios/guest_user_admin/user_spec.rb
cantango-0.9.4.5 spec/active_record/scenarios/guest_user_admin/user_spec.rb
cantango-0.9.4.3 spec/active_record/scenarios/guest_user_admin/user_spec.rb
cantango-0.9.4.2 spec/active_record/scenarios/guest_user_admin/user_spec.rb