From 59b7feff1296efc8e7a7e00117e5230a2665f3b7 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 8 Apr 2026 12:25:25 +0000 Subject: [PATCH 1/3] Initial plan From 16b9d666eb712d6addb5e0a423cbd8ce4d54ddb6 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 8 Apr 2026 12:44:19 +0000 Subject: [PATCH 2/3] Fix table_cell_selector to strip special characters like slashes from column names Agent-Logs-Url: https://github.com/activeadmin-plugins/capybara_active_admin/sessions/7498bf2c-1012-4f45-a573-e5f8a7124f08 Co-authored-by: senid231 <8393857+senid231@users.noreply.github.com> --- lib/capybara/active_admin/selectors/table.rb | 2 +- spec/lib/selectors/table_spec.rb | 29 ++++++++++++++++++++ 2 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 spec/lib/selectors/table_spec.rb diff --git a/lib/capybara/active_admin/selectors/table.rb b/lib/capybara/active_admin/selectors/table.rb index 10b84da..07d047f 100644 --- a/lib/capybara/active_admin/selectors/table.rb +++ b/lib/capybara/active_admin/selectors/table.rb @@ -32,7 +32,7 @@ def table_header_selector def table_cell_selector(column = nil) return 'td.col' if column.nil? - column = column.to_s.gsub(' ', '_').downcase + column = column.to_s.downcase.gsub(/[^a-z0-9\s]/, '').gsub(/\s+/, '_').squeeze('_') "td.col.col-#{column}" end diff --git a/spec/lib/selectors/table_spec.rb b/spec/lib/selectors/table_spec.rb new file mode 100644 index 0000000..8001bdd --- /dev/null +++ b/spec/lib/selectors/table_spec.rb @@ -0,0 +1,29 @@ +# frozen_string_literal: true + +RSpec.describe Capybara::ActiveAdmin::Selectors::Table do + subject(:helper) do + Class.new { include Capybara::ActiveAdmin::Selectors::Table }.new + end + + describe '#table_cell_selector' do + it 'returns generic selector when column is nil' do + expect(helper.table_cell_selector).to eq('td.col') + end + + it 'converts spaces to underscores' do + expect(helper.table_cell_selector('Full Name')).to eq('td.col.col-full_name') + end + + it 'downcases the column name' do + expect(helper.table_cell_selector('ID')).to eq('td.col.col-id') + end + + it 'strips slashes from column name' do + expect(helper.table_cell_selector('Country / Region')).to eq('td.col.col-country_region') + end + + it 'strips other special characters from column name' do + expect(helper.table_cell_selector('Price (USD)')).to eq('td.col.col-price_usd') + end + end +end From 6e4ecc56a5ded0d072f198be53c8038660366fd2 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 8 Apr 2026 12:46:01 +0000 Subject: [PATCH 3/3] Add clarifying comment to table_cell_selector transformation Agent-Logs-Url: https://github.com/activeadmin-plugins/capybara_active_admin/sessions/7498bf2c-1012-4f45-a573-e5f8a7124f08 Co-authored-by: senid231 <8393857+senid231@users.noreply.github.com> --- lib/capybara/active_admin/selectors/table.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/capybara/active_admin/selectors/table.rb b/lib/capybara/active_admin/selectors/table.rb index 07d047f..170bfa4 100644 --- a/lib/capybara/active_admin/selectors/table.rb +++ b/lib/capybara/active_admin/selectors/table.rb @@ -32,6 +32,7 @@ def table_header_selector def table_cell_selector(column = nil) return 'td.col' if column.nil? + # Downcase, strip non-alphanumeric chars (e.g. '/'), convert spaces to '_', deduplicate '_' column = column.to_s.downcase.gsub(/[^a-z0-9\s]/, '').gsub(/\s+/, '_').squeeze('_') "td.col.col-#{column}" end