Move user db creation to service

This commit is contained in:
2020-12-08 17:39:54 +01:00
parent 44fadb12d6
commit e8c1a6066a
4 changed files with 45 additions and 11 deletions

View File

@@ -7,6 +7,22 @@ RSpec.describe CreateAccount, type: :model do
allow(service).to receive(:ldap_client).and_return(ldap_client_mock)
end
describe "#create_user_in_database" do
let(:service) { CreateAccount.new(
username: 'isaacnewton',
email: 'isaacnewton@example.com',
password: 'bright-ideas-in-autumn'
)}
it "creates a new user record in the akkounts database" do
expect(User.count).to eq(0)
service.send(:create_user_in_database)
expect(User.count).to eq(1)
expect(User.last.cn).to eq("isaacnewton")
expect(User.last.email).to eq("isaacnewton@example.com")
end
end
describe "#add_ldap_document" do
let(:service) { CreateAccount.new(
username: 'halfinney',