Self-hosted project management for devs and their clients: tickets, time tracking, docs and meetings, with an AI assistant that cites its sources. AGPL-3.0.
Ruby agplai-assistantdockerdsgvogdprhotwireissue-trackerjira-alternativeknowledge-basellmmcp-servermeeting-notesopen-sourceproject-managementredmine-alternativeruby-on-railsself-hostedticketingtime-tracking
# frozen_string_literal: true
require 'rails_helper'
# The way into /admin of a fresh instance (`bin/rails lalabase:setup`). Pinned: the
# admin it creates can actually sign in (role AND active, the column default of
# active is false), and a second run is refused instead of adding a second door.
RSpec.describe Setup::CreateFirstAdmin do
let(:password) { 'a' * described_class::MINIMUM_PASSWORD_LENGTH }
it 'creates an active admin who passes the admin login check' do
admin = described_class.call(email: ' [email protected] ', password: password)
expect(admin).to be_persisted
expect(admin.email).to eq('[email protected]')
expect(admin.authenticate(password)).to be_truthy
expect(admin).to be_admin
expect(admin).to be_active
end
it 'refuses once any admin exists' do
Beuser.create!(email: '[email protected]', password: password)
expect { described_class.call(email: '[email protected]', password: password) }
.to raise_error(described_class::Refused, /exists already/)
expect(Beuser.count).to eq(1)
end
it 'refuses a blank email' do
expect { described_class.call(email: ' ', password: password) }
.to raise_error(described_class::Refused, /Email/)
end
it 'refuses a password one character short of the user minimum' do
expect { described_class.call(email: '[email protected]', password: password.chop) }
.to raise_error(described_class::Refused, /at least #{described_class::MINIMUM_PASSWORD_LENGTH}/)
expect(Beuser.count).to eq(0)
end
end