Sha256: 233e86e6eb4c48246124b95859f93203cb6fec915e15253a8a9dbb909ffb68e1
Contents?: true
Size: 976 Bytes
Versions: 5
Compression:
Stored size: 976 Bytes
Contents
# frozen_string_literal: true 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.present? end can :create, Spree::FeedbackReview do |_review| review_ability_class.allow_anonymous_reviews? || user.email.present? end # You can only change your own feedback_review can [:update, :destroy], Spree::FeedbackReview do |feedback_review| feedback_review.user == user end # You can read your own reviews, and everyone can read approved ones can :read, Spree::Review do |review| review.user == user || review.approved? end # You can only change your own review can [:update, :destroy], Spree::Review do |review| review.user == user end end def self.allow_anonymous_reviews? !Spree::Reviews::Config[:require_login] end end
Version data entries
5 entries across 5 versions & 1 rubygems