From a6df782fef420ce583d550932863a57ddc1c86a6 Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Sun, 16 Aug 2015 01:27:45 +0200 Subject: [PATCH] Small improvement. --- test/controllers/packages_controller_test.rb | 11 +++++++++++ test/controllers/settings_controller_test.rb | 11 +++++++++++ 2 files changed, 22 insertions(+) diff --git a/test/controllers/packages_controller_test.rb b/test/controllers/packages_controller_test.rb index 12d938b53..4992801d5 100644 --- a/test/controllers/packages_controller_test.rb +++ b/test/controllers/packages_controller_test.rb @@ -50,6 +50,17 @@ class PackagesControllerTest < ActionDispatch::IntegrationTest end + test 'packages index with nobody' do + + # index + get '/api/v1/packages' + assert_response(401) + result = JSON.parse(@response.body) + assert_equal(result.class, Hash) + assert_not(result['packages']) + + end + test 'packages index with admin' do credentials = ActionController::HttpAuthentication::Basic.encode_credentials('packages-admin@example.com', 'adminpw') diff --git a/test/controllers/settings_controller_test.rb b/test/controllers/settings_controller_test.rb index 984b18378..9ff63a560 100644 --- a/test/controllers/settings_controller_test.rb +++ b/test/controllers/settings_controller_test.rb @@ -50,6 +50,17 @@ class SettingsControllerTest < ActionDispatch::IntegrationTest end + test 'settings index with nobody' do + + # index + get '/api/v1/settings' + assert_response(401) + result = JSON.parse(@response.body) + assert_equal(result.class, Hash) + assert_not(result['settings']) + + end + test 'settings index with admin' do credentials = ActionController::HttpAuthentication::Basic.encode_credentials('packages-admin@example.com', 'adminpw')