Sha256: 6f3ef53ddb0c987bcfde38d3f282e1fd78157796d81c376b6f23c0cb7226bc3d

Contents?: true

Size: 1.07 KB

Versions: 1

Compression:

Stored size: 1.07 KB

Contents

require 'spec/spec_helper'

# Reusing stage table to simplify database integration tests
class FakeForSymbolAttribute < ActiveRecord::Base
  set_table_name :pipeline_stages
  
  symbol_attr :status
end

module Pipeline
  describe SymbolAttribute do
    before(:each) do
      FakeForSymbolAttribute.delete_all
    end
    
    it "should extend active record to allow symbol attributes to be saved as string" do
      obj = FakeForSymbolAttribute.new(:status => 'started')
      obj.save!
      obj.status.should == :started
      obj.reload.status.should == :started
      
      obj.status = 'finished'
      obj.save!
      obj.status.should == :finished
      obj.reload.status.should == :finished
    end

    it "should extend Symbol to allow symbol attributes in conditions" do
      objs = FakeForSymbolAttribute.find(:all, :conditions => ['status = ?', :started])
      objs.should be_empty
      
      FakeForSymbolAttribute.create(:status => :started)

      objs = FakeForSymbolAttribute.find(:all, :conditions => ['status = ?', :started])
      objs.size.should == 1
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
pipeline-0.0.9 spec/pipeline/core_ext/symbol_attribute_spec.rb