spec/dummy/app/models/ability.rb in enju_circulation-0.0.40 vs spec/dummy/app/models/ability.rb in enju_circulation-0.0.41

- old
+ new

@@ -7,11 +7,10 @@ can :manage, [ Basket, CarrierTypeHasCheckoutType, CheckedItem, Checkin, - Checkout, CheckoutStatHasManifestation, CheckoutStatHasUser, CheckoutType, ItemHasUseRestriction, ManifestationCheckoutStat, @@ -21,10 +20,14 @@ ReserveStatHasUser, UserCheckoutStat, UserGroupHasCheckoutType, UserReserveStat ] + can [:read, :create, :update, :remove_all], Checkout + can :destroy, Checkout do |checkout| + checkout.checkin + end can [:read, :update], [ CirculationStatus, LendingPolicy, UseRestriction ] @@ -40,15 +43,18 @@ when 'Librarian' can :manage, [ Basket, CheckedItem, Checkin, - Checkout, ManifestationCheckoutStat, ManifestationReserveStat, Reserve ] + can [:read, :create, :update, :remove_all], Checkout + can :destroy, Checkout do |checkout| + checkout.checkin + end can [:read, :create, :update], UserCheckoutStat can [:read, :create, :update], UserReserveStat can :read, [ CarrierTypeHasCheckoutType, CheckoutType, @@ -70,11 +76,14 @@ can :destroy, Manifestation do |manifestation| manifestation.items.empty? and !manifestation.periodical_master? and !manifestation.is_reserved? end when 'User' can [:index, :create, :remove_all], Checkout - can [:show, :update, :destroy], Checkout do |checkout| + can [:show, :update], Checkout do |checkout| checkout.user == user + end + can :destroy, Checkout do |checkout| + checkout.user == user && checkout.checkin end can :index, Reserve can :create, Reserve do |reserve| user.user_number.present? end