Skip to content

Commit

Permalink
DEV: Handle empty strings for small_links migration
Browse files Browse the repository at this point in the history
Follow up to 105b001
  • Loading branch information
tgxworld committed May 6, 2024
1 parent 105b001 commit 7c930d3
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
2 changes: 2 additions & 0 deletions migrations/settings/0003-migrate-small-links-setting.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ export default function migrate(settings, helpers) {
});

settings.set("small_links", newSmallLinks);
} else if (oldSmallLinks?.trim() === "") {
settings.set("small_links", []);
}

return settings;
Expand Down
13 changes: 13 additions & 0 deletions spec/migrations/0003_migrate_small_links_setting_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,19 @@
RSpec.describe "0003-migrate-small-links-setting migration" do
let!(:theme) { upload_theme_component }

it "should handle an empty string for old setting" do
theme.theme_settings.create!(
name: "small_links",
theme:,
data_type: ThemeSetting.types[:string],
value: " ",
)

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

expect(theme.settings[:small_links].value).to eq([])
end

it "should set target property to `_blank` if previous target component is not valid or empty" do
theme.theme_settings.create!(
name: "small_links",
Expand Down

0 comments on commit 7c930d3

Please sign in to comment.