discourse/spec
Blake Erickson 2861b9337d
DEV: Fix flaky admin badges.json api docs spec (#17210)
* DEV: Fix flaky admin badges.json api docs spec

This commit is to fix this incredibly vague error message:

```
Failure/Error: expect(valid).to eq(true)

  expected: true
       got: false
```

From this test:

> Assertion: badges /admin/badges.json get success response behaves like
> a JSON endpoint response body matches the documented response schema

I was finally able to repro locally using parallel tests:

```
RAILS_ENV=test bundle exec ./bin/turbo_rspec
```

I *think* the parallel tests might be swallowing the `puts` output, but
when I also specified the individual spec file

```
RAILS_ENV=test bundle exec ./bin/turbo_rspec spec/requests/api/badges_spec.rb
```

It revealed the issue:

```
VALIDATION DETAILS: {"missing_keys"=>["i18n_name"]}
```

``` ruby
...
  def include_i18n_name?
    object.system?
  end
```

Looks like if the "system" user isn't being used the `i18n_name` won't
be returned in the json response so we shouldn't mark it as a required
attribute.

* Switch to using fab!

When using `let(:badge)` to fabricate a test badge it wouldn't be
returned from the controller, but switching to using `fab!` allows it to
be returned in the json data giving us a non-system badge to test
against.
2022-06-23 14:32:17 -06:00
..
fabricators FIX: respect user timezone in emails about silencing and suspending (#16918) 2022-05-27 13:58:54 +04:00
fixtures FIX: Missing translation when translation override contained a %{key} (#16625) 2022-05-04 17:35:22 +02:00
helpers DEV: Remove ember-cli flags from the backend (#17147) 2022-06-20 16:33:05 +02:00
import_export DEV: Automatically require 'rails_helper' in all specs (#16077) 2022-03-01 17:50:50 +00:00
initializers DEV: Automatically require 'rails_helper' in all specs (#16077) 2022-03-01 17:50:50 +00:00
integration DEV: Cleanup topic thumbnail enqueuing (#17119) 2022-06-17 11:07:32 +01:00
integrity DEV: Upgrade to Rails 7 2022-04-28 11:51:03 +02:00
jobs DEV: drop unused column flair_url from groups table. (#17179) 2022-06-22 00:15:05 +05:30
lib FIX: Use first supported type item when JSON-LD returns array (#17217) 2022-06-23 13:02:01 -04:00
mailers FIX: respect user timezone in emails about silencing and suspending (#16918) 2022-05-27 13:58:54 +04:00
models FIX: Use bookmarkable pattern for bookmark cleanup (#17202) 2022-06-23 14:09:39 +10:00
multisite FEATURE: Make S3 presigned GET URL expiry configurable (#16912) 2022-05-26 09:53:01 +10:00
requests DEV: Fix flaky admin badges.json api docs spec (#17210) 2022-06-23 14:32:17 -06:00
script/import_scripts FEATURE: Promote polymorphic bookmarks to default and migrate (#16729) 2022-05-23 10:07:15 +10:00
serializers UX: Change wording for 'regular' categories to 'normal' (#17134) 2022-06-20 06:49:33 +03:00
services FEATURE: Custom unsubscribe options (#17090) 2022-06-21 15:49:47 -03:00
support FIX: Allow .ics for polymorphic bookmarks (#16694) 2022-05-11 09:29:24 +10:00
tasks FEATURE: Create upload_references table (#16146) 2022-06-09 09:24:30 +10:00
views DEV: Upgrade to Rails 7 2022-04-28 11:51:03 +02:00
rails_helper.rb DEV: Apply Rails 6.1 defaults 2022-05-24 17:13:44 +02:00
regenerate_swagger_docs DEV: Add API docs for uploads and API doc watcher (#15387) 2021-12-23 08:40:15 +10:00
swagger_helper.rb DEV: Fix openapi definition logo URL (#17038) 2022-06-08 13:10:20 +01:00