2010-10-22 20:46:06 +02:00
When / ^I delete the context "([^ \ "]*)"$ / do | context_name |
2013-04-19 22:55:54 +02:00
context = find_context ( context_name )
2012-01-31 12:09:00 +01:00
handle_js_confirm do
click_link " delete_context_ #{ context . id } "
2010-10-22 20:46:06 +02:00
end
2012-01-31 12:09:00 +01:00
get_confirm_text . should == " Are you sure that you want to delete the context ' #{ context_name } '? Be aware that this will also delete all (repeating) actions in this context! "
2012-03-19 14:05:54 +01:00
# wait until the context is removed
page . should_not have_css ( " a # delete_context_ #{ context . id } " )
2010-10-22 20:46:06 +02:00
end
When / ^I edit the context to rename it to "([^ \ "]*)"$ / do | new_name |
2012-01-31 12:09:00 +01:00
find ( " a # link_edit_context_ #{ @context . id } " ) . click
2013-02-15 20:51:35 +01:00
2013-04-19 22:55:54 +02:00
wait_for_context_form_to_appear ( @context )
2013-01-01 17:38:59 +01:00
within " div.edit-form " do
fill_in " context_name " , :with = > new_name
click_button " submit_context_ #{ @context . id } "
end
2012-03-19 14:05:54 +01:00
2013-04-19 22:55:54 +02:00
wait_for_context_form_to_go_away ( @context )
2010-10-22 20:46:06 +02:00
end
2013-04-19 22:55:54 +02:00
When ( / ^I add a new context "([^"]*)"$ / ) do | context_name |
2010-10-22 20:46:06 +02:00
fill_in " context[name] " , :with = > context_name
submit_new_context_form
end
2013-04-19 22:55:54 +02:00
When ( / ^I add a new active context "([^"]*)"$ / ) do | context_name |
2012-02-21 20:18:26 +01:00
step " I add a new context \" #{ context_name } \" "
2010-10-22 20:46:06 +02:00
end
2013-04-19 22:55:54 +02:00
When ( / ^I add a new hidden context "([^"]*)"$ / ) do | context_name |
2010-10-22 20:46:06 +02:00
fill_in " context[name] " , :with = > context_name
2013-03-01 16:20:15 +01:00
check " context_state_hide "
2010-10-22 20:46:06 +02:00
submit_new_context_form
end
2013-04-19 22:55:54 +02:00
When ( / ^I drag context "([^"]*)" above context "([^"]*)"$ / ) do | context_drag , context_drop |
drag_id = find_context ( context_drag ) . id
2011-03-28 12:26:54 +02:00
2012-01-31 16:51:20 +01:00
drag_index = context_list_find_index ( context_drag )
drop_index = context_list_find_index ( context_drop )
2012-01-31 12:09:00 +01:00
2013-04-19 22:55:54 +02:00
context_drag_and_drop ( drag_id , drop_index - drag_index )
2011-03-28 12:26:54 +02:00
end
2013-03-01 16:20:15 +01:00
When / ^I edit the state of context "(.*?)" to closed$ / do | context_name |
2013-04-19 22:55:54 +02:00
context = find_context ( context_name )
2013-03-01 16:20:15 +01:00
2013-04-19 22:55:54 +02:00
open_context_edit_form ( context )
2013-03-01 16:20:15 +01:00
# change state
within " form # edit_form_context_ #{ context . id } " do
find ( " input # context_state_closed " ) . click
click_button " submit_context_ #{ context . id } "
end
2013-04-19 22:55:54 +02:00
wait_for_context_form_to_go_away ( context )
2013-03-01 16:20:15 +01:00
end
2011-09-28 23:28:36 +02:00
Then / ^context "([^"]*)" should be above context "([^"]*)"$ / do | context_high , context_low |
2012-01-31 16:51:20 +01:00
context_list_find_index ( context_high ) . should < context_list_find_index ( context_low )
2011-09-28 23:28:36 +02:00
end
2013-04-19 22:55:54 +02:00
Then ( / ^I should see that a context named "([^"]*)" (is|is not) present$ / ) do | context_name , present |
2012-03-24 10:01:17 +01:00
is_not = present == " is not " ? " not " : " "
2012-01-31 12:09:00 +01:00
within " div # display_box " do
2012-03-24 10:01:17 +01:00
step " I should #{ is_not } see \" #{ context_name } \" "
2012-01-31 12:09:00 +01:00
end
2010-10-23 17:52:50 +02:00
end
2013-03-01 16:20:15 +01:00
Then / ^I should see that the context container for (.*) contexts (is|is not) present$ / do | state , visible |
2013-04-19 22:55:54 +02:00
v = { " is " = > " see " , " is not " = > " not see " } [ visible ] # map is|is not to see|not see
check_css_visibility ( v , " div # list- #{ state } -contexts-container " )
2010-10-23 17:52:50 +02:00
end
2010-10-22 20:46:06 +02:00
Then / ^I should see the context "([^"]*)" under "([^"]*)"$ / do | context_name , state |
2013-04-19 22:55:54 +02:00
context = find_context ( context_name )
check_css_visibility ( " see " , " div # list-contexts- #{ state } div # context_ #{ context . id } " )
2010-10-22 20:46:06 +02:00
end
2010-10-23 17:52:50 +02:00
2013-03-01 16:20:15 +01:00
Then / ^the new context form should (be|not be) visible$ / do | visible |
2013-04-19 22:55:54 +02:00
v = { " be " = > " see " , " not be " = > " not see " } [ visible ] # map be|not be to see|not see
check_css_visibility ( v , " div # context_new " )
2011-03-28 12:26:54 +02:00
end
2010-10-23 17:52:50 +02:00
Then / ^the context list badge for ([^"]*) contexts should show ( \ d+)$ / do | state_name , count |
2012-01-31 12:09:00 +01:00
find ( " span # #{ state_name } -contexts-count " ) . text . should == count
2010-10-23 17:52:50 +02:00
end
2013-02-18 17:14:37 +01:00
2013-03-01 16:20:15 +01:00
Then / ^I should (see|not see) empty message for (active|hidden|closed) contexts$ / do | visible , state |
2013-04-19 22:55:54 +02:00
check_css_visibility ( visible , " div # #{ state } -contexts-empty-nd " )
2013-02-18 17:14:37 +01:00
end