All checks were successful
continuous-integration/drone/push Build is passing
32 lines
782 B
Ruby
32 lines
782 B
Ruby
require 'rails_helper'
|
|
|
|
RSpec.describe User, type: :model do
|
|
let(:user) { create :user }
|
|
|
|
describe "#is_admin?" do
|
|
it "returns true when admin flag is set in LDAP" do
|
|
expect(Devise::LDAP::Adapter).to receive(:get_ldap_param)
|
|
.with(user.cn, :admin)
|
|
.and_return("true")
|
|
|
|
expect(user.is_admin?).to be true
|
|
end
|
|
|
|
it "returns false when admin flag is not set in LDAP" do
|
|
expect(Devise::LDAP::Adapter).to receive(:get_ldap_param)
|
|
.with(user.cn, :admin)
|
|
.and_return(nil)
|
|
|
|
expect(user.is_admin?).to be false
|
|
end
|
|
end
|
|
|
|
describe "#address" do
|
|
let(:user) { build :user, cn: "jimmy", ou: "kosmos.org" }
|
|
|
|
it "returns the user address" do
|
|
expect(user.address).to eq("jimmy@kosmos.org")
|
|
end
|
|
end
|
|
end
|