-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #391 from projecthydra/avoid_send
Use find_by instead of a dynamic finder
- Loading branch information
Showing
2 changed files
with
14 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,6 @@ | ||
require 'spec_helper' | ||
|
||
describe RoleMapper do | ||
before do | ||
allow(Devise).to receive(:authentication_keys).and_return(['uid']) | ||
end | ||
|
||
it "defines the 4 roles" do | ||
expect(RoleMapper.role_names.sort).to eq %w(admin_policy_object_editor archivist donor patron researcher) | ||
end | ||
|
@@ -51,11 +47,16 @@ | |
expect(RoleMapper.roles('[email protected]')).to eq ['archivist'] | ||
end | ||
|
||
it "doesn't change its response when it's called repeatedly" do | ||
u = User.new(:uid=>'[email protected]') | ||
allow(u).to receive(:new_record?).and_return(false) | ||
expect(RoleMapper.roles(u).sort).to eq ['archivist', 'donor', 'patron'] | ||
expect(RoleMapper.roles(u).sort).to eq ['archivist', 'donor', 'patron'] | ||
context "when called with a user instance" do | ||
let(:user) { User.new(email: '[email protected]') } | ||
before do | ||
allow(user).to receive(:new_record?).and_return(false) | ||
end | ||
|
||
it "doesn't change its response when it's called repeatedly" do | ||
expect(RoleMapper.roles(user).sort).to eq ['archivist', 'donor', 'patron'] | ||
expect(RoleMapper.roles(user).sort).to eq ['archivist', 'donor', 'patron'] | ||
end | ||
end | ||
|
||
it "returns an empty array if there are no roles" do | ||
|