tests rubocopified

This commit is contained in:
Christoph Haas 2024-07-15 00:05:56 +02:00
parent 48e3a8c67f
commit 55ea782b86
4 changed files with 26 additions and 14 deletions

View file

@ -97,6 +97,8 @@ group :development, :test do
# Call 'byebug' anywhere in the code to stop execution and get a debugger console # Call 'byebug' anywhere in the code to stop execution and get a debugger console
gem 'byebug', platform: :mri gem 'byebug', platform: :mri
gem 'factory_bot_rails'
end end
group :test do group :test do

View file

@ -138,6 +138,11 @@ GEM
e2mmap (0.1.0) e2mmap (0.1.0)
erubi (1.12.0) erubi (1.12.0)
execjs (2.9.1) execjs (2.9.1)
factory_bot (6.4.6)
activesupport (>= 5.0.0)
factory_bot_rails (6.4.3)
factory_bot (~> 6.4)
railties (>= 5.0.0)
faraday (2.8.1) faraday (2.8.1)
base64 base64
faraday-net_http (>= 2.0, < 3.1) faraday-net_http (>= 2.0, < 3.1)
@ -495,6 +500,7 @@ DEPENDENCIES
capybara capybara
debug debug
devise devise
factory_bot_rails
fastimage fastimage
font-awesome-rails font-awesome-rails
foundation-rails (~> 6.6) foundation-rails (~> 6.6)

View file

@ -1,18 +1,18 @@
require "test_helper" require 'test_helper'
class AdminControllerTest < ActionController::TestCase class AdminControllerTest < ActionController::TestCase
test "user must login" do test 'user must login' do
get :status get :status
assert_redirected_to user_session_path assert_redirected_to user_session_path
end end
test "normal user must not see admin status" do test 'normal user must not see admin status' do
sign_in users(:normal) sign_in users(:normal)
get :status get :status
assert_response :forbidden assert_response :forbidden
end end
test "admin can see status" do test 'admin can see status' do
sign_in users(:admin) sign_in users(:admin)
get :status get :status
assert_response :success assert_response :success

View file

@ -1,21 +1,25 @@
ENV['RAILS_ENV'] ||= 'test' ENV['RAILS_ENV'] ||= 'test'
require File.expand_path("../../config/environment", __FILE__) require File.expand_path('../config/environment', __dir__)
require "rails/test_help" require 'rails/test_help'
require "minitest/reporters" require 'minitest/reporters'
Minitest::Reporters.use! Minitest::Reporters.use!
# require "minitest/rails" # require "minitest/rails"
# require "minitest/autorun" # require "minitest/autorun"
# Uncomment for awesome colorful output # Uncomment for awesome colorful output
require "minitest/pride" require 'minitest/pride'
class ActiveSupport::TestCase module ActiveSupport
# Setup all fixtures in test/fixtures/*.(yml|csv) for all tests in alphabetical order. class TestCase
fixtures :all # Setup all fixtures in test/fixtures/*.(yml|csv) for all tests in alphabetical order.
fixtures :all
end
end end
class ActionController::TestCase module ActionController
include Devise::Test::ControllerHelpers class TestCase
include Devise::Test::ControllerHelpers
end
end end