Sha256: c3c3c3b9e7c77f8c1b510ee86537ad43f3c2d2819db125662941af585119aa20
Contents?: true
Size: 1.38 KB
Versions: 15
Compression:
Stored size: 1.38 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 let(:user) { FactoryGirl.create(:user) } describe "that doesn't point at a user" do let(:args) { { role: 'curator', user_key: 'bob' } } it 'does not be valid' do expect(subject).not_to be_valid expect(subject.errors.messages).to eq(user_key: ['User must sign up first.']) end end describe 'that points at a user' do 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 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