Sha256: 6b66778fc7b4c3ef6a99d40994fec8113226bdaeaa8bfc24324142fedef6ae76

Contents?: true

Size: 1.46 KB

Versions: 15

Compression:

Stored size: 1.46 KB

Contents

describe Spotlight::Role, type: :model do
  describe 'validations' do
    subject { described_class.new(args) }
    describe 'with nothing' do
      let(:args) { { user_key: '' } }
      it 'does not be valid' do
        expect(subject).not_to be_valid
        expect(subject.errors.messages).to eq(role: ['is not included in the list'], user_key: ["can't be blank"])
      end
    end
    describe 'with user_key' do
      describe "that doesn't point at a user" do
        let(:user) { FactoryGirl.build(:user) }
        let(:args) { { role: 'curator', user_key: user.email } }
        it 'does not be valid' do
          expect(subject).to be_valid
          subject.save!
          expect(subject.user).to be_invite_pending
        end
      end
      describe 'that points at a user' do
        let(:user) { FactoryGirl.create(:user) }
        let(:args) { { role: 'curator', user_key: user.email } }
        it 'is valid' do
          expect(subject).to be_valid
          expect(subject.errors.messages).to be_empty
        end
      end
      describe 'that points at a user with an existing role' do
        let(:user) { FactoryGirl.create(:user) }
        before { described_class.create!(role: 'curator', user: user) }
        let(:args) { { role: 'curator', user_key: user.email } }
        it 'is valid' do
          expect(subject).not_to be_valid
          expect(subject.errors.messages).to eq(user_key: ['already a member of this exhibit'])
        end
      end
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
blacklight-spotlight-0.34.1 spec/models/spotlight/role_spec.rb
blacklight-spotlight-0.34.0 spec/models/spotlight/role_spec.rb
blacklight-spotlight-0.33.3 spec/models/spotlight/role_spec.rb
blacklight-spotlight-0.33.2 spec/models/spotlight/role_spec.rb
blacklight-spotlight-0.33.1 spec/models/spotlight/role_spec.rb
blacklight-spotlight-0.33.0 spec/models/spotlight/role_spec.rb
blacklight-spotlight-0.32.0 spec/models/spotlight/role_spec.rb
blacklight-spotlight-0.31.0 spec/models/spotlight/role_spec.rb
blacklight-spotlight-0.30.0 spec/models/spotlight/role_spec.rb
blacklight-spotlight-0.29.1 spec/models/spotlight/role_spec.rb
blacklight-spotlight-0.29.0 spec/models/spotlight/role_spec.rb
blacklight-spotlight-0.28.3 spec/models/spotlight/role_spec.rb
blacklight-spotlight-0.28.2 spec/models/spotlight/role_spec.rb
blacklight-spotlight-0.28.1 spec/models/spotlight/role_spec.rb
blacklight-spotlight-0.28.0 spec/models/spotlight/role_spec.rb