Add specs for User#is_admin?
This commit is contained in:
@@ -1,5 +1,23 @@
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe User, type: :model do
|
||||
pending "add some examples to (or delete) #{__FILE__}"
|
||||
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
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user