seanblue encountered a test failure in their Discourse plugin, discourse-ruby, with the error undefined method 'test_transaction=' for #<MiniSqlMultisiteConnection>. The issue occurred when running specs using d/rake plugin:spec['discourse-ruby'], despite the plugin working manually. tgxworld asked for the test command used, and riking suggested ensuring LOAD_PLUGINS=1 is set — though seanblue confirmed it was already being passed implicitly. tgxworld then identified the root cause: the d/rake script defaults to the development environment, which doesn’t support test transactions. The fix was to explicitly set RAILS_ENV=test before running the command: RAILS_ENV=test d/rake plugin:spec['discourse-ruby']. seanblue confirmed this resolved the issue.
I built a plugin last year and wanted to verify that it still works on the latest version of Discourse. After reinitializing my dev environment (I had DB migration issues) I was able to manually verify that the plugin still works. However, when I run my spec tests (which passed last year when I wrote them), I get the following error:
Failure/Error: DB.test_transaction = ActiveRecord::Base.connection.current_transaction
NoMethodError:
undefined method `test_transaction=' for #<MiniSqlMultisiteConnection:0x00007fb8b3815c40>
I also had Discourse Footnote installed locally, and I get the same error when I run those tests.
Can anyone suggest how to fix my environment and/or my tests so that they pass on the current version of Discourse?
Make sure to include LOAD_PLUGINS=1 when running bin/rspec from the discourse source directory (with the plugin repo symlinked from the plugins/ folder).
I’m running the following command from the discourse directory:
d/rake plugin:spec['discourse-ruby']
@riking I’m not explicitly including LOAD_PLUGINS=1, but that seems to happen anyway (I assume since I’m doing plugin:spec). The first line after executing the command is:
It looks like the d/rake script defaults to the development environment by default so you’ll need to run the following instead: RAILS_ENV=test d/rake plugin:spec['discourse-ruby']