discourse/spec/requests/api
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
..
schemas DEV: Fix flaky admin badges.json api docs spec (#17210) 2022-06-23 14:32:17 -06:00
shared document user endpoints (#11894) 2021-01-29 11:27:11 -07:00
backups_spec.rb DEV: Fix methods removed in Ruby 3.2 (#15459) 2022-01-05 18:45:08 +01:00
badges_spec.rb DEV: Fix flaky admin badges.json api docs spec (#17210) 2022-06-23 14:32:17 -06:00
categories_spec.rb DEV: Add include_subcategories param to api docs (#14534) 2021-10-06 12:34:03 -06:00
groups_spec.rb DEV: Add missing operationIds to the api docs (#14235) 2021-09-03 07:39:29 -06:00
invites_spec.rb repair structural problems with the openapi spec (#16710) 2022-06-20 10:56:56 -06:00
notifications_spec.rb DEV: Add missing operationIds to the api docs (#14235) 2021-09-03 07:39:29 -06:00
posts_spec.rb DEV: Fix broken spec due to 213bcde080 (#17009) 2022-06-06 16:37:08 +08:00
private_messages_spec.rb DEV: Add missing operationIds to the api docs (#14235) 2021-09-03 07:39:29 -06:00
search_spec.rb FIX: Limits for PM and group header search (#16887) 2022-05-24 11:31:24 -04:00
site_spec.rb DEV: Add site.json to api docs (#14249) 2021-09-07 10:36:05 -06:00
tags_spec.rb DEV: Add missing operationIds to the api docs (#14235) 2021-09-03 07:39:29 -06:00
topics_spec.rb DEV: Allow params to be passed on topic redirects (#16218) 2022-03-17 19:27:51 -06:00
uploads_spec.rb DEV: Correctly tag heredocs (#16061) 2022-02-28 20:50:55 +01:00
user_badges_spec.rb DEV: Add missing operationIds to the api docs (#14235) 2021-09-03 07:39:29 -06:00
users_spec.rb FIX: Show suspended by user (#16927) 2022-06-01 14:54:23 +02:00