Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DEV: Handle empty strings for small_links migration #51

Merged
merged 1 commit into from
May 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading