Sha256: 8a152a6faaec0f33afa578a67d37eaf6c4d0bee110120c7bf91aeea1ad94fffc

Contents?: true

Size: 833 Bytes

Versions: 43

Compression:

Stored size: 833 Bytes

Contents

# frozen_string_literal: true

require 'rails_helper'

module Spree
  RSpec.describe Spree::PromotionRule, type: :model do
    class BadTestRule < Spree::PromotionRule; end

    class TestRule < Spree::PromotionRule
      def eligible?(_promotable, _options = {})
        true
      end
    end

    it "forces developer to implement eligible? method" do
      expect { BadTestRule.new.eligible?("promotable") }.to raise_error NotImplementedError
    end

    it "validates unique rules for a promotion" do
      p1 = TestRule.new
      p1.promotion_id = 1
      p1.save

      p2 = TestRule.new
      p2.promotion_id = 1
      expect(p2).not_to be_valid
    end

    it "generates its own partial path" do
      rule = TestRule.new
      expect(rule.to_partial_path).to eq 'spree/admin/promotions/rules/test_rule'
    end
  end
end

Version data entries

43 entries across 43 versions & 2 rubygems

Version Path
solidus_core-2.8.1 spec/models/spree/promotion_rule_spec.rb
solidus_core-2.6.3 spec/models/spree/promotion_rule_spec.rb
solidus_core-2.8.0 spec/models/spree/promotion_rule_spec.rb
solidus_core-2.7.1 spec/models/spree/promotion_rule_spec.rb
solidus_core-2.6.2 spec/models/spree/promotion_rule_spec.rb
solidus_core_devise_token_auth-2.8.0.alpha.14 spec/models/spree/promotion_rule_spec.rb
solidus_core_devise_token_auth-2.8.0.alpha.13 spec/models/spree/promotion_rule_spec.rb
solidus_core_devise_token_auth-2.8.0.alpha.12 spec/models/spree/promotion_rule_spec.rb
solidus_core_devise_token_auth-2.8.0.alpha.11 spec/models/spree/promotion_rule_spec.rb
solidus_core_devise_token_auth-2.8.0.alpha.10 spec/models/spree/promotion_rule_spec.rb
solidus_core_devise_token_auth-2.8.0.alpha.9 spec/models/spree/promotion_rule_spec.rb
solidus_core_devise_token_auth-2.8.0.alpha.8 spec/models/spree/promotion_rule_spec.rb
solidus_core_devise_token_auth-2.8.0.alpha.7 spec/models/spree/promotion_rule_spec.rb
solidus_core_devise_token_auth-2.8.0.alpha.6 spec/models/spree/promotion_rule_spec.rb
solidus_core_devise_token_auth-2.8.0.alpha.5 spec/models/spree/promotion_rule_spec.rb
solidus_core_devise_token_auth-2.8.0.alpha.4 spec/models/spree/promotion_rule_spec.rb
solidus_core_devise_token_auth-2.8.0.alpha.3 spec/models/spree/promotion_rule_spec.rb
solidus_core_devise_token_auth-2.8.0.alpha.1 spec/models/spree/promotion_rule_spec.rb
solidus_core_devise_token_auth-2.8.0.alpha.0 spec/models/spree/promotion_rule_spec.rb
solidus_core-2.7.0 spec/models/spree/promotion_rule_spec.rb