Sha256: 2f991ca1a16a68162d208c2c43129a426311673d800e21d9d813fb84126575c5

Contents?: true

Size: 1.64 KB

Versions: 8

Compression:

Stored size: 1.64 KB

Contents

# frozen_string_literal: true
require "decidim/faker/localized"
require "decidim/dev"

FactoryGirl.define do
  factory :budget_feature, parent: :feature do
    name { Decidim::Features::Namer.new(participatory_process.organization.available_locales, :budgets).i18n_name }
    manifest_name :budgets
    participatory_process { create(:participatory_process, :with_steps) }

    trait :with_total_budget_and_vote_threshold_percent do
      transient do
        total_budget 100_000_000
        vote_threshold_percent 70
      end

      settings do
        {
          total_budget: total_budget,
          vote_threshold_percent: vote_threshold_percent
        }
      end
    end

    trait :with_votes_disabled do
      step_settings do
        {
          participatory_process.active_step.id => {
            votes_enabled: false
          }
        }
      end
    end

    trait :with_show_votes_enabled do
      step_settings do
        {
          participatory_process.active_step.id => {
            show_votes: true
          }
        }
      end
    end
  end

  factory :project, class: Decidim::Budgets::Project do
    title { Decidim::Faker::Localized.sentence(3) }
    description { Decidim::Faker::Localized.wrapped("<p>", "</p>") { Decidim::Faker::Localized.sentence(4) } }
    budget { Faker::Number.number(8) }
    feature { create(:budget_feature) }
  end

  factory :order, class: Decidim::Budgets::Order do
    feature { create(:budget_feature) }
    user { create(:user, organization: feature.organization) }
  end

  factory :line_item, class: Decidim::Budgets::LineItem do
    order
    project { create(:project, feature: order.feature) }
  end
end

Version data entries

8 entries across 8 versions & 2 rubygems

Version Path
decidim-budgets-0.1.0 lib/decidim/budgets/test/factories.rb
decidim-0.1.0 decidim-budgets/lib/decidim/budgets/test/factories.rb
decidim-budgets-0.0.8.1 lib/decidim/budgets/test/factories.rb
decidim-0.0.8.1 decidim-budgets/lib/decidim/budgets/test/factories.rb
decidim-budgets-0.0.7 lib/decidim/budgets/test/factories.rb
decidim-0.0.7 decidim-budgets/lib/decidim/budgets/test/factories.rb
decidim-budgets-0.0.6 lib/decidim/budgets/test/factories.rb
decidim-0.0.6 decidim-budgets/lib/decidim/budgets/test/factories.rb