mirror of
https://github.com/discourse/discourse.git
synced 2024-11-26 10:13:45 +08:00
2861b9337d
* 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. |
||
---|---|---|
.. | ||
schemas | ||
shared | ||
backups_spec.rb | ||
badges_spec.rb | ||
categories_spec.rb | ||
groups_spec.rb | ||
invites_spec.rb | ||
notifications_spec.rb | ||
posts_spec.rb | ||
private_messages_spec.rb | ||
search_spec.rb | ||
site_spec.rb | ||
tags_spec.rb | ||
topics_spec.rb | ||
uploads_spec.rb | ||
user_badges_spec.rb | ||
users_spec.rb |