Sha256: 1cf16763fddf5229f7c4a9a204cb4551d157e8593099299eb241b481a9a88abf

Contents?: true

Size: 719 Bytes

Versions: 7

Compression:

Stored size: 719 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).to_a }

    its(:size) { should == 3 }

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

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

  end

end

Version data entries

7 entries across 7 versions & 2 rubygems

Version Path
ranked-model-0.4.4 spec/ego-model/ego_spec.rb
ranked-model-0.4.3 spec/ego-model/ego_spec.rb
ranked-model-0.4.2 spec/ego-model/ego_spec.rb
ranked-model-0.4.1 spec/ego-model/ego_spec.rb
ranked-model-rails2-0.4.0 spec/ego-model/ego_spec.rb
ranked-model-0.4.0 spec/ego-model/ego_spec.rb
ranked-model-0.3 spec/ego-model/ego_spec.rb