[openstreetmap/openstreetmap-website] DB seed script (PR #6432)

Tom Hughes notifications at github.com
Thu Feb 5 19:04:57 UTC 2026


@tomhughes commented on this pull request.

In addition to the inline comments I think there's probably scope here for tidying up the commit history as there seem to be cases here where later commits are fixing up earlier ones?

> +
+def create_user(display_name:, password:, email:, admin: false)
+  user = User.find_or_create_by!(:display_name => display_name) do |record|
+    record.email = email
+    record.pass_crypt = password
+    record.pass_crypt_confirmation = password
+    record.tou_agreed = Time.now.utc
+    record.terms_seen = true
+    record.terms_agreed = Time.now.utc
+    record.email_valid = true
+    record.data_public = true
+  end
+
+  unless user.confirmed?
+    user.activate!
+    user.confirm!

Why are we confirming the users? That's not a normal step - most users are only activated and confirmation is something that only happens occasionally if an admin wants to override an automatic suspension.

> +  puts(
+    <<~MESSAGE
+      #{initial_line}:
+        - Display name: #{display_name}
+        - Email: #{email}
+        - Password: #{password}
+    MESSAGE
+  )
+end
+
+namespace "dev" do
+  desc "Populate the development database with some fake data"
+  task "populate" => :environment do
+    raise "This task can only be run in development mode" unless Rails.env.development?
+
+    require "active_support/testing/time_helpers"

Does this need to be here or could it be at the top level? It was you that moved other requires out of nested scopes in 3b5035461ffc83e20237239b32186dc0e4d97a9b after all ;-)

-- 
Reply to this email directly or view it on GitHub:
https://github.com/openstreetmap/openstreetmap-website/pull/6432#pullrequestreview-3758731823
You are receiving this because you are subscribed to this thread.

Message ID: <openstreetmap/openstreetmap-website/pull/6432/review/3758731823 at github.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstreetmap.org/pipermail/rails-dev/attachments/20260205/8ed285fa/attachment-0001.htm>


More information about the rails-dev mailing list