migrate deleting of contexts

This commit is contained in:
Reinier Balt 2010-10-23 17:52:50 +02:00
parent 15fdb1e572
commit e52a8609c7
10 changed files with 124 additions and 31 deletions

View file

@ -10,14 +10,29 @@ Feature: Manage the list of contexts
| testuser | secret | false |
And I have logged in as "testuser" with password "secret"
@selenium, @wip
@selenium
Scenario: Delete context from context page should update badge
Given I have a context called "@computer"
And I have a context called "@ipad"
When I go to the contexts page
Then the badge should show 1
Then the badge should show 2
And the context list badge for active contexts should show 2
When I delete the context "@computer"
Then he should see that a context named "@computer" is not present
And the badge should show 0
And the badge should show 1
And the context list badge for active contexts should show 1
@selenium, @wip
Scenario: Delete last context from context page should remove the contexts container for hidden or active contexts
Given I have a context called "@computer"
And I have a hidden context called "@ipad"
When I go to the contexts page
When I delete the context "@computer"
Then I should see that a context named "@computer" is not present
And I should see that the context container for active contexts is not present
When I delete the context "@ipad"
Then I should see that a context named "@ipad" is not present
And I should see that the context container for hidden contexts is not present
@selenium, @wip
Scenario: Delete context from context page right after an edit

View file

@ -36,14 +36,27 @@ When /^I add a new active context "([^"]*)"$/ do |context_name|
When "I add a new context \"#{context_name}\""
end
When /^I add a new hidden context "([^"]*)"$/ do |context_name|
fill_in "context[name]", :with => context_name
check "context_hide"
submit_new_context_form
end
Then /^I should see that a context named "([^"]*)" is not present$/ do |context_name|
Then "I should not see \"#{context_name}\""
end
Then /^I should see that the context container for (.*) contexts is not present$/ do |state|
present = selenium.is_element_present("list-contexts-#{state}'")
present.should_not be_true
end
Then /^I should see the context "([^"]*)" under "([^"]*)"$/ do |context_name, state|
context = Context.find_by_name(context_name)
context.should_not be_nil
response.should have_xpath("//div[@id='list-contexts-#{state}']//div[@id='context_#{context.id}']")
end
Then /^the context list badge for ([^"]*) contexts should show (\d+)$/ do |state_name, count|
selenium.get_text("xpath=//span[@id='#{state_name}-contexts-count']").should == count
end

View file

@ -3,14 +3,28 @@ Given /^I have no contexts$/ do
Context.delete_all
end
Given /^there exists a context called "([^"]*)" for user "([^"]*)"$/ do |context_name, login|
Given /^there exists an active context called "([^"]*)" for user "([^"]*)"$/ do |context_name, login|
user = User.find_by_login(login)
user.should_not be_nil
@context = user.contexts.create!(:name => context_name)
@context = user.contexts.create!(:name => context_name, :hide => false)
end
Given /^there exists a hidden context called "([^"]*)" for user "([^"]*)"$/ do |context_name, login|
user = User.find_by_login(login)
user.should_not be_nil
@context = user.contexts.create!(:name => context_name, :hide => true)
end
Given /^I have a context called "([^\"]*)"$/ do |context_name|
Given "there exists a context called \"#{context_name}\" for user \"#{@current_user.login}\""
Given "there exists an active context called \"#{context_name}\" for user \"#{@current_user.login}\""
end
Given /^I have an active context called "([^\"]*)"$/ do |context_name|
Given "there exists an active context called \"#{context_name}\" for user \"#{@current_user.login}\""
end
Given /^I have a hidden context called "([^\"]*)"$/ do |context_name|
Given "there exists a hidden context called \"#{context_name}\" for user \"#{@current_user.login}\""
end
Given /^I have the following contexts:$/ do |table|