Sha256: 00e048f083545955a4ebd7d41f81ba6fa4d6844f8b704d8117343032145fd419

Contents?: true

Size: 635 Bytes

Versions: 83

Compression:

Stored size: 635 Bytes

Contents

require 'spec_helper'

class DummyClass
  include Tenon::Reorderable
  attr_accessor :id, :list_order

  def initialize(id)
    @id = id
  end

  def save
    true
  end
end

describe 'Tenon::Reorderable' do
  it 'should set the list order on the correct item' do
    one, two, three = DummyClass.new(1), DummyClass.new(2), DummyClass.new(3)
    DummyClass.stub(:find_by_id).with(1).and_return(one)
    DummyClass.stub(:find_by_id).with(2).and_return(two)
    DummyClass.stub(:find_by_id).with(3).and_return(three)
    DummyClass.reorder!([2, 1, 3])
    [one.list_order, two.list_order, three.list_order].should == [1, 0, 2]
  end
end

Version data entries

83 entries across 83 versions & 1 rubygems

Version Path
tenon-1.0.43 spec/lib/tenon/reorderable_spec.rb
tenon-1.0.42 spec/lib/tenon/reorderable_spec.rb
tenon-1.0.41 spec/lib/tenon/reorderable_spec.rb
tenon-1.0.40 spec/lib/tenon/reorderable_spec.rb
tenon-1.0.39 spec/lib/tenon/reorderable_spec.rb
tenon-1.0.38 spec/lib/tenon/reorderable_spec.rb
tenon-1.0.37 spec/lib/tenon/reorderable_spec.rb
tenon-1.0.36 spec/lib/tenon/reorderable_spec.rb
tenon-1.0.35 spec/lib/tenon/reorderable_spec.rb
tenon-1.0.33 spec/lib/tenon/reorderable_spec.rb
tenon-1.0.32 spec/lib/tenon/reorderable_spec.rb
tenon-1.0.31 spec/lib/tenon/reorderable_spec.rb
tenon-1.0.30 spec/lib/tenon/reorderable_spec.rb
tenon-1.0.29 spec/lib/tenon/reorderable_spec.rb
tenon-1.0.28 spec/lib/tenon/reorderable_spec.rb
tenon-1.0.27 spec/lib/tenon/reorderable_spec.rb
tenon-1.0.26 spec/lib/tenon/reorderable_spec.rb
tenon-1.0.25 spec/lib/tenon/reorderable_spec.rb
tenon-1.0.24 spec/lib/tenon/reorderable_spec.rb
tenon-1.0.23 spec/lib/tenon/reorderable_spec.rb