Sha256: 23f48cdfbe5aa4eb1c9e6298dac64bfbfef58e5449e57c4d190f63c9297c6939

Contents?: true

Size: 1.79 KB

Versions: 18

Compression:

Stored size: 1.79 KB

Contents

module CharacterReorderTest

  def reorder(factory_name, class_name, list_of_modules)
    test 'Reorder Items' do
      create_n_objects(3, factory_name)
      position_0_before = class_name.find(@instances_of_class[0].id)._position
      position_1 = class_name.find(@instances_of_class[1].id)._position
      position_2 = class_name.find(@instances_of_class[2].id)._position
      visit('/admin')
      wait_for_ajax
      # Select Module
      select_last_module_from_list(list_of_modules)
      drag_item(@instances_of_class[0], @instances_of_class[1])
      position_0_after = class_name.find(@instances_of_class[0].id)._position
      title_2 = find("a[data-id='#{@instances_of_class[0].id}']+a").text
      title_0 = find("a[data-id='#{@instances_of_class[1].id}']+a").text

      assert page.has_css?('div.item-title', text: @instances_of_class[0].title, count: 1)
      assert_not_equal position_0_before, position_0_after
      assert position_0_after > position_1 && position_0_after < position_2
      assert_equal @instances_of_class[0].title, title_0
      assert_equal @instances_of_class[2].title, title_2    
    end
  end


  def reorder_to_begin_of_list(factory_name, class_name, list_of_modules)
    test 'Reorder Item in Begining of List' do
      create_per_page_plus_n_objects(2, factory_name)
      visit('/admin')
      wait_for_ajax
      select_last_module_from_list(list_of_modules)
      wait_for_ajax
      sleep(1.0)
      assert page.has_css?('div.item-title', count: @loaded_items)
      scroll_to_bottom
      wait_for_ajax
      scroll_to_bottom
      drag_item(@last_item, @first_item)
      title_second_item = find("a[data-id='#{@last_item.id}']+a").text
      assert page.has_css?('div.item-title', count: class_name.count)
      assert_equal @first_item.title, title_second_item
    end
  end

end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
chr-0.5.1 test/support/chr/list_reorder.rb
chr-0.5.0 test/support/chr/list_reorder.rb
chr-0.4.25 test/support/chr/list_reorder.rb
chr-0.4.24 test/support/chr/list_reorder.rb
chr-0.4.23 test/support/chr/list_reorder.rb
chr-0.4.22 test/support/chr/list_reorder.rb
chr-0.4.21 test/support/chr/list_reorder.rb
chr-0.4.20 test/support/chr/list_reorder.rb
chr-0.4.19 test/support/chr/list_reorder.rb
chr-0.4.18 test/support/chr/list_reorder.rb
chr-0.4.17 test/support/chr/list_reorder.rb
chr-0.4.15 test/support/chr/list_reorder.rb
chr-0.4.14 test/support/chr/list_reorder.rb
chr-0.4.13 test/support/chr/list_reorder.rb
chr-0.4.12 test/support/chr/list_reorder.rb
chr-0.4.11 test/support/chr/list_reorder.rb
chr-0.4.10 test/support/chr/list_reorder.rb
chr-0.4.9 test/support/chr/list_reorder.rb