Files
nairobi/spec/components/admin/settings/table_component_spec.rb
Senén Rodero Rodríguez f8835debae 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.
2024-01-25 18:29:38 +01:00

55 lines
1.7 KiB
Ruby

require "rails_helper"
describe Admin::Settings::TableComponent do
describe "#key_header" do
it "returns correct table header for the setting name colums" do
render_inline Admin::Settings::TableComponent.new setting_name: "feature"
expect(page).to have_content("Feature")
render_inline Admin::Settings::TableComponent.new setting_name: "setting"
expect(page).to have_content("Setting")
render_inline Admin::Settings::TableComponent.new setting_name: "remote_census_general_name"
expect(page).to have_content("General Information")
render_inline Admin::Settings::TableComponent.new setting_name: "remote_census_request_name"
expect(page).to have_content("Request Data")
render_inline Admin::Settings::TableComponent.new setting_name: "remote_census_response_name"
expect(page).to have_content("Response Data")
end
end
describe "#value_header" do
it "returns correct table header for the setting interface column" do
render_inline Admin::Settings::TableComponent.new setting_name: "feature"
expect(page).to have_content("Enabled")
render_inline Admin::Settings::TableComponent.new setting_name: "setting"
expect(page).to have_content("Value")
end
end
describe "#table_class" do
it "returns the `mixed-settings-table` by default" do
render_inline Admin::Settings::TableComponent.new setting_name: "feature"
expect(page).to have_css(".mixed-settings-table")
end
it "returns the given table_class" do
render_inline Admin::Settings::TableComponent.new setting_name: "feature", table_class: "my-table-class"
expect(page).not_to have_css(".mixed-settings-table")
expect(page).to have_css(".my-table-class")
end
end
end