Sha256: d89a4ab8ab5c035d343375214b35632b0291cc1e11fcc51aa46bb1697bfd634a

Contents?: true

Size: 1.59 KB

Versions: 24

Compression:

Stored size: 1.59 KB

Contents

# frozen_string_literal: true

require "decidim/faker/localized"
require "decidim/core/test/factories"
require "decidim/participatory_processes/test/factories"

FactoryBot.define do
  factory :sortition_component, parent: :component do
    name { Decidim::Components::Namer.new(participatory_space.organization.available_locales, :sortitions).i18n_name }
    manifest_name { :sortitions }
    participatory_space { create(:participatory_process, :with_steps, organization: organization) }
  end

  factory :sortition, class: "Decidim::Sortitions::Sortition" do
    component { create(:sortition_component) }
    decidim_proposals_component { create(:proposal_component, organization: component.organization) }

    title { generate_localized_title }
    author do
      create(:user, :admin, organization: component.organization) if component
    end

    dice { Faker::Number.between(1, 6).to_i }
    target_items { Faker::Number.between(1, 5).to_i }
    request_timestamp { Time.now.utc }
    witnesses { Decidim::Faker::Localized.wrapped("<p>", "</p>") { generate_localized_title } }
    additional_info { Decidim::Faker::Localized.wrapped("<p>", "</p>") { generate_localized_title } }
    selected_proposals { create_list(:proposal, target_items, component: decidim_proposals_component).pluck(:id) }
    candidate_proposals { selected_proposals }

    trait :cancelled do
      cancelled_on { Time.now.utc }
      cancel_reason { Decidim::Faker::Localized.wrapped("<p>", "</p>") { generate_localized_title } }
      cancelled_by_user { create(:user, :admin, organization: component.organization) if component }
    end
  end
end

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
decidim-sortitions-0.23.6 lib/decidim/sortitions/test/factories.rb
decidim-sortitions-0.23.5 lib/decidim/sortitions/test/factories.rb
decidim-sortitions-0.23.4 lib/decidim/sortitions/test/factories.rb
decidim-sortitions-0.23.3 lib/decidim/sortitions/test/factories.rb
decidim-sortitions-0.23.2 lib/decidim/sortitions/test/factories.rb
decidim-sortitions-0.23.1 lib/decidim/sortitions/test/factories.rb
decidim-sortitions-0.23.1.rc1 lib/decidim/sortitions/test/factories.rb
decidim-sortitions-0.23.0 lib/decidim/sortitions/test/factories.rb
decidim-sortitions-0.22.0 lib/decidim/sortitions/test/factories.rb
decidim-sortitions-0.21.0 lib/decidim/sortitions/test/factories.rb
decidim-sortitions-0.20.1 lib/decidim/sortitions/test/factories.rb
decidim-sortitions-0.20.0 lib/decidim/sortitions/test/factories.rb
decidim-sortitions-0.19.1 lib/decidim/sortitions/test/factories.rb
decidim-sortitions-0.18.1 lib/decidim/sortitions/test/factories.rb
decidim-sortitions-0.19.0 lib/decidim/sortitions/test/factories.rb
decidim-sortitions-0.17.2 lib/decidim/sortitions/test/factories.rb
decidim-sortitions-0.18.0 lib/decidim/sortitions/test/factories.rb
decidim-sortitions-0.17.1 lib/decidim/sortitions/test/factories.rb
decidim-sortitions-0.16.1 lib/decidim/sortitions/test/factories.rb
decidim-sortitions-0.17.0 lib/decidim/sortitions/test/factories.rb