Sha256: 74697a1a867b89d3f8937eaa5a3f6796a4c18f916151a89009dc6fdf104bb475

Contents?: true

Size: 1.02 KB

Versions: 18

Compression:

Stored size: 1.02 KB

Contents

require 'spec_helper'
require 'cancan/matchers'

describe "User" do
  subject { ability }
  let(:ability) { Ability.new(user) }
  let(:other) { build(:user) { |u| u.id = 2 } }

  context "when working with User" do
    context "as a non-admin" do
      let(:user) { build(:user) { |u| u.id = 1 } }

      context "operating on themselves" do
        it { should     be_able_to(:read, user) }
        it { should     be_able_to(:update, user) }
        it { should_not be_able_to(:destroy, user) }
      end

      context "operating on someone else" do
        it { should_not be_able_to(:manage, other) }
        it { should_not be_able_to(:create, User) }
      end
    end

    context "as an admin" do
      let(:user) { build(:admin) { |u| u.id = 1 } }

      context "operating on themselves" do
        it { should     be_able_to(:manage, user) }
        it { should_not be_able_to(:destroy, user) }
      end

      context "operating on someone else" do
        it { should be_able_to(:manage, other) }
      end
    end
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
raygun-0.0.34 rails_32/spec/models/ability_spec.rb
raygun-0.0.34.pre2 rails_32/spec/models/ability_spec.rb
raygun-0.0.33 rails_32/spec/models/ability_spec.rb
raygun-0.0.32 rails_32/spec/models/ability_spec.rb
raygun-0.0.31 rails_32/spec/models/ability_spec.rb
raygun-0.0.30 rails_32/spec/models/ability_spec.rb
raygun-0.0.29 rails_32/spec/models/ability_spec.rb
raygun-0.0.28 rails_32/spec/models/ability_spec.rb
raygun-0.0.27 app_prototype/spec/models/ability_spec.rb
raygun-0.0.26 app_prototype/spec/models/ability_spec.rb
raygun-0.0.25 app_prototype/spec/models/ability_spec.rb
raygun-0.0.24 app_prototype/spec/models/ability_spec.rb
raygun-0.0.23 app_prototype/spec/models/ability_spec.rb
raygun-0.0.22 app_prototype/spec/models/ability_spec.rb
raygun-0.0.21 app_prototype/spec/models/ability_spec.rb
raygun-0.0.18 app_prototype/spec/models/ability_spec.rb
raygun-0.0.17 app_prototype/spec/models/ability_spec.rb
raygun-0.0.16 app_prototype/spec/models/ability_spec.rb