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.1.8 spec/lib/tenon/reorderable_spec.rb
tenon-1.1.7 spec/lib/tenon/reorderable_spec.rb
tenon-1.1.6 spec/lib/tenon/reorderable_spec.rb
tenon-1.1.5 spec/lib/tenon/reorderable_spec.rb
tenon-1.1.4 spec/lib/tenon/reorderable_spec.rb
tenon-1.1.3 spec/lib/tenon/reorderable_spec.rb
tenon-1.1.2 spec/lib/tenon/reorderable_spec.rb
tenon-1.1.1 spec/lib/tenon/reorderable_spec.rb
tenon-1.0.76 spec/lib/tenon/reorderable_spec.rb
tenon-1.0.75 spec/lib/tenon/reorderable_spec.rb
tenon-1.0.74 spec/lib/tenon/reorderable_spec.rb
tenon-1.0.73 spec/lib/tenon/reorderable_spec.rb
tenon-1.0.72 spec/lib/tenon/reorderable_spec.rb
tenon-1.0.71 spec/lib/tenon/reorderable_spec.rb
tenon-1.0.70 spec/lib/tenon/reorderable_spec.rb
tenon-1.0.69 spec/lib/tenon/reorderable_spec.rb
tenon-1.0.68 spec/lib/tenon/reorderable_spec.rb
tenon-1.0.67 spec/lib/tenon/reorderable_spec.rb
tenon-1.0.66 spec/lib/tenon/reorderable_spec.rb
tenon-1.0.65 spec/lib/tenon/reorderable_spec.rb