discourse/spec/integration
Alan Guo Xiang Tan 864b7b6bc8
DEV: Fix flaky test (#30215)
The test was flaky and failing with the following errors:

```
Failure/Error:
  klass
    .connection
    .select_raw(relation.arel) do |result, _|
      result.type_map = DB.type_map
      result.nfields == 1 ? result.column_values(0) : result.values
    end

NoMethodError:
  undefined method `select_raw' for nil

./lib/freedom_patches/fast_pluck.rb:60:in `pluck'
./vendor/bundle/ruby/3.3.0/gems/activerecord-7.2.2.1/lib/active_record/relation/calculations.rb:354:in `pick'
./app/models/web_crawler_request.rb:27:in `request_id'
./app/models/web_crawler_request.rb:31:in `rescue in request_id'
./app/models/web_crawler_request.rb:26:in `request_id'
./app/models/web_crawler_request.rb:19:in `write_cache!'
./app/models/concerns/cached_counting.rb:135:in `block (3 levels) in flush_to_db'
./vendor/bundle/ruby/3.3.0/gems/rails_multisite-6.1.0/lib/rails_multisite/connection_management/null_instance.rb:49:in `with_connection'
./vendor/bundle/ruby/3.3.0/gems/rails_multisite-6.1.0/lib/rails_multisite/connection_management.rb:21:in `with_connection'
./app/models/concerns/cached_counting.rb:134:in `block (2 levels) in flush_to_db'
./app/models/concerns/cached_counting.rb:124:in `each'
./app/models/concerns/cached_counting.rb:124:in `block in flush_to_db'
./lib/distributed_mutex.rb:53:in `block in synchronize'
./lib/distributed_mutex.rb:49:in `synchronize'
./lib/distributed_mutex.rb:49:in `synchronize'
./lib/distributed_mutex.rb:34:in `synchronize'
./app/models/concerns/cached_counting.rb:120:in `flush_to_db'
./app/models/concerns/cached_counting.rb:187:in `perform_increment!'
./app/models/web_crawler_request.rb:15:in `increment!'
./lib/middleware/request_tracker.rb:74:in `log_request'
./lib/middleware/request_tracker.rb:409:in `block in log_later'
./lib/scheduler/defer.rb:125:in `block in do_work'
./vendor/bundle/ruby/3.3.0/gems/rails_multisite-6.1.0/lib/rails_multisite/connection_management/null_instance.rb:49:in `with_connection'
./vendor/bundle/ruby/3.3.0/gems/rails_multisite-6.1.0/lib/rails_multisite/connection_management.rb:21:in `with_connection'
./lib/scheduler/defer.rb:119:in `do_work'
./lib/scheduler/defer.rb:105:in `block (2 levels) in start_thread'
```

This was due to running the defer thread in an async manner which is
actually no representative of the production environment. It also
revealed a spot in our code base where writes are happening in a GET
request which can cause requests to fail if ActiveRecord is in readonly
mode.
2024-12-11 10:12:58 +08:00
..
activerecord_preventing_writes_spec.rb DEV: Fix flaky test (#30215) 2024-12-11 10:12:58 +08:00
api_keys_spec.rb
auto_reject_reviewable_users_spec.rb
blocked_hotlinked_media_spec.rb
category_tag_spec.rb
content_security_policy_spec.rb
discord_omniauth_spec.rb
email_outbound_spec.rb
email_style_spec.rb DEV: deduplicate inline styles in emails (#30015) 2024-11-30 16:38:45 +01:00
facebook_omniauth_spec.rb
flags_spec.rb
github_omniauth_spec.rb
group_spec.rb
invalid_request_spec.rb DEV: Enable Rails 7.1 defaults 2024-08-12 10:41:13 +02:00
invite_only_registration_spec.rb
message_bus_spec.rb
multisite_cookies_spec.rb
multisite_spec.rb
rate_limiting_spec.rb DEV: Call Discourse.redis.flushdb after the end of each test (#29117) 2024-10-09 07:19:31 +08:00
request_tracker_spec.rb
same_ip_spammers_spec.rb
secure_uploads_spec.rb
smtp_spec.rb DEV: Attempt to fix a flaky spec (#29155) 2024-10-10 17:19:53 +08:00
spam_rules_spec.rb
tag_counts_spec.rb
topic_auto_close_spec.rb
topic_thumbnail_spec.rb
twitter_omniauth_spec.rb
watched_words_spec.rb