[openstreetmap/openstreetmap-website] Automatically provide a language in diary entries factory (PR #7009)

Pablo Brasero notifications at github.com
Thu Apr 16 16:31:16 UTC 2026


@pablobm commented on this pull request.



> @@ -5,6 +5,7 @@
     sequence(:title) { |n| "Diary entry #{n}" }
     sequence(:body) { |n| "This is diary entry #{n}" }
 
+    language { Language.find_by(:code => "en") || create(:language, :code => "en") }

Hm, losing the factory feels a bit wrong. How about the following?

```suggestion
    language do
      Language.find_or_create_by(:code => "en") do |record|
        record.assign_attributes(attributes_for(:language))
      end
    end
```

Significantly more verbose though...

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

Message ID: <openstreetmap/openstreetmap-website/pull/7009/review/4122623850 at github.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstreetmap.org/pipermail/rails-dev/attachments/20260416/92cec4b2/attachment-0001.htm>


More information about the rails-dev mailing list