Sha256: e6d4788c3dbb84d57f01be38628d988a4989158fb7383e3101dce88162573b94

Contents?: true

Size: 1.08 KB

Versions: 2

Compression:

Stored size: 1.08 KB

Contents

require "spec_helper"

class Book
  include ActiveAttr::Model
end

class Shelf
  include ActiveAttr::Model
end

class Ability
  include CanCan::Ability

  def initialize
    canf :update, Book, :title

    canf [:create, :update], Shelf, [:name, :position]
  end
end

describe "CanField::CanCan" do
  describe "::AbilityAdditions" do
    subject{ ability }
    let(:ability) {Ability.new}

    describe "#canf" do
      it { should     be_able_to(:_cf_update_fl_title,  Book.new) }
      it { should_not be_able_to(:_cf_update_fl_author, Book.new) }

      it { should     be_able_to(:update, Book.new) }
      it { should_not be_able_to(:create, Book.new) }

      it { should be_able_to(:_cf_update_fl_name,     Shelf.new) }
      it { should be_able_to(:_cf_update_fl_position, Shelf.new) }
      it { should be_able_to(:_cf_create_fl_name,     Shelf.new) }
      it { should be_able_to(:_cf_create_fl_position, Shelf.new) }

      it { should     be_able_to(:update, Shelf.new)}
      it { should     be_able_to(:create, Shelf.new)}
      it { should_not be_able_to(:read,   Shelf.new)}
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
can_field-0.0.2 spec/can_field/can_can_spec.rb
can_field-0.0.1 spec/can_field/can_can_spec.rb