Sha256: fac70ba70459e2b2231ef0e8ad122c660d936729577843370bbfd6e37ea9681e

Contents?: true

Size: 1.56 KB

Versions: 9

Compression:

Stored size: 1.56 KB

Contents

# frozen_string_literal: true

require "spec_helper"

describe Decidim::Budgets::Project do
  let(:project) { create :project }
  subject { project }

  include_examples "has reference"

  it { is_expected.to be_valid }

  context "without a feature" do
    let(:project) { build :project, feature: nil }

    it { is_expected.not_to be_valid }
  end

  context "when the scope is from another organization" do
    let(:scope) { create :scope }
    let(:project) { build :project, scope: scope }

    it { is_expected.not_to be_valid }
  end

  context "when the category is from another organization" do
    let(:category) { create :category }
    let(:project) { build :project, category: category }

    it { is_expected.not_to be_valid }
  end

  context "#orders_count" do
    let(:project) { create :project, budget: 75_000_000 }
    let(:order) { create :order, feature: project.feature }
    let(:unfinished_order) { create :order, feature: project.feature }
    let!(:line_item) { create :line_item, project: project, order: order }
    let!(:line_item_1) { create :line_item, project: project, order: unfinished_order }

    it "return number of finished orders for this project" do
      order.reload.update_attributes!(checked_out_at: Time.current)
      expect(project.confirmed_orders_count).to eq(1)
    end
  end

  describe "#users_to_notify_on_comment_created" do
    let!(:follows) { create_list(:follow, 3, followable: subject) }

    it "returns the followers" do
      expect(subject.users_to_notify_on_comment_created).to match_array(follows.map(&:user))
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
decidim-0.6.8 decidim-budgets/spec/models/project_spec.rb
decidim-0.6.7 decidim-budgets/spec/models/project_spec.rb
decidim-0.6.6 decidim-budgets/spec/models/project_spec.rb
decidim-0.6.5 decidim-budgets/spec/models/project_spec.rb
decidim-0.6.4 decidim-budgets/spec/models/project_spec.rb
decidim-0.6.3 decidim-budgets/spec/models/project_spec.rb
decidim-0.6.2 decidim-budgets/spec/models/project_spec.rb
decidim-0.6.1 decidim-budgets/spec/models/project_spec.rb
decidim-0.6.0 decidim-budgets/spec/models/project_spec.rb