Sha256: 26c839a360e8daa291487a5220fdc5ab83b47d51e40d50bcacb6fdef8d8b9036
Contents?: true
Size: 1.07 KB
Versions: 4
Compression:
Stored size: 1.07 KB
Contents
require 'spec_helper' describe 'Cistern::Singular' do before { class Sample::Settings < Sample::Singular attribute :name, type: :string attribute :count, type: :number belongs_to :entity, -> { cistern.settings(name: '1') } def save result = @@settings = attributes.merge(dirty_attributes) merge_attributes(result) end def get settings = @@settings ||= {} settings[:count] ||= 0 settings[:count] += 1 merge_attributes(settings) end end } let!(:service) { Sample.new } describe 'deprecation', :deprecated do it 'responds to #service' do sample = service.settings.load expect(sample.service).to eq(sample.cistern) end end it 'allows associations' do expect(service.settings.load.entity.name).to eq('1') end it 'reloads' do singular = service.settings(count: 0) expect { singular.reload }.to change(singular, :count).by(1) end it 'updates' do service.settings.update(name: 6) expect(service.settings.load.name).to eq('6') end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
cistern-2.8.0 | spec/singular_spec.rb |
cistern-2.7.2 | spec/singular_spec.rb |
cistern-2.7.1 | spec/singular_spec.rb |
cistern-2.7.0 | spec/singular_spec.rb |