lib/decidim/debates/test/factories.rb in decidim-debates-0.27.5 vs lib/decidim/debates/test/factories.rb in decidim-debates-0.27.6
- old
+ new
@@ -8,21 +8,15 @@
factory :debate, class: "Decidim::Debates::Debate" do
transient do
skip_injection { false }
end
- title do
- if skip_injection
- Decidim::Faker::Localized.localized { generate(:title) }
- else
- Decidim::Faker::Localized.localized { "<script>alert(\"TITLE\");</script> #{generate(:title)}" }
- end
- end
- 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 } }
- component { build(:debates_component) }
+ title { generate_localized_title(:debate_title, skip_injection: skip_injection) }
+ description { generate_localized_description(:debate_description, skip_injection: skip_injection) }
+ information_updates { generate_localized_description(:debate_information_updates, skip_injection: skip_injection) }
+ instructions { generate_localized_description(:debate_instructions, skip_injection: skip_injection) }
+ component { build(:debates_component, skip_injection: skip_injection) }
author { component.try(:organization) }
trait :open_ama do
start_time { 1.day.ago }
end_time { 1.day.from_now }
@@ -30,42 +24,45 @@
trait :participant_author do
start_time { nil }
end_time { nil }
author do
- build(:user, organization: component.organization) if component
+ build(:user, organization: component.organization, skip_injection: skip_injection) if component
end
end
trait :official do
author { component.try(:organization) }
end
trait :user_group_author do
author do
- create(:user, organization: component.organization) if component
+ create(:user, organization: component.organization, skip_injection: skip_injection) if component
end
user_group do
- create(:user_group, :verified, organization: component.organization, users: [author]) if component
+ create(:user_group, :verified, organization: component.organization, users: [author], skip_injection: skip_injection) if component
end
end
trait :closed do
closed_at { Time.current }
- conclusions { Decidim::Faker::Localized.wrapped("<p>", "</p>") { generate_localized_debate_title } }
+ conclusions { generate_localized_description(:debate_conclusions, skip_injection: skip_injection) }
end
after(:build) do |debate|
debate.title = Decidim::ContentProcessor.parse_with_processor(:hashtag, debate.title, current_organization: debate.organization).rewrite
debate.description = Decidim::ContentProcessor.parse_with_processor(:hashtag, debate.description, current_organization: debate.organization).rewrite
end
end
factory :debates_component, parent: :component do
- name { Decidim::Components::Namer.new(participatory_space.organization.available_locales, :debates).i18n_name }
+ transient do
+ skip_injection { false }
+ end
+ name { generate_component_name(participatory_space.organization.available_locales, :debates, skip_injection: skip_injection) }
manifest_name { :debates }
- participatory_space { create(:participatory_process, :with_steps, organization: organization) }
+ participatory_space { create(:participatory_process, :with_steps, organization: organization, skip_injection: skip_injection) }
settings do
{
comments_enabled: true,
comments_max_length: organization.comments_max_length
}