Sha256: 45c33b28839a886024f36675c29f829ce4180b8073bc82033792a73feccd4c82
Contents?: true
Size: 1.48 KB
Versions: 6
Compression:
Stored size: 1.48 KB
Contents
# frozen_string_literal: true include MinterStateHelper describe MinterState, type: :model do before { reset_minter_state_table } after(:all) { reset_minter_state_table } let(:state) { described_class.new } let(:first) { described_class.first } it 'db is seeded with first row' do expect { first }.not_to raise_error expect(first.namespace).to eq 'default' expect(first.template).to eq '.reeddeeddk' expect(first.seq).to eq 0 expect(described_class.group(:namespace).count).to eq('default' => 1) end describe 'validation' do it 'blocks invalid template' do expect { state.save! }.to raise_error(ActiveRecord::RecordInvalid) # empty state.template = 'bad_template' expect { state.save! }.to raise_error(ActiveRecord::RecordInvalid) state.template = 'reeddddk' # close, but missing '.' expect { state.save! }.to raise_error(ActiveRecord::RecordInvalid) end it 'allows valid template (edit)' do first.template = '.reeddddk' expect { first.save! }.not_to raise_error # OK! end it 'blocks new record in same namespace' do state.template = '.reeddddk' expect { state.save! }.to raise_error(ActiveRecord::RecordInvalid) end it 'allows new record in distinct namespace' do state.template = '.reeddddk' state.namespace = 'foobar' expect { state.save! }.not_to raise_error # OK! expect(described_class.group(:namespace).count).to eq('default' => 1, 'foobar' => 1) end end end
Version data entries
6 entries across 6 versions & 1 rubygems