Top Level Namespace

Defined Under Namespace

Modules: ActiveModel, Decidim, Devise Classes: ComponentValidator, EtiquetteValidator, FileContentTypeValidator, GeocodingValidator, OrganizationPresentValidator, PassthruValidator, PasswordValidator, Premailer, ScopeBelongsToComponentValidator, TimeZoneValidator, TranslatablePresenceValidator, UploaderContentTypeValidator, UploaderImageDimensionsValidator, UrlValidator

Instance Method Summary collapse

Instance Method Details

#generate_component_name(locales, manifest_name, skip_injection: false) ⇒ Object



12
13
14
15
16
# File 'lib/decidim/core/test/factories.rb', line 12

def generate_component_name(locales, manifest_name, skip_injection: false)
  prepend = skip_injection ? "" : "<script>alert(\"#{manifest_name}\");</script>"

  Decidim::Components::Namer.new(locales, manifest_name).i18n_name.transform_values { |v| [prepend, v].compact_blank.join(" ") }
end

#generate_localized_description(field = nil, skip_injection: false, before: "<p>", after: "</p>") ⇒ Object



18
19
20
21
22
# File 'lib/decidim/core/test/factories.rb', line 18

def generate_localized_description(field = nil, skip_injection: false, before: "<p>", after: "</p>")
  Decidim::Faker::Localized.wrapped(before, after) do
    generate_localized_title(field, skip_injection:)
  end
end

#generate_localized_title(field = nil, skip_injection: false) ⇒ Object



35
36
37
38
39
40
41
42
43
44
45
# File 'lib/decidim/core/test/factories.rb', line 35

def generate_localized_title(field = nil, skip_injection: false)
  skip_injection = true if field.nil?

  Decidim::Faker::Localized.localized do
    if skip_injection
      generate(:title)
    else
      "<script>alert(\"#{field}\");</script> #{generate(:title)}"
    end
  end
end

#generate_localized_word(field = nil, skip_injection: false) ⇒ Object



24
25
26
27
28
29
30
31
32
33
# File 'lib/decidim/core/test/factories.rb', line 24

def generate_localized_word(field = nil, skip_injection: false)
  skip_injection = true if field.nil?
  Decidim::Faker::Localized.localized do
    if skip_injection
      Faker::Lorem.word
    else
      "<script>alert(\"#{field}\");</script> #{Faker::Lorem.word}"
    end
  end
end