Use normal db transactions around tests (#13035)

* Use normal db transactions around tests

An unrelated spec failure was observed when this was run before
another test expecting the seed data to be present. It looks like the
specific pain point in https://github.com/forem/forem/pull/8865 was
around an rss reader spec (which is no longer in use) and I'd like to
try reverting this truncation behavior here.

The minimal failing test case I had on master was this

```
 rspec ./spec/system/dashboards/user_sorts_dashboard_articles_spec.rb:44  ./spec/lib/data_update_scripts/fix_profile_field_edge_cases_spec.rb
```

The find_by(attribute:...) in the edge case spec returned nil (since
there was no such profile field, the table had been truncated). Tests
pass locally so this might be fine to just leave on the defaults (if
that's the case the truncation support added in #8865 can also be
removed, this is the last caller).

* Reenable transactional feeds imports

rhymes pointed out that a second test uses this db_strategy and that's
the successor to the rss_feed_spec.rb that was the initial issue.

Attempt removal of the truncation strategy, and reenable the
transactional tests, for the feeds import.

* Remove database cleaner

Having removed the last use of it (in the feeds import spec) we no
longer need this gem.

* remove spec support for database cleaner
This commit is contained in:
Daniel Uber 2021-03-18 12:56:55 -05:00 committed by GitHub
parent 8dd65bd0a3
commit 195b202d85
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 2 additions and 19 deletions

View file

@ -160,7 +160,6 @@ end
group :test do
gem "approvals", "~> 0.0" # A library to make it easier to do golden-master style testing in Ruby
gem "database_cleaner-active_record", "~> 2.0.0", require: false # Strategies for cleaning databases using ActiveRecord. Can be used to ensure a clean state for testing.
gem "exifr", ">= 1.3.6" # EXIF Reader is a module to read EXIF from JPEG and TIFF images
gem "factory_bot_rails", "~> 6.1" # factory_bot is a fixtures replacement with a straightforward definition syntax, support for multiple build strategies
gem "launchy", "~> 2.5" # Launchy is helper class for launching cross-platform applications in a fire and forget manner.

View file

@ -219,10 +219,6 @@ GEM
puma (>= 3.8.0)
railties (>= 5.2.0)
dante (0.2.0)
database_cleaner-active_record (2.0.0)
activerecord (>= 5.a)
database_cleaner-core (~> 2.0.0)
database_cleaner-core (2.0.0)
ddtrace (0.46.0)
msgpack
dead_end (1.1.4)
@ -908,7 +904,6 @@ DEPENDENCIES
cloudinary (~> 1.19)
counter_culture (~> 2.8)
cypress-rails (~> 0.4.2)
database_cleaner-active_record (~> 2.0.0)
ddtrace (~> 0.46.0)
derailed_benchmarks (~> 2.0)
devise!

View file

@ -1,8 +1,6 @@
require "rails_helper"
RSpec.describe Feeds::Import, type: :service, vcr: true, db_strategy: :truncation do
self.use_transactional_tests = false
RSpec.describe Feeds::Import, type: :service, vcr: true do
let(:link) { "https://medium.com/feed/@vaidehijoshi" }
let(:nonmedium_link) { "https://circleci.com/blog/feed.xml" }
let(:nonpermanent_link) { "https://medium.com/feed/@macsiri/" }

View file

@ -1,7 +0,0 @@
require "database_cleaner-active_record"
RSpec.configure do |config|
config.after(:each, db_strategy: :truncation) do |_example|
DatabaseCleaner.clean_with(:truncation)
end
end

View file

@ -1,8 +1,6 @@
require "rails_helper"
RSpec.describe "Sorting Dashboard Articles", type: :system, js: true, db_strategy: :truncation do
self.use_transactional_tests = false
RSpec.describe "Sorting Dashboard Articles", type: :system, js: true do
let(:user) { create(:user) }
let(:article1) do
create(:article, user_id: user.id, published_at: 10.minutes.ago, created_at: 1.day.ago, public_reactions_count: 5,

Binary file not shown.