Move logic from key definition to views

Before this change, two important things depend on the format of each key,
where to render it in the administration panel and which kind of interface
to use for each setting. Following this strategy led us to a very complex
code, very difficult to maintain or modify. So, we do not want to depend
on the setting key structure anymore to decide how or where to render each
setting.

With this commit, we get rid of the key format-based rules. Now we render
each setting explicitly passing to it the type and the tab where it belongs.
This commit is contained in:
Senén Rodero Rodríguez
2023-12-07 17:06:42 +01:00
committed by Javi Martín
parent 91c3bde36b
commit f8835debae
19 changed files with 157 additions and 150 deletions

View File

@@ -27,15 +27,6 @@ describe Setting do
end
end
describe "#feature?" do
it "returns true if the key prefix is process, feature or sdg" do
expect(Setting.find_by!(key: "process.debates").feature?).to be true
expect(Setting.find_by!(key: "feature.map").feature?).to be true
expect(Setting.find_by!(key: "sdg.process.debates").feature?).to be true
expect(Setting.find_by!(key: "uploads.documents.max_size").feature?).to be false
end
end
describe "#enabled?" do
it "is true if value is present" do
setting = Setting.create!(key: "feature.whatever", value: 1)
@@ -57,16 +48,6 @@ describe Setting do
end
end
describe "#content_type?" do
it "returns true if the last part of the key is content_types" do
expect(Setting.create!(key: "key_name.content_types").content_type?).to be true
end
it "returns false if the last part of the key is not content_types" do
expect(Setting.create!(key: "key_name.whatever").content_type?).to be false
end
end
describe "#content_type_group" do
it "returns the group for content_types settings" do
images = Setting.create!(key: "update.images.content_types")