add ui for changing state of context to closed. This fixes #645

This commit is contained in:
Reinier Balt 2013-03-01 16:20:15 +01:00
parent acab98d4c7
commit 4df340bd7b
12 changed files with 114 additions and 86 deletions

View file

@ -39,7 +39,7 @@ end
When /^I add a new hidden context "([^"]*)"$/ do |context_name|
fill_in "context[name]", :with => context_name
check "context_hide"
check "context_state_hide"
submit_new_context_form
end
@ -53,6 +53,28 @@ When /^I drag context "([^"]*)" above context "([^"]*)"$/ do |context_drag, cont
page.execute_script "$('#{sortable_css}').simulateDragSortable({move: #{drop_index-drag_index}, handle: '.grip'});"
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)
# 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
page.should have_css("a#link_edit_context_#{context.id}", :visible=> true)
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
@ -64,12 +86,8 @@ Then /^I should see that a context named "([^"]*)" (is|is not) present$/ do |con
end
end
Then /^I should see that the context container for (.*) contexts is not present$/ do |state|
page.should_not have_css("div#list-#{state}-contexts-container", :visible => true)
end
Then /^I should see that the context container for (.*) contexts is present$/ do |state|
page.should have_css("div#list-#{state}-contexts-container", :visible => true)
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))
end
Then /^I should see the context "([^"]*)" under "([^"]*)"$/ do |context_name, state|
@ -79,20 +97,16 @@ Then /^I should see the context "([^"]*)" under "([^"]*)"$/ do |context_name, st
page.has_css?("div#list-contexts-#{state} div#context_#{context.id}").should be_true
end
Then /^the new context form should be visible$/ do
page.has_css?("div#context_new", :visible => true).should be_true
end
Then /^the new context form should not be visible$/ do
page.has_css?("div#context_new", :visible => true).should be_false
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)
end
Then /^the context list badge for ([^"]*) contexts should show (\d+)$/ do |state_name, count|
find("span##{state_name}-contexts-count").text.should == count
end
Then /^I should (see|not see) empty message for (active|hidden) contexts$/ do |visible, state|
box = (state=='active') ? "div#active-contexts-empty-nd" : "div#hidden-contexts-empty-nd"
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