Files
nairobi/db/dev_seeds/sdg.rb
dependabot[bot] 21d39bac62 Bump rubocop-rails from 2.20.2 to 2.21.2
Bumps [rubocop-rails](https://github.com/rubocop/rubocop-rails) from 2.20.2 to 2.21.2.
- [Release notes](https://github.com/rubocop/rubocop-rails/releases)
- [Changelog](https://github.com/rubocop/rubocop-rails/blob/master/CHANGELOG.md)
- [Commits](https://github.com/rubocop/rubocop-rails/compare/v2.20.2...v2.21.2)

---
updated-dependencies:
- dependency-name: rubocop-rails
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Note version 2.21.0 relaxes the default `Include` path for
`Rails/FindEach`, and so this version can find and correct offenses
outside the `app/models/` folder [1].

Also note this version replaces `unless something.include?` with `if
something.exclude?`; since we don't use the `exclude?` method anywhere,
we're removing the `include?` method from the list of methods checked by
this cop.

Finally, the Rails/HttpStatus method now returns a false positive when
rendering a dashboard partial and passing the `status` variable. In
order to avoid this issue, we could change the name of the local
variable or move the partial to a component, but for now we're simply
excluding these files for this cop.

[1] https://github.com/rubocop/rubocop-rails/pull/1059/commits/0066b3505

Signed-off-by: dependabot[bot] <support@github.com>
2023-11-20 14:22:09 +01:00

40 lines
1.5 KiB
Ruby

section "Creating Sustainable Development Goals" do
load Rails.root.join("db", "sdg.rb")
SDG::Target.sample(30).each do |target|
title = "Title for default locale"
description = "Description for default locale"
rand(2..3).times do |n|
local_target = SDG::LocalTarget.create!(code: "#{target.code}.#{n + 1}",
title: title,
description: description,
target: target)
random_locales.map do |locale|
Globalize.with_locale(locale) do
local_target.title = "Title for locale #{locale}"
local_target.description = "Description for locale #{locale}"
local_target.save!
end
end
end
end
relatables = [Debate, Proposal, Poll, Legislation::Process, Budget::Investment]
relatables.map { |relatable| relatable.sample(5) }.flatten.each do |relatable|
Array(SDG::Goal.sample(rand(1..3))).each do |goal|
target = goal.targets.sample
local_target = target.local_targets.sample
relatable.sdg_goals << goal
relatable.sdg_targets << target
relatable.sdg_local_targets << local_target if local_target.present?
end
end
end
section "Creating SDG homepage cards" do
SDG::Phase.all.find_each do |phase|
Widget::Card.create!(cardable: phase, title: "#{phase.title} card",
link_text: "Link Text", link_url: "/any_path")
end
end