discourse/spec/support
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
..
versioning
bookmarkable_helper.rb
common_basic_reviewable_serializer.rb
concurrency.rb DEV: Fix various rubocop lints (#24749) 2023-12-06 23:25:00 +01:00
diagnostics_helper.rb
discourse_event_helper.rb
dom_matcher.rb
dummy_custom_summarization.rb FEATURE: Prefer topic_embed's cached content when summarizing (#25190) 2024-01-09 14:00:01 -03:00
fake_bookmark_hashtag_data_source.rb
fake_logger.rb DEV: Fix Lint/DuplicateMethods (#24746) 2023-12-06 13:18:34 +01:00
fake_s3.rb
fast_image_helpers.rb
final_destination_helper.rb
helpers.rb DEV: Introduce `run_theme_migration` spec helper in test environment (#26845) 2024-05-03 06:29:18 +08:00
imap_helper.rb DEV: lint against Layout/EmptyLineBetweenDefs (#24914) 2023-12-15 23:46:04 +08:00
integration_helpers.rb
match_html_matcher.rb
mock_git_importer.rb
negated_matcher.rb
onebox_helpers.rb
problem_check_matcher.rb DEV: Move non scheduled problem checks to classes (#26122) 2024-03-14 10:55:01 +08:00
rate_limit_matcher.rb
sample_plugin_site_settings.yml FIX: Sort plugins by their setting category name (#25128) 2024-01-08 09:57:25 +10:00
service_matchers.rb DEV: Move chat service objects into core (#26506) 2024-04-04 10:57:41 -03:00
shared_examples_for_custom_fields.rb
shared_examples_for_stats_cacheable.rb
sidekiq_helpers.rb
site_settings_helpers.rb
system_helpers.rb DEV: Introduce `run_theme_migration` spec helper in test environment (#26845) 2024-05-03 06:29:18 +08:00
test_second_factor_action.rb
time_matcher.rb
topic_guardian_can_see_consistency_check.rb
ts_vector_matcher.rb
uploads_helpers.rb
user_sidebar_serializer_attributes.rb
webauthn_integration_helpers.rb