rs-activeadmin-searchable_select 4.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.actrc +20 -0
- data/.claude/commands/fix-tests.md +203 -0
- data/.github/workflows/ci.yml +170 -0
- data/.github/workflows/npm-publish.yml +47 -0
- data/.gitignore +27 -0
- data/.npmignore +58 -0
- data/.rspec +2 -0
- data/.rubocop.yml +67 -0
- data/.yardopts +2 -0
- data/AGENTS.md +39 -0
- data/Appraisals +15 -0
- data/CHANGELOG.md +24 -0
- data/CLAUDE.md +104 -0
- data/Gemfile +11 -0
- data/Gemfile.lock +366 -0
- data/LICENSE.txt +25 -0
- data/README.md +439 -0
- data/Rakefile +4 -0
- data/bin/rspec +17 -0
- data/config/database.yml +16 -0
- data/config.ru +28 -0
- data/docs/activeadmin-4-detailed-reference.md +932 -0
- data/docs/activeadmin-4-gem-migration-guide.md +313 -0
- data/docs/combustion.md +213 -0
- data/docs/for-next-session.md +199 -0
- data/docs/guide-update-your-app.md +213 -0
- data/docs/propshaft-readme.md +121 -0
- data/docs/propshaft-upgrade.md +267 -0
- data/docs/rails-7-asset-pipeline.md +279 -0
- data/docs/setup-activeadmin-app.md +552 -0
- data/docs/setup-activeadmin-gem.md +535 -0
- data/docs/upload-system.md +225 -0
- data/gemfiles/rails_7.x_active_admin_4.x.gemfile +11 -0
- data/gemfiles/rails_7.x_active_admin_4.x.gemfile.lock +371 -0
- data/gemfiles/rails_8.x_active_admin_4.x.gemfile +11 -0
- data/gemfiles/rails_8.x_active_admin_4.x.gemfile.lock +366 -0
- data/lefthook.yml +17 -0
- data/lib/activeadmin/inputs/filters/searchable_select_input.rb +13 -0
- data/lib/activeadmin/inputs/searchable_select_input.rb +11 -0
- data/lib/activeadmin/searchable_select/engine.rb +17 -0
- data/lib/activeadmin/searchable_select/option_collection.rb +119 -0
- data/lib/activeadmin/searchable_select/resource_dsl_extension.rb +56 -0
- data/lib/activeadmin/searchable_select/resource_extension.rb +10 -0
- data/lib/activeadmin/searchable_select/select_input_extension.rb +159 -0
- data/lib/activeadmin/searchable_select/version.rb +5 -0
- data/lib/activeadmin/searchable_select.rb +20 -0
- data/lib/activeadmin-searchable_select.rb +4 -0
- data/lib/generators/active_admin/searchable_select/install/install_generator.rb +217 -0
- data/package-lock.json +18 -0
- data/package.json +45 -0
- data/rs-activeadmin-searchable_select.gemspec +38 -0
- data/sonar-project.properties +25 -0
- data/spec/features/ajax_params_spec.rb +31 -0
- data/spec/features/end_to_end_spec.rb +227 -0
- data/spec/features/filter_input_spec.rb +137 -0
- data/spec/features/form_input_spec.rb +122 -0
- data/spec/features/inline_ajax_setting_spec.rb +26 -0
- data/spec/features/input_errors_spec.rb +76 -0
- data/spec/features/input_html_options_spec.rb +30 -0
- data/spec/features/options_dsl_spec.rb +220 -0
- data/spec/features/production_build_spec.rb +108 -0
- data/spec/internal/app/admin/categories.rb +26 -0
- data/spec/internal/app/admin/dashboard.rb +29 -0
- data/spec/internal/app/admin/option_types.rb +19 -0
- data/spec/internal/app/admin/option_values.rb +30 -0
- data/spec/internal/app/admin/posts.rb +27 -0
- data/spec/internal/app/admin/products.rb +22 -0
- data/spec/internal/app/admin/rgb_colors.rb +25 -0
- data/spec/internal/app/admin/tag_names.rb +21 -0
- data/spec/internal/app/admin/test_ajax_params_category.rb +10 -0
- data/spec/internal/app/admin/test_ajax_params_post.rb +20 -0
- data/spec/internal/app/admin/test_form_post_class.rb +7 -0
- data/spec/internal/app/admin/test_form_post_custom.rb +11 -0
- data/spec/internal/app/admin/test_form_post_resource.rb +11 -0
- data/spec/internal/app/admin/test_form_post_resource_custom.rb +12 -0
- data/spec/internal/app/admin/test_inline_ajax_post.rb +9 -0
- data/spec/internal/app/admin/test_input_html_post.rb +11 -0
- data/spec/internal/app/admin/test_posts_display_text.rb +9 -0
- data/spec/internal/app/admin/test_posts_filter.rb +9 -0
- data/spec/internal/app/admin/test_posts_named.rb +9 -0
- data/spec/internal/app/admin/test_posts_pagination.rb +9 -0
- data/spec/internal/app/admin/test_posts_payload_lambda.rb +11 -0
- data/spec/internal/app/admin/test_posts_payload_proc.rb +9 -0
- data/spec/internal/app/admin/test_posts_scope_lambda.rb +8 -0
- data/spec/internal/app/admin/test_posts_scope_params.rb +8 -0
- data/spec/internal/app/admin/test_posts_scope_user.rb +8 -0
- data/spec/internal/app/admin/test_posts_text_attr.rb +5 -0
- data/spec/internal/app/admin/users.rb +23 -0
- data/spec/internal/app/admin/variants.rb +31 -0
- data/spec/internal/app/assets/config/manifest.js +1 -0
- data/spec/internal/app/assets/javascripts/active_admin.js +2 -0
- data/spec/internal/app/assets/javascripts/searchable_select_test.js +2 -0
- data/spec/internal/app/controllers/application_controller.rb +5 -0
- data/spec/internal/app/css/active_admin_source.css +81 -0
- data/spec/internal/app/js/active_admin.js +17 -0
- data/spec/internal/app/models/article.rb +12 -0
- data/spec/internal/app/models/category.rb +12 -0
- data/spec/internal/app/models/internal/tag_name.rb +14 -0
- data/spec/internal/app/models/internal_tag_name.rb +11 -0
- data/spec/internal/app/models/option_type.rb +12 -0
- data/spec/internal/app/models/option_value.rb +4 -0
- data/spec/internal/app/models/post.rb +15 -0
- data/spec/internal/app/models/product.rb +12 -0
- data/spec/internal/app/models/rgb_color.rb +16 -0
- data/spec/internal/app/models/user.rb +12 -0
- data/spec/internal/app/models/variant.rb +12 -0
- data/spec/internal/build_activeadmin_css.js +115 -0
- data/spec/internal/config/database.yml +7 -0
- data/spec/internal/config/environment.rb +48 -0
- data/spec/internal/config/initializers/active_admin.rb +53 -0
- data/spec/internal/config/initializers/assets.rb +9 -0
- data/spec/internal/config/initializers/searchable_select.rb +6 -0
- data/spec/internal/config/routes.rb +4 -0
- data/spec/internal/config.ru +4 -0
- data/spec/internal/db/schema.rb +63 -0
- data/spec/internal/db/seeds.rb +88 -0
- data/spec/internal/esbuild.config.js +30 -0
- data/spec/internal/inject-jquery.js +4 -0
- data/spec/internal/log/.gitignore +1 -0
- data/spec/internal/package/LICENSE.txt +25 -0
- data/spec/internal/package/README.md +439 -0
- data/spec/internal/package/package.json +45 -0
- data/spec/internal/package/src/index.js +1 -0
- data/spec/internal/package/src/searchable_select/init.js +1 -0
- data/spec/internal/package/src/searchable_select.css +1 -0
- data/spec/internal/package/src/searchable_select.scss +1 -0
- data/spec/internal/package-lock.json +1385 -0
- data/spec/internal/package.json +26 -0
- data/spec/internal/public/favicon.ico +0 -0
- data/spec/internal/spec/internal/app/css/active_admin_source.css +38 -0
- data/spec/internal/spec/internal/log/test.log +0 -0
- data/spec/internal/tailwind-active_admin.config.js +53 -0
- data/spec/rails_helper.rb +86 -0
- data/spec/spec_helper.rb +137 -0
- data/spec/support/active_admin_helpers.rb +17 -0
- data/spec/support/capybara.rb +8 -0
- data/spec/support/models.rb +88 -0
- data/spec/support/pluck_polyfill.rb +12 -0
- data/spec/support/reset_settings.rb +5 -0
- data/src/index.js +77 -0
- data/src/searchable_select/init.js +58 -0
- data/src/searchable_select.css +5 -0
- data/src/searchable_select.css.map +1 -0
- metadata +405 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 9ac843d93217b19681b7716c4f69b2ee9a3400ebc9cb201616e8e737e7ad6551
|
4
|
+
data.tar.gz: 02e567a06c832180a0c592825c5e7f48c19c3fa32663ede65b3fddf2c4bd50d5
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: '04629998441c0e1cf50847dd14650777406458ca235d7231f3017a28253872158859a696b65d2c190b28956df103c7b26d2a54b9f7f08ad21ed6c78b6622744f'
|
7
|
+
data.tar.gz: a0a7bf5e955134e2e877c0958a65322a6436fd76e63e7fc882043245da0702f4b354788dbb25ba68fb952c09717bf9bb3dc638df90d01c834e24fe9350570a81
|
data/.actrc
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
# Act configuration for local GitHub Actions testing
|
2
|
+
# This file configures act to work efficiently with caching
|
3
|
+
|
4
|
+
# Use medium-sized runner image for better compatibility
|
5
|
+
--platform ubuntu-latest=catthehacker/ubuntu:act-latest
|
6
|
+
|
7
|
+
# Enable reuse of containers for faster subsequent runs
|
8
|
+
--reuse
|
9
|
+
|
10
|
+
# Use local .env file if it exists (for secrets during local testing)
|
11
|
+
--env-file .env.local
|
12
|
+
|
13
|
+
# Pull docker images if newer version exists
|
14
|
+
--pull=false
|
15
|
+
|
16
|
+
# Bind working directory for better performance with local files
|
17
|
+
--bind
|
18
|
+
|
19
|
+
# Use host network for faster downloads and to avoid network issues
|
20
|
+
--network host
|
@@ -0,0 +1,203 @@
|
|
1
|
+
# Fix Tests - ActiveAdmin Searchable Select
|
2
|
+
|
3
|
+
## Overview
|
4
|
+
This guide provides instructions for debugging and fixing failing tests in the ActiveAdmin Searchable Select gem, particularly issues related to Select2 initialization and DOM element selection.
|
5
|
+
|
6
|
+
## Common Test Failures
|
7
|
+
|
8
|
+
### 1. Select2 Container Not Found
|
9
|
+
**Error:** `Unable to find css ".select2-container"`
|
10
|
+
|
11
|
+
**Root Causes:**
|
12
|
+
- JavaScript dependencies (jQuery, Select2) not loaded in test environment
|
13
|
+
- ActiveAdmin 4 expects `importmap-rails` but test environment uses no-op shims
|
14
|
+
|
15
|
+
**Solution:**
|
16
|
+
Check `/spec/internal/config/initializers/active_admin.rb` and ensure JavaScript dependencies are properly loaded:
|
17
|
+
|
18
|
+
```ruby
|
19
|
+
# Replace no-op javascript_importmap_tags with working implementation
|
20
|
+
config.register_javascript do
|
21
|
+
raw <<~HTML
|
22
|
+
<link href="https://cdn.jsdelivr.net/npm/select2@4.1.0-rc.0/dist/css/select2.min.css" rel="stylesheet" />
|
23
|
+
<script src="https://code.jquery.com/jquery-3.7.1.min.js"></script>
|
24
|
+
<script src="https://cdn.jsdelivr.net/npm/select2@4.1.0-rc.0/dist/js/select2.min.js"></script>
|
25
|
+
<script type="text/javascript">
|
26
|
+
#{File.read(Rails.root.join('../../app/assets/javascripts/active_admin/searchable_select/init.js'))}
|
27
|
+
</script>
|
28
|
+
HTML
|
29
|
+
end
|
30
|
+
```
|
31
|
+
|
32
|
+
### 2. Filter Form Selector Changes
|
33
|
+
**Error:** `Unable to find css ".filter_form"`
|
34
|
+
|
35
|
+
**Root Cause:** ActiveAdmin 4 changed the filter form class from `.filter_form` to `.filters-form` (with an 's')
|
36
|
+
|
37
|
+
**Solution:** Update selectors in tests:
|
38
|
+
```ruby
|
39
|
+
# Old (incorrect)
|
40
|
+
within '.filter_form' do
|
41
|
+
find('.select2-container').click
|
42
|
+
end
|
43
|
+
|
44
|
+
# New (correct)
|
45
|
+
within '.filters-form' do
|
46
|
+
find('.select2-container').click
|
47
|
+
end
|
48
|
+
```
|
49
|
+
|
50
|
+
## Debugging Workflow
|
51
|
+
|
52
|
+
### Step 1: Add HTML Debug Output
|
53
|
+
When a test fails due to missing elements, add debug output to see the actual page structure:
|
54
|
+
|
55
|
+
```ruby
|
56
|
+
it 'your test' do
|
57
|
+
visit '/admin/posts'
|
58
|
+
|
59
|
+
# Debug: output page HTML
|
60
|
+
puts "\n=== DEBUG: Page HTML ==="
|
61
|
+
puts page.html
|
62
|
+
puts "=== END DEBUG ===\n"
|
63
|
+
|
64
|
+
# Debug: check for specific elements
|
65
|
+
puts "Select2 containers found: #{page.all('.select2-container').count}"
|
66
|
+
puts "Searchable select inputs: #{page.all('.searchable-select-input').count}"
|
67
|
+
|
68
|
+
# Your test code here
|
69
|
+
end
|
70
|
+
```
|
71
|
+
|
72
|
+
### Step 2: Check JavaScript Loading
|
73
|
+
Add JavaScript debugging to verify dependencies are loaded:
|
74
|
+
|
75
|
+
```ruby
|
76
|
+
it 'checks JavaScript dependencies' do
|
77
|
+
visit '/admin/posts'
|
78
|
+
|
79
|
+
# Check if jQuery is loaded
|
80
|
+
jquery_loaded = page.evaluate_script('typeof jQuery !== "undefined"')
|
81
|
+
puts "jQuery loaded: #{jquery_loaded}"
|
82
|
+
|
83
|
+
# Check jQuery version
|
84
|
+
if jquery_loaded
|
85
|
+
jquery_version = page.evaluate_script('jQuery.fn.jquery')
|
86
|
+
puts "jQuery version: #{jquery_version}"
|
87
|
+
end
|
88
|
+
|
89
|
+
# Check if Select2 is loaded
|
90
|
+
select2_loaded = page.evaluate_script('typeof jQuery !== "undefined" && jQuery.fn.select2 !== undefined')
|
91
|
+
puts "Select2 loaded: #{select2_loaded}"
|
92
|
+
end
|
93
|
+
```
|
94
|
+
|
95
|
+
### Step 3: Capture Console Errors
|
96
|
+
For JavaScript-capable drivers, capture console errors:
|
97
|
+
|
98
|
+
```ruby
|
99
|
+
# Add to test setup
|
100
|
+
page.driver.browser.manage.logs.get(:browser).each do |log|
|
101
|
+
puts "Console #{log.level}: #{log.message}"
|
102
|
+
end
|
103
|
+
```
|
104
|
+
|
105
|
+
### Step 4: Wait for Dynamic Elements
|
106
|
+
Ensure elements have time to initialize:
|
107
|
+
|
108
|
+
```ruby
|
109
|
+
# Use Capybara's wait functionality
|
110
|
+
expect(page).to have_css('.select2-container', wait: 5)
|
111
|
+
|
112
|
+
# Or wait for specific conditions
|
113
|
+
Capybara.using_wait_time(5) do
|
114
|
+
find('.select2-container').click
|
115
|
+
end
|
116
|
+
```
|
117
|
+
|
118
|
+
## Project-Specific Considerations
|
119
|
+
|
120
|
+
### 1. Test Environment Setup
|
121
|
+
The test suite uses Combustion to create a minimal Rails app in `spec/internal/`. Key files:
|
122
|
+
- `spec/internal/config/initializers/active_admin.rb` - ActiveAdmin configuration
|
123
|
+
- `spec/internal/app/admin/` - Test admin resources
|
124
|
+
- `spec/internal/app/models/` - Test models
|
125
|
+
|
126
|
+
### 2. ActiveAdmin Version Compatibility
|
127
|
+
This gem supports multiple ActiveAdmin versions through Appraisal. Test against specific versions:
|
128
|
+
```bash
|
129
|
+
# Install appraisals
|
130
|
+
appraisal install
|
131
|
+
|
132
|
+
# Run tests against specific version
|
133
|
+
appraisal activeadmin-4 rspec
|
134
|
+
```
|
135
|
+
|
136
|
+
### 3. JavaScript Asset Loading
|
137
|
+
The gem's JavaScript is in `app/assets/javascripts/active_admin/searchable_select/`. In tests, ensure these files are loaded either:
|
138
|
+
- Via CDN (for simplicity in tests)
|
139
|
+
- Via Rails asset pipeline (for integration testing)
|
140
|
+
- Inline in the test initializer (current approach)
|
141
|
+
|
142
|
+
### 4. Inline AJAX Options Mode
|
143
|
+
For testing without real AJAX calls, enable inline mode:
|
144
|
+
```ruby
|
145
|
+
ActiveAdmin::SearchableSelect.inline_ajax_options = true
|
146
|
+
```
|
147
|
+
This renders all options statically in the HTML.
|
148
|
+
|
149
|
+
## Running Tests
|
150
|
+
|
151
|
+
```bash
|
152
|
+
# Run all tests
|
153
|
+
bundle exec rspec
|
154
|
+
|
155
|
+
# Run specific test file
|
156
|
+
bundle exec rspec spec/features/end_to_end_spec.rb
|
157
|
+
|
158
|
+
# Run specific test by line number
|
159
|
+
bundle exec rspec spec/features/production_build_spec.rb:56
|
160
|
+
|
161
|
+
# Run with documentation format for clarity
|
162
|
+
bundle exec rspec --format documentation
|
163
|
+
|
164
|
+
# Run tests matching a pattern
|
165
|
+
bundle exec rspec -e "searchable select"
|
166
|
+
```
|
167
|
+
|
168
|
+
## Common Fixes Checklist
|
169
|
+
|
170
|
+
1. ✅ Verify jQuery is loaded (version 3.x recommended)
|
171
|
+
2. ✅ Verify Select2 is loaded (version 4.1.0-rc.0)
|
172
|
+
3. ✅ Check CSS selectors match current ActiveAdmin version
|
173
|
+
4. ✅ Ensure test database has seed data if needed
|
174
|
+
5. ✅ Check for JavaScript console errors
|
175
|
+
6. ✅ Verify AJAX endpoints are defined (`searchable_select_options` in resource)
|
176
|
+
7. ✅ Wait for dynamic elements to initialize
|
177
|
+
8. ✅ Use correct Capybara driver for JavaScript tests (`:selenium_chrome_headless`)
|
178
|
+
|
179
|
+
## Troubleshooting Tips
|
180
|
+
|
181
|
+
1. **"Warning: method `all_options` already defined"** - Normal warning, can be ignored
|
182
|
+
2. **Flaky tests** - Add explicit waits or use `have_css` with wait parameter
|
183
|
+
3. **Different behavior in CI** - Check for timing issues, add debug output
|
184
|
+
4. **Select2 not initializing** - Verify document ready events are firing correctly
|
185
|
+
|
186
|
+
## Quick Debug Template
|
187
|
+
|
188
|
+
Add this to any failing test for comprehensive debugging:
|
189
|
+
|
190
|
+
```ruby
|
191
|
+
# Debug template
|
192
|
+
puts "\n=== DEBUG START ==="
|
193
|
+
puts "Current URL: #{current_url}"
|
194
|
+
puts "Page title: #{page.title}"
|
195
|
+
puts "Select2 containers: #{page.all('.select2-container').count}"
|
196
|
+
puts "Searchable inputs: #{page.all('.searchable-select-input').count}"
|
197
|
+
puts "jQuery loaded: #{page.evaluate_script('typeof jQuery !== "undefined"')}"
|
198
|
+
puts "Select2 loaded: #{page.evaluate_script('typeof jQuery !== "undefined" && jQuery.fn.select2 !== undefined')}"
|
199
|
+
save_screenshot('debug_screenshot.png') if respond_to?(:save_screenshot)
|
200
|
+
puts "=== DEBUG END ===\n"
|
201
|
+
```
|
202
|
+
|
203
|
+
This guide should help quickly diagnose and fix test failures related to the searchable select functionality.
|
@@ -0,0 +1,170 @@
|
|
1
|
+
name: CI
|
2
|
+
|
3
|
+
on:
|
4
|
+
push:
|
5
|
+
branches: [master, main]
|
6
|
+
pull_request:
|
7
|
+
branches: [master, main]
|
8
|
+
|
9
|
+
jobs:
|
10
|
+
test:
|
11
|
+
runs-on: ubuntu-latest
|
12
|
+
timeout-minutes: 15
|
13
|
+
|
14
|
+
strategy:
|
15
|
+
fail-fast: false
|
16
|
+
matrix:
|
17
|
+
ruby: ['3.3', '3.4']
|
18
|
+
gemfile:
|
19
|
+
- rails_7.x_active_admin_4.x
|
20
|
+
- rails_8.x_active_admin_4.x
|
21
|
+
|
22
|
+
env:
|
23
|
+
BUNDLE_GEMFILE: ${{ github.workspace }}/gemfiles/${{ matrix.gemfile }}.gemfile
|
24
|
+
RAILS_ENV: test
|
25
|
+
PLAYWRIGHT_BROWSERS_PATH: ${{ github.workspace }}/ms-playwright
|
26
|
+
|
27
|
+
steps:
|
28
|
+
- uses: actions/checkout@v5
|
29
|
+
|
30
|
+
- name: Set up Ruby
|
31
|
+
uses: ruby/setup-ruby@v1
|
32
|
+
with:
|
33
|
+
ruby-version: ${{ matrix.ruby }}
|
34
|
+
bundler-cache: true
|
35
|
+
|
36
|
+
# Cache APT packages for Playwright dependencies
|
37
|
+
- name: Cache APT packages
|
38
|
+
uses: awalsh128/cache-apt-pkgs-action@v1.5.3
|
39
|
+
with:
|
40
|
+
packages: libnss3 libnspr4 libatk1.0-0 libatk-bridge2.0-0 libcups2 libdrm2 libdbus-1-3 libatspi2.0-0 libx11-6 libxcomposite1 libxdamage1 libxext6 libxfixes3 libxrandr2 libgbm1 libxcb1 libxkbcommon0 libpango-1.0-0 libcairo2 libasound2
|
41
|
+
version: 1.0
|
42
|
+
execute_install_scripts: true
|
43
|
+
|
44
|
+
# Get Playwright version for cache key
|
45
|
+
- name: Get Playwright version
|
46
|
+
id: playwright-version
|
47
|
+
run: |
|
48
|
+
PLAYWRIGHT_VERSION=$(npm ls @playwright/test 2>/dev/null | grep @playwright/test | sed 's/.*@//' | head -1)
|
49
|
+
if [ -z "$PLAYWRIGHT_VERSION" ]; then
|
50
|
+
PLAYWRIGHT_VERSION=$(npx playwright --version | sed 's/Version //')
|
51
|
+
fi
|
52
|
+
echo "version=$PLAYWRIGHT_VERSION" >> $GITHUB_OUTPUT
|
53
|
+
|
54
|
+
# Cache Playwright browsers
|
55
|
+
- name: Cache Playwright browsers
|
56
|
+
id: playwright-cache
|
57
|
+
uses: actions/cache@v4
|
58
|
+
with:
|
59
|
+
path: ${{ github.workspace }}/ms-playwright
|
60
|
+
key: ${{ runner.os }}-playwright-${{ steps.playwright-version.outputs.version }}-${{ hashFiles('**/package-lock.json', '**/yarn.lock', '**/pnpm-lock.yaml') }}
|
61
|
+
restore-keys: |
|
62
|
+
${{ runner.os }}-playwright-${{ steps.playwright-version.outputs.version }}-
|
63
|
+
${{ runner.os }}-playwright-
|
64
|
+
|
65
|
+
- name: Install npm dependencies
|
66
|
+
run: npm install
|
67
|
+
|
68
|
+
- name: Build and install npm package
|
69
|
+
run: |
|
70
|
+
# Build the npm package
|
71
|
+
npm pack
|
72
|
+
|
73
|
+
# Extract it to a temporary location
|
74
|
+
mkdir -p /tmp/npm-package
|
75
|
+
tar -xzf rocket-sensei-activeadmin-searchable_select-*.tgz -C /tmp/npm-package
|
76
|
+
|
77
|
+
# Update spec/internal to use the extracted package
|
78
|
+
cd spec/internal
|
79
|
+
# Remove any existing symlink/folder
|
80
|
+
rm -rf package
|
81
|
+
rm -rf node_modules/@rocket-sensei/activeadmin-searchable_select
|
82
|
+
npm install
|
83
|
+
|
84
|
+
# Install from the extracted package
|
85
|
+
npm install /tmp/npm-package/package
|
86
|
+
|
87
|
+
# Build assets (JS and CSS)
|
88
|
+
echo "Building JavaScript assets..."
|
89
|
+
npm run build:js
|
90
|
+
|
91
|
+
echo "Building CSS assets..."
|
92
|
+
npm run build:css:activeadmin
|
93
|
+
|
94
|
+
echo "Copying Select2 assets..."
|
95
|
+
npm run copy:select2
|
96
|
+
|
97
|
+
# Verify assets were built
|
98
|
+
echo "Checking built assets..."
|
99
|
+
ls -la app/assets/builds/
|
100
|
+
|
101
|
+
echo "Checking public/select2..."
|
102
|
+
ls -la public/select2/ || echo "public/select2 not found"
|
103
|
+
|
104
|
+
- name: Install Playwright browsers
|
105
|
+
if: steps.playwright-cache.outputs.cache-hit != 'true'
|
106
|
+
run: npx playwright install chromium
|
107
|
+
|
108
|
+
- name: Setup test database
|
109
|
+
run: |
|
110
|
+
# The database tasks may not be available, skip for now
|
111
|
+
echo "Database setup will be handled by test suite"
|
112
|
+
|
113
|
+
- name: Run tests with coverage
|
114
|
+
run: |
|
115
|
+
bundle exec rspec --format progress --format RspecJunitFormatter --out rspec-results.xml
|
116
|
+
continue-on-error: true
|
117
|
+
|
118
|
+
- name: Upload coverage to Codecov
|
119
|
+
if: matrix.ruby == '3.4' && matrix.gemfile == 'rails_7.x_active_admin_4.x'
|
120
|
+
uses: codecov/codecov-action@v5
|
121
|
+
with:
|
122
|
+
file: ./coverage/coverage.xml
|
123
|
+
fail_ci_if_error: false
|
124
|
+
token: ${{ secrets.CODECOV_TOKEN }}
|
125
|
+
|
126
|
+
- name: SonarQube Scan
|
127
|
+
if: matrix.ruby == '3.4' && matrix.gemfile == 'rails_7.x_active_admin_4.x' && github.event_name != 'pull_request'
|
128
|
+
uses: sonarsource/sonarqube-scan-action@v3
|
129
|
+
env:
|
130
|
+
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
|
131
|
+
SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL || 'https://sonarcloud.io' }}
|
132
|
+
with:
|
133
|
+
args: >
|
134
|
+
-Dsonar.projectKey=glebtv_activeadmin-searchable_select
|
135
|
+
-Dsonar.ruby.coverage.reportPaths=coverage/coverage.xml
|
136
|
+
-Dsonar.ruby.rspec.reportPaths=rspec-results.xml
|
137
|
+
continue-on-error: true
|
138
|
+
|
139
|
+
lint:
|
140
|
+
runs-on: ubuntu-latest
|
141
|
+
|
142
|
+
steps:
|
143
|
+
- uses: actions/checkout@v5
|
144
|
+
|
145
|
+
- name: Set up Ruby
|
146
|
+
uses: ruby/setup-ruby@v1
|
147
|
+
with:
|
148
|
+
ruby-version: '3.4'
|
149
|
+
bundler-cache: true
|
150
|
+
|
151
|
+
- name: Run RuboCop
|
152
|
+
run: bundle exec rubocop --force-exclusion
|
153
|
+
|
154
|
+
build-npm:
|
155
|
+
runs-on: ubuntu-latest
|
156
|
+
|
157
|
+
steps:
|
158
|
+
- uses: actions/checkout@v5
|
159
|
+
|
160
|
+
- name: Setup Node.js
|
161
|
+
uses: actions/setup-node@v4
|
162
|
+
with:
|
163
|
+
node-version: '22'
|
164
|
+
cache: 'npm'
|
165
|
+
|
166
|
+
- name: Install dependencies
|
167
|
+
run: npm ci
|
168
|
+
|
169
|
+
- name: Check package
|
170
|
+
run: npm pack --dry-run
|
@@ -0,0 +1,47 @@
|
|
1
|
+
name: Publish to NPM
|
2
|
+
|
3
|
+
on:
|
4
|
+
release:
|
5
|
+
types: [published]
|
6
|
+
|
7
|
+
jobs:
|
8
|
+
publish-npm:
|
9
|
+
runs-on: ubuntu-latest
|
10
|
+
permissions:
|
11
|
+
contents: read
|
12
|
+
id-token: write
|
13
|
+
|
14
|
+
steps:
|
15
|
+
- uses: actions/checkout@v5
|
16
|
+
|
17
|
+
- name: Setup Node.js
|
18
|
+
uses: actions/setup-node@v4
|
19
|
+
with:
|
20
|
+
node-version: '22'
|
21
|
+
registry-url: 'https://registry.npmjs.org'
|
22
|
+
|
23
|
+
- name: Verify package files
|
24
|
+
run: |
|
25
|
+
echo "Package files to be published:"
|
26
|
+
npm pack --dry-run
|
27
|
+
echo ""
|
28
|
+
echo "Package name: $(npm view . name)"
|
29
|
+
echo "Package version: $(npm view . version)"
|
30
|
+
|
31
|
+
- name: Publish to NPM
|
32
|
+
run: npm publish --access public
|
33
|
+
env:
|
34
|
+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
35
|
+
|
36
|
+
- name: Add publish summary
|
37
|
+
run: |
|
38
|
+
echo "### NPM Package Published! 🎉" >> $GITHUB_STEP_SUMMARY
|
39
|
+
echo "" >> $GITHUB_STEP_SUMMARY
|
40
|
+
echo "Package: \`@rocket-sensei/activeadmin-searchable_select@$(npm view . version)\`" >> $GITHUB_STEP_SUMMARY
|
41
|
+
echo "" >> $GITHUB_STEP_SUMMARY
|
42
|
+
echo "Install with:" >> $GITHUB_STEP_SUMMARY
|
43
|
+
echo "\`\`\`bash" >> $GITHUB_STEP_SUMMARY
|
44
|
+
echo "npm install @rocket-sensei/activeadmin-searchable_select" >> $GITHUB_STEP_SUMMARY
|
45
|
+
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY
|
46
|
+
echo "" >> $GITHUB_STEP_SUMMARY
|
47
|
+
echo "View on NPM: https://www.npmjs.com/package/@rocket-sensei/activeadmin-searchable_select" >> $GITHUB_STEP_SUMMARY
|
data/.gitignore
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
.bundle
|
2
|
+
.ruby-version
|
3
|
+
.ruby-gemset
|
4
|
+
/pkg/*
|
5
|
+
/spec/internal/tmp
|
6
|
+
/spec/internal/db/*.sqlite
|
7
|
+
/spec/internal/db/*.sqlite-shm
|
8
|
+
/spec/internal/db/*.sqlite-wal
|
9
|
+
/spec/examples.txt
|
10
|
+
/node_modules
|
11
|
+
/vendor/bundle
|
12
|
+
.cache
|
13
|
+
/.cache
|
14
|
+
|
15
|
+
# Generated/built files only
|
16
|
+
/spec/internal/node_modules/
|
17
|
+
/spec/internal/app/assets/builds/
|
18
|
+
/spec/internal/public/select2/
|
19
|
+
|
20
|
+
# Debug and temporary files
|
21
|
+
/debug_*.rb
|
22
|
+
/spec/debug_*.rb
|
23
|
+
/*.tgz
|
24
|
+
|
25
|
+
# Code coverage reports
|
26
|
+
/coverage/
|
27
|
+
*.lcov
|
data/.npmignore
ADDED
@@ -0,0 +1,58 @@
|
|
1
|
+
# Ruby/Rails files
|
2
|
+
*.gemspec
|
3
|
+
Gemfile
|
4
|
+
Gemfile.lock
|
5
|
+
Rakefile
|
6
|
+
Appraisals
|
7
|
+
.rubocop.yml
|
8
|
+
.rubocop.todo.yml
|
9
|
+
.ruby-version
|
10
|
+
.ruby-gemset
|
11
|
+
.rspec
|
12
|
+
|
13
|
+
# Ruby source code (not needed for npm package)
|
14
|
+
/lib/
|
15
|
+
/app/assets/stylesheets/
|
16
|
+
|
17
|
+
# Test files
|
18
|
+
/spec/
|
19
|
+
/test/
|
20
|
+
/gemfiles/
|
21
|
+
|
22
|
+
# Documentation
|
23
|
+
*.md
|
24
|
+
LICENSE
|
25
|
+
CHANGELOG*
|
26
|
+
|
27
|
+
# Development files
|
28
|
+
.gitignore
|
29
|
+
.actrc
|
30
|
+
|
31
|
+
# CI/CD
|
32
|
+
.github/
|
33
|
+
.travis.yml
|
34
|
+
|
35
|
+
# Build artifacts
|
36
|
+
/pkg/
|
37
|
+
/tmp/
|
38
|
+
/log/
|
39
|
+
*.gem
|
40
|
+
|
41
|
+
# Bundler
|
42
|
+
/.bundle/
|
43
|
+
/vendor/bundle/
|
44
|
+
/vendor/cache/
|
45
|
+
|
46
|
+
# Node modules (shouldn't be in package)
|
47
|
+
/node_modules/
|
48
|
+
|
49
|
+
# Editor files
|
50
|
+
.idea/
|
51
|
+
.vscode/
|
52
|
+
*.swp
|
53
|
+
*.swo
|
54
|
+
*~
|
55
|
+
.DS_Store
|
56
|
+
|
57
|
+
# Keep only the built JavaScript and CSS files
|
58
|
+
!src/
|
data/.rspec
ADDED
data/.rubocop.yml
ADDED
@@ -0,0 +1,67 @@
|
|
1
|
+
inherit_mode:
|
2
|
+
merge:
|
3
|
+
- Exclude
|
4
|
+
|
5
|
+
AllCops:
|
6
|
+
TargetRubyVersion: 3.0
|
7
|
+
NewCops: enable
|
8
|
+
SuggestExtensions: false
|
9
|
+
Exclude:
|
10
|
+
- 'bin/**/*'
|
11
|
+
- 'vendor/**/*'
|
12
|
+
- 'gemfiles/vendor/**/*'
|
13
|
+
- '**/vendor/**/*'
|
14
|
+
|
15
|
+
# The default of 80 characters is a little to narrow.
|
16
|
+
Layout/LineLength:
|
17
|
+
Max: 100
|
18
|
+
|
19
|
+
# Do not warn about missing magic comment
|
20
|
+
Style/FrozenStringLiteralComment:
|
21
|
+
Enabled: false
|
22
|
+
|
23
|
+
# Disable block length checks for spec files
|
24
|
+
Metrics/BlockLength:
|
25
|
+
Exclude:
|
26
|
+
- 'spec/**/*'
|
27
|
+
- 'spec/internal/db/schema.rb'
|
28
|
+
- '*.gemspec'
|
29
|
+
|
30
|
+
# Allow empty blocks in specs (for ActiveAdmin.setup {})
|
31
|
+
Lint/EmptyBlock:
|
32
|
+
Exclude:
|
33
|
+
- 'spec/**/*'
|
34
|
+
|
35
|
+
# Naming exception for gem main file
|
36
|
+
Naming/FileName:
|
37
|
+
Exclude:
|
38
|
+
- 'lib/activeadmin-searchable_select.rb'
|
39
|
+
|
40
|
+
# Allow development dependencies in gemspec
|
41
|
+
Gemspec/DevelopmentDependencies:
|
42
|
+
Enabled: false
|
43
|
+
|
44
|
+
# Allow Ruby version mismatch (we support multiple versions)
|
45
|
+
Gemspec/RequiredRubyVersion:
|
46
|
+
Enabled: false
|
47
|
+
|
48
|
+
# Allow longer classes for generators
|
49
|
+
Metrics/ClassLength:
|
50
|
+
Exclude:
|
51
|
+
- 'lib/generators/**/*'
|
52
|
+
|
53
|
+
# Allow longer methods for generators
|
54
|
+
Metrics/MethodLength:
|
55
|
+
Exclude:
|
56
|
+
- 'lib/generators/**/*'
|
57
|
+
|
58
|
+
# Allow complex methods for generators
|
59
|
+
Metrics/AbcSize:
|
60
|
+
Exclude:
|
61
|
+
- 'lib/generators/**/*'
|
62
|
+
|
63
|
+
# Documentation not required for generators and test support files
|
64
|
+
Style/Documentation:
|
65
|
+
Exclude:
|
66
|
+
- 'lib/generators/**/*'
|
67
|
+
- 'spec/**/*'
|
data/.yardopts
ADDED
data/AGENTS.md
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
# Repository Guidelines
|
2
|
+
|
3
|
+
## Project Structure & Module Organization
|
4
|
+
- `lib/`: Ruby engine, extensions, and DSL under `ActiveAdmin::SearchableSelect`.
|
5
|
+
- `app/assets/`: Legacy Sprockets JS/CSS entry points for ActiveAdmin.
|
6
|
+
- `src/`: ESM sources for the npm package (`searchable_select.js/.scss`).
|
7
|
+
- `vendor/assets/javascripts/`: Importmap-friendly JS build.
|
8
|
+
- `spec/`: RSpec suite with Combustion Rails app under `spec/internal`; feature specs in `spec/features/**`.
|
9
|
+
- `docs/`: Setup and integration guides.
|
10
|
+
|
11
|
+
## Build, Test, and Development Commands
|
12
|
+
- `bundle && bundle exec rspec`: Install gems and run the test suite.
|
13
|
+
- `appraisal install && appraisal rspec`: Run the Rails/ActiveAdmin matrix (see `Appraisals`).
|
14
|
+
- `bundle exec rubocop --force-exclusion`: Lint Ruby code per `.rubocop.yml`.
|
15
|
+
- `npm ci && npm run prepublishOnly`: Build npm artifacts from `app/assets` into `src/`.
|
16
|
+
- `npx playwright install chromium`: One-time browser install for JS feature specs.
|
17
|
+
- `rake build` / `rake release`: Build/release the gem via Bundler tasks.
|
18
|
+
- Example (headed browser): `HEADLESS=false bundle exec rspec`.
|
19
|
+
|
20
|
+
## Coding Style & Naming Conventions
|
21
|
+
- Ruby: 2-space indent, TargetRuby 3.0, max line length 100; follow RuboCop rules.
|
22
|
+
- Names: Ruby files in `lib/activeadmin/searchable_select/` use snake_case; modules under `ActiveAdmin::SearchableSelect`.
|
23
|
+
- JS: ESM modules in `src/`; keep imports explicit. Avoid global jQuery except for ActiveAdmin integration.
|
24
|
+
|
25
|
+
## Testing Guidelines
|
26
|
+
- Framework: RSpec. Feature/system specs use Capybara with Playwright; unit/integration via Combustion.
|
27
|
+
- Layout: Place UI/Select2 specs under `spec/features/**` and tag `type: :feature, js: true`.
|
28
|
+
- Run: `bundle exec rspec` locally; use `appraisal rspec` to validate matrices before PRs.
|
29
|
+
- Browser: Install once with `npx playwright install chromium`. Use `HEADLESS=false` to visualize.
|
30
|
+
|
31
|
+
## Commit & Pull Request Guidelines
|
32
|
+
- Commits: Imperative, concise messages (e.g., "Fix Select2 init on esbuild"). Group related changes.
|
33
|
+
- PRs: Provide clear description, rationale, linked issues; add screenshots/GIFs for UI changes. Update `README.md`/`docs/` and `CHANGELOG.md` for behavior changes.
|
34
|
+
- Quality gate: Ensure `rspec` and `rubocop` pass; for npm-facing changes, run `npm run prepublishOnly` to verify `src/` packaging.
|
35
|
+
|
36
|
+
## JS Integration Notes
|
37
|
+
- Bundlers (esbuild/webpack): `import 'jquery'` and `import 'select2'`, then call `select2($)` and ensure `window.$ = window.jQuery = $` before importing this package.
|
38
|
+
- Importmap: Use `vendor/assets/javascripts/activeadmin-searchable_select.js`.
|
39
|
+
|
data/Appraisals
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
appraise 'rails-7.x-active-admin-4.x' do
|
2
|
+
gem 'rails', '~> 7.1'
|
3
|
+
gem 'activeadmin', '4.0.0.beta16'
|
4
|
+
gem 'rspec_junit_formatter', require: false
|
5
|
+
gem 'simplecov', require: false
|
6
|
+
gem 'simplecov-cobertura', require: false
|
7
|
+
end
|
8
|
+
|
9
|
+
appraise 'rails-8.x-active-admin-4.x' do
|
10
|
+
gem 'rails', '~> 8.0'
|
11
|
+
gem 'activeadmin', '4.0.0.beta16'
|
12
|
+
gem 'rspec_junit_formatter', require: false
|
13
|
+
gem 'simplecov', require: false
|
14
|
+
gem 'simplecov-cobertura', require: false
|
15
|
+
end
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
# CHANGELOG
|
2
|
+
|
3
|
+
### Version 0.5.0 (Draft - Unreleased)
|
4
|
+
|
5
|
+
[Compare changes](https://github.com/glebtv/activeadmin-searchable_select/compare/1-8-stable...master)
|
6
|
+
|
7
|
+
#### Changes
|
8
|
+
- Forked from original repository to @rocket-sensei organization
|
9
|
+
- Updated package name to `@rocket-sensei/activeadmin-searchable_select` for NPM publishing
|
10
|
+
- Added GitHub Actions workflow for automated NPM publishing on release
|
11
|
+
- Fixed all RuboCop linting violations for improved code quality
|
12
|
+
- Updated CI configuration for better test stability
|
13
|
+
|
14
|
+
#### Technical Improvements
|
15
|
+
- Fixed Playwright browser caching in CI
|
16
|
+
- Resolved Select2 initialization issues
|
17
|
+
- Improved filter form selectors compatibility
|
18
|
+
- Enhanced code style consistency throughout the codebase
|
19
|
+
|
20
|
+
### Previous Releases
|
21
|
+
|
22
|
+
See
|
23
|
+
[1-8-stable branch](https://github.com/codevise/activeadmin-searchable_select/blob/1-8-stable/CHANGELOG.md)
|
24
|
+
for previous changes.
|