Sha256: 394cf1cb8766cf7b9460cfe1975068250c6808748c0b15f13dc6f01c06fc5c86

Contents?: true

Size: 811 Bytes

Versions: 5

Compression:

Stored size: 811 Bytes

Contents

require 'spec_helper'

describe Number do

  before {
    200.times do |i|
      Number.create :value => i
    end
  }

  describe "a rearrangement with keyword column name" do

    before {
      @first = Number.first
      @second = Number.offset(1).first
      @ordered = Number.rank(:order).where(Number.arel_table[:id].not_in([@first.id, @second.id])).collect {|d| d.id }
      @first.update :order => RankedModel::MAX_RANK_VALUE
      @second.update :order => RankedModel::MAX_RANK_VALUE
    }

    context {

      subject { Number.rank(:order).collect {|d| d.id } }

      it { should == (@ordered[0..-2] + [@ordered[-1], @first.id, @second.id]) }

    }

  end

  describe "getting a position with keyword column name" do

    subject { Number.first }

    its(:order_rank) { should == 0 }

  end

end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
ranked-model-0.4.11 spec/number-model/number_spec.rb
ranked-model-0.4.10 spec/number-model/number_spec.rb
ranked-model-0.4.9 spec/number-model/number_spec.rb
ranked-model-0.4.8 spec/number-model/number_spec.rb
ranked-model-0.4.7 spec/number-model/number_spec.rb