Sha256: 3234c4b1699d8715981be6dc4e6e095cbcb0f70c09d5ac1219f51885481b4eae

Contents?: true

Size: 1.17 KB

Versions: 20

Compression:

Stored size: 1.17 KB

Contents

# frozen_string_literal: true

require "spec_helper"

describe Decidim::Budgets::CancelOrder do
  let(:user) { create(:user) }
  let(:feature) do
    create(
      :budget_feature,
      :with_total_budget_and_vote_threshold_percent,
      organization: user.organization
    )
  end
  let(:project) { create(:project, feature: feature, budget: 90_000_000) }
  let(:order) do
    order = create(:order, user: user, feature: feature)
    order.projects << project
    order.checked_out_at = Time.zone.now
    order.save!
    order
  end

  subject { described_class.new(order) }

  context "when everything is ok" do
    it "broadcasts ok" do
      expect { subject.call }.to broadcast(:ok)
    end

    it "destroys the order" do
      subject.call
      expect(Decidim::Budgets::Order.count).to eq(0)
    end
  end

  context "when the order is not present" do
    let(:order) { nil }

    it "broadcasts invalid" do
      expect { subject.call }.to broadcast(:invalid)
    end
  end

  context "when the order is not checked out" do
    let(:order) { create(:order, user: user, feature: feature) }

    it "broadcasts invalid" do
      expect { subject.call }.to broadcast(:invalid)
    end
  end
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
decidim-0.6.8 decidim-budgets/spec/commands/cancel_order_spec.rb
decidim-0.6.7 decidim-budgets/spec/commands/cancel_order_spec.rb
decidim-0.6.6 decidim-budgets/spec/commands/cancel_order_spec.rb
decidim-0.6.5 decidim-budgets/spec/commands/cancel_order_spec.rb
decidim-0.6.4 decidim-budgets/spec/commands/cancel_order_spec.rb
decidim-0.6.3 decidim-budgets/spec/commands/cancel_order_spec.rb
decidim-0.6.2 decidim-budgets/spec/commands/cancel_order_spec.rb
decidim-0.6.1 decidim-budgets/spec/commands/cancel_order_spec.rb
decidim-0.6.0 decidim-budgets/spec/commands/cancel_order_spec.rb
decidim-0.5.1 decidim-budgets/spec/commands/cancel_order_spec.rb
decidim-0.5.0 decidim-budgets/spec/commands/cancel_order_spec.rb
decidim-0.4.4 decidim-budgets/spec/commands/cancel_order_spec.rb
decidim-0.4.3 decidim-budgets/spec/commands/cancel_order_spec.rb
decidim-0.4.2 decidim-budgets/spec/commands/cancel_order_spec.rb
decidim-0.4.1 decidim-budgets/spec/commands/cancel_order_spec.rb
decidim-0.4.0 decidim-budgets/spec/commands/cancel_order_spec.rb
decidim-0.3.2 decidim-budgets/spec/commands/cancel_order_spec.rb
decidim-0.3.1 decidim-budgets/spec/commands/cancel_order_spec.rb
decidim-0.3.0 decidim-budgets/spec/commands/cancel_order_spec.rb
decidim-0.2.0 decidim-budgets/spec/commands/cancel_order_spec.rb