DEV: Refactor Theme#settings to return a hash instead of array (#25516)

Why this change?

Returning an array makes it hard to immediately retrieve a setting by
name and makes the retrieval an O(N) operation. By returning an array,
we make it easier for us to lookup a setting by name and retrieval is
O(1) as well.
This commit is contained in:
Alan Guo Xiang Tan
2024-02-01 10:26:56 +08:00
committed by GitHub
parent fb469e7e2f
commit 44f8418093
5 changed files with 36 additions and 38 deletions

View File

@@ -198,7 +198,7 @@ RSpec.describe RemoteTheme do
expect(mapped.length).to eq(12)
expect(theme.settings.length).to eq(1)
expect(theme.settings.first.value).to eq(true)
expect(theme.settings[:boolean_setting].value).to eq(true)
expect(remote.remote_updated_at).to eq_time(time)
@@ -247,7 +247,7 @@ RSpec.describe RemoteTheme do
expect(mapped["1-scss"]).to eq(scss_data)
expect(theme.settings.length).to eq(1)
expect(theme.settings.first.value).to eq(32)
expect(theme.settings[:integer_setting].value).to eq(32)
expect(remote.remote_updated_at).to eq_time(time)
expect(remote.about_url).to eq("https://newsite.com/about")