Sha256: d58abf0c7d3dc2607c5ff19ddbc16a517d8e9d829a02e0a3e2e2f19fd4e426f0

Contents?: true

Size: 1.24 KB

Versions: 20

Compression:

Stored size: 1.24 KB

Contents

# frozen_string_literal: true

require "spec_helper"

describe Decidim::Budgets::Checkout 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.save!
    order
  end

  let(:current_order) { order }

  subject { described_class.new(current_order, feature) }

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

    it "sets the checked out at" do
      subject.call
      order.reload
      expect(order.checked_out_at).not_to be_nil
    end
  end

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

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

  context "when the order total budget doesn't exceed the threshold" do
    let(:project) { create(:project, feature: feature, budget: 30_000_000) }

    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/checkout_spec.rb
decidim-0.6.7 decidim-budgets/spec/commands/checkout_spec.rb
decidim-0.6.6 decidim-budgets/spec/commands/checkout_spec.rb
decidim-0.6.5 decidim-budgets/spec/commands/checkout_spec.rb
decidim-0.6.4 decidim-budgets/spec/commands/checkout_spec.rb
decidim-0.6.3 decidim-budgets/spec/commands/checkout_spec.rb
decidim-0.6.2 decidim-budgets/spec/commands/checkout_spec.rb
decidim-0.6.1 decidim-budgets/spec/commands/checkout_spec.rb
decidim-0.6.0 decidim-budgets/spec/commands/checkout_spec.rb
decidim-0.5.1 decidim-budgets/spec/commands/checkout_spec.rb
decidim-0.5.0 decidim-budgets/spec/commands/checkout_spec.rb
decidim-0.4.4 decidim-budgets/spec/commands/checkout_spec.rb
decidim-0.4.3 decidim-budgets/spec/commands/checkout_spec.rb
decidim-0.4.2 decidim-budgets/spec/commands/checkout_spec.rb
decidim-0.4.1 decidim-budgets/spec/commands/checkout_spec.rb
decidim-0.4.0 decidim-budgets/spec/commands/checkout_spec.rb
decidim-0.3.2 decidim-budgets/spec/commands/checkout_spec.rb
decidim-0.3.1 decidim-budgets/spec/commands/checkout_spec.rb
decidim-0.3.0 decidim-budgets/spec/commands/checkout_spec.rb
decidim-0.2.0 decidim-budgets/spec/commands/checkout_spec.rb