Sha256: e7a77a34543fe7e4e1ff2f7673b88c732674d21ed9e86050f9a5bf618aab1954

Contents?: true

Size: 671 Bytes

Versions: 1

Compression:

Stored size: 671 Bytes

Contents

require 'spec_no_rails_helper'
require 'sortables'

class SomeSuchClass < ActiveRecord::Base
  sortable
end

class MigrateDatabase < ActiveRecord::Migration
  unless table_exists?('some_such_classes')
    create_table :some_such_classes do |t|
      t.integer :position
    end
  end
end

describe Sortables do
  before { @class = SomeSuchClass }

  it "sorts automatically" do
    obj = @class.create!
    obj2 = @class.create!

    obj.position.should == 0
    obj2.position.should == 1
  end

  it "default scopes by position ASC" do
    obj  = @class.create!(:position => 45)
    obj2 = @class.create!(:position => 25)

    @class.all.should == [obj2, obj]
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
sortables-0.0.1 spec/sortable_spec.rb