Sha256: b790f8344abcc720af41e1ea58eab6e3779e2d422dfd20e6ec9764ecb5a40bde
Contents?: true
Size: 1.89 KB
Versions: 2
Compression:
Stored size: 1.89 KB
Contents
require 'test_helper' class PositionableControllerTest < ActionController::TestCase # Action and updated position based on second item of the list actions = { :move_lower => 3, :move_down => 3, :move_higher => 1, :move_up => 1, :move_to_bottom => 4, :insert_at_bottom => 4, :move_to_top => 1, :insert_at_top => 1 } def setup 4.times { MultipleListItem.create } @item = MultipleListItem.find(:all, :order => 'id').second end actions.each_pair do |action, position| test "#{action} should update the resource" do put action, :resource => 'multiple_list_item', :id => @item, :list => 'client' assert_equal position, assigns(:resource).list_position(:client) end end test "remove_from_list should remove the resource from the list" do put :remove_from_list, :resource => 'multiple_list_item', :id => @item, :list => 'client' assert !assigns(:resource).in_list?(:client) end test "insert_at should update the resource" do position = @item.list_position(:client) + 1 put :insert_at, :resource => 'multiple_list_item', :id => @item, :list => 'client', :position => position.to_s assert_equal position, assigns(:resource).list_position(:client) end test "actions should redirect back if referer is available" do @request.env['HTTP_REFERER'] = 'http://back.com' put :move_up, :resource => 'multiple_list_item', :id => @item, :list => 'client' assert_redirected_to 'http://back.com' end test "actions should redirect to root if no referer is available" do put :move_up, :resource => 'multiple_list_item', :id => @item, :list => 'client' assert_redirected_to '/' end test "should match routes" do assert_routing( {:method => 'put', :path => 'resource/17/list/position/move_up'}, {:controller => 'positionable', :action => 'move_up', :id => '17', :resource => 'resource', :list => 'list'}) end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
aguids-positionable-0.2.1 | test/rails_root/test/functional/positionable_controller_test.rb |
aguids-positionable-0.2.2 | test/rails_root/test/functional/positionable_controller_test.rb |