further fixing regressions

This commit is contained in:
Reinier Balt 2013-04-19 22:55:54 +02:00
parent a8e426a2cd
commit 8b464112ad
7 changed files with 61 additions and 59 deletions

View file

@ -1,6 +1,5 @@
When /^I delete the context "([^\"]*)"$/ do |context_name|
context = @current_user.contexts.where(:name => context_name).first
context.should_not be_nil
context = find_context(context_name)
handle_js_confirm do
click_link "delete_context_#{context.id}"
@ -14,75 +13,58 @@ end
When /^I edit the context to rename it to "([^\"]*)"$/ do |new_name|
find("a#link_edit_context_#{@context.id}").click
# wait for the form to appear (which included a submit button)
page.should have_css("button#submit_context_#{@context.id}", :visible=>true)
wait_for_context_form_to_appear(@context)
within "div.edit-form" do
fill_in "context_name", :with => new_name
click_button "submit_context_#{@context.id}"
end
# wait for the form to go away
page.should_not have_css("button#submit_context_#{@context.id}", :visible => true)
# wait for the changed context to appear
page.should have_css("a#link_edit_context_#{@context.id}", :visible=> true)
wait_for_context_form_to_go_away(@context)
end
When /^I add a new context "([^"]*)"$/ do |context_name|
When(/^I add a new context "([^"]*)"$/) do |context_name|
fill_in "context[name]", :with => context_name
submit_new_context_form
end
When /^I add a new active context "([^"]*)"$/ do |context_name|
When(/^I add a new active context "([^"]*)"$/) do |context_name|
step "I add a new context \"#{context_name}\""
end
When /^I add a new hidden context "([^"]*)"$/ do |context_name|
When(/^I add a new hidden context "([^"]*)"$/) do |context_name|
fill_in "context[name]", :with => context_name
check "context_state_hide"
submit_new_context_form
end
When /^I drag context "([^"]*)" above context "([^"]*)"$/ do |context_drag, context_drop|
drag_id = @current_user.contexts.where(:name => context_drag).first.id
sortable_css = "div.ui-sortable div#container_context_#{drag_id}"
When(/^I drag context "([^"]*)" above context "([^"]*)"$/) do |context_drag, context_drop|
drag_id = find_context(context_drag).id
drag_index = context_list_find_index(context_drag)
drop_index = context_list_find_index(context_drop)
page.execute_script "$('#{sortable_css}').simulateDragSortable({move: #{drop_index-drag_index}, handle: '.grip'});"
context_drag_and_drop(drag_id, drop_index-drag_index)
end
When /^I edit the state of context "(.*?)" to closed$/ do |context_name|
context = @current_user.contexts.where(:name => context_name).first
context.should_not be_nil
# open edit form
page.find("a#link_edit_context_#{context.id}").click
# wait for the form to appear (which included a submit button)
page.should have_css("button#submit_context_#{context.id}", :visible=>true)
context = find_context(context_name)
open_context_edit_form(context)
# change state
within "form#edit_form_context_#{context.id}" do
find("input#context_state_closed").click
click_button "submit_context_#{context.id}"
end
# wait for the form to go away
page.should_not have_css("button#submit_context_#{context.id}", :visible => true)
# wait for the changed context to appear
elem = page.find("a#link_edit_context_#{context.id}")
elem.should_not be_nil
page.should have_css("a#link_edit_context_#{context.id}", :visible=> true)
wait_for_context_form_to_go_away(context)
end
Then /^context "([^"]*)" should be above context "([^"]*)"$/ do |context_high, context_low|
context_list_find_index(context_high).should < context_list_find_index(context_low)
end
Then /^I should see that a context named "([^"]*)" (is|is not) present$/ do |context_name, present|
Then(/^I should see that a context named "([^"]*)" (is|is not) present$/) do |context_name, present|
is_not = present=="is not" ? "not " : ""
within "div#display_box" do
step "I should #{is_not}see \"#{context_name}\""
@ -90,18 +72,18 @@ Then /^I should see that a context named "([^"]*)" (is|is not) present$/ do |con
end
Then /^I should see that the context container for (.*) contexts (is|is not) present$/ do |state, visible|
page.send(visible=="is" ? :should : :should_not, have_css("div#list-#{state}-contexts-container", :visible => true))
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" )
end
Then /^I should see the context "([^"]*)" under "([^"]*)"$/ do |context_name, state|
context = Context.where(:name => context_name).first
context.should_not be_nil
page.has_css?("div#list-contexts-#{state} div#context_#{context.id}").should be_true
context = find_context(context_name)
check_css_visibility("see", "div#list-contexts-#{state} div#context_#{context.id}")
end
Then /^the new context form should (be|not be) visible$/ do |visible|
page.has_css?("div#context_new", :visible => true).should (visible=="be" ? be_true : be_false)
v = {"be" => "see", "not be" => "not see"}[visible] # map be|not be to see|not see
check_css_visibility(v, "div#context_new")
end
Then /^the context list badge for ([^"]*) contexts should show (\d+)$/ do |state_name, count|
@ -109,10 +91,5 @@ Then /^the context list badge for ([^"]*) contexts should show (\d+)$/ do |state
end
Then /^I should (see|not see) empty message for (active|hidden|closed) contexts$/ do |visible, state|
box = "div##{state}-contexts-empty-nd"
elem = page.find(box)
elem.should_not be_nil
elem.send(visible=="see" ? "should" : "should_not", be_visible)
check_css_visibility(visible, "div##{state}-contexts-empty-nd")
end