From 767508c9d1567364388d58155efd66dae9a9cc34 Mon Sep 17 00:00:00 2001 From: Pascal Zumkehr Date: Mon, 18 Nov 2024 17:13:17 +0100 Subject: [PATCH] Update rails to 8.0 --- Gemfile | 9 +- Gemfile.lock | 143 ++++---- app/models/access_code.rb | 2 +- app/models/archive_format.rb | 6 +- app/models/user.rb | 2 +- app/services/downgrade/action_handler.rb | 2 +- app/services/import/recording/composer.rb | 2 +- bin/dev | 4 + bin/rubocop | 10 + config/application.rb | 7 +- config/deploy.rb | 2 +- config/environments/development.rb | 3 + config/environments/production.rb | 9 + config/environments/test.rb | 5 +- config/initializers/inflections.rb | 1 + config/puma.rb | 65 ++-- doc/swagger.json | 344 +++++------------- .../admin/access_codes_controller_test.rb | 12 +- .../admin/archive_formats_controller_test.rb | 14 +- .../admin/audio_encodings_controller_test.rb | 2 +- .../downgrade_actions_controller_test.rb | 12 +- .../admin/playback_formats_controller_test.rb | 12 +- .../admin/profiles_controller_test.rb | 14 +- .../admin/shows_controller_test.rb | 18 +- .../admin/stats_controller_test.rb | 2 +- .../admin/users_controller_test.rb | 14 +- .../audio_files_controller_test.rb | 24 +- .../controllers/broadcasts_controller_test.rb | 6 +- test/controllers/login_controller_test.rb | 28 +- test/controllers/shows_controller_test.rb | 4 +- test/controllers/tracks_controller_test.rb | 6 +- test/integration/api/authorization_test.rb | 14 +- test/integration/api/media_type_test.rb | 4 +- 33 files changed, 333 insertions(+), 469 deletions(-) create mode 100755 bin/dev create mode 100755 bin/rubocop diff --git a/Gemfile b/Gemfile index 18d2c39..d63c7cc 100644 --- a/Gemfile +++ b/Gemfile @@ -6,7 +6,7 @@ gem 'actionpack' gem 'activerecord' gem 'railties' -gem 'pg', '< 1.3.0' # newer requires posgresql >= 9.3 +gem 'pg' gem 'active_model_serializers' gem 'jwt' @@ -28,9 +28,6 @@ gem 'bootsnap', require: false # which is currently not available in production. gem 'rdoc', '< 6.4.0' -# Ruby 3.0 uses this version of the base64 default gem -gem 'base64', '0.1.0' - group :development, :test do # Use sqlite3 as the database for Active Record gem 'sqlite3' @@ -48,10 +45,6 @@ group :development do gem 'rubocop-rails' # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring gem 'spring' - - # Loading the listen gem enables an evented file system monitor. Check - # https://github.com/guard/listen#listen-adapters if on Windows or *BSD. - # gem 'listen', '~> 3.0.4' end group :test do diff --git a/Gemfile.lock b/Gemfile.lock index 3091b33..42e558c 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,18 +1,18 @@ GEM remote: https://rubygems.org/ specs: - actionpack (7.1.4.1) - actionview (= 7.1.4.1) - activesupport (= 7.1.4.1) + actionpack (8.0.0) + actionview (= 8.0.0) + activesupport (= 8.0.0) nokogiri (>= 1.8.5) - racc rack (>= 2.2.4) rack-session (>= 1.0.1) rack-test (>= 0.6.3) rails-dom-testing (~> 2.2) rails-html-sanitizer (~> 1.6) - actionview (7.1.4.1) - activesupport (= 7.1.4.1) + useragent (~> 0.16) + actionview (8.0.0) + activesupport (= 8.0.0) builder (~> 3.1) erubi (~> 1.11) rails-dom-testing (~> 2.2) @@ -22,37 +22,41 @@ GEM activemodel (>= 4.1) case_transform (>= 0.2) jsonapi-renderer (>= 0.1.1.beta1, < 0.3) - activemodel (7.1.4.1) - activesupport (= 7.1.4.1) - activerecord (7.1.4.1) - activemodel (= 7.1.4.1) - activesupport (= 7.1.4.1) + activemodel (8.0.0) + activesupport (= 8.0.0) + activerecord (8.0.0) + activemodel (= 8.0.0) + activesupport (= 8.0.0) timeout (>= 0.4.0) - activesupport (7.1.4.1) + activesupport (8.0.0) base64 + benchmark (>= 0.3) bigdecimal - concurrent-ruby (~> 1.0, >= 1.0.2) + concurrent-ruby (~> 1.0, >= 1.3.1) connection_pool (>= 2.2.5) drb i18n (>= 1.6, < 2) + logger (>= 1.4.2) minitest (>= 5.1) - mutex_m - tzinfo (~> 2.0) - airbrussh (1.5.1) + securerandom (>= 0.3) + tzinfo (~> 2.0, >= 2.0.5) + uri (>= 0.13.1) + airbrussh (1.5.3) sshkit (>= 1.6.1, != 1.7.0) ast (2.4.2) base64 (0.1.0) + benchmark (0.4.0) bigdecimal (3.1.8) - bootsnap (1.18.3) + bootsnap (1.18.4) msgpack (~> 1.2) builder (3.3.0) byebug (11.1.3) - capistrano (3.18.0) + capistrano (3.19.2) airbrussh (>= 1.0.0) i18n rake (>= 10.0.0) sshkit (>= 1.9.0) - capistrano-bundler (2.1.0) + capistrano-bundler (2.1.1) capistrano (~> 3.1) capistrano-passenger (0.2.1) capistrano (~> 3.0) @@ -65,18 +69,18 @@ GEM concurrent-ruby (1.3.4) connection_pool (2.4.1) crass (1.0.6) - docile (1.4.0) + docile (1.4.1) drb (2.2.1) erubi (1.13.0) i18n (1.14.6) concurrent-ruby (~> 1.0) io-console (0.7.2) - irb (1.11.2) - rdoc + irb (1.14.1) + rdoc (>= 4.0.0) reline (>= 0.4.2) - json (2.7.1) + json (2.8.2) jsonapi-renderer (0.2.2) - jwt (2.8.0) + jwt (2.9.3) base64 kaminari (1.2.2) activesupport (>= 4.1.0) @@ -91,32 +95,33 @@ GEM kaminari-core (= 1.2.2) kaminari-core (1.2.2) language_server-protocol (3.17.0.3) - loofah (2.22.0) + logger (1.6.1) + loofah (2.23.1) crass (~> 1.0.2) nokogiri (>= 1.12.0) - mini_portile2 (2.8.7) + mini_portile2 (2.8.8) minitest (5.25.1) - mocha (2.1.0) + mocha (2.5.0) ruby2_keywords (>= 0.0.5) - msgpack (1.7.2) + msgpack (1.7.5) multi_json (1.15.0) - mutex_m (0.2.0) net-scp (4.0.0) net-ssh (>= 2.6.5, < 8.0.0) net-sftp (4.0.0) net-ssh (>= 5.0.0, < 8.0.0) - net-ssh (7.2.1) - nio4r (2.7.3) + net-ssh (7.3.0) + nio4r (2.7.4) nokogiri (1.16.7) mini_portile2 (~> 2.8.2) racc (~> 1.4) nokogiri (1.16.7-x86_64-linux) racc (~> 1.4) - parallel (1.24.0) - parser (3.3.0.5) + ostruct (0.6.1) + parallel (1.26.3) + parser (3.3.6.0) ast (~> 2.4.1) racc - pg (1.2.3) + pg (1.5.9) puma (6.4.3) nio4r (~> 2.0) racc (1.8.1) @@ -127,9 +132,8 @@ GEM rack (>= 3.0.0) rack-test (2.1.0) rack (>= 1.3) - rackup (2.1.0) + rackup (2.2.1) rack (>= 3) - webrick (~> 1.8) rails-dom-testing (2.2.0) activesupport (>= 5.0.0) minitest @@ -142,75 +146,77 @@ GEM rails-html-sanitizer (1.6.0) loofah (~> 2.21) nokogiri (~> 1.14) - rails-i18n (7.0.8) + rails-i18n (8.0.1) i18n (>= 0.7, < 2) - railties (>= 6.0.0, < 8) - railties (7.1.4.1) - actionpack (= 7.1.4.1) - activesupport (= 7.1.4.1) - irb + railties (>= 8.0.0, < 9) + railties (8.0.0) + actionpack (= 8.0.0) + activesupport (= 8.0.0) + irb (~> 1.13) rackup (>= 1.0.0) rake (>= 12.2) thor (~> 1.0, >= 1.2.2) zeitwerk (~> 2.6) rainbow (3.1.1) - rake (13.1.0) + rake (13.2.1) rdoc (6.3.4.1) - regexp_parser (2.9.0) - reline (0.4.2) + regexp_parser (2.9.2) + reline (0.5.11) io-console (~> 0.5) rexml (3.3.9) - rubocop (1.60.2) + rubocop (1.68.0) json (~> 2.3) language_server-protocol (>= 3.17.0) parallel (~> 1.10) parser (>= 3.3.0.2) rainbow (>= 2.2.2, < 4.0) - regexp_parser (>= 1.8, < 3.0) - rexml (>= 3.2.5, < 4.0) - rubocop-ast (>= 1.30.0, < 2.0) + regexp_parser (>= 2.4, < 3.0) + rubocop-ast (>= 1.32.2, < 2.0) ruby-progressbar (~> 1.7) unicode-display_width (>= 2.4.0, < 3.0) - rubocop-ast (1.30.0) - parser (>= 3.2.1.0) - rubocop-performance (1.20.2) + rubocop-ast (1.36.1) + parser (>= 3.3.1.0) + rubocop-performance (1.23.0) rubocop (>= 1.48.1, < 2.0) - rubocop-ast (>= 1.30.0, < 2.0) - rubocop-rails (2.23.1) + rubocop-ast (>= 1.31.1, < 2.0) + rubocop-rails (2.27.0) activesupport (>= 4.2.0) rack (>= 1.1) - rubocop (>= 1.33.0, < 2.0) - rubocop-ast (>= 1.30.0, < 2.0) + rubocop (>= 1.52.0, < 2.0) + rubocop-ast (>= 1.31.1, < 2.0) ruby-graphviz (1.2.5) rexml ruby-progressbar (1.13.0) ruby2_keywords (0.0.5) + securerandom (0.3.2) simplecov (0.22.0) docile (~> 1.1) simplecov-html (~> 0.11) simplecov_json_formatter (~> 0.1) - simplecov-html (0.12.3) + simplecov-html (0.13.1) simplecov-lcov (0.8.0) simplecov_json_formatter (0.1.4) - spring (4.1.3) - sqlite3 (1.7.2) + spring (4.2.1) + sqlite3 (2.2.0) mini_portile2 (~> 2.8.0) - sqlite3 (1.7.2-x86_64-linux) - sshkit (1.22.0) - mutex_m + sqlite3 (2.2.0-x86_64-linux-gnu) + sshkit (1.23.2) + base64 net-scp (>= 1.1.2) net-sftp (>= 2.1.2) net-ssh (>= 2.8.0) + ostruct streamio-ffmpeg (3.0.2) multi_json (~> 1.8) swagger-blocks (3.0.0) - thor (1.3.0) - timeout (0.4.1) + thor (1.3.2) + timeout (0.4.2) tzinfo (2.0.6) concurrent-ruby (~> 1.0) - unicode-display_width (2.5.0) - webrick (1.8.2) - zeitwerk (2.6.13) + unicode-display_width (2.6.0) + uri (1.0.2) + useragent (0.16.10) + zeitwerk (2.7.1) PLATFORMS ruby @@ -220,7 +226,6 @@ DEPENDENCIES actionpack active_model_serializers activerecord - base64 (= 0.1.0) bootsnap byebug capistrano-passenger @@ -228,7 +233,7 @@ DEPENDENCIES jwt kaminari mocha - pg (< 1.3.0) + pg puma rack-cors rails-erd diff --git a/app/models/access_code.rb b/app/models/access_code.rb index afe0901..a3b7845 100644 --- a/app/models/access_code.rb +++ b/app/models/access_code.rb @@ -23,7 +23,7 @@ class AccessCode < ApplicationRecord before_validation :generate_code, on: :create scope :list, -> { order(expires_at: :desc) } - scope :expired, -> { where('expires_at < ?', Time.zone.today) } + scope :expired, -> { where(expires_at: ...Time.zone.today) } private diff --git a/app/models/archive_format.rb b/app/models/archive_format.rb index d8a38c1..e0a6f6a 100644 --- a/app/models/archive_format.rb +++ b/app/models/archive_format.rb @@ -27,8 +27,8 @@ class ArchiveFormat < ApplicationRecord attr_readonly :codec - enum download_permission: { public: 0, logged_in: 1, priviledged: 2, admin: 3 }, - _prefix: true + enum :download_permission, { public: 0, logged_in: 1, priviledged: 2, admin: 3 }, + prefix: true belongs_to :profile @@ -72,7 +72,7 @@ class ArchiveFormat < ApplicationRecord def priviledged_groups=(value) value = value.join(',') if value.is_a?(Array) - super(value) + super end def priviledged_group_list diff --git a/app/models/user.rb b/app/models/user.rb index 311dbb8..0f8fbc9 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -41,7 +41,7 @@ def admin? def groups=(value) value = value.join(',') if value.is_a?(Array) - super(value) + super end def group_list diff --git a/app/services/downgrade/action_handler.rb b/app/services/downgrade/action_handler.rb index 0f20b08..9ebd51f 100644 --- a/app/services/downgrade/action_handler.rb +++ b/app/services/downgrade/action_handler.rb @@ -35,7 +35,7 @@ def pending_files .joins(broadcast: { show: { profile: :archive_formats } }) .where(archive_formats: { id: action.archive_format_id }) .where('audio_files.codec = archive_formats.codec') - .where('broadcasts.started_at < ?', Time.zone.now - action.months.months) + .where(broadcasts: { started_at: ...(Time.zone.now - action.months.months) }) end def handle(file) diff --git a/app/services/import/recording/composer.rb b/app/services/import/recording/composer.rb index fc7855d..7e67731 100644 --- a/app/services/import/recording/composer.rb +++ b/app/services/import/recording/composer.rb @@ -225,7 +225,7 @@ def convert_file_list(list) converted = [] # use `each` instead of `map` to be able to close previously converted files # if an error is raised in the middle of the list. - list.each { |file| converted << yield(file) } + list.each { |file| converted << yield(file) } # rubocop:disable Style/MapIntoArray converted rescue StandardError close_files(converted) diff --git a/bin/dev b/bin/dev new file mode 100755 index 0000000..3925783 --- /dev/null +++ b/bin/dev @@ -0,0 +1,4 @@ +#!/usr/bin/env ruby +# frozen_string_literal: true + +exec './bin/rails', 'server', *ARGV diff --git a/bin/rubocop b/bin/rubocop new file mode 100755 index 0000000..f45b065 --- /dev/null +++ b/bin/rubocop @@ -0,0 +1,10 @@ +#!/usr/bin/env ruby +# frozen_string_literal: true + +require 'rubygems' +require 'bundler/setup' + +# explicit rubocop config increases performance slightly while avoiding config confusion. +ARGV.unshift('--config', File.expand_path('../.rubocop.yml', __dir__)) + +load Gem.bin_path('rubocop', 'rubocop') diff --git a/config/application.rb b/config/application.rb index 9edd55b..82830fb 100644 --- a/config/application.rb +++ b/config/application.rb @@ -18,11 +18,16 @@ class Application < Rails::Application attr_accessor :settings # Initialize configuration defaults for originally generated Rails version. - config.load_defaults 7.1 + config.load_defaults 8.0 # Settings in config/environments/* take precedence over those specified here. # Application configuration should go into files in config/initializers # -- all .rb files in that directory are automatically loaded. + # + # Please, add to the `ignore` list any other `lib` subdirectories that do + # not contain `.rb` files, or that should not be reloaded or eager loaded. + # Common ones are `templates`, `generators`, or `middleware`, for example. + config.autoload_lib(ignore: %w[tasks capistrano]) # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone. # Run "rake time:zones:all" for a time zone names list. Default is UTC. diff --git a/config/deploy.rb b/config/deploy.rb index b3caa0e..633b0a5 100644 --- a/config/deploy.rb +++ b/config/deploy.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true # config valid only for current version of Capistrano -lock '3.18.0' +lock '3.19.2' set :application, 'raar' set :repo_url, 'git@github.com:radiorabe/raar.git' diff --git a/config/environments/development.rb b/config/environments/development.rb index b1136f4..4395e3d 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -48,4 +48,7 @@ # Highlight code that triggered database queries in logs. config.active_record.verbose_query_logs = true + + # Raise error when a before_action's only/except options reference missing actions. + config.action_controller.raise_on_missing_callback_actions = true end diff --git a/config/environments/production.rb b/config/environments/production.rb index e51c86a..19c6921 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -21,6 +21,9 @@ # Apache or NGINX already handles this. config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present? + # Cache assets for far-future expiry since they are all digest stamped. + config.public_file_server.headers = { 'cache-control' => "public, max-age=#{1.year.to_i}" } + # Enable serving of images, stylesheets, and JavaScripts from an asset server. # config.asset_host = 'http://assets.example.com' @@ -28,6 +31,9 @@ config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX + # Assume all access to the app is happening through a SSL-terminating reverse proxy. + config.assume_ssl = true + # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies. config.force_ssl = ENV['RAAR_SSL'] == 'true' @@ -62,6 +68,9 @@ end end + # Prevent health checks from clogging up the logs. + config.silence_healthcheck_path = '/up' + # Use a different cache store in production. # config.cache_store = :mem_cache_store diff --git a/config/environments/test.rb b/config/environments/test.rb index b5bd854..24b9ce1 100644 --- a/config/environments/test.rb +++ b/config/environments/test.rb @@ -13,7 +13,7 @@ # Do not eager load code on boot. This avoids loading your whole application # just for the purpose of running a single test. If you are using a tool that # preloads Rails for running tests, you may have to set it to true. - config.eager_load = false + config.eager_load = ENV['CI'].present? # Configure public file server for tests with Cache-Control for performance. config.public_file_server.enabled = true @@ -51,4 +51,7 @@ # Raises error for missing translations # config.action_view.raise_on_missing_translations = true + + # Raise error when a before_action's only/except options reference missing actions. + config.action_controller.raise_on_missing_callback_actions = true end diff --git a/config/initializers/inflections.rb b/config/initializers/inflections.rb index aa7435f..dc84742 100644 --- a/config/initializers/inflections.rb +++ b/config/initializers/inflections.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + # Be sure to restart your server when you modify this file. # Add new inflection rules using the following format. Inflections diff --git a/config/puma.rb b/config/puma.rb index 69e2645..d398337 100644 --- a/config/puma.rb +++ b/config/puma.rb @@ -1,40 +1,43 @@ # frozen_string_literal: true -# Puma can serve each request in a thread from an internal thread pool. -# The `threads` method setting takes two numbers: a minimum and maximum. -# Any libraries that use thread pools should be configured to match -# the maximum value specified for Puma. Default is set to 5 threads for minimum -# and maximum; this matches the default thread size of Active Record. +# This configuration file will be evaluated by Puma. The top-level methods that +# are invoked here are part of Puma's configuration DSL. For more information +# about methods provided by the DSL, see https://puma.io/puma/Puma/DSL.html. # -max_threads_count = ENV.fetch('RAILS_MAX_THREADS', 5) -min_threads_count = ENV.fetch('RAILS_MIN_THREADS') { max_threads_count } -threads min_threads_count, max_threads_count - -# Specifies the `port` that Puma will listen on to receive requests; default is 3000. +# Puma starts a configurable number of processes (workers) and each process +# serves each request in a thread from an internal thread pool. # -port ENV.fetch('PORT', 3000) - -# Specifies the `environment` that Puma will run in. +# You can control the number of workers using ENV["WEB_CONCURRENCY"]. You +# should only set this value when you want to run 2 or more workers. The +# default is already 1. # -environment ENV.fetch('RAILS_ENV', 'development') - -# Specifies the `pidfile` that Puma will use. -pidfile ENV.fetch('PIDFILE', 'tmp/pids/server.pid') - -# Specifies the number of `workers` to boot in clustered mode. -# Workers are forked web server processes. If using threads and workers together -# the concurrency of the application would be max `threads` * `workers`. -# Workers do not work on JRuby or Windows (both of which do not support -# processes). +# The ideal number of threads per worker depends both on how much time the +# application spends waiting for IO operations and on how much you wish to +# prioritize throughput over latency. # -# workers ENV.fetch("WEB_CONCURRENCY") { 2 } - -# Use the `preload_app!` method when specifying a `workers` number. -# This directive tells Puma to first boot the application and load code -# before forking the application. This takes advantage of Copy On Write -# process behavior so workers use less memory. +# As a rule of thumb, increasing the number of threads will increase how much +# traffic a given process can handle (throughput), but due to CRuby's +# Global VM Lock (GVL) it has diminishing returns and will degrade the +# response time (latency) of the application. # -# preload_app! +# The default is set to 3 threads as it's deemed a decent compromise between +# throughput and latency for the average Rails application. +# +# Any libraries that use a connection pool or another resource pool should +# be configured to provide at least as many connections as the number of +# threads. This includes Active Record's `pool` parameter in `database.yml`. +threads_count = ENV.fetch('RAILS_MAX_THREADS', 3) +threads threads_count, threads_count + +# Specifies the `port` that Puma will listen on to receive requests; default is 3000. +port ENV.fetch('PORT', 3000) -# Allow puma to be restarted by `rails restart` command. +# Allow puma to be restarted by `bin/rails restart` command. plugin :tmp_restart + +# Run the Solid Queue supervisor inside of Puma for single-server deployments +plugin :solid_queue if ENV['SOLID_QUEUE_IN_PUMA'] + +# Specify the PID file. Defaults to tmp/pids/server.pid in development. +# In other environments, only set the PID file if requested. +pidfile ENV['PIDFILE'] if ENV['PIDFILE'] diff --git a/doc/swagger.json b/doc/swagger.json index 967cc67..43081b3 100644 --- a/doc/swagger.json +++ b/doc/swagger.json @@ -124,19 +124,13 @@ }, "security": [ { - "http_token": [ - - ] + "http_token": [] }, { - "api_token": [ - - ] + "api_token": [] }, { - "access_code": [ - - ] + "access_code": [] } ] } @@ -227,19 +221,13 @@ }, "security": [ { - "http_token": [ - - ] + "http_token": [] }, { - "api_token": [ - - ] + "api_token": [] }, { - "access_code": [ - - ] + "access_code": [] } ] } @@ -288,19 +276,13 @@ }, "security": [ { - "http_token": [ - - ] + "http_token": [] }, { - "api_token": [ - - ] + "api_token": [] }, { - "access_code": [ - - ] + "access_code": [] } ] } @@ -391,19 +373,13 @@ }, "security": [ { - "http_token": [ - - ] + "http_token": [] }, { - "api_token": [ - - ] + "api_token": [] }, { - "access_code": [ - - ] + "access_code": [] } ] } @@ -459,19 +435,13 @@ }, "security": [ { - "http_token": [ - - ] + "http_token": [] }, { - "api_token": [ - - ] + "api_token": [] }, { - "access_code": [ - - ] + "access_code": [] } ] } @@ -505,19 +475,13 @@ }, "security": [ { - "http_token": [ - - ] + "http_token": [] }, { - "api_token": [ - - ] + "api_token": [] }, { - "access_code": [ - - ] + "access_code": [] } ] }, @@ -565,19 +529,13 @@ }, "security": [ { - "api_token": [ - - ] + "api_token": [] }, { - "http_token": [ - - ] + "http_token": [] }, { - "jwt_token": [ - - ] + "jwt_token": [] } ] } @@ -605,24 +563,16 @@ }, "security": [ { - "http_token": [ - - ] + "http_token": [] }, { - "api_token": [ - - ] + "api_token": [] }, { - "access_code": [ - - ] + "access_code": [] }, { - "jwt_token": [ - - ] + "jwt_token": [] } ] }, @@ -715,19 +665,13 @@ }, "security": [ { - "http_token": [ - - ] + "http_token": [] }, { - "api_token": [ - - ] + "api_token": [] }, { - "access_code": [ - - ] + "access_code": [] } ] } @@ -762,19 +706,13 @@ }, "security": [ { - "http_token": [ - - ] + "http_token": [] }, { - "api_token": [ - - ] + "api_token": [] }, { - "access_code": [ - - ] + "access_code": [] } ] }, @@ -822,19 +760,13 @@ }, "security": [ { - "api_token": [ - - ] + "api_token": [] }, { - "http_token": [ - - ] + "http_token": [] }, { - "jwt_token": [ - - ] + "jwt_token": [] } ] } @@ -877,9 +809,7 @@ }, "security": [ { - "jwt_token": [ - - ] + "jwt_token": [] } ] }, @@ -920,9 +850,7 @@ }, "security": [ { - "jwt_token": [ - - ] + "jwt_token": [] } ] } @@ -957,9 +885,7 @@ }, "security": [ { - "jwt_token": [ - - ] + "jwt_token": [] } ] }, @@ -1007,9 +933,7 @@ }, "security": [ { - "jwt_token": [ - - ] + "jwt_token": [] } ] }, @@ -1037,9 +961,7 @@ }, "security": [ { - "jwt_token": [ - - ] + "jwt_token": [] } ] } @@ -1121,19 +1043,13 @@ }, "security": [ { - "http_token": [ - - ] + "http_token": [] }, { - "api_token": [ - - ] + "api_token": [] }, { - "access_code": [ - - ] + "access_code": [] } ] } @@ -1180,19 +1096,13 @@ }, "security": [ { - "http_token": [ - - ] + "http_token": [] }, { - "api_token": [ - - ] + "api_token": [] }, { - "access_code": [ - - ] + "access_code": [] } ] } @@ -1239,19 +1149,13 @@ }, "security": [ { - "http_token": [ - - ] + "http_token": [] }, { - "api_token": [ - - ] + "api_token": [] }, { - "access_code": [ - - ] + "access_code": [] } ] } @@ -1322,9 +1226,7 @@ }, "security": [ { - "jwt_token": [ - - ] + "jwt_token": [] } ] }, @@ -1366,9 +1268,7 @@ }, "security": [ { - "jwt_token": [ - - ] + "jwt_token": [] } ] } @@ -1403,9 +1303,7 @@ }, "security": [ { - "jwt_token": [ - - ] + "jwt_token": [] } ] }, @@ -1454,9 +1352,7 @@ }, "security": [ { - "jwt_token": [ - - ] + "jwt_token": [] } ] }, @@ -1485,9 +1381,7 @@ }, "security": [ { - "jwt_token": [ - - ] + "jwt_token": [] } ] } @@ -1534,9 +1428,7 @@ }, "security": [ { - "jwt_token": [ - - ] + "jwt_token": [] } ] }, @@ -1585,9 +1477,7 @@ }, "security": [ { - "jwt_token": [ - - ] + "jwt_token": [] } ] } @@ -1629,9 +1519,7 @@ }, "security": [ { - "jwt_token": [ - - ] + "jwt_token": [] } ] }, @@ -1687,9 +1575,7 @@ }, "security": [ { - "jwt_token": [ - - ] + "jwt_token": [] } ] }, @@ -1725,9 +1611,7 @@ }, "security": [ { - "jwt_token": [ - - ] + "jwt_token": [] } ] } @@ -1756,9 +1640,7 @@ }, "security": [ { - "jwt_token": [ - - ] + "jwt_token": [] } ] } @@ -1812,9 +1694,7 @@ }, "security": [ { - "jwt_token": [ - - ] + "jwt_token": [] } ] }, @@ -1870,9 +1750,7 @@ }, "security": [ { - "jwt_token": [ - - ] + "jwt_token": [] } ] } @@ -1921,9 +1799,7 @@ }, "security": [ { - "jwt_token": [ - - ] + "jwt_token": [] } ] }, @@ -1986,9 +1862,7 @@ }, "security": [ { - "jwt_token": [ - - ] + "jwt_token": [] } ] }, @@ -2031,9 +1905,7 @@ }, "security": [ { - "jwt_token": [ - - ] + "jwt_token": [] } ] } @@ -2076,9 +1948,7 @@ }, "security": [ { - "jwt_token": [ - - ] + "jwt_token": [] } ] }, @@ -2120,9 +1990,7 @@ }, "security": [ { - "jwt_token": [ - - ] + "jwt_token": [] } ] } @@ -2157,9 +2025,7 @@ }, "security": [ { - "jwt_token": [ - - ] + "jwt_token": [] } ] }, @@ -2208,9 +2074,7 @@ }, "security": [ { - "jwt_token": [ - - ] + "jwt_token": [] } ] }, @@ -2239,9 +2103,7 @@ }, "security": [ { - "jwt_token": [ - - ] + "jwt_token": [] } ] } @@ -2284,9 +2146,7 @@ }, "security": [ { - "jwt_token": [ - - ] + "jwt_token": [] } ] }, @@ -2328,9 +2188,7 @@ }, "security": [ { - "jwt_token": [ - - ] + "jwt_token": [] } ] } @@ -2365,9 +2223,7 @@ }, "security": [ { - "jwt_token": [ - - ] + "jwt_token": [] } ] }, @@ -2416,9 +2272,7 @@ }, "security": [ { - "jwt_token": [ - - ] + "jwt_token": [] } ] }, @@ -2447,9 +2301,7 @@ }, "security": [ { - "jwt_token": [ - - ] + "jwt_token": [] } ] } @@ -2489,9 +2341,7 @@ }, "security": [ { - "jwt_token": [ - - ] + "jwt_token": [] } ] }, @@ -2533,9 +2383,7 @@ }, "security": [ { - "jwt_token": [ - - ] + "jwt_token": [] } ] } @@ -2570,9 +2418,7 @@ }, "security": [ { - "jwt_token": [ - - ] + "jwt_token": [] } ] }, @@ -2621,9 +2467,7 @@ }, "security": [ { - "jwt_token": [ - - ] + "jwt_token": [] } ] }, @@ -2652,9 +2496,7 @@ }, "security": [ { - "jwt_token": [ - - ] + "jwt_token": [] } ] } @@ -2695,9 +2537,7 @@ }, "security": [ { - "jwt_token": [ - - ] + "jwt_token": [] } ] } @@ -2740,9 +2580,7 @@ }, "security": [ { - "jwt_token": [ - - ] + "jwt_token": [] } ] }, @@ -2784,9 +2622,7 @@ }, "security": [ { - "jwt_token": [ - - ] + "jwt_token": [] } ] } @@ -2821,9 +2657,7 @@ }, "security": [ { - "jwt_token": [ - - ] + "jwt_token": [] } ] }, @@ -2872,9 +2706,7 @@ }, "security": [ { - "jwt_token": [ - - ] + "jwt_token": [] } ] }, @@ -2903,9 +2735,7 @@ }, "security": [ { - "jwt_token": [ - - ] + "jwt_token": [] } ] } @@ -2947,9 +2777,7 @@ }, "security": [ { - "jwt_token": [ - - ] + "jwt_token": [] } ] } diff --git a/test/controllers/admin/access_codes_controller_test.rb b/test/controllers/admin/access_codes_controller_test.rb index 6ee819f..a66196a 100644 --- a/test/controllers/admin/access_codes_controller_test.rb +++ b/test/controllers/admin/access_codes_controller_test.rb @@ -29,7 +29,7 @@ class AccessCodesControllerTest < ActionController::TestCase test 'GET index returns unauthorized if not logged in' do logout get :index - assert_response 401 + assert_response :unauthorized end test 'GET show returns entry' do @@ -48,7 +48,7 @@ class AccessCodesControllerTest < ActionController::TestCase } } } - assert_response 201 + assert_response :created end assert_equal '2100-02-01', json['data']['attributes']['expires_at'] assert_equal AccessCode::CODE_LENGTH, json['data']['attributes']['code'].size @@ -64,7 +64,7 @@ class AccessCodesControllerTest < ActionController::TestCase } } } - assert_response 422 + assert_response :unprocessable_content end end @@ -74,7 +74,7 @@ class AccessCodesControllerTest < ActionController::TestCase id: entry.id, data: { attributes: { expires_at: '2100-02-01' } } } - assert_response 200 + assert_response :ok assert_equal '2100-02-01', json['data']['attributes']['expires_at'] end @@ -84,7 +84,7 @@ class AccessCodesControllerTest < ActionController::TestCase id: entry.id, data: { attributes: { expires_at: nil } } } - assert_response 422 + assert_response :unprocessable_content end test 'DELETE destroy removes existing entry' do @@ -92,7 +92,7 @@ class AccessCodesControllerTest < ActionController::TestCase assert_difference('AccessCode.count', -1) do delete :destroy, params: { id: entry.id } end - assert_response 204 + assert_response :no_content end private diff --git a/test/controllers/admin/archive_formats_controller_test.rb b/test/controllers/admin/archive_formats_controller_test.rb index 248ffbe..59dbdf2 100644 --- a/test/controllers/admin/archive_formats_controller_test.rb +++ b/test/controllers/admin/archive_formats_controller_test.rb @@ -15,7 +15,7 @@ class ArchiveFormatsControllerTest < ActionController::TestCase test 'GET index returns unauthorized if not logged in' do logout get :index, params: { profile_id: profiles(:default).id } - assert_response 401 + assert_response :unauthorized end test 'GET show returns entry' do @@ -41,7 +41,7 @@ class ArchiveFormatsControllerTest < ActionController::TestCase } } } - assert_response 201 + assert_response :created end format = ArchiveFormat.find(json['data']['id']) assert_equal %w[staff sendungsmachende], format.priviledged_group_list @@ -62,7 +62,7 @@ class ArchiveFormatsControllerTest < ActionController::TestCase } } } - assert_response 422 + assert_response :unprocessable_content end assert_equal 1, json['errors'].size assert_equal '/data/attributes/codec', json['errors'].first['source']['pointer'] @@ -75,7 +75,7 @@ class ArchiveFormatsControllerTest < ActionController::TestCase profile_id: profiles(:default).id, data: { attributes: { codec: 'mp3', initial_bitrate: 224 } } } - assert_response 200 + assert_response :ok assert_equal 'mp3', json['data']['attributes']['codec'] assert_equal 224, json['data']['attributes']['initial_bitrate'] assert_equal 'mp3', entry.reload.codec @@ -89,7 +89,7 @@ class ArchiveFormatsControllerTest < ActionController::TestCase profile_id: profiles(:default).id, data: { attributes: { codec: 'flac', initial_bitrate: 1 } } } - assert_response 422 + assert_response :unprocessable_content assert_match /must not be changed/, response.body assert_equal 'mp3', entry.reload.codec end @@ -101,7 +101,7 @@ class ArchiveFormatsControllerTest < ActionController::TestCase profile_id: profiles(:default).id, data: { attributes: { initial_bitrate: 123 } } } - assert_response 422 + assert_response :unprocessable_content assert_match /not included/, response.body assert_equal 256, entry.reload.initial_bitrate end @@ -110,7 +110,7 @@ class ArchiveFormatsControllerTest < ActionController::TestCase assert_difference('ArchiveFormat.count', -1) do delete :destroy, params: { id: entry.id, profile_id: profiles(:default).id } end - assert_response 204 + assert_response :no_content end private diff --git a/test/controllers/admin/audio_encodings_controller_test.rb b/test/controllers/admin/audio_encodings_controller_test.rb index 0bb964f..730a057 100644 --- a/test/controllers/admin/audio_encodings_controller_test.rb +++ b/test/controllers/admin/audio_encodings_controller_test.rb @@ -16,7 +16,7 @@ class AudioEncodingsControllerTest < ActionController::TestCase test 'GET index returns unauthorized if not logged in' do logout get :index - assert_response 401 + assert_response :unauthorized end end diff --git a/test/controllers/admin/downgrade_actions_controller_test.rb b/test/controllers/admin/downgrade_actions_controller_test.rb index 02cc10a..147fdce 100644 --- a/test/controllers/admin/downgrade_actions_controller_test.rb +++ b/test/controllers/admin/downgrade_actions_controller_test.rb @@ -23,7 +23,7 @@ class DowngradeActionsControllerTest < ActionController::TestCase profile_id: profiles(:default).id, archive_format_id: archive_formats(:default_mp3).id } - assert_response 401 + assert_response :unauthorized end test 'GET show returns entry' do @@ -50,7 +50,7 @@ class DowngradeActionsControllerTest < ActionController::TestCase } } } - assert_response 201 + assert_response :created end assert_equal 12, json['data']['attributes']['months'] end @@ -69,7 +69,7 @@ class DowngradeActionsControllerTest < ActionController::TestCase } } } - assert_response 422 + assert_response :unprocessable_content end end @@ -81,7 +81,7 @@ class DowngradeActionsControllerTest < ActionController::TestCase archive_format_id: archive_formats(:default_mp3).id, data: { attributes: { months: 6, bitrate: 224 } } } - assert_response 200, response.body + assert_response :ok, response.body assert_equal 6, json['data']['attributes']['months'] assert_equal 224, json['data']['attributes']['bitrate'] assert_equal 6, entry.reload.months @@ -96,7 +96,7 @@ class DowngradeActionsControllerTest < ActionController::TestCase archive_format_id: archive_formats(:default_mp3).id, data: { attributes: { bitrate: 123 } } } - assert_response 422 + assert_response :unprocessable_content assert_match /not included/, response.body assert_equal 192, entry.reload.bitrate end @@ -110,7 +110,7 @@ class DowngradeActionsControllerTest < ActionController::TestCase archive_format_id: archive_formats(:default_mp3).id } end - assert_response 204 + assert_response :no_content end private diff --git a/test/controllers/admin/playback_formats_controller_test.rb b/test/controllers/admin/playback_formats_controller_test.rb index d966e34..08e0d2b 100644 --- a/test/controllers/admin/playback_formats_controller_test.rb +++ b/test/controllers/admin/playback_formats_controller_test.rb @@ -15,7 +15,7 @@ class PlaybackFormatsControllerTest < ActionController::TestCase test 'GET index returns unauthorized if not logged in' do logout get :index - assert_response 401 + assert_response :unauthorized end test 'GET show returns entry' do @@ -36,7 +36,7 @@ class PlaybackFormatsControllerTest < ActionController::TestCase } } } - assert_response 201 + assert_response :created end assert_equal 'mid', json['data']['attributes']['name'] end @@ -53,7 +53,7 @@ class PlaybackFormatsControllerTest < ActionController::TestCase } } } - assert_response 422 + assert_response :unprocessable_content end assert_match /can't be blank/, response.body end @@ -64,7 +64,7 @@ class PlaybackFormatsControllerTest < ActionController::TestCase id: entry.id, data: { attributes: { channels: 2 } } } - assert_response 200 + assert_response :ok assert_equal 2, json['data']['attributes']['channels'] assert_equal 2, entry.reload.channels end @@ -75,7 +75,7 @@ class PlaybackFormatsControllerTest < ActionController::TestCase id: entry.id, data: { attributes: { bitrate: '123' } } } - assert_response 422 + assert_response :unprocessable_content assert_match /not included/, response.body assert_equal 96, entry.reload.bitrate end @@ -84,7 +84,7 @@ class PlaybackFormatsControllerTest < ActionController::TestCase assert_difference('PlaybackFormat.count', -1) do delete :destroy, params: { id: entry.id } end - assert_response 204 + assert_response :no_content end private diff --git a/test/controllers/admin/profiles_controller_test.rb b/test/controllers/admin/profiles_controller_test.rb index 636d26d..6a1b4a5 100644 --- a/test/controllers/admin/profiles_controller_test.rb +++ b/test/controllers/admin/profiles_controller_test.rb @@ -15,7 +15,7 @@ class ProfilesControllerTest < ActionController::TestCase test 'GET index returns unauthorized if not logged in' do logout get :index - assert_response 401 + assert_response :unauthorized end test 'GET show returns entry' do @@ -35,7 +35,7 @@ class ProfilesControllerTest < ActionController::TestCase } } } - assert_response 201 + assert_response :created end assert_equal 'Live', json['data']['attributes']['name'] assert_equal users(:admin).id, json['data']['attributes']['creator_id'] @@ -52,7 +52,7 @@ class ProfilesControllerTest < ActionController::TestCase } } } - assert_response 422 + assert_response :unprocessable_content end end @@ -62,7 +62,7 @@ class ProfilesControllerTest < ActionController::TestCase id: entry.id, data: { attributes: { description: 'Very important shows' } } } - assert_response 200 + assert_response :ok assert_equal 'Very important shows', json['data']['attributes']['description'] assert_nil json['data']['attributes']['creator_id'] assert_equal users(:admin).id, json['data']['attributes']['updater_id'] @@ -77,7 +77,7 @@ class ProfilesControllerTest < ActionController::TestCase id: entry.id, data: { attributes: { name: 'Unimportant' } } } - assert_response 422 + assert_response :unprocessable_content assert_match /taken/, response.body assert_equal 'Important', entry.reload.name end @@ -87,14 +87,14 @@ class ProfilesControllerTest < ActionController::TestCase assert_difference('Profile.count', -1) do delete :destroy, params: { id: profile.id } end - assert_response 204 + assert_response :no_content end test 'DELETE destroy does not remove used entry' do assert_no_difference('Profile.count') do delete :destroy, params: { id: entry.id } end - assert_response 422 + assert_response :unprocessable_content assert_match /dependent shows/, response.body end diff --git a/test/controllers/admin/shows_controller_test.rb b/test/controllers/admin/shows_controller_test.rb index 53c9af4..48882a9 100644 --- a/test/controllers/admin/shows_controller_test.rb +++ b/test/controllers/admin/shows_controller_test.rb @@ -26,7 +26,7 @@ class ShowsControllerTest < ActionController::TestCase test 'GET create returns unauthorized if not logged in' do logout post :create - assert_response 401 + assert_response :unauthorized end test 'POST create adds new show' do @@ -40,7 +40,7 @@ class ShowsControllerTest < ActionController::TestCase } } } - assert_response 201 + assert_response :created end assert_equal 'foo', json['data']['attributes']['name'] assert_equal profiles(:default).id.to_s, json['data']['relationships']['profile']['data']['id'] @@ -56,7 +56,7 @@ class ShowsControllerTest < ActionController::TestCase } } } - assert_response 422 + assert_response :unprocessable_content end end @@ -78,7 +78,7 @@ class ShowsControllerTest < ActionController::TestCase } } } - assert_response 201 + assert_response :created end assert_equal 'foo', json['data']['attributes']['name'] @@ -91,7 +91,7 @@ class ShowsControllerTest < ActionController::TestCase id: shows(:info).id, data: { attributes: { details: 'yabadabadoo' } } } - assert_response 200 + assert_response :ok assert_equal 'yabadabadoo', json['data']['attributes']['details'] assert_equal 'yabadabadoo', shows(:info).reload.details assert_equal profiles(:important).id, shows(:info).profile_id @@ -112,7 +112,7 @@ class ShowsControllerTest < ActionController::TestCase } } } - assert_response 200 + assert_response :ok assert_equal profiles(:unimportant).id, shows(:info).reload.profile_id end @@ -122,7 +122,7 @@ class ShowsControllerTest < ActionController::TestCase id: shows(:info).id, data: { attributes: { name: 'Klangbecken' } } } - assert_response 422 + assert_response :unprocessable_content assert_match /taken/, response.body assert_equal 'Info', shows(:info).reload.name end @@ -132,14 +132,14 @@ class ShowsControllerTest < ActionController::TestCase assert_difference('Show.count', -1) do delete :destroy, params: { id: show.id } end - assert_response 204 + assert_response :no_content end test 'DELETE destroy does not remove show with broadcasts' do assert_no_difference('Show.count') do delete :destroy, params: { id: shows(:info).id } end - assert_response 422 + assert_response :unprocessable_content end end diff --git a/test/controllers/admin/stats_controller_test.rb b/test/controllers/admin/stats_controller_test.rb index 5c1a86e..29c0eac 100644 --- a/test/controllers/admin/stats_controller_test.rb +++ b/test/controllers/admin/stats_controller_test.rb @@ -25,7 +25,7 @@ class StatsControllerTest < ActionController::TestCase test 'GET index returns unauthorized if not logged in' do logout get :index, params: { year: 2013 } - assert_response 401 + assert_response :unauthorized end private diff --git a/test/controllers/admin/users_controller_test.rb b/test/controllers/admin/users_controller_test.rb index 0733324..5ac02ec 100644 --- a/test/controllers/admin/users_controller_test.rb +++ b/test/controllers/admin/users_controller_test.rb @@ -20,13 +20,13 @@ class UsersControllerTest < ActionController::TestCase test 'GET show returns unauthorized for api token' do login('speedee') get :show, params: { id: users(:admin).id } - assert_response 401 + assert_response :unauthorized end test 'GET show returns unauthorized if not logged in' do logout get :show, params: { id: users(:speedee).id } - assert_response 401 + assert_response :unauthorized end test 'POST create adds new user' do @@ -42,7 +42,7 @@ class UsersControllerTest < ActionController::TestCase } } } - assert_response 201 + assert_response :created end assert_equal 'foo', json['data']['attributes']['username'] end @@ -60,7 +60,7 @@ class UsersControllerTest < ActionController::TestCase } } } - assert_response 422 + assert_response :unprocessable_content end assert_equal 1, json['errors'].size assert_equal '/data/attributes/username', json['errors'].first['source']['pointer'] @@ -72,7 +72,7 @@ class UsersControllerTest < ActionController::TestCase id: users(:speedee).id, data: { attributes: { first_name: 'Spee', last_name: 'Dee' } } } - assert_response 200 + assert_response :ok assert_equal 'Spee', json['data']['attributes']['first_name'] assert_equal 'Spee', users(:speedee).reload.first_name assert_equal 'Dee', users(:speedee).last_name @@ -84,7 +84,7 @@ class UsersControllerTest < ActionController::TestCase id: users(:speedee).id, data: { attributes: { username: 'admin' } } } - assert_response 422 + assert_response :unprocessable_content assert_match /taken/, response.body assert_equal 'speedee', users(:speedee).reload.username end @@ -93,7 +93,7 @@ class UsersControllerTest < ActionController::TestCase assert_difference('User.count', -1) do delete :destroy, params: { id: users(:speedee).id } end - assert_response 204 + assert_response :no_content end end diff --git a/test/controllers/audio_files_controller_test.rb b/test/controllers/audio_files_controller_test.rb index 77aeb0f..167ccdb 100644 --- a/test/controllers/audio_files_controller_test.rb +++ b/test/controllers/audio_files_controller_test.rb @@ -205,7 +205,7 @@ class AudioFilesControllerTest < ActionController::TestCase format: 'mp3' } - assert_response 401 + assert_response :unauthorized end test 'GET show for public file returns audio file' do @@ -223,7 +223,7 @@ class AudioFilesControllerTest < ActionController::TestCase format: 'mp3' } - assert_response 200 + assert_response :ok assert_equal AudioEncoding::Mp3.mime_type, response.headers['Content-Type'] assert_match 'inline', response.headers['Content-Disposition'] end @@ -244,7 +244,7 @@ class AudioFilesControllerTest < ActionController::TestCase download: 'true' } - assert_response 401 + assert_response :unauthorized end test 'GET show for file with no max_public_bitrate set returns audio file' do @@ -263,7 +263,7 @@ class AudioFilesControllerTest < ActionController::TestCase format: 'mp3' } - assert_response 200 + assert_response :ok assert_equal AudioEncoding::Mp3.mime_type, response.headers['Content-Type'] end @@ -281,7 +281,7 @@ class AudioFilesControllerTest < ActionController::TestCase format: 'mp3' } - assert_response 200 + assert_response :ok assert_equal AudioEncoding::Mp3.mime_type, response.headers['Content-Type'] end @@ -298,7 +298,7 @@ class AudioFilesControllerTest < ActionController::TestCase format: 'mp3' } - assert_response 200 + assert_response :ok end test 'GET show logged in with best quality returns audio file' do @@ -314,7 +314,7 @@ class AudioFilesControllerTest < ActionController::TestCase format: 'mp3' } - assert_response 200 + assert_response :ok assert_match 'inline', response.headers['Content-Disposition'] end @@ -332,7 +332,7 @@ class AudioFilesControllerTest < ActionController::TestCase download: true } - assert_response 200 + assert_response :ok assert_match 'attachment', response.headers['Content-Disposition'] end @@ -351,7 +351,7 @@ class AudioFilesControllerTest < ActionController::TestCase api_token: users(:member).api_token } - assert_response 401 + assert_response :unauthorized end test 'GET show via access_code with high quality and download flag returns audio file' do @@ -371,7 +371,7 @@ class AudioFilesControllerTest < ActionController::TestCase access_code: code } - assert_response 200 + assert_response :ok assert_match 'attachment', response.headers['Content-Disposition'] end @@ -420,7 +420,7 @@ class AudioFilesControllerTest < ActionController::TestCase format: 'mp3' } - assert_response 404 + assert_response :not_found end test 'GET show in the future returns 404' do @@ -438,7 +438,7 @@ class AudioFilesControllerTest < ActionController::TestCase format: 'mp3' } - assert_response 404 + assert_response :not_found end test 'GET index with time parts up to minutes resolves params correctly' do diff --git a/test/controllers/broadcasts_controller_test.rb b/test/controllers/broadcasts_controller_test.rb index 54a7a32..7bdbbce 100644 --- a/test/controllers/broadcasts_controller_test.rb +++ b/test/controllers/broadcasts_controller_test.rb @@ -158,7 +158,7 @@ class BroadcastsControllerTest < ActionController::TestCase id: entry.id, data: { attributes: { details: 'Very important shows', started_at: '17:00' } } } - assert_response 200 + assert_response :ok assert_equal 'Very important shows', json['data']['attributes']['details'] assert_equal '2013-04-10T11:00:00.000+02:00', json['data']['attributes']['started_at'] assert_equal 'Very important shows', entry.reload.details @@ -176,7 +176,7 @@ class BroadcastsControllerTest < ActionController::TestCase started_at: '17:00' } } } - assert_response 200 + assert_response :ok assert_equal 'Info April 1', json['data']['attributes']['label'] assert_equal 'Very important shows', json['data']['attributes']['details'] assert_equal '2013-04-10T11:00:00.000+02:00', json['data']['attributes']['started_at'] @@ -192,7 +192,7 @@ class BroadcastsControllerTest < ActionController::TestCase id: entry.id, data: { attributes: { details: 'Very important shows', started_at: '17:00' } } } - assert_response 401 + assert_response :unauthorized end test 'DELETE destroy is not possible' do diff --git a/test/controllers/login_controller_test.rb b/test/controllers/login_controller_test.rb index 20ecbc9..51aa2b2 100644 --- a/test/controllers/login_controller_test.rb +++ b/test/controllers/login_controller_test.rb @@ -7,7 +7,7 @@ class LoginControllerTest < ActionController::TestCase test 'GET show with REMOTE_USER returns user object' do request.env['REMOTE_USER'] = +'speedee' get :show - assert_response 200 + assert_response :ok assert_equal 'speedee', json['data']['attributes']['username'] assert_match /\A#{users(:speedee).id}\$[A-Za-z0-9]{24}\z/, json['data']['attributes']['api_token'] @@ -17,7 +17,7 @@ class LoginControllerTest < ActionController::TestCase test 'GET show with REMOTE_USER returns admin user object and jwt' do request.env['REMOTE_USER'] = +'admin' get :show - assert_response 200 + assert_response :ok assert_equal 'admin', json['data']['attributes']['username'] assert_match /\A#{users(:admin).id}\$[A-Za-z0-9]{24}\z/, json['data']['attributes']['api_token'] @@ -27,14 +27,14 @@ class LoginControllerTest < ActionController::TestCase test 'GET show with api_token returns user object' do get :show, params: { api_token: users(:speedee).api_token } - assert_response 200 + assert_response :ok assert_equal 'speedee', json['data']['attributes']['username'] end test 'GET show with api_token returns admin user object but no JWT' do get :show, params: { api_token: users(:admin).api_token } - assert_response 200 + assert_response :ok assert_equal 'admin', json['data']['attributes']['username'] assert response.headers['X-Auth-Token'].blank? end @@ -43,20 +43,20 @@ class LoginControllerTest < ActionController::TestCase code = AccessCode.create!(expires_at: 1.month.from_now).code get :show, params: { access_code: code } - assert_response 200 + assert_response :ok assert_nil json['data']['attributes']['username'] end test 'GET show without auth returns unauthorized' do get :show - assert_response 401 + assert_response :unauthorized end test 'POST login with REMOTE_USER returns user object' do request.env['REMOTE_USER'] = +'speedee' post :create, params: { username: 'speedee', password: 'foo' } - assert_response 200 + assert_response :ok assert_equal 'speedee', json['data']['attributes']['username'] assert_match /\A#{users(:speedee).id}\$[A-Za-z0-9]{24}\z/, json['data']['attributes']['api_token'] @@ -67,7 +67,7 @@ class LoginControllerTest < ActionController::TestCase request.env['REMOTE_USER'] = +'admin' post :create, params: { username: 'admin', password: 'foo' } - assert_response 200 + assert_response :ok assert_equal 'admin', json['data']['attributes']['username'] assert_match /\A#{users(:admin).id}\$[A-Za-z0-9]{24}\z/, json['data']['attributes']['api_token'] @@ -77,21 +77,21 @@ class LoginControllerTest < ActionController::TestCase test 'POST login without REMOTE_USER returns error' do post :create, params: { username: 'speedee', password: 'foo' } - assert_response 401 + assert_response :unauthorized assert_match /Not authenticated/, response.body end test 'POST login with api_token responds unauthorized' do post :create, params: { api_token: users(:speedee).api_token } - assert_response 401 + assert_response :unauthorized end test 'POST login with EXTERNAL_AUTH_ERROR returns error' do request.env['EXTERNAL_AUTH_ERROR'] = 'invalid password' post :create, params: { username: 'speedee', password: 'foo' } - assert_response 401 + assert_response :unauthorized assert_match /invalid password/, response.body end @@ -100,7 +100,7 @@ class LoginControllerTest < ActionController::TestCase user = users(:speedee) key = user.api_key patch :update - assert_response 200 + assert_response :ok assert_not_equal key, user.reload.api_key assert_equal user.api_token, json['data']['attributes']['api_token'] end @@ -109,13 +109,13 @@ class LoginControllerTest < ActionController::TestCase user = users(:speedee) key = user.api_key patch :update, params: { api_token: user.api_token } - assert_response 401 + assert_response :unauthorized assert_equal key, user.reload.api_key end test 'PATCH update responds unauthorized without authentication' do patch :update - assert_response 401 + assert_response :unauthorized end end diff --git a/test/controllers/shows_controller_test.rb b/test/controllers/shows_controller_test.rb index 79c4ad6..49ae95c 100644 --- a/test/controllers/shows_controller_test.rb +++ b/test/controllers/shows_controller_test.rb @@ -59,7 +59,7 @@ class ShowsControllerTest < ActionController::TestCase details: 'The best sound all over' } } } - assert_response 200 + assert_response :ok assert_equal 'Klangbecken', json['data']['attributes']['name'] assert_equal 'The best sound all over', json['data']['attributes']['details'] assert_equal 'Klangbecken', entry.reload.name @@ -75,7 +75,7 @@ class ShowsControllerTest < ActionController::TestCase id: shows(:klangbecken).id, data: { attributes: { details: 'Very important shows', started_at: '17:00' } } } - assert_response 401 + assert_response :unauthorized end end diff --git a/test/controllers/tracks_controller_test.rb b/test/controllers/tracks_controller_test.rb index 6ff40a2..65d50c2 100644 --- a/test/controllers/tracks_controller_test.rb +++ b/test/controllers/tracks_controller_test.rb @@ -147,7 +147,7 @@ class TracksControllerTest < ActionController::TestCase id: entry.id, data: { attributes: { artist: 'ChocoLocoColo', finished_at: '2013-05-20T20:13:06' } } } - assert_response 200 + assert_response :ok assert_equal 'ChocoLocoColo', json['data']['attributes']['artist'] assert_equal '2013-05-20T20:10:44.000+02:00', json['data']['attributes']['started_at'] assert_equal '2013-05-20T20:13:06.000+02:00', json['data']['attributes']['finished_at'] @@ -164,7 +164,7 @@ class TracksControllerTest < ActionController::TestCase started_at: '2013-05-20T20:10:40' } } } - assert_response 200 + assert_response :ok assert_equal 'Vvvroom', json['data']['attributes']['title'] assert_equal '2013-05-20T20:10:40.000+02:00', json['data']['attributes']['started_at'] assert_equal '2013-05-20T20:13:05.000+02:00', json['data']['attributes']['finished_at'] @@ -179,7 +179,7 @@ class TracksControllerTest < ActionController::TestCase id: entry.id, data: { attributes: { artist: 'Blabla', started_at: '17:00' } } } - assert_response 401 + assert_response :unauthorized end test 'DELETE destroy removes entry' do diff --git a/test/integration/api/authorization_test.rb b/test/integration/api/authorization_test.rb index 611c344..7353e04 100644 --- a/test/integration/api/authorization_test.rb +++ b/test/integration/api/authorization_test.rb @@ -10,45 +10,45 @@ class AuthorizationTest < ActionDispatch::IntegrationTest test 'GET show audio file with HTTP token is allowed' do assert_no_difference('User.count') do get audio_path, headers: { 'HTTP_AUTHORIZATION' => encode_token(users(:admin).api_token) } - assert_response 200 + assert_response :ok end end test 'GET show audio file with api_token param is allowed' do assert_no_difference('User.count') do get "#{audio_path}?api_token=#{users(:admin).api_token}" - assert_response 200 + assert_response :ok end end test 'GET show audio file without authorization fails' do assert_no_difference('User.count') do get audio_path - assert_response 401 + assert_response :unauthorized end end test 'GET show profile without authorization fails' do get admin_profile_path(profiles(:default).id) - assert_response 401 + assert_response :unauthorized end test 'GET show profile with api token fails' do get admin_profile_path(profiles(:default).id), headers: { 'HTTP_AUTHORIZATION' => encode_token(users(:admin).api_token) } - assert_response 401 + assert_response :unauthorized end test 'GET show profile with jwt token works' do get admin_profile_path(profiles(:default).id), headers: { 'HTTP_AUTHORIZATION' => encode_token(Auth::Jwt.generate_token(users(:admin))) } - assert_response 200 + assert_response :ok end test 'GET show profile with jwt token fails for non-admin user' do get admin_profile_path(profiles(:default).id), headers: { 'HTTP_AUTHORIZATION' => encode_token(Auth::Jwt.generate_token(users(:speedee))) } - assert_response 403 + assert_response :forbidden end private diff --git a/test/integration/api/media_type_test.rb b/test/integration/api/media_type_test.rb index b8ac7fc..829991f 100644 --- a/test/integration/api/media_type_test.rb +++ b/test/integration/api/media_type_test.rb @@ -23,7 +23,7 @@ class MediaTypeTest < ActionDispatch::IntegrationTest env: { 'HTTP_AUTHORIZATION' => encode_token(Auth::Jwt.generate_token(users(:admin))) } - assert_response 201 + assert_response :created assert_equal 'application/vnd.api+json; charset=utf-8', response.headers['Content-Type'] end assert_equal 'foo', json['data']['attributes']['username'] @@ -48,7 +48,7 @@ class MediaTypeTest < ActionDispatch::IntegrationTest env: { 'HTTP_AUTHORIZATION' => encode_token(Auth::Jwt.generate_token(users(:admin))) } - assert_response 201 + assert_response :created end assert_equal 'foo', json['data']['attributes']['username'] end