Sha256: 3dc6aa870d059e773c6f4c7dc4fee9231192be28cb7743e6c495375c0446f32c
Contents?: true
Size: 1.53 KB
Versions: 12
Compression:
Stored size: 1.53 KB
Contents
# frozen_string_literal: true 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.transform_values(&:to_a)).to include(role: ['is not included in the list'], 'user.email': ["can't be blank"]) end end describe 'with user_key' do describe "that doesn't point at a user" do let(:user) { FactoryBot.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) { FactoryBot.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) { FactoryBot.create(:user) } let(:args) { { role: 'curator', user_key: user.email } } before { described_class.create!(role: 'curator', user: user) } 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
12 entries across 12 versions & 1 rubygems