Sha256: 08f6c5ec60a7e847b3743432b5293f6f2620f7e1a5a2ebe99ec0ae6d2d2235c0

Contents?: true

Size: 1.19 KB

Versions: 2

Compression:

Stored size: 1.19 KB

Contents

require 'spec_helper'

describe Hydra::RoleManagement::UserRoles do
  let(:librarian) { Role.create!(name: 'librarian') }
  describe "a real user" do
    subject do
      User.create!(email: 'fred@example.com', password: 'password')
    end

    it "should have admin?" do
      expect(subject).not_to be_admin
    end

    describe "with roles" do
      before do
        subject.roles << librarian
      end

      its(:roles) { should eq [librarian] }
      its(:groups) { should include('registered', 'librarian') }
    end
  end

  describe "when DeviseGuests is installed" do
    before do
      stub_const("DeviseGuests", true)
    end

    describe "a real user" do
      subject do
        User.create!(email: 'fred@example.com', password: 'password')
      end

      it { should_not be_admin }

      describe "with roles" do
        before do
          subject.roles << librarian
        end

        its(:groups) { should include('registered', 'librarian') }
      end
    end
    describe "a guest user" do
      subject do
        User.create!(email: 'fred@example.com', password: 'password', guest: true)
      end

      it { should_not be_admin }
      its(:groups) { should be_empty }
    end
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
hydra-role-management-0.2.2 spec/lib/user_roles_spec.rb
hydra-role-management-0.2.1 spec/lib/user_roles_spec.rb