diff --git a/app/views/layouts/standard.html.erb b/app/views/layouts/standard.html.erb
index 2ab7a614..0db15a5d 100644
--- a/app/views/layouts/standard.html.erb
+++ b/app/views/layouts/standard.html.erb
@@ -12,7 +12,7 @@
<%= javascript_include_tag 'hoverIntent','superfish','application',
'accesskey-hints','niftycube','swfobject',
:cache => 'tracks-cached' %>
- <%= javascript_include_tag('jquery.simulate.drag-sortable') if ENV['RAILS_ENV']=='test' -%>
+ <%= javascript_include_tag('jquery.simulate.drag-sortable') if ENV['RAILS_ENV']=='cucumber' -%>
<%= javascript_tag "var AUTH_TOKEN = #{form_authenticity_token.inspect};" if protect_against_forgery? %>
<%= javascript_tag "var SOURCE_VIEW = '#{@source_view}';" %>
<%= javascript_tag "var TAG_NAME = '#{@tag_name}';" if @tag_name %>
diff --git a/features/step_definitions/context_list_steps.rb b/features/step_definitions/context_list_steps.rb
index ce20e114..ee8c6138 100644
--- a/features/step_definitions/context_list_steps.rb
+++ b/features/step_definitions/context_list_steps.rb
@@ -42,37 +42,16 @@ end
When /^I drag context "([^"]*)" above context "([^"]*)"$/ do |context_drag, context_drop|
drag_id = @current_user.contexts.find_by_name(context_drag).id
- drop_id = @current_user.contexts.find_by_name(context_drop).id
+ sortable_css = "div.ui-sortable div#container_context_#{drag_id}"
- # container_height = page.driver.get_element_height("//div[@id='container_context_#{drag_id}']").to_i
- # vertical_offset = container_height*2
- # coord_string = "10,#{vertical_offset}"
-
- drag_context_handle = find("div#context_#{drag_id} span.handle")
- drag_context_handle.text.should == "DRAG"
+ drag_index = context_list_find_index(context_drag)
+ drop_index = context_list_find_index(context_drop)
- drop_context_container = find("div#container_context_#{drop_id}")
-
- drag_context_handle.drag_to(drop_context_container)
-
- # TODO: omzetten naar volgende script
- page.execute_script %Q{
- $('.sortable-books li:last').simulateDragSortable({move: -4});
- }
-
- sleep(5)
-
- # page.driver.mouse_down_at(drag_context_handle_xpath,"2,2")
- # page.driver.mouse_move_at(drop_context_container_xpath,coord_string)
- # # no need to simulate mouse_over for this test
- # page.driver.mouse_up_at(drop_context_container_xpath,coord_string)
+ page.execute_script "$('#{sortable_css}').simulateDragSortable({move: #{drop_index-drag_index}, handle: '.handle'});"
end
Then /^context "([^"]*)" should be above context "([^"]*)"$/ do |context_high, context_low|
- high_id = "context_#{@current_user.contexts.find_by_name(context_high).id}"
- low_id = "context_#{@current_user.contexts.find_by_name(context_low).id}"
- contexts = page.all("div.context").map { |x| x[:id] }
- contexts.find_index(high_id).should < contexts.find_index(low_id)
+ context_list_find_index(context_high).should < context_list_find_index(context_low)
end
Then /^I should see that a context named "([^"]*)" is not present$/ do |context_name|
diff --git a/features/support/env.rb b/features/support/env.rb
index 4a6ef770..68df1dd2 100644
--- a/features/support/env.rb
+++ b/features/support/env.rb
@@ -19,7 +19,7 @@ require 'capybara/session'
# BUG in this version of cucumber/capybara: require 'cucumber/rails/capybara_javascript_emulation' # Lets you click links with onclick javascript handlers without using @culerity or @javascript
Capybara.default_wait_time = 5
-Capybara.javascript_driver = :selenium
+Capybara.javascript_driver = :webkit
if Capybara.javascript_driver == :webkit
require 'capybara/webkit'
diff --git a/features/support/world.rb b/features/support/world.rb
index e7a3c0e1..6adc0f2b 100644
--- a/features/support/world.rb
+++ b/features/support/world.rb
@@ -82,6 +82,12 @@ module TracksStepHelper
end
end
+ def context_list_find_index(context_name)
+ div_id = "context_#{@current_user.contexts.find_by_name(context_name).id}"
+ contexts = page.all("div.context").map { |x| x[:id] }
+ return contexts.find_index(div_id)
+ end
+
end
World(TracksStepHelper)
\ No newline at end of file
diff --git a/public/javascripts/jquery.simulate.drag-sortable.js b/public/javascripts/jquery.simulate.drag-sortable.js
index a1d9e41a..0c58ac44 100644
--- a/public/javascripts/jquery.simulate.drag-sortable.js
+++ b/public/javascripts/jquery.simulate.drag-sortable.js
@@ -27,7 +27,7 @@
direction = moveCounter > 0 ? 'down' : 'up',
moveVerticalAmount = 0,
dragPastBy = 0;
-
+
if (moveCounter === 0) { return; }
while (moveCounter !== 0) {