Migrate to Rais 8.0
- Remove all Rodauth stuff and implement simple custom auth - Migrate from sprockets to propshaft, hack some bootstrap stuff
This commit is contained in:
parent
0198a22278
commit
c35c7da6e0
66 changed files with 518 additions and 684 deletions
|
|
@ -17,19 +17,23 @@ class ApplicationSystemTestCase < ActionDispatch::SystemTestCase
|
|||
end
|
||||
|
||||
def login(email, password)
|
||||
visit "/login"
|
||||
visit "/session/new"
|
||||
assert_selector("h1", text: "Login")
|
||||
fill_in "Login", with: email
|
||||
fill_in "Password", with: password
|
||||
fill_in "Passwort", with: password
|
||||
click_button "Login"
|
||||
assert_text("Dashboard")
|
||||
save_screenshot "after_login.png"
|
||||
end
|
||||
|
||||
def logout
|
||||
visit "/logout"
|
||||
click_on "Log out"
|
||||
Session.destroy_all
|
||||
end
|
||||
|
||||
def login_test
|
||||
Account.create(email: "test@example.com", password: "password")
|
||||
login("test@example.com", "password")
|
||||
user = User.find_or_initialize_by(email_address: "test@example.com")
|
||||
user.update!(password: "password")
|
||||
login(user.email_address, user.password)
|
||||
save_screenshot "login.png"
|
||||
end
|
||||
end
|
||||
|
|
|
|||
15
test/controller_test.rb
Normal file
15
test/controller_test.rb
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require "test_helper"
|
||||
|
||||
class ControllerTest < ActionDispatch::IntegrationTest
|
||||
def login(email, password)
|
||||
post "/session", params: { email_address: email, password: password }
|
||||
assert_redirected_to "/"
|
||||
end
|
||||
|
||||
def logout
|
||||
delete "/session"
|
||||
assert_redirected_to "/session/new"
|
||||
end
|
||||
end
|
||||
|
|
@ -3,23 +3,13 @@
|
|||
require "test_helper"
|
||||
|
||||
module Admin
|
||||
class BackupsControllerTest < ActionDispatch::IntegrationTest
|
||||
def login(email, password)
|
||||
post "/login", params: { email: email, password: password }
|
||||
assert_redirected_to "/"
|
||||
end
|
||||
|
||||
def logout
|
||||
post "/logout"
|
||||
assert_redirected_to "/"
|
||||
end
|
||||
|
||||
class BackupsControllerTest < ::ControllerTest
|
||||
teardown do
|
||||
logout
|
||||
end
|
||||
|
||||
setup do
|
||||
Account.create(email: "test@example.com", password: "password")
|
||||
User.create!(email_address: "test@example.com", password: "password")
|
||||
login("test@example.com", "password")
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -1,22 +1,12 @@
|
|||
require "test_helper"
|
||||
|
||||
class BackofficeControllerTest < ActionDispatch::IntegrationTest
|
||||
def login(email, password)
|
||||
post "/login", params: { email: email, password: password }
|
||||
assert_redirected_to "/"
|
||||
end
|
||||
|
||||
def logout
|
||||
post "/logout"
|
||||
assert_redirected_to "/"
|
||||
end
|
||||
|
||||
class BackofficeControllerTest < ::ControllerTest
|
||||
teardown do
|
||||
logout
|
||||
end
|
||||
|
||||
setup do
|
||||
Account.create(email: "test@example.com", password: "password")
|
||||
User.create!(email_address: "test@example.com", password: "password")
|
||||
login("test@example.com", "password")
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -2,24 +2,14 @@
|
|||
|
||||
require "test_helper"
|
||||
|
||||
class ChecklistEntriesControllerTest < ActionDispatch::IntegrationTest
|
||||
def login(email, password)
|
||||
post "/login", params: { email: email, password: password }
|
||||
assert_redirected_to "/"
|
||||
end
|
||||
|
||||
def logout
|
||||
post "/logout"
|
||||
assert_redirected_to "/"
|
||||
end
|
||||
|
||||
class ChecklistEntriesControllerTest < ::ControllerTest
|
||||
teardown do
|
||||
logout
|
||||
end
|
||||
|
||||
setup do
|
||||
@checklist_entry = checklist_entries(:one)
|
||||
Account.create(email: "test@example.com", password: "password")
|
||||
User.create!(email_address: "test@example.com", password: "password")
|
||||
login("test@example.com", "password")
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -2,24 +2,14 @@
|
|||
|
||||
require "test_helper"
|
||||
|
||||
class ChecklistsControllerTest < ActionDispatch::IntegrationTest
|
||||
def login(email, password)
|
||||
post "/login", params: { email: email, password: password }
|
||||
assert_redirected_to "/"
|
||||
end
|
||||
|
||||
def logout
|
||||
post "/logout"
|
||||
assert_redirected_to "/"
|
||||
end
|
||||
|
||||
class ChecklistsControllerTest < ::ControllerTest
|
||||
teardown do
|
||||
logout
|
||||
end
|
||||
|
||||
setup do
|
||||
@checklist = checklists(:one)
|
||||
Account.create(email: "test@example.com", password: "password")
|
||||
User.create!(email_address: "test@example.com", password: "password")
|
||||
login("test@example.com", "password")
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -2,17 +2,7 @@
|
|||
|
||||
require "test_helper"
|
||||
|
||||
class ChecksControllerTest < ActionDispatch::IntegrationTest
|
||||
def login(email, password)
|
||||
post "/login", params: { email: email, password: password }
|
||||
assert_redirected_to "/"
|
||||
end
|
||||
|
||||
def logout
|
||||
post "/logout"
|
||||
assert_redirected_to "/"
|
||||
end
|
||||
|
||||
class ChecksControllerTest < ::ControllerTest
|
||||
teardown do
|
||||
logout
|
||||
end
|
||||
|
|
@ -20,7 +10,7 @@ class ChecksControllerTest < ActionDispatch::IntegrationTest
|
|||
setup do
|
||||
@principle = principles(:one)
|
||||
@check = checks(:deletable)
|
||||
Account.create(email: "test@example.com", password: "password")
|
||||
User.create!(email_address: "test@example.com", password: "password")
|
||||
login("test@example.com", "password")
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -2,17 +2,7 @@
|
|||
|
||||
require "test_helper"
|
||||
|
||||
class ElementsControllerTest < ActionDispatch::IntegrationTest
|
||||
def login(email, password)
|
||||
post "/login", params: { email: email, password: password }
|
||||
assert_redirected_to "/"
|
||||
end
|
||||
|
||||
def logout
|
||||
post "/logout"
|
||||
assert_redirected_to "/"
|
||||
end
|
||||
|
||||
class ElementsControllerTest < ::ControllerTest
|
||||
teardown do
|
||||
logout
|
||||
end
|
||||
|
|
@ -20,7 +10,7 @@ class ElementsControllerTest < ActionDispatch::IntegrationTest
|
|||
setup do
|
||||
@element = elements(:one)
|
||||
@checklist = checklists(:one)
|
||||
Account.create(email: "test@example.com", password: "password")
|
||||
User.create!(email_address: "test@example.com", password: "password")
|
||||
login("test@example.com", "password")
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
require "test_helper"
|
||||
|
||||
class HomeControllerTest < ActionDispatch::IntegrationTest
|
||||
class HomeControllerTest < ::ControllerTest
|
||||
test "should get show" do
|
||||
get root_url
|
||||
assert_response :success
|
||||
|
|
|
|||
|
|
@ -2,24 +2,14 @@
|
|||
|
||||
require "test_helper"
|
||||
|
||||
class LinkCategoriesControllerTest < ActionDispatch::IntegrationTest
|
||||
def login(email, password)
|
||||
post "/login", params: { email: email, password: password }
|
||||
assert_redirected_to "/"
|
||||
end
|
||||
|
||||
def logout
|
||||
post "/logout"
|
||||
assert_redirected_to "/"
|
||||
end
|
||||
|
||||
class LinkCategoriesControllerTest < ::ControllerTest
|
||||
teardown do
|
||||
logout
|
||||
end
|
||||
|
||||
setup do
|
||||
@link_category = link_categories(:one)
|
||||
Account.create(email: "test@example.com", password: "password")
|
||||
User.create!(email_address: "test@example.com", password: "password")
|
||||
login("test@example.com", "password")
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -2,24 +2,14 @@
|
|||
|
||||
require "test_helper"
|
||||
|
||||
class LinksControllerTest < ActionDispatch::IntegrationTest
|
||||
def login(email, password)
|
||||
post "/login", params: { email: email, password: password }
|
||||
assert_redirected_to "/"
|
||||
end
|
||||
|
||||
def logout
|
||||
post "/logout"
|
||||
assert_redirected_to "/"
|
||||
end
|
||||
|
||||
class LinksControllerTest < ::ControllerTest
|
||||
teardown do
|
||||
logout
|
||||
end
|
||||
|
||||
setup do
|
||||
@link = links(:one)
|
||||
Account.create(email: "test@example.com", password: "password")
|
||||
User.create!(email_address: "test@example.com", password: "password")
|
||||
login("test@example.com", "password")
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -1,22 +1,12 @@
|
|||
require "test_helper"
|
||||
|
||||
class PagesControllerTest < ActionDispatch::IntegrationTest
|
||||
def login(email, password)
|
||||
post "/login", params: { email: email, password: password }
|
||||
assert_redirected_to "/"
|
||||
end
|
||||
|
||||
def logout
|
||||
post "/logout"
|
||||
assert_redirected_to "/"
|
||||
end
|
||||
|
||||
class PagesControllerTest < ::ControllerTest
|
||||
teardown do
|
||||
logout
|
||||
end
|
||||
|
||||
setup do
|
||||
Account.create(email: "test@example.com", password: "password")
|
||||
User.create!(email_address: "test@example.com", password: "password")
|
||||
@page = pages(:one)
|
||||
login("test@example.com", "password")
|
||||
end
|
||||
|
|
|
|||
|
|
@ -2,24 +2,14 @@
|
|||
|
||||
require "test_helper"
|
||||
|
||||
class ReportsControllerTest < ActionDispatch::IntegrationTest
|
||||
def login(email, password)
|
||||
post "/login", params: { email: email, password: password }
|
||||
assert_redirected_to "/"
|
||||
end
|
||||
|
||||
def logout
|
||||
post "/logout"
|
||||
assert_redirected_to "/"
|
||||
end
|
||||
|
||||
class ReportsControllerTest < ::ControllerTest
|
||||
teardown do
|
||||
logout
|
||||
end
|
||||
|
||||
setup do
|
||||
@report = reports(:one)
|
||||
Account.create(email: "test@example.com", password: "password")
|
||||
User.create!(email_address: "test@example.com", password: "password")
|
||||
login("test@example.com", "password")
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -2,24 +2,14 @@
|
|||
|
||||
require "test_helper"
|
||||
|
||||
class SuccessCriteriaControllerTest < ActionDispatch::IntegrationTest
|
||||
def login(email, password)
|
||||
post "/login", params: { email: email, password: password }
|
||||
assert_redirected_to "/"
|
||||
end
|
||||
|
||||
def logout
|
||||
post "/logout"
|
||||
assert_redirected_to "/"
|
||||
end
|
||||
|
||||
class SuccessCriteriaControllerTest < ::ControllerTest
|
||||
teardown do
|
||||
logout
|
||||
end
|
||||
|
||||
setup do
|
||||
@success_criterion = success_criteria(:one)
|
||||
Account.create(email: "test@example.com", password: "password")
|
||||
User.create!(email_address: "test@example.com", password: "password")
|
||||
login("test@example.com", "password")
|
||||
end
|
||||
|
||||
|
|
|
|||
10
test/fixtures/accounts.yml
vendored
10
test/fixtures/accounts.yml
vendored
|
|
@ -1,10 +0,0 @@
|
|||
# Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
|
||||
one:
|
||||
email: freddie@queen.com
|
||||
password_hash: <%= RodauthApp.rodauth.allocate.password_hash("password") %>
|
||||
status: verified
|
||||
|
||||
two:
|
||||
email: brian@queen.com
|
||||
password_hash: <%= RodauthApp.rodauth.allocate.password_hash("password") %>
|
||||
status: verified
|
||||
9
test/fixtures/users.yml
vendored
Normal file
9
test/fixtures/users.yml
vendored
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
<% password_digest = BCrypt::Password.create("password") %>
|
||||
|
||||
one:
|
||||
email_address: one@example.com
|
||||
password_digest: <%= password_digest %>
|
||||
|
||||
two:
|
||||
email_address: two@example.com
|
||||
password_digest: <%= password_digest %>
|
||||
7
test/mailers/previews/passwords_mailer_preview.rb
Normal file
7
test/mailers/previews/passwords_mailer_preview.rb
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
# Preview all emails at http://localhost:3000/rails/mailers/passwords_mailer
|
||||
class PasswordsMailerPreview < ActionMailer::Preview
|
||||
# Preview this email at http://localhost:3000/rails/mailers/passwords_mailer/reset
|
||||
def reset
|
||||
PasswordsMailer.reset(User.take)
|
||||
end
|
||||
end
|
||||
7
test/models/user_test.rb
Normal file
7
test/models/user_test.rb
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
require "test_helper"
|
||||
|
||||
class UserTest < ActiveSupport::TestCase
|
||||
# test "the truth" do
|
||||
# assert true
|
||||
# end
|
||||
end
|
||||
|
|
@ -4,12 +4,14 @@ ENV["RAILS_ENV"] ||= "test"
|
|||
require_relative "../config/environment"
|
||||
require "rails/test_help"
|
||||
require "action_text/system_test_helper"
|
||||
require "capybara/rails"
|
||||
require "controller_test"
|
||||
|
||||
module ActiveSupport
|
||||
class TestCase
|
||||
include ActionText::SystemTestHelper
|
||||
# Run tests in parallel with specified workers
|
||||
parallelize(workers: :number_of_processors)
|
||||
# parallelize(workers: :number_of_processors)
|
||||
|
||||
# Setup all fixtures in test/fixtures/*.yml for all tests in alphabetical order.
|
||||
fixtures :all
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue