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:
committed by
Javi Martín
parent
91c3bde36b
commit
f8835debae
@@ -2,24 +2,18 @@ require "rails_helper"
|
||||
|
||||
describe "Admin settings", :admin do
|
||||
scenario "Index" do
|
||||
create(:setting, key: "super.users.first")
|
||||
create(:setting, key: "super.users.second")
|
||||
create(:setting, key: "super.users.third")
|
||||
|
||||
visit admin_settings_path
|
||||
|
||||
expect(page).to have_content "First"
|
||||
expect(page).to have_content "Second"
|
||||
expect(page).to have_content "Third"
|
||||
expect(page).to have_content "Level 1 public official"
|
||||
expect(page).to have_content "Maximum ratio of anonymous votes per Debate"
|
||||
expect(page).to have_content "Comments body max length"
|
||||
end
|
||||
|
||||
scenario "Update" do
|
||||
create(:setting, key: "super.users.first")
|
||||
|
||||
visit admin_settings_path
|
||||
|
||||
within "tr", text: "First" do
|
||||
fill_in "First", with: "Super Users of level 1"
|
||||
within "tr", text: "Level 1 public official" do
|
||||
fill_in "Level 1 public official", with: "Super Users of level 1"
|
||||
click_button "Update"
|
||||
end
|
||||
|
||||
@@ -173,13 +167,11 @@ describe "Admin settings", :admin do
|
||||
end
|
||||
|
||||
scenario "On #tab-remote-census-configuration" do
|
||||
create(:setting, key: "remote_census.general.whatever")
|
||||
|
||||
visit admin_settings_path
|
||||
find("#remote-census-tab").click
|
||||
|
||||
within "tr", text: "Whatever" do
|
||||
fill_in "Whatever", with: "New value"
|
||||
within "tr", text: "Endpoint" do
|
||||
fill_in "Endpoint", with: "example.org/webservice"
|
||||
click_button "Update"
|
||||
end
|
||||
|
||||
@@ -189,13 +181,10 @@ describe "Admin settings", :admin do
|
||||
end
|
||||
|
||||
scenario "On #tab-configuration" do
|
||||
Setting.create!(key: "whatever")
|
||||
|
||||
visit admin_settings_path
|
||||
find("#tab-configuration").click
|
||||
|
||||
within "tr", text: "Whatever" do
|
||||
fill_in "Whatever", with: "New value"
|
||||
within "tr", text: "Level 1 public official" do
|
||||
fill_in "Level 1 public official", with: "Super Users of level 1"
|
||||
click_button "Update"
|
||||
end
|
||||
|
||||
@@ -209,13 +198,11 @@ describe "Admin settings", :admin do
|
||||
end
|
||||
|
||||
scenario "On #tab-map-configuration" do
|
||||
Setting.create!(key: "map.whatever")
|
||||
|
||||
visit admin_settings_path
|
||||
click_link "Map configuration"
|
||||
|
||||
within "tr", text: "Whatever" do
|
||||
fill_in "Whatever", with: "New value"
|
||||
within "tr", text: "Latitude" do
|
||||
fill_in "Latitude", with: "-3.636"
|
||||
click_button "Update"
|
||||
end
|
||||
|
||||
@@ -236,13 +223,11 @@ describe "Admin settings", :admin do
|
||||
end
|
||||
|
||||
scenario "On #tab-proposals" do
|
||||
Setting.create!(key: "proposals.whatever")
|
||||
|
||||
visit admin_settings_path
|
||||
find("#proposals-tab").click
|
||||
|
||||
within "tr", text: "Whatever" do
|
||||
fill_in "Whatever", with: "New value"
|
||||
within "tr", text: "Polls description" do
|
||||
fill_in "Polls description", with: "Polls description"
|
||||
click_button "Update"
|
||||
end
|
||||
|
||||
@@ -251,22 +236,18 @@ describe "Admin settings", :admin do
|
||||
end
|
||||
|
||||
scenario "On #tab-participation-processes" do
|
||||
Setting.create!(key: "process.whatever")
|
||||
|
||||
visit admin_settings_path
|
||||
find("#participation-processes-tab").click
|
||||
within("tr", text: "Whatever") { click_button "No" }
|
||||
within("tr", text: "Debates") { click_button "Yes" }
|
||||
|
||||
expect(page).to have_current_path(admin_settings_path)
|
||||
expect(page).to have_css("div#tab-participation-processes.is-active")
|
||||
end
|
||||
|
||||
scenario "On #tab-feature-flags" do
|
||||
Setting.create!(key: "feature.whatever")
|
||||
|
||||
visit admin_settings_path
|
||||
find("#features-tab").click
|
||||
within("tr", text: "Whatever") { click_button "No" }
|
||||
within("tr", text: "Featured proposals") { click_button "No" }
|
||||
|
||||
expect(page).to have_current_path(admin_settings_path)
|
||||
expect(page).to have_css("div#tab-feature-flags.is-active")
|
||||
@@ -274,15 +255,13 @@ describe "Admin settings", :admin do
|
||||
|
||||
scenario "On #tab-sdg-configuration" do
|
||||
Setting["feature.sdg"] = true
|
||||
Setting.create!(key: "sdg.whatever")
|
||||
|
||||
visit admin_settings_path
|
||||
click_link "SDG configuration"
|
||||
|
||||
within("tr", text: "Whatever") do
|
||||
click_button "No"
|
||||
within("tr", text: "Related SDG in debates") do
|
||||
click_button "Yes"
|
||||
|
||||
expect(page).to have_button "Yes"
|
||||
expect(page).to have_button "No"
|
||||
end
|
||||
|
||||
expect(page).to have_current_path(admin_settings_path)
|
||||
|
||||
Reference in New Issue
Block a user