From 97f3241259d42d65ef56a7eac6d0bd0976802b1d Mon Sep 17 00:00:00 2001 From: Pascal Zumkehr Date: Mon, 18 Nov 2024 21:00:00 +0100 Subject: [PATCH] Update rails to 7.1.5 --- .github/workflows/build.yml | 8 +- Gemfile.lock | 125 +++++++++--------- app/models/access_code.rb | 2 +- app/models/archive_format.rb | 2 +- app/models/user.rb | 2 +- app/services/downgrade/action_handler.rb | 2 +- app/services/import/recording/composer.rb | 2 +- config/initializers/inflections.rb | 1 + .../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 +- 24 files changed, 168 insertions(+), 162 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 16ec60c..6e9df2d 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -41,7 +41,7 @@ jobs: --health-retries 5 steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Set up Ruby uses: ruby/setup-ruby@v1 with: @@ -63,7 +63,7 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Set up Ruby uses: ruby/setup-ruby@v1 with: @@ -91,7 +91,7 @@ jobs: --health-retries 5 steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Set up Ruby uses: ruby/setup-ruby@v1 with: @@ -108,7 +108,7 @@ jobs: - name: Run tests run: bundle exec rails test - name: Coveralls - uses: coverallsapp/github-action@master + uses: coverallsapp/github-action@v2 with: github-token: ${{ secrets.GITHUB_TOKEN }} path-to-lcov: "./test/coverage/lcov.info" diff --git a/Gemfile.lock b/Gemfile.lock index 3091b33..962bed1 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,9 +1,9 @@ GEM remote: https://rubygems.org/ specs: - actionpack (7.1.4.1) - actionview (= 7.1.4.1) - activesupport (= 7.1.4.1) + actionpack (7.1.5) + actionview (= 7.1.5) + activesupport (= 7.1.5) nokogiri (>= 1.8.5) racc rack (>= 2.2.4) @@ -11,8 +11,8 @@ GEM 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) + actionview (7.1.5) + activesupport (= 7.1.5) 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 (7.1.5) + activesupport (= 7.1.5) + activerecord (7.1.5) + activemodel (= 7.1.5) + activesupport (= 7.1.5) timeout (>= 0.4.0) - activesupport (7.1.4.1) + activesupport (7.1.5) base64 + benchmark (>= 0.3) bigdecimal concurrent-ruby (~> 1.0, >= 1.0.2) connection_pool (>= 2.2.5) drb i18n (>= 1.6, < 2) + logger (>= 1.4.2) minitest (>= 5.1) mutex_m + securerandom (>= 0.3) tzinfo (~> 2.0) - airbrussh (1.5.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,29 +95,31 @@ 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) @@ -127,9 +133,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 +147,75 @@ GEM rails-html-sanitizer (1.6.0) loofah (~> 2.21) nokogiri (~> 1.14) - rails-i18n (7.0.8) + rails-i18n (7.0.10) i18n (>= 0.7, < 2) railties (>= 6.0.0, < 8) - railties (7.1.4.1) - actionpack (= 7.1.4.1) - activesupport (= 7.1.4.1) + railties (7.1.5) + actionpack (= 7.1.5) + activesupport (= 7.1.5) irb 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.0.4) mini_portile2 (~> 2.8.0) - sqlite3 (1.7.2-x86_64-linux) - sshkit (1.22.0) - mutex_m + sqlite3 (2.0.4-x86_64-linux) + 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) + zeitwerk (2.6.18) PLATFORMS ruby @@ -245,4 +250,4 @@ DEPENDENCIES swagger-blocks BUNDLED WITH - 2.3.19 + 2.5.23 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..9db3ed2 100644 --- a/app/models/archive_format.rb +++ b/app/models/archive_format.rb @@ -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/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/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