Sha256: fb3edacba014f26b69507b63106f38db8beb58b013ab913de61f181a458208be
Contents?: true
Size: 1.66 KB
Versions: 6
Compression:
Stored size: 1.66 KB
Contents
require_relative './spec_helper' describe Groovy::Model do before :all do Groovy.open('tmp/model', 'model_spec') load_schema! 'model_spec' end after :all do Groovy.close('model_spec') end describe '.schema' do end describe '.scope' do before :all do TestProduct.class_eval do scope :with_name, -> (name) { where(name: name) if name } scope :by_price_asc, -> { sort_by(price: :asc) } scope :cheapest, -> { by_price_asc } end end it 'does not perform query by default' do expect(TestProduct.table).not_to receive(:select) TestProduct.with_name('foo') end describe 'chaining' do it 'allow chaining (even if methods dont return the query)' do expect do TestProduct.with_name('foo').by_price_asc.cheapest end.not_to raise_error end it 'does not duplicate params' do res = TestProduct.with_name('foo').by_price_asc.cheapest expect(res).to be_a(Groovy::Query) expect(res.parameters).to eq(["+name:foo"]) expect(res.sorting).to eq(:by=>[{:key=>"price", :order=>:asc}], :limit=>-1, :offset=>0) end end end describe '.create' do end describe '.find' do end describe '.find_by' do end describe '.delete_all' do end describe '#[]' do end describe '#[]=' do end describe '#increment' do end describe '#dirty' do end describe '#update_attributes' do end describe '#save' do end describe '#delete' do end describe '#reload' do end describe 'attributes accessors' do end describe 'singular refs' do end describe 'plural refs' do end end
Version data entries
6 entries across 6 versions & 1 rubygems