Sha256: a9bc6753ad095cf976aae85177ba876dd21561acc3e3fe6816212ed1259c9a5b

Contents?: true

Size: 1.66 KB

Versions: 23

Compression:

Stored size: 1.66 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_space.organization.available_locales, :budgets).i18n_name }
    manifest_name :budgets
    participatory_space { create(:participatory_process, :with_steps, organization: organization) }

    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_space.active_step.id => {
            votes_enabled: false
          }
        }
      end
    end

    trait :with_show_votes_enabled do
      step_settings do
        {
          participatory_space.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

23 entries across 23 versions & 2 rubygems

Version Path
decidim-budgets-0.7.4 lib/decidim/budgets/test/factories.rb
decidim-budgets-0.7.3 lib/decidim/budgets/test/factories.rb
decidim-budgets-0.7.2 lib/decidim/budgets/test/factories.rb
decidim-budgets-0.7.1 lib/decidim/budgets/test/factories.rb
decidim-budgets-0.7.0 lib/decidim/budgets/test/factories.rb
decidim-budgets-0.6.8 lib/decidim/budgets/test/factories.rb
decidim-0.6.8 decidim-budgets/lib/decidim/budgets/test/factories.rb
decidim-budgets-0.6.7 lib/decidim/budgets/test/factories.rb
decidim-0.6.7 decidim-budgets/lib/decidim/budgets/test/factories.rb
decidim-budgets-0.6.6 lib/decidim/budgets/test/factories.rb
decidim-0.6.6 decidim-budgets/lib/decidim/budgets/test/factories.rb
decidim-budgets-0.6.5 lib/decidim/budgets/test/factories.rb
decidim-0.6.5 decidim-budgets/lib/decidim/budgets/test/factories.rb
decidim-budgets-0.6.4 lib/decidim/budgets/test/factories.rb
decidim-0.6.4 decidim-budgets/lib/decidim/budgets/test/factories.rb
decidim-budgets-0.6.3 lib/decidim/budgets/test/factories.rb
decidim-0.6.3 decidim-budgets/lib/decidim/budgets/test/factories.rb
decidim-budgets-0.6.2 lib/decidim/budgets/test/factories.rb
decidim-0.6.2 decidim-budgets/lib/decidim/budgets/test/factories.rb
decidim-budgets-0.6.1 lib/decidim/budgets/test/factories.rb