Sha256: 0d050e5044a27d7272335259ec13c1a3c00455b7b53405222fab04887e8df233

Contents?: true

Size: 1 KB

Versions: 1

Compression:

Stored size: 1 KB

Contents

require File.dirname(__FILE__) + '/spec_helper'

describe 'reload' do
  class Table
    include CouchPotato::Persistence
    property :rows
    has_many :cols, :stored => :inline
    has_many :ext_cols, :stored => :separately
  end
  
  class ExtCol
    include CouchPotato::Persistence
    belongs_to :table
    property :name
  end
  
  class Col
    include CouchPotato::Persistence
    property :name
  end
  
  it "should reload simple properties" do
    table = Table.create! :rows => 3
    table.rows = 4
    table.reload
    table.rows.should == 3
  end
  
  it "should reload inline has_many associations" do
    table = Table.new
    table.cols.build :name => 'col1'
    table.save!
    table.cols.build :name => 'col2'
    table.reload
    table.cols.size.should == 1
  end
  
  it "should reload external has_many associations" do
    table = Table.new
    table.ext_cols.build :name => 'col1'
    table.save!
    table.ext_cols.build :name => 'col2'
    table.reload
    table.ext_cols.size.should == 1
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
langalex-couch_potato-0.1 spec/reload_spec.rb