zooniverse / talk-api

Apache License 2.0
6 stars 0 forks source link

Rails 5.0 - Updated tests to get announcements_controller working #323

Closed yuenmichelle1 closed 4 months ago

yuenmichelle1 commented 5 months ago

These changes were geared to get announcements_controller.rb tests to pass. (Because of shared examples/specs were laid out on talk, it may be possible more tests have passed because of this).

What's surprisingly nice is that talk actually does boot up on Rails 5.0. 👍

Changes: 1) Rails 4 -> 5, parameters no longer inherit from HashWithIndifferentAccess (https://guides.rubyonrails.org/upgrading_ruby_on_rails.html#actioncontroller-parameters-no-longer-inherits-from-hashwithindifferentaccess) 2) response.json no longer is valid in Rails 5. response's class in Rails 4 is ActionController::TestResponse in Rails 5, response's class is ActionDispatch::TestResponse
3) Starting Rails 5, responses will default to 204s unless specified otherwise. And status of 204 will return response.content_type as nil when response body is empty (https://www.bigbinary.com/blog/controller-actions-default-no-content-in-rails-5-if-template-is-missing)

TODO: —> ENSURE THIS (responding with content_type nil vs application/json on 204s) DOES NOT AFFECT TALK’S FRONT END IN PFE