Sha256: 4855854649ed9eb55d7289b52f2fc69fe27c52bb7b8e8e0cd8217534b6d5888d

Contents?: true

Size: 634 Bytes

Versions: 5

Compression:

Stored size: 634 Bytes

Contents

require 'spec_helper'

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

  def initialize(id)
    @id = id
  end

  def save
    true
  end
end

describe "Forge::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

5 entries across 5 versions & 1 rubygems

Version Path
forge-cli-0.1.10 lib/forge/spec/models/reorderable_spec.rb
forge-cli-0.1.9 lib/forge/spec/models/reorderable_spec.rb
forge-cli-0.1.8 lib/forge/spec/models/reorderable_spec.rb
forge-cli-0.1.7 lib/forge/spec/models/reorderable_spec.rb
forge-cli-0.1.6 lib/forge/spec/models/reorderable_spec.rb