From 234f73e7a00ed0804fbaae8ebaa61c9c7a97e1f1 Mon Sep 17 00:00:00 2001 From: Martin Meyerhoff Date: Thu, 2 Nov 2023 13:57:19 +0100 Subject: [PATCH] Add a null promotion handler This class is useful for satisfying Solidus' need for a shipping promotion handler. With SolidusFriendlyPromotions, shipping promotions are handled just like other promotions, so we don't need to do anything here. --- .../promotion_handler/null.rb | 20 +++++++++++++++++++ .../promotion_handler/null_spec.rb | 14 +++++++++++++ 2 files changed, 34 insertions(+) create mode 100644 promotions/app/models/solidus_friendly_promotions/promotion_handler/null.rb create mode 100644 promotions/spec/models/solidus_friendly_promotions/promotion_handler/null_spec.rb diff --git a/promotions/app/models/solidus_friendly_promotions/promotion_handler/null.rb b/promotions/app/models/solidus_friendly_promotions/promotion_handler/null.rb new file mode 100644 index 00000000..5b2cf29a --- /dev/null +++ b/promotions/app/models/solidus_friendly_promotions/promotion_handler/null.rb @@ -0,0 +1,20 @@ +# frozen_string_literal: true + +module SolidusFriendlyPromotions + module PromotionHandler + # We handle shipping promotions just like other promotions, so we don't need a + # special promotion handler for shipping. However, Solidus wants us to implement one. + # This is what this class is for. + class Null + attr_reader :order + attr_accessor :error, :success + + def initialize(order) + @order = order + end + + def activate + end + end + end +end diff --git a/promotions/spec/models/solidus_friendly_promotions/promotion_handler/null_spec.rb b/promotions/spec/models/solidus_friendly_promotions/promotion_handler/null_spec.rb new file mode 100644 index 00000000..280c30aa --- /dev/null +++ b/promotions/spec/models/solidus_friendly_promotions/promotion_handler/null_spec.rb @@ -0,0 +1,14 @@ +# frozen_string_literal: true + +require "spec_helper" + +RSpec.describe SolidusFriendlyPromotions::PromotionHandler::Null do + let(:order) { double } + + subject { described_class.new(order) } + + it { is_expected.to respond_to(:order) } + it { is_expected.to respond_to(:error) } + it { is_expected.to respond_to(:success) } + it { is_expected.to respond_to(:activate) } +end