Sha256: 28a3a1de89fc2bd35df0f0048326e6e44af160d6d7ba33184431bff7449fdf10

Contents?: true

Size: 1.13 KB

Versions: 15

Compression:

Stored size: 1.13 KB

Contents

# frozen_string_literal: true

FactoryBot.define do
  # Create as a sequence to avoid key collisions
  sequence :translation_key do |n|
    "#{::Faker::Lorem.words(rand(1..3)).join(".").downcase}.tr#{n}"
  end

  factory :translation_set, class: Decidim::TermCustomizer::TranslationSet do
    transient do
      organization { nil }
    end

    name do
      {
        en: generate(:title),
        fi: generate(:title),
        sv: generate(:title)
      }
    end

    after(:create) do |set, evaluator|
      if evaluator.organization
        set.constraints.create!(
          organization: evaluator.organization
        )
      end
    end
  end

  factory :translation, class: Decidim::TermCustomizer::Translation do
    locale { :en }
    key { generate(:translation_key) }
    value { ::Faker::Lorem.words(rand(1..10)).join(" ") }
    translation_set { create(:translation_set) }
  end

  factory :translation_set_constraint, class: Decidim::TermCustomizer::Constraint do
    organization { create(:organization) }
    translation_set { create(:translation_set) }
    subject { create(:participatory_process, organization: organization) }
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
decidim-term_customizer-0.23.0 lib/decidim/term_customizer/test/factories.rb
decidim-term_customizer-0.22.0 lib/decidim/term_customizer/test/factories.rb
decidim-term_customizer-0.21.0 lib/decidim/term_customizer/test/factories.rb
decidim-term_customizer-0.20.0 lib/decidim/term_customizer/test/factories.rb
decidim-term_customizer-0.19.1 lib/decidim/term_customizer/test/factories.rb
decidim-term_customizer-0.19.0 lib/decidim/term_customizer/test/factories.rb
decidim-term_customizer-0.18.0 lib/decidim/term_customizer/test/factories.rb
decidim-term_customizer-0.17.1 lib/decidim/term_customizer/test/factories.rb
decidim-term_customizer-0.17.0 lib/decidim/term_customizer/test/factories.rb
decidim-term_customizer-0.16.6 lib/decidim/term_customizer/test/factories.rb
decidim-term_customizer-0.16.5 lib/decidim/term_customizer/test/factories.rb
decidim-term_customizer-0.16.3 lib/decidim/term_customizer/test/factories.rb
decidim-term_customizer-0.16.2 lib/decidim/term_customizer/test/factories.rb
decidim-term_customizer-0.16.1 lib/decidim/term_customizer/test/factories.rb
decidim-term_customizer-0.16.0 lib/decidim/term_customizer/test/factories.rb