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.
Files changed (145) hide show
  1. checksums.yaml +7 -0
  2. data/.actrc +20 -0
  3. data/.claude/commands/fix-tests.md +203 -0
  4. data/.github/workflows/ci.yml +170 -0
  5. data/.github/workflows/npm-publish.yml +47 -0
  6. data/.gitignore +27 -0
  7. data/.npmignore +58 -0
  8. data/.rspec +2 -0
  9. data/.rubocop.yml +67 -0
  10. data/.yardopts +2 -0
  11. data/AGENTS.md +39 -0
  12. data/Appraisals +15 -0
  13. data/CHANGELOG.md +24 -0
  14. data/CLAUDE.md +104 -0
  15. data/Gemfile +11 -0
  16. data/Gemfile.lock +366 -0
  17. data/LICENSE.txt +25 -0
  18. data/README.md +439 -0
  19. data/Rakefile +4 -0
  20. data/bin/rspec +17 -0
  21. data/config/database.yml +16 -0
  22. data/config.ru +28 -0
  23. data/docs/activeadmin-4-detailed-reference.md +932 -0
  24. data/docs/activeadmin-4-gem-migration-guide.md +313 -0
  25. data/docs/combustion.md +213 -0
  26. data/docs/for-next-session.md +199 -0
  27. data/docs/guide-update-your-app.md +213 -0
  28. data/docs/propshaft-readme.md +121 -0
  29. data/docs/propshaft-upgrade.md +267 -0
  30. data/docs/rails-7-asset-pipeline.md +279 -0
  31. data/docs/setup-activeadmin-app.md +552 -0
  32. data/docs/setup-activeadmin-gem.md +535 -0
  33. data/docs/upload-system.md +225 -0
  34. data/gemfiles/rails_7.x_active_admin_4.x.gemfile +11 -0
  35. data/gemfiles/rails_7.x_active_admin_4.x.gemfile.lock +371 -0
  36. data/gemfiles/rails_8.x_active_admin_4.x.gemfile +11 -0
  37. data/gemfiles/rails_8.x_active_admin_4.x.gemfile.lock +366 -0
  38. data/lefthook.yml +17 -0
  39. data/lib/activeadmin/inputs/filters/searchable_select_input.rb +13 -0
  40. data/lib/activeadmin/inputs/searchable_select_input.rb +11 -0
  41. data/lib/activeadmin/searchable_select/engine.rb +17 -0
  42. data/lib/activeadmin/searchable_select/option_collection.rb +119 -0
  43. data/lib/activeadmin/searchable_select/resource_dsl_extension.rb +56 -0
  44. data/lib/activeadmin/searchable_select/resource_extension.rb +10 -0
  45. data/lib/activeadmin/searchable_select/select_input_extension.rb +159 -0
  46. data/lib/activeadmin/searchable_select/version.rb +5 -0
  47. data/lib/activeadmin/searchable_select.rb +20 -0
  48. data/lib/activeadmin-searchable_select.rb +4 -0
  49. data/lib/generators/active_admin/searchable_select/install/install_generator.rb +217 -0
  50. data/package-lock.json +18 -0
  51. data/package.json +45 -0
  52. data/rs-activeadmin-searchable_select.gemspec +38 -0
  53. data/sonar-project.properties +25 -0
  54. data/spec/features/ajax_params_spec.rb +31 -0
  55. data/spec/features/end_to_end_spec.rb +227 -0
  56. data/spec/features/filter_input_spec.rb +137 -0
  57. data/spec/features/form_input_spec.rb +122 -0
  58. data/spec/features/inline_ajax_setting_spec.rb +26 -0
  59. data/spec/features/input_errors_spec.rb +76 -0
  60. data/spec/features/input_html_options_spec.rb +30 -0
  61. data/spec/features/options_dsl_spec.rb +220 -0
  62. data/spec/features/production_build_spec.rb +108 -0
  63. data/spec/internal/app/admin/categories.rb +26 -0
  64. data/spec/internal/app/admin/dashboard.rb +29 -0
  65. data/spec/internal/app/admin/option_types.rb +19 -0
  66. data/spec/internal/app/admin/option_values.rb +30 -0
  67. data/spec/internal/app/admin/posts.rb +27 -0
  68. data/spec/internal/app/admin/products.rb +22 -0
  69. data/spec/internal/app/admin/rgb_colors.rb +25 -0
  70. data/spec/internal/app/admin/tag_names.rb +21 -0
  71. data/spec/internal/app/admin/test_ajax_params_category.rb +10 -0
  72. data/spec/internal/app/admin/test_ajax_params_post.rb +20 -0
  73. data/spec/internal/app/admin/test_form_post_class.rb +7 -0
  74. data/spec/internal/app/admin/test_form_post_custom.rb +11 -0
  75. data/spec/internal/app/admin/test_form_post_resource.rb +11 -0
  76. data/spec/internal/app/admin/test_form_post_resource_custom.rb +12 -0
  77. data/spec/internal/app/admin/test_inline_ajax_post.rb +9 -0
  78. data/spec/internal/app/admin/test_input_html_post.rb +11 -0
  79. data/spec/internal/app/admin/test_posts_display_text.rb +9 -0
  80. data/spec/internal/app/admin/test_posts_filter.rb +9 -0
  81. data/spec/internal/app/admin/test_posts_named.rb +9 -0
  82. data/spec/internal/app/admin/test_posts_pagination.rb +9 -0
  83. data/spec/internal/app/admin/test_posts_payload_lambda.rb +11 -0
  84. data/spec/internal/app/admin/test_posts_payload_proc.rb +9 -0
  85. data/spec/internal/app/admin/test_posts_scope_lambda.rb +8 -0
  86. data/spec/internal/app/admin/test_posts_scope_params.rb +8 -0
  87. data/spec/internal/app/admin/test_posts_scope_user.rb +8 -0
  88. data/spec/internal/app/admin/test_posts_text_attr.rb +5 -0
  89. data/spec/internal/app/admin/users.rb +23 -0
  90. data/spec/internal/app/admin/variants.rb +31 -0
  91. data/spec/internal/app/assets/config/manifest.js +1 -0
  92. data/spec/internal/app/assets/javascripts/active_admin.js +2 -0
  93. data/spec/internal/app/assets/javascripts/searchable_select_test.js +2 -0
  94. data/spec/internal/app/controllers/application_controller.rb +5 -0
  95. data/spec/internal/app/css/active_admin_source.css +81 -0
  96. data/spec/internal/app/js/active_admin.js +17 -0
  97. data/spec/internal/app/models/article.rb +12 -0
  98. data/spec/internal/app/models/category.rb +12 -0
  99. data/spec/internal/app/models/internal/tag_name.rb +14 -0
  100. data/spec/internal/app/models/internal_tag_name.rb +11 -0
  101. data/spec/internal/app/models/option_type.rb +12 -0
  102. data/spec/internal/app/models/option_value.rb +4 -0
  103. data/spec/internal/app/models/post.rb +15 -0
  104. data/spec/internal/app/models/product.rb +12 -0
  105. data/spec/internal/app/models/rgb_color.rb +16 -0
  106. data/spec/internal/app/models/user.rb +12 -0
  107. data/spec/internal/app/models/variant.rb +12 -0
  108. data/spec/internal/build_activeadmin_css.js +115 -0
  109. data/spec/internal/config/database.yml +7 -0
  110. data/spec/internal/config/environment.rb +48 -0
  111. data/spec/internal/config/initializers/active_admin.rb +53 -0
  112. data/spec/internal/config/initializers/assets.rb +9 -0
  113. data/spec/internal/config/initializers/searchable_select.rb +6 -0
  114. data/spec/internal/config/routes.rb +4 -0
  115. data/spec/internal/config.ru +4 -0
  116. data/spec/internal/db/schema.rb +63 -0
  117. data/spec/internal/db/seeds.rb +88 -0
  118. data/spec/internal/esbuild.config.js +30 -0
  119. data/spec/internal/inject-jquery.js +4 -0
  120. data/spec/internal/log/.gitignore +1 -0
  121. data/spec/internal/package/LICENSE.txt +25 -0
  122. data/spec/internal/package/README.md +439 -0
  123. data/spec/internal/package/package.json +45 -0
  124. data/spec/internal/package/src/index.js +1 -0
  125. data/spec/internal/package/src/searchable_select/init.js +1 -0
  126. data/spec/internal/package/src/searchable_select.css +1 -0
  127. data/spec/internal/package/src/searchable_select.scss +1 -0
  128. data/spec/internal/package-lock.json +1385 -0
  129. data/spec/internal/package.json +26 -0
  130. data/spec/internal/public/favicon.ico +0 -0
  131. data/spec/internal/spec/internal/app/css/active_admin_source.css +38 -0
  132. data/spec/internal/spec/internal/log/test.log +0 -0
  133. data/spec/internal/tailwind-active_admin.config.js +53 -0
  134. data/spec/rails_helper.rb +86 -0
  135. data/spec/spec_helper.rb +137 -0
  136. data/spec/support/active_admin_helpers.rb +17 -0
  137. data/spec/support/capybara.rb +8 -0
  138. data/spec/support/models.rb +88 -0
  139. data/spec/support/pluck_polyfill.rb +12 -0
  140. data/spec/support/reset_settings.rb +5 -0
  141. data/src/index.js +77 -0
  142. data/src/searchable_select/init.js +58 -0
  143. data/src/searchable_select.css +5 -0
  144. data/src/searchable_select.css.map +1 -0
  145. metadata +405 -0
@@ -0,0 +1,313 @@
1
+ # ActiveAdmin Trumbowyg 2.x Migration Guide
2
+
3
+ ## Overview
4
+ This guide covers migrating from activeadmin_trumbowyg 1.x to 2.x, which adds support for ActiveAdmin 4 and modern JavaScript build tools. Version 2.x introduces a new NPM package for easier integration with esbuild and webpack projects.
5
+
6
+ ## What's New in Version 2.x
7
+
8
+ ### NPM Package Support
9
+ - Published on NPM as `@rocket-sensei/activeadmin_trumbowyg`
10
+ - Direct integration with esbuild and webpack projects
11
+ - No generator needed for modern JavaScript bundlers
12
+ - Automatic jQuery dependency management
13
+
14
+ ### Path Changes
15
+ - JavaScript module paths changed from `activeadmin/` to `active_admin/`
16
+ - CSS paths updated to follow Rails conventions
17
+
18
+ ### Compatibility
19
+ - ActiveAdmin 3.x and 4.x support
20
+ - Rails 7.0+ required
21
+ - Ruby 3.2+ required
22
+ - Works with both Sprockets (legacy) and Propshaft
23
+
24
+ ## Installation Methods
25
+
26
+ ### Option 1: Modern JavaScript Bundlers (esbuild/webpack) - Recommended
27
+
28
+ #### Install the NPM package:
29
+ ```bash
30
+ npm install @rocket-sensei/activeadmin_trumbowyg
31
+ # or
32
+ yarn add @rocket-sensei/activeadmin_trumbowyg
33
+ ```
34
+
35
+ #### Import in your JavaScript entry point:
36
+ ```javascript
37
+ // app/javascript/active_admin.js or similar
38
+ import '@rocket-sensei/activeadmin_trumbowyg'
39
+ ```
40
+
41
+ That's it! No generator needed. The package automatically handles jQuery dependencies and initialization.
42
+
43
+ ### Option 2: Sprockets/Importmap (Legacy)
44
+
45
+ #### Add to Gemfile:
46
+ ```ruby
47
+ gem 'activeadmin_trumbowyg', '~> 2.0'
48
+ ```
49
+
50
+ #### Run the generator:
51
+ ```bash
52
+ rails generate activeadmin_trumbowyg:install
53
+ ```
54
+
55
+ This will add the necessary JavaScript and CSS to your ActiveAdmin configuration.
56
+
57
+ ## Migration from Version 1.x to 2.x
58
+
59
+ ### Step 1: Update Your Gemfile
60
+ ```ruby
61
+ # Old (1.x)
62
+ gem 'activeadmin_trumbowyg', '~> 1.0'
63
+
64
+ # New (2.x)
65
+ gem 'activeadmin_trumbowyg', '~> 2.0'
66
+ ```
67
+
68
+ ### Step 2: Update JavaScript Paths
69
+
70
+ If you're using esbuild or webpack, switch to the NPM package:
71
+
72
+ ```javascript
73
+ // Old (1.x) - Using gem assets
74
+ //= require activeadmin/trumbowyg/trumbowyg
75
+ //= require activeadmin/trumbowyg_input
76
+
77
+ // New (2.x) - Using NPM package
78
+ import '@rocket-sensei/activeadmin_trumbowyg'
79
+ ```
80
+
81
+ For Sprockets users, update the paths:
82
+
83
+ ```javascript
84
+ // Old (1.x)
85
+ //= require activeadmin/trumbowyg/trumbowyg
86
+ //= require activeadmin/trumbowyg_input
87
+
88
+ // New (2.x)
89
+ //= require active_admin/trumbowyg/trumbowyg
90
+ //= require active_admin/trumbowyg_input
91
+ ```
92
+
93
+ ### Step 3: Update CSS Imports
94
+
95
+ ```css
96
+ /* Old (1.x) */
97
+ @import "activeadmin/trumbowyg/trumbowyg";
98
+
99
+ /* New (2.x) */
100
+ @import "active_admin/trumbowyg/trumbowyg";
101
+ ```
102
+
103
+ ## Configuration Examples
104
+
105
+ ### esbuild Configuration
106
+
107
+ ```javascript
108
+ // esbuild.config.js
109
+ import esbuild from 'esbuild'
110
+
111
+ esbuild.build({
112
+ entryPoints: ['app/javascript/active_admin.js'],
113
+ bundle: true,
114
+ sourcemap: true,
115
+ format: 'esm',
116
+ outdir: 'app/assets/builds',
117
+ loader: {
118
+ '.js': 'jsx',
119
+ },
120
+ external: [], // jQuery is bundled by the NPM package
121
+ })
122
+ ```
123
+
124
+ ### webpack Configuration
125
+
126
+ ```javascript
127
+ // webpack.config.js
128
+ module.exports = {
129
+ entry: './app/javascript/active_admin.js',
130
+ output: {
131
+ path: path.resolve(__dirname, 'app/assets/builds'),
132
+ filename: 'active_admin.js'
133
+ },
134
+ module: {
135
+ rules: [
136
+ {
137
+ test: /\.js$/,
138
+ exclude: /node_modules/,
139
+ use: 'babel-loader'
140
+ }
141
+ ]
142
+ }
143
+ }
144
+ ```
145
+
146
+ ### Package.json Example
147
+
148
+ ```json
149
+ {
150
+ "name": "your-app",
151
+ "dependencies": {
152
+ "@rocket-sensei/activeadmin_trumbowyg": "^2.0.0",
153
+ "jquery": "^3.7.1"
154
+ },
155
+ "scripts": {
156
+ "build": "esbuild app/javascript/*.* --bundle --sourcemap --outdir=app/assets/builds"
157
+ }
158
+ }
159
+ ```
160
+
161
+ ## Usage in ActiveAdmin
162
+
163
+ After installation, use the Trumbowyg editor in your admin forms:
164
+
165
+ ```ruby
166
+ # app/admin/posts.rb
167
+ ActiveAdmin.register Post do
168
+ form do |f|
169
+ f.inputs do
170
+ f.input :title
171
+ f.input :content, as: :trumbowyg
172
+ # With options
173
+ f.input :description, as: :trumbowyg, input_html: {
174
+ data: {
175
+ trumbowyg_options: {
176
+ btns: [
177
+ ['viewHTML'],
178
+ ['formatting'],
179
+ ['strong', 'em', 'del'],
180
+ ['link'],
181
+ ['insertImage'],
182
+ ['unorderedList', 'orderedList'],
183
+ ['horizontalRule'],
184
+ ['removeformat'],
185
+ ['fullscreen']
186
+ ],
187
+ minimalLinks: true,
188
+ removeformatPasted: true
189
+ }
190
+ }
191
+ }
192
+ end
193
+ f.actions
194
+ end
195
+ end
196
+ ```
197
+
198
+ ## Customizing Trumbowyg
199
+
200
+ ### Custom Buttons and Plugins
201
+
202
+ The NPM package includes all Trumbowyg plugins. To use them:
203
+
204
+ ```javascript
205
+ // app/javascript/active_admin.js
206
+ import '@rocket-sensei/activeadmin_trumbowyg'
207
+
208
+ // Custom initialization (optional)
209
+ document.addEventListener('DOMContentLoaded', () => {
210
+ // Custom global defaults
211
+ $.trumbowyg.svgPath = '/assets/icons.svg'
212
+
213
+ // Language settings
214
+ $.trumbowyg.langs.en.bold = 'Strong'
215
+ })
216
+ ```
217
+
218
+ ### Styling the Editor
219
+
220
+ Add custom styles in your ActiveAdmin stylesheet:
221
+
222
+ ```scss
223
+ // app/assets/stylesheets/active_admin.scss
224
+ @import "active_admin/trumbowyg/trumbowyg";
225
+
226
+ // Custom overrides
227
+ .trumbowyg-box {
228
+ margin: 0;
229
+
230
+ .trumbowyg-editor {
231
+ min-height: 300px;
232
+ }
233
+ }
234
+
235
+ // Dark mode support
236
+ .dark {
237
+ .trumbowyg-box {
238
+ background: #374151;
239
+
240
+ .trumbowyg-editor {
241
+ background: #1f2937;
242
+ color: #f3f4f6;
243
+ }
244
+ }
245
+ }
246
+ ```
247
+
248
+ ## Troubleshooting
249
+
250
+ ### Common Issues and Solutions
251
+
252
+ #### Issue: Trumbowyg not initializing
253
+ **Solution**: Ensure jQuery is loaded before the Trumbowyg package:
254
+ ```javascript
255
+ // Correct order
256
+ import $ from 'jquery'
257
+ window.$ = window.jQuery = $
258
+ import '@rocket-sensei/activeadmin_trumbowyg'
259
+ ```
260
+
261
+ #### Issue: Icons not displaying
262
+ **Solution**: The SVG path might be incorrect. Set it explicitly:
263
+ ```javascript
264
+ $.trumbowyg.svgPath = '/assets/trumbowyg/icons.svg'
265
+ ```
266
+
267
+ #### Issue: Styles not loading with NPM package
268
+ **Solution**: Import the CSS separately in your stylesheet:
269
+ ```css
270
+ /* app/assets/stylesheets/active_admin.scss */
271
+ @import "@rocket-sensei/activeadmin_trumbowyg/dist/trumbowyg.min.css";
272
+ ```
273
+
274
+ #### Issue: Editor not working in nested forms
275
+ **Solution**: Re-initialize after adding new fields:
276
+ ```javascript
277
+ $(document).on('has_many_add:after', '.has_many_container', function() {
278
+ $(this).find('[data-trumbowyg]').each(function() {
279
+ if (!$(this).hasClass('trumbowyg-textarea-init')) {
280
+ const options = $(this).data('trumbowyg-options') || {}
281
+ $(this).trumbowyg(options)
282
+ }
283
+ })
284
+ })
285
+ ```
286
+
287
+ ## Breaking Changes from 1.x
288
+
289
+ 1. **Path changes**: All paths changed from `activeadmin/` to `active_admin/`
290
+ 2. **NPM package**: New recommended installation method via NPM
291
+ 3. **No generator for modern bundlers**: esbuild/webpack users don't need the generator
292
+ 4. **jQuery handling**: NPM package bundles jQuery dependencies automatically
293
+
294
+ ## Version Compatibility
295
+
296
+ | activeadmin_trumbowyg | ActiveAdmin | Rails | Ruby |
297
+ |-----------------------|-------------|-------|------|
298
+ | 2.x | 3.x - 4.x | 7.0+ | 3.2+ |
299
+ | 1.x | 1.x - 3.x | 5.2+ | 2.5+ |
300
+
301
+ ## Resources
302
+
303
+ - [NPM Package](https://www.npmjs.com/package/@rocket-sensei/activeadmin_trumbowyg)
304
+ - [GitHub Repository](https://github.com/rocket-sensei/activeadmin_trumbowyg)
305
+ - [Trumbowyg Documentation](https://alex-d.github.io/Trumbowyg/)
306
+ - [ActiveAdmin Documentation](https://activeadmin.info/)
307
+
308
+ ## Support
309
+
310
+ For issues or questions:
311
+ 1. Check the [GitHub Issues](https://github.com/rocket-sensei/activeadmin_trumbowyg/issues)
312
+ 2. Consult the [Trumbowyg documentation](https://alex-d.github.io/Trumbowyg/) for editor-specific questions
313
+ 3. For ActiveAdmin 4 specific issues, see the [ActiveAdmin upgrade guide](https://activeadmin.info/)
@@ -0,0 +1,213 @@
1
+ # Combustion
2
+
3
+ Combustion is a library to help you test your Rails Engines in a simple and effective manner, instead of creating a full Rails application in your spec or test folder.
4
+
5
+ It allows you to write your specs within the context of your engine, using only the parts of a Rails app you need.
6
+
7
+ ## Usage
8
+
9
+ Get the gem into either your gemspec or your Gemfile, depending on how you manage your engine's dependencies:
10
+
11
+ ```ruby
12
+ # gemspec
13
+ gem.add_development_dependency 'combustion', '~> 1.3'
14
+
15
+ # Gemfile
16
+ gem 'combustion', '~> 1.3'
17
+ ```
18
+
19
+ In your `spec_helper.rb`, get Combustion to set itself up - which has to happen before you introduce `rspec/rails` and - if being used - `capybara/rails`. Here's an example within context:
20
+
21
+ ```ruby
22
+ require 'bundler'
23
+
24
+ Bundler.require :default, :development
25
+
26
+ # If you're using all parts of Rails:
27
+ Combustion.initialize! :all
28
+ # Or, load just what you need:
29
+ # Combustion.initialize! :active_record, :action_controller
30
+
31
+ require 'rspec/rails'
32
+ # If you're using Capybara:
33
+ # require 'capybara/rails'
34
+
35
+ RSpec.configure do |config|
36
+ config.use_transactional_fixtures = true
37
+ end
38
+ ```
39
+
40
+ Please note that using `:all` as an argument for `Combustion.initialize!` will load all key parts of Rails that are considered essential for that version. For example: ActiveJob is only loaded for Rails 4.2 onwards, and Sprockets is only loaded for Rails 3.1-6.1 (as it is no longer part of the default set in 7.0).
41
+
42
+ You'll also want to run the generator that creates a minimal set of files expected by Rails - run this in the directory of your engine:
43
+
44
+ ```shell
45
+ combust
46
+
47
+ # or, if bundling with the git repo:
48
+ bundle exec combust
49
+ ```
50
+
51
+ Minitest support is considered to be experimental, but it's certainly working [for some](https://github.com/pat/combustion/issues/78). Comments on others' experiences are welcome!
52
+
53
+ What Combustion is doing is setting up a Rails application at `spec/internal` - but you only need to add the files within that directory that you're going to use. Read on for some detail about what that involves.
54
+
55
+ If you want to use Cucumber, I recommend starting with [these notes in issue #16](https://github.com/pat/combustion/issues/16) from Niklas Cathor.
56
+
57
+ ### Configuring a different test app directory
58
+
59
+ If you want your app to be located somewhere other than `spec/internal`, then make sure you configure it before you call `Combustion.initialize!`:
60
+
61
+ ```ruby
62
+ Combustion.path = 'spec/dummy'
63
+ Combustion.initialize! :all
64
+ ```
65
+
66
+
67
+ ### Configuring which Rails modules should be loaded.
68
+
69
+ By default, Combustion doesn't come with any of the Rails stack. You can customise this though - just pass in what you'd like loaded to the `Combustion.initialize!` call:
70
+
71
+ ```ruby
72
+ Combustion.initialize! :active_record, :action_controller,
73
+ :action_view, :sprockets
74
+ ```
75
+
76
+
77
+ And then in your engine's Gemfile:
78
+
79
+ ```ruby
80
+ group :test do
81
+ gem 'activerecord'
82
+ gem 'actionpack' # action_controller, action_view
83
+ gem 'sprockets'
84
+ end
85
+ ```
86
+
87
+ Make sure to specify the appropriate version that you want to use.
88
+
89
+ ActiveSupport and Railties are always loaded, as they're an integral part of Rails.
90
+
91
+ ### Using Models and ActiveRecord
92
+
93
+ If you're using ActiveRecord, then there are two critical files within your internal Rails app at `spec/internal` that you'll need to modify:
94
+
95
+ * config/database.yml
96
+ * db/schema.rb
97
+
98
+ Both follow the same structure as in any normal Rails application - and the schema file lets you avoid migrations, as it gets run whenever the test suite starts. Here's a quick sample (note that tables are overwritten if they already exist - this is necessary):
99
+
100
+ ```ruby
101
+ ActiveRecord::Schema.define do
102
+ create_table(:pages, :force => true) do |t|
103
+ t.string :name
104
+ t.text :content
105
+ t.timestamps
106
+ end
107
+ end
108
+ ```
109
+
110
+ #### Disabling Database Preparation
111
+
112
+ If you are preparing your own database manually or through different processes, you can disable different parts of the setup process by the following flags: `:database_reset`, `:load_schema`, and `:database_migrate`. All default to true.
113
+
114
+ ```ruby
115
+ Combustion.initialize! :active_record,
116
+ :database_reset => false,
117
+ :load_schema => false
118
+ ```
119
+
120
+ ### Configuring Combustion to initialise the test db from a .sql file instead of schema.rb
121
+
122
+ Name the file structure.sql and configure Combustion to use it before initialising:
123
+
124
+ ```ruby
125
+ Combustion.schema_format = :sql
126
+ Combustion.initialize! :all
127
+ ```
128
+
129
+ Any models that aren't provided by your engine should be located at `spec/internal/app/models`.
130
+
131
+ ### Using ActionController and ActionView
132
+
133
+ You'll only need to add controllers and views to your internal Rails app for whatever you're testing that your engine doesn't provide - this may be nothing at all, so perhaps you don't even need `spec/internal/app/views` or `spec/internal/app/controllers` directories.
134
+
135
+ However, if you're doing any testing of your engine's controllers or views, then you're going to need routes set up for them - so modify `spec/internal/config/routes.rb` accordingly:
136
+
137
+ ```ruby
138
+ Rails.application.routes.draw do
139
+ resources :pages
140
+ end
141
+ ```
142
+
143
+ Just like in a standard Rails app, if you have a mounted engine, then its routes are accessible through whatever it has been loaded as.
144
+
145
+ ### Customizing Rails application settings
146
+
147
+ If you would like to specify any Rails configuration parameter, you can do it without creating any environment file, simply passing a block to Combustion.initialize! like this:
148
+
149
+ ```ruby
150
+ Combustion.initialize! :all do
151
+ config.active_record.whitelist_attributes = false
152
+ end
153
+ ```
154
+
155
+ Values given through the initialize! block will be set during Rails initialization process, exactly before the corresponding environment file inside `spec/internals/config/enviroments` is loaded (when that file exists), overriding Combustion's defaults.
156
+
157
+ Parameters defined in, for instance, `spec/internals/config/environments/test.rb`, would override Combustion's defaults and also config settings passed to initialize!.
158
+
159
+ ### Using other Rails-focused libraries
160
+
161
+ Be aware that other gems may require parts of Rails when they're loaded, and this could cause some issues with Combustion's own setup. You may need to manage the loading yourself by setting `:require` to false in your Gemfile for the gem in question, and then requiring it manually in your spec_helper. View [issue #33](https://github.com/pat/combustion/issues/33) for an example with FactoryBot.
162
+
163
+ ### Environment and Logging
164
+
165
+ Your tests will execute within the test environment for the internal Rails app - and so logs are available at `spec/internal/log/test.log`. You should probably create that log directory so Rails doesn't complain.
166
+
167
+ ### Rack it up
168
+
169
+ Once you've got this set up, you can fire up your test environment quite easily with Rack - a `config.ru` file is provided by the generator. Just run `rackup` and visit [http://localhost:9292](http://localhost:9292).
170
+
171
+ ### Get your test on!
172
+
173
+ Now you're good to go - you can write specs within your engine's spec directory just like you were testing a full Rails application - models in `spec/models`, controllers in `spec/controllers`. If you bring Capybara into the mix, then the standard helpers from that will be loaded as well.
174
+
175
+ ```ruby
176
+ require 'spec_helper'
177
+
178
+ describe Page do
179
+ describe '#valid' do
180
+ it 'requires a name' do
181
+ # This is just an example. Go write your own tests!
182
+ end
183
+ end
184
+ end
185
+ ```
186
+
187
+
188
+ ## Compatibility
189
+
190
+ The current test matrix covers MRI 2.4 to 3.1, and Rails 3.1 to 7.0. It will possibly work on older versions and other Ruby implementations as well.
191
+
192
+ You can also use Combustion with multiple versions of Rails to test compatibility across them. [Appraisal](https://github.com/thoughtbot/appraisal) is a gem that can help with this, and a good starting reference is the [Thinking Sphinx](https://github.com/pat/thinking-sphinx) test suite, which runs against [multiple versions](https://github.com/pat/thinking-sphinx/blob/master/Appraisals) of Rails.
193
+
194
+ ## Limitations and Known Issues
195
+
196
+ Combustion is currently written with the expectation it'll be used with RSpec, but others have got it working with [Minitest](https://github.com/pat/combustion/issues/78). I'd love to make this more flexible - if you want to give it a shot before I get around to it, patches are very much welcome.
197
+
198
+ I've not tried using this with Cucumber, but it should work in theory without too much hassle. Let me know if I'm wrong!
199
+
200
+ ## Contributing
201
+
202
+ Please note that this project now has a [Contributor Code of Conduct](http://contributor-covenant.org/version/1/0/0/). By participating in this project you agree to abide by its terms.
203
+
204
+ Contributions are very much welcome - but keep in mind the following:
205
+
206
+ * Keep patches in a separate branch
207
+ * Don't mess with the version or history file. I'll take care of that when the patch is merged in.
208
+
209
+ The tests are extremely minimal, and patches to extend the suite are especially welcome.
210
+
211
+ ## Credits
212
+
213
+ Copyright (c) 2011-2021, Combustion is developed and maintained by Pat Allan, and is released under the open MIT Licence. Many thanks to HyperTiny for encouraging its development, and [all who have contributed patches](https://github.com/pat/combustion/contributors).