From 3aef307621607fb9881fea9980778ebc231773fb 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:11 +0000 Subject: [PATCH 1/2] Initial plan From a7f7e928730ebba217f428528cd50aad5a9ebf05 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 8 Apr 2026 12:38:08 +0000 Subject: [PATCH 2/2] Fix row class generation for labels containing slashes (e.g. USA/UAH) Agent-Logs-Url: https://github.com/activeadmin-plugins/capybara_active_admin/sessions/9bdfb67e-494b-4593-9e0f-2b41c37fbe56 Co-authored-by: senid231 <8393857+senid231@users.noreply.github.com> --- .../selectors/attributes_table.rb | 2 +- spec/lib/selectors/attributes_table_spec.rb | 25 +++++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 spec/lib/selectors/attributes_table_spec.rb diff --git a/lib/capybara/active_admin/selectors/attributes_table.rb b/lib/capybara/active_admin/selectors/attributes_table.rb index b1c2793..8f80925 100644 --- a/lib/capybara/active_admin/selectors/attributes_table.rb +++ b/lib/capybara/active_admin/selectors/attributes_table.rb @@ -18,7 +18,7 @@ def attributes_table_selector(model: nil, id: nil) def attributes_row_selector(label = nil) return 'tr.row > td' if label.nil? - label = label.to_s.gsub(' ', '_').downcase + label = label.to_s.gsub(/[\s\/]/, '_').downcase "tr.row.row-#{label} > td" end end diff --git a/spec/lib/selectors/attributes_table_spec.rb b/spec/lib/selectors/attributes_table_spec.rb new file mode 100644 index 0000000..181f883 --- /dev/null +++ b/spec/lib/selectors/attributes_table_spec.rb @@ -0,0 +1,25 @@ +# frozen_string_literal: true + +RSpec.describe Capybara::ActiveAdmin::Selectors::AttributesTable do + subject(:helper) do + Class.new { include Capybara::ActiveAdmin::Selectors::AttributesTable }.new + end + + describe '#attributes_row_selector' do + it 'returns a generic row selector when no label given' do + expect(helper.attributes_row_selector).to eq('tr.row > td') + end + + it 'builds selector from a simple label' do + expect(helper.attributes_row_selector('Full name')).to eq('tr.row.row-full_name > td') + end + + it 'replaces slash with underscore to match ActiveAdmin class generation' do + expect(helper.attributes_row_selector('USA/UAH')).to eq('tr.row.row-usa_uah > td') + end + + it 'replaces spaces and slashes with underscores' do + expect(helper.attributes_row_selector('A/B C')).to eq('tr.row.row-a_b_c > td') + end + end +end