Sha256: cdafe2c0d209356ce77badd0115146cf332cbc88b03b36dff0b8ad091fb2b7bf

Contents?: true

Size: 1.34 KB

Versions: 8

Compression:

Stored size: 1.34 KB

Contents

# frozen_string_literal: true

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

FactoryBot.define do
  factory :post_component, parent: :component do
    transient do
      skip_injection { false }
    end

    name { generate_component_name(participatory_space.organization.available_locales, :blogs, skip_injection:) }
    manifest_name { :blogs }
    participatory_space { create(:participatory_process, :with_steps, skip_injection:, organization:) }
  end

  factory :post, class: "Decidim::Blogs::Post" do
    transient do
      skip_injection { false }
    end

    title { generate_localized_title(:blog_title, skip_injection:) }
    body { generate_localized_description(:blog_body, skip_injection:) }
    component { build(:post_component, skip_injection:) }
    author { build(:user, :confirmed, skip_injection:, organization: component.organization) }

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

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
decidim-blogs-0.29.0 lib/decidim/blogs/test/factories.rb
decidim-blogs-0.28.3 lib/decidim/blogs/test/factories.rb
decidim-blogs-0.29.0.rc4 lib/decidim/blogs/test/factories.rb
decidim-blogs-0.29.0.rc3 lib/decidim/blogs/test/factories.rb
decidim-blogs-0.29.0.rc2 lib/decidim/blogs/test/factories.rb
decidim-blogs-0.29.0.rc1 lib/decidim/blogs/test/factories.rb
decidim-blogs-0.28.2 lib/decidim/blogs/test/factories.rb
decidim-blogs-0.28.1 lib/decidim/blogs/test/factories.rb