Spec Fix: Use Truncation For Tests Where Transactions Get Stuck (#8865)
This commit is contained in:
parent
dda6422e22
commit
757e611f6d
8 changed files with 17 additions and 4 deletions
|
|
@ -35,7 +35,6 @@ env:
|
|||
- GITHUB_SECRET=dummy
|
||||
- KNAPSACK_PRO_FIXED_QUEUE_SPLIT=true
|
||||
- KNAPSACK_PRO_LOG_LEVEL=info
|
||||
- KNAPSACK_PRO_TEST_FILE_EXCLUDE_PATTERN="spec/services/rss_reader_spec.rb"
|
||||
- KNAPSACK_PRO_CI_NODE_TOTAL=3
|
||||
- COVERAGE_REPORTS_TOTAL=4
|
||||
jobs:
|
||||
|
|
@ -72,7 +71,6 @@ script:
|
|||
- if [ "$KNAPSACK_PRO_CI_NODE_INDEX" == "1" ]; then bundle exec bundle-audit check --update --ignore CVE-2015-9284; fi
|
||||
- if [ "$KNAPSACK_PRO_CI_NODE_INDEX" == "1" ]; then yarn build-storybook; fi
|
||||
- if [ "$KNAPSACK_PRO_CI_NODE_INDEX" == "2" ]; then bundle exec rails runner -e production 'puts "App booted successfully"'; fi
|
||||
- if [ "$KNAPSACK_PRO_CI_NODE_INDEX" == "2" ]; then bundle exec rspec spec/services/rss_reader_spec.rb; fi
|
||||
after_script:
|
||||
- ./cc-test-reporter format-coverage -t simplecov -o ./coverage/codeclimate.$KNAPSACK_PRO_CI_NODE_INDEX.json ./coverage/spec/.resultset.json
|
||||
- ./cc-test-reporter sum-coverage --output - --parts $COVERAGE_REPORTS_TOTAL coverage/codeclimate.*.json | ./cc-test-reporter upload-coverage --input -
|
||||
|
|
|
|||
1
Gemfile
1
Gemfile
|
|
@ -148,6 +148,7 @@ 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", "~> 1.8.0"
|
||||
gem "exifr", ">= 1.3.6" # EXIF Reader is a module to read EXIF from JPEG and TIFF images
|
||||
gem "factory_bot_rails", "~> 6.0" # 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.
|
||||
|
|
|
|||
|
|
@ -222,6 +222,10 @@ GEM
|
|||
safe_yaml (~> 1.0.0)
|
||||
crass (1.0.6)
|
||||
dante (0.2.0)
|
||||
database_cleaner (1.8.5)
|
||||
database_cleaner-active_record (1.8.0)
|
||||
activerecord
|
||||
database_cleaner (~> 1.8.0)
|
||||
datetime_picker_rails (0.0.7)
|
||||
momentjs-rails (>= 2.8.1)
|
||||
ddtrace (0.36.0)
|
||||
|
|
@ -903,6 +907,7 @@ DEPENDENCIES
|
|||
cld (~> 0.8)
|
||||
cloudinary (~> 1.15)
|
||||
counter_culture (~> 2.5)
|
||||
database_cleaner-active_record (~> 1.8.0)
|
||||
ddtrace (~> 0.36.0)
|
||||
derailed_benchmarks (~> 1.7)
|
||||
devise (~> 4.7)
|
||||
|
|
|
|||
|
|
@ -3,7 +3,9 @@ require "rss"
|
|||
|
||||
default_logger = Rails.logger
|
||||
|
||||
RSpec.describe RssReader, type: :service, vcr: true do
|
||||
RSpec.describe RssReader, type: :service, vcr: true, db_strategy: :truncation do
|
||||
self.use_transactional_tests = false
|
||||
|
||||
let(:link) { "https://medium.com/feed/@vaidehijoshi" }
|
||||
let(:nonmedium_link) { "https://circleci.com/blog/feed.xml" }
|
||||
let(:nonpermanent_link) { "https://medium.com/feed/@macsiri/" }
|
||||
|
|
|
|||
5
spec/support/database_cleaner.rb
Normal file
5
spec/support/database_cleaner.rb
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
RSpec.configure do |config|
|
||||
config.after(:each, db_strategy: :truncation) do |_example|
|
||||
DatabaseCleaner.clean_with(:truncation)
|
||||
end
|
||||
end
|
||||
|
|
@ -1,6 +1,8 @@
|
|||
require "rails_helper"
|
||||
|
||||
RSpec.describe "Sorting Dashboard Articles", type: :system, js: true do
|
||||
RSpec.describe "Sorting Dashboard Articles", type: :system, js: true, db_strategy: :truncation do
|
||||
self.use_transactional_tests = false
|
||||
|
||||
let(:user) { create(:user) }
|
||||
let(:article1) { create(:article, user_id: user.id, published_at: 10.minutes.ago, created_at: 1.day.ago, public_reactions_count: 5, page_views_count: 0, comments_count: 100) }
|
||||
let(:article2) { create(:article, user_id: user.id, published_at: 1.minute.ago, created_at: 2.days.ago, public_reactions_count: 1, page_views_count: 10, comments_count: 0) }
|
||||
|
|
|
|||
BIN
vendor/cache/database_cleaner-1.8.5.gem
vendored
Normal file
BIN
vendor/cache/database_cleaner-1.8.5.gem
vendored
Normal file
Binary file not shown.
BIN
vendor/cache/database_cleaner-active_record-1.8.0.gem
vendored
Normal file
BIN
vendor/cache/database_cleaner-active_record-1.8.0.gem
vendored
Normal file
Binary file not shown.
Loading…
Add table
Reference in a new issue