discourse/app
Alan Guo Xiang Tan 243fcb6ffc
DEV: Introduce run_theme_migration spec helper in test environment (#26845)
This commit introduces the `run_theme_migration` spec helper to allow
theme developers to write RSpec tests for theme migrations. For example,
this allows the following RSpec test to be written in themes:

```
RSpec.describe "0003-migrate-small-links-setting migration" do
  let!(:theme) { upload_theme_component }

  it "should set target property to `_blank` if previous target component is not valid or empty" do
    theme.theme_settings.create!(
      name: "small_links",
      theme: theme,
      data_type: ThemeSetting.types[:string],
      value: "some text, #|some text 2, #, invalid target",
    )

    run_theme_migration(theme, "0003-migrate-small-links-setting")

    expect(theme.settings[:small_links].value).to eq(
      [
        { "text" => "some text", "url" => "#", "target" => "_blank" },
        { "text" => "some text 2", "url" => "#", "target" => "_blank" },
      ],
    )
  end
end
```

This change is being introduced because we realised that writting just
javascript tests for the migrations is insufficient since javascript
tests do not ensure that the migrated theme settings can actually be
successfully saved into the database. Hence, we are introduce this
helper as a way for theme developers to write "end-to-end" migrations
tests.
2024-05-03 06:29:18 +08:00
..
assets DEV: Improve built-in browser performance marks/measurements (#26758) 2024-05-02 23:07:36 +01:00
controllers DEV: Use safer SQL function for string queries when searching groups (#26851) 2024-05-02 13:41:49 -05:00
helpers FIX: Include HTML content for authenticated users with crawler UA (#26757) 2024-04-25 22:41:57 +01:00
jobs FIX: Better tracking of topic visibility changes (#26709) 2024-04-29 10:34:46 +10:00
mailers FIX: Correctly re-attach allowed images in activity summary e-mail (#26642) 2024-04-18 10:27:46 +08:00
models DEV: Introduce run_theme_migration spec helper in test environment (#26845) 2024-05-03 06:29:18 +08:00
serializers DEV: Add more structure for admin plugin config nav (#26707) 2024-05-02 11:36:46 +10:00
services DEV: Introduce run_theme_migration spec helper in test environment (#26845) 2024-05-03 06:29:18 +08:00
views FEATURE: Add experimental tracking of 'real browser' pageviews (#26647) 2024-04-25 11:00:01 +01:00