Sha256: 6678c31c6c7c429b076ca16861cab2bde02925f544fe8ce80ad5222c9c3780c0
Contents?: true
Size: 1.7 KB
Versions: 2
Compression:
Stored size: 1.7 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:) } trait :with_endorsements_enabled do step_settings do { participatory_space.active_step.id => { endorsements_enabled: true } } end end trait :with_endorsements_disabled do step_settings do { participatory_space.active_step.id => { endorsements_enabled: false } } end end 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
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
decidim-blogs-0.29.1 | lib/decidim/blogs/test/factories.rb |
decidim-blogs-0.28.4 | lib/decidim/blogs/test/factories.rb |