Sha256: f1ca52db781a23b95fe664396942efa25a007ab518d8ed57a2ec554d357261ee

Contents?: true

Size: 470 Bytes

Versions: 3

Compression:

Stored size: 470 Bytes

Contents

class Spree::ReviewsAbility
  include CanCan::Ability

  def initialize user
    review_ability_class = self.class
    can :create, Spree::Review do |review|
      review_ability_class.allow_anonymous_reviews? || !user.email.blank?
    end
    can :create, Spree::FeedbackReview do |review|
      review_ability_class.allow_anonymous_reviews? || !user.email.blank?
    end
  end

  def self.allow_anonymous_reviews?
    !Spree::Reviews::Config[:require_login]
  end
end

Version data entries

3 entries across 3 versions & 2 rubygems

Version Path
solidus_reviews-1.0.0 app/models/spree/reviews_ability.rb
jiffyshirts_spree_reviews-2.3.1.2 app/models/spree/reviews_ability.rb
jiffyshirts_spree_reviews-2.3.1.1 app/models/spree/reviews_ability.rb