Sha256: 02fd265b05afea0d1fe3c921cb95e98d6d13f7a3478668ad65378bfdfd82ead7

Contents?: true

Size: 718 Bytes

Versions: 1

Compression:

Stored size: 718 Bytes

Contents

require 'spec_helper'

describe Ego do

  before {
    @egos = {
      :bob   => Ego.create(:name => 'Bob'),
      :nick  => Ego.create(:name => 'Nick'),
      :sally => Ego.create(:name => 'Sally')
    }
    @egos.each { |name, ego|
      ego.reload
      ego.update_attribute :size_position, 0
      ego.save!
    }
    @egos.each {|name, ego| ego.reload }
  }

  describe "sorting on size alternative primary key" do

    before {
      @egos[:nick].update_attribute :size_position, 0
      @egos[:sally].update_attribute :size_position, 2
    }

    subject { Ego.rank(:size).all }

    its(:size) { should == 3 }

    its(:first) { should == @egos[:nick] }

    its(:last) { should == @egos[:sally] }

  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ranked-model-0.2.1 spec/ego-model/ego_spec.rb