Sha256: d1174977db43beb36b1559d935f4a3fbfea6f3900284a1cb7f4000d5c62c0aab

Contents?: true

Size: 1.03 KB

Versions: 42

Compression:

Stored size: 1.03 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 :post_component, parent: :component do
    name { Decidim::Components::Namer.new(participatory_space.organization.available_locales, :blogs).i18n_name }
    manifest_name { :blogs }
    participatory_space { create(:participatory_process, :with_steps, organization: organization) }
  end

  factory :post, class: "Decidim::Blogs::Post" do
    title { generate_localized_title }
    body { Decidim::Faker::Localized.wrapped("<p>", "</p>") { generate_localized_title } }
    component { build(:component, manifest_name: "blogs") }
    author { build(:user, :confirmed, organization: component.organization) }

    trait :with_endorsements do
      after :create do |post|
        5.times.collect do
          create(:endorsement, resource: post, author: build(:user, organization: post.participatory_space.organization))
        end
      end
    end
  end
end

Version data entries

42 entries across 42 versions & 1 rubygems

Version Path
decidim-blogs-0.23.0 lib/decidim/blogs/test/factories.rb
decidim-blogs-0.22.0 lib/decidim/blogs/test/factories.rb