# Plugin tests fail with "undefined method \`test\_transaction='"

**URL:** https://meta.discourse.org/t/plugin-tests-fail-with-undefined-method-test-transaction/176292
**Category:** Development
**Created:** [January 16, 2021, 4:25pm UTC](https://meta.discourse.org/t/plugin-tests-fail-with-undefined-method-test-transaction/176292 "2021-01-16T16:25:31Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![seanblue](https://avatars.discourse-cdn.com/v4/letter/s/dc4da7/32.png) [@seanblue](https://meta.discourse.org/u/seanblue)
#### Post date: [January 16, 2021, 4:25pm UTC](https://meta.discourse.org/t/plugin-tests-fail-with-undefined-method-test-transaction/176292/1 "2021-01-16T16:25:31Z")

</div>

I built [a plugin](https://github.com/seanblue/discourse-ruby) 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](https://github.com/seanblue/discourse-ruby/blob/master/spec/markdown_ruby_spec.rb) (which passed last year when I wrote them), I get the following error:

```plaintext
Failure/Error: DB.test_transaction = ActiveRecord::Base.connection.current_transaction
      
      NoMethodError:
        undefined method `test_transaction=' for #<MiniSqlMultisiteConnection:0x00007fb8b3815c40>

```

I also had [Discourse Footnote](https://meta.discourse.org/t/discourse-footnote/84533) 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?

---

<div class="post-metadata">

### Author: ![tgxworld](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/tgxworld/32/106117_2.png) [@tgxworld](https://meta.discourse.org/u/tgxworld)
#### Post date: [January 22, 2021, 4:55am UTC](https://meta.discourse.org/t/plugin-tests-fail-with-undefined-method-test-transaction/176292/2 "2021-01-22T04:55:20Z")

</div>

What command did you use to run your test?

---

<div class="post-metadata">

### Author: ![riking](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/riking/32/170938_2.png) [@riking](https://meta.discourse.org/u/riking)
#### Post date: [January 22, 2021, 5:55am UTC](https://meta.discourse.org/t/plugin-tests-fail-with-undefined-method-test-transaction/176292/3 "2021-01-22T05:55:11Z")

</div>

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).

---

<div class="post-metadata">

### Author: ![seanblue](https://avatars.discourse-cdn.com/v4/letter/s/dc4da7/32.png) [@seanblue](https://meta.discourse.org/u/seanblue)
#### Post date: [January 22, 2021, 1:19pm UTC](https://meta.discourse.org/t/plugin-tests-fail-with-undefined-method-test-transaction/176292/4 "2021-01-22T13:19:52Z")

</div>

I’m running the following command from the `discourse` directory:

```plaintext
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:

```plaintext
LOAD_PLUGINS=1 /usr/local/bin/ruby -S rspec ./plugins/discourse-ruby/spec/markdown_ruby_spec.rb --profile

```

If I include it explicitly as in the following, I get the same error:

```plaintext
d/rake plugin:spec['discourse-ruby'] LOAD_PLUGINS=1

```

---

<div class="post-metadata">

### Author: ![tgxworld](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/tgxworld/32/106117_2.png) [@tgxworld](https://meta.discourse.org/u/tgxworld)
#### Post date: [January 25, 2021, 1:10am UTC](https://meta.discourse.org/t/plugin-tests-fail-with-undefined-method-test-transaction/176292/5 "2021-01-25T01:10:25Z")

</div>

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']`

---

<div class="post-metadata">

### Author: ![seanblue](https://avatars.discourse-cdn.com/v4/letter/s/dc4da7/32.png) [@seanblue](https://meta.discourse.org/u/seanblue)
#### Post date: [January 28, 2021, 10:39pm UTC](https://meta.discourse.org/t/plugin-tests-fail-with-undefined-method-test-transaction/176292/6 "2021-01-28T22:39:07Z")

</div>

This worked, thank you!
