Sha256: 54ea5556c6ee77eb52b3d6eaa140ee48f0516849aca6bb80d9c729185b8e87a7

Contents?: true

Size: 1.83 KB

Versions: 10

Compression:

Stored size: 1.83 KB

Contents

# frozen_string_literal: true

def generate_localized_debate_title
  Decidim::Faker::Localized.localized { "<script>alert(\"TITLE\");</script> " + generate(:title) }
end

FactoryBot.define do
  factory :debate, class: "Decidim::Debates::Debate" do
    title { generate_localized_debate_title }
    description { Decidim::Faker::Localized.wrapped("<p>", "</p>") { generate_localized_debate_title } }
    information_updates { Decidim::Faker::Localized.wrapped("<p>", "</p>") { generate_localized_debate_title } }
    instructions { Decidim::Faker::Localized.wrapped("<p>", "</p>") { generate_localized_debate_title } }
    start_time { 1.day.from_now }
    end_time { start_time.advance(hours: 2) }
    component { build(:component, manifest_name: "debates") }
    author { component.try(:organization) }

    trait :open_ama do
      start_time { 1.day.ago }
      end_time { 1.day.from_now }
    end

    trait :with_author do
      author do
        build(:user, organization: component.organization) if component
      end
    end

    trait :with_user_group_author do
      author do
        build(:user, organization: component.organization) if component
      end
      user_group do
        build(:user_group, :verified, organization: component.organization, users: [author]) if component
      end
    end
  end

  factory :debates_component, parent: :component do
    name { Decidim::Components::Namer.new(participatory_space.organization.available_locales, :debates).i18n_name }
    manifest_name { :debates }
    participatory_space { create(:participatory_process, :with_steps, organization: organization) }
    settings do
      {
        comments_enabled: true
      }
    end

    trait :with_creation_enabled do
      step_settings do
        {
          participatory_space.active_step.id => { creation_enabled: true }
        }
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
decidim-debates-0.22.0 lib/decidim/debates/test/factories.rb
decidim-debates-0.21.0 lib/decidim/debates/test/factories.rb
decidim-debates-0.20.1 lib/decidim/debates/test/factories.rb
decidim-debates-0.20.0 lib/decidim/debates/test/factories.rb
decidim-debates-0.19.1 lib/decidim/debates/test/factories.rb
decidim-debates-0.18.1 lib/decidim/debates/test/factories.rb
decidim-debates-0.19.0 lib/decidim/debates/test/factories.rb
decidim-debates-0.17.2 lib/decidim/debates/test/factories.rb
decidim-debates-0.18.0 lib/decidim/debates/test/factories.rb
decidim-debates-0.17.1 lib/decidim/debates/test/factories.rb