Sha256: dda332531d96b8669a9b72ea94944b175bfde5c6a575b132da2ee27b3cf8d7cb

Contents?: true

Size: 1.09 KB

Versions: 12

Compression:

Stored size: 1.09 KB

Contents

# frozen_string_literal: true

require "spec_helper"

describe Decidim::Budgets::RemoveLineItem do
  let(:user) { create(:user) }

  let(:feature) do
    create(:budget_feature,
           organization: user.organization,
           settings: { "total_budget" => 100_000, "vote_threshold_percent": 50 })
  end

  let(:project) { create(:project, feature: feature, budget: 100) }

  let(:order) do
    order = create(:order, user: user, feature: feature)
    order.projects << project
    order.save!
    order
  end

  subject { described_class.new(order, project) }

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

    it "removes a line item from the order" do
      subject.call
      last_order = Decidim::Budgets::Order.last
      expect(last_order.line_items.collect(&:project)).to be_empty
    end
  end

  context "when the order is checked out" do
    before do
      order.update_attribute :checked_out_at, Time.current
    end

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

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
decidim-0.6.8 decidim-budgets/spec/commands/remove_line_item_spec.rb
decidim-0.6.7 decidim-budgets/spec/commands/remove_line_item_spec.rb
decidim-0.6.6 decidim-budgets/spec/commands/remove_line_item_spec.rb
decidim-0.6.5 decidim-budgets/spec/commands/remove_line_item_spec.rb
decidim-0.6.4 decidim-budgets/spec/commands/remove_line_item_spec.rb
decidim-0.6.3 decidim-budgets/spec/commands/remove_line_item_spec.rb
decidim-0.6.2 decidim-budgets/spec/commands/remove_line_item_spec.rb
decidim-0.6.1 decidim-budgets/spec/commands/remove_line_item_spec.rb
decidim-0.6.0 decidim-budgets/spec/commands/remove_line_item_spec.rb
decidim-0.5.1 decidim-budgets/spec/commands/remove_line_item_spec.rb
decidim-0.5.0 decidim-budgets/spec/commands/remove_line_item_spec.rb
decidim-0.4.4 decidim-budgets/spec/commands/remove_line_item_spec.rb