Sha256: fbd8e6811233dd94ccb51e5a42cb842546bc7e0b8a57fc35fa5e4b206292564c

Contents?: true

Size: 691 Bytes

Versions: 3

Compression:

Stored size: 691 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_attribute :order, RankedModel::MAX_RANK_VALUE
      @second.update_attribute :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

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
ranked-model-0.4.4 spec/number-model/number_spec.rb
ranked-model-0.4.3 spec/number-model/number_spec.rb
ranked-model-0.4.2 spec/number-model/number_spec.rb