Sha256: eebdb7fd2ca81cb0d639aefbd218626ceab8059b8aef38ef5f16f72b8af32f84

Contents?: true

Size: 669 Bytes

Versions: 7

Compression:

Stored size: 669 Bytes

Contents

require 'spec_helper'

describe SortableController, type: :controller do
  describe "POST reorder" do
    before do
      @item1 = Item.create!
      @item2 = Item.create!
      @item3 = Item.create!
    end
    it "should reorder models" do
      if Gem::Version.new(Rails.version) < Gem::Version.new(5)
        post :reorder, Item: [@item1.id, @item3.id, @item2.id]
      else
        post :reorder, params: { Item: [@item1.id, @item3.id, @item2.id] }
      end
      expect(response.body).to be_blank
      expect(Item.find(@item1.id).sort).to eql 0
      expect(Item.find(@item2.id).sort).to eql 2
      expect(Item.find(@item3.id).sort).to eql 1
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
rails_sortable-1.1.3 spec/controllers/sortable_controller_spec.rb
rails_sortable-1.1.2 spec/controllers/sortable_controller_spec.rb
rails_sortable-1.1.1 spec/controllers/sortable_controller_spec.rb
rails_sortable-1.1.0 spec/controllers/sortable_controller_spec.rb
rails_sortable-1.0.0 spec/controllers/sortable_controller_spec.rb
rails_sortable-0.1.1 spec/controllers/sortable_controller_spec.rb
rails_sortable-0.1.0 spec/controllers/sortable_controller_spec.rb