2010-07-16 14:41:04 +02:00
|
|
|
module TracksStepHelper
|
|
|
|
|
def submit_multiple_next_action_form
|
|
|
|
|
selenium.click("xpath=//form[@id='todo-form-multi-new-action']//button[@id='todo_multi_new_action_submit']", :wait_for => :ajax, :javascript_framework => :jquery)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def submit_next_action_form
|
2012-01-30 03:42:47 +01:00
|
|
|
within("#todo-form-new-action") do
|
|
|
|
|
click_button("todo_new_action_submit")
|
|
|
|
|
end
|
2011-03-02 08:44:34 +01:00
|
|
|
sleep(1)
|
2010-07-16 14:41:04 +02:00
|
|
|
end
|
|
|
|
|
|
2010-07-29 18:06:30 +02:00
|
|
|
def submit_new_context_form
|
2012-01-31 12:09:00 +01:00
|
|
|
within "form#context-form" do
|
|
|
|
|
find("button#context_new_submit").click
|
|
|
|
|
end
|
|
|
|
|
wait_for_animations_to_end
|
2010-07-29 18:06:30 +02:00
|
|
|
end
|
|
|
|
|
|
2010-10-16 16:45:08 +02:00
|
|
|
def submit_new_project_form
|
|
|
|
|
selenium.click("xpath=//form[@id='project_form']//button[@id='project_new_project_submit']", :wait_for => :ajax, :javascript_framework => :jquery)
|
|
|
|
|
end
|
2011-01-08 09:12:37 +01:00
|
|
|
|
2012-01-30 03:42:47 +01:00
|
|
|
def wait_for_form_to_go_away(todo)
|
|
|
|
|
page.should_not have_content("button#submit_todo_#{todo.id}")
|
|
|
|
|
end
|
|
|
|
|
|
2011-02-03 16:59:59 +01:00
|
|
|
def submit_edit_todo_form (todo)
|
2012-01-30 03:42:47 +01:00
|
|
|
within "div#edit_todo_#{todo.id}" do
|
|
|
|
|
click_button "submit_todo_#{todo.id}"
|
2011-03-02 08:44:34 +01:00
|
|
|
end
|
2012-01-30 03:42:47 +01:00
|
|
|
wait_for_form_to_go_away(todo)
|
|
|
|
|
wait_for_animations_to_end
|
2011-02-03 16:59:59 +01:00
|
|
|
end
|
2011-09-13 11:15:14 +02:00
|
|
|
|
2011-01-08 09:12:37 +01:00
|
|
|
def format_date(date)
|
|
|
|
|
# copy-and-past from ApplicationController::format_date
|
|
|
|
|
return date ? date.in_time_zone(@current_user.prefs.time_zone).strftime("#{@current_user.prefs.date_format}") : ''
|
|
|
|
|
end
|
|
|
|
|
|
2011-01-08 19:50:19 +01:00
|
|
|
def execute_javascript(js)
|
2012-01-30 03:42:47 +01:00
|
|
|
page.execute_script(js)
|
2011-01-08 19:50:19 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def clear_context_name_from_next_action_form
|
|
|
|
|
execute_javascript("$('#todo_context_name').val('');")
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def clear_project_name_from_next_action_form
|
|
|
|
|
execute_javascript("$('#todo_project_name').val('');")
|
|
|
|
|
end
|
2012-01-30 03:42:47 +01:00
|
|
|
|
2011-02-27 00:35:19 +01:00
|
|
|
def open_edit_form_for(todo)
|
2012-01-30 03:42:47 +01:00
|
|
|
within "div#line_todo_#{todo.id}" do
|
|
|
|
|
find("a#icon_edit_todo_#{todo.id}").click
|
2011-03-10 16:50:19 +01:00
|
|
|
end
|
2012-01-30 03:42:47 +01:00
|
|
|
wait_for_animations_to_end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def wait_for_animations_to_end
|
|
|
|
|
wait_until do
|
|
|
|
|
page.evaluate_script('$(":animated").length') == 0
|
|
|
|
|
end
|
|
|
|
|
end
|
2011-09-13 11:15:14 +02:00
|
|
|
|
2012-01-30 03:42:47 +01:00
|
|
|
def handle_js_confirm(accept=true)
|
|
|
|
|
page.execute_script "window.original_confirm_function = window.confirm"
|
|
|
|
|
page.execute_script "window.confirmMsg = null"
|
|
|
|
|
page.execute_script "window.confirm = function(msg) { window.confirmMsg = msg; return #{!!accept}; }"
|
|
|
|
|
yield
|
|
|
|
|
ensure
|
|
|
|
|
page.execute_script "window.confirm = window.original_confirm_function"
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def get_confirm_text
|
|
|
|
|
page.evaluate_script "window.confirmMsg"
|
2011-02-27 00:35:19 +01:00
|
|
|
end
|
2011-03-08 23:28:48 +01:00
|
|
|
|
2012-01-30 03:42:47 +01:00
|
|
|
def open_submenu_for(todo)
|
|
|
|
|
within "div#line_todo_#{todo.id}" do
|
|
|
|
|
find("img#todo-submenu").click
|
|
|
|
|
end
|
2011-03-08 23:28:48 +01:00
|
|
|
end
|
2011-09-13 11:15:14 +02:00
|
|
|
|
2012-01-31 16:51:20 +01:00
|
|
|
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
|
|
|
|
|
|
2010-07-16 14:41:04 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
World(TracksStepHelper)
|