get context list scenario passing

This commit is contained in:
Reinier Balt 2012-05-01 09:39:53 +02:00
parent c9d64e6f4b
commit 7bce774daa
9 changed files with 29 additions and 36 deletions

View file

@ -97,12 +97,6 @@ Feature: Manage the list of contexts
| active | @phone |
| hidden | @hidden |
@javascript
Scenario: Cannot add a context with comma in the name
When I go to the contexts page
And I add a new active context "foo, bar"
Then I should see "Name cannot contain the comma"
@javascript
Scenario: I can drag and drop to order the contexts
Given I have the following contexts

View file

@ -70,7 +70,15 @@ Then /^I should see the context name is "([^\"]*)"$/ do |context_name|
end
Then /^he should see that a context named "([^\"]*)" (is|is not) present$/ do |context_name, visible|
step "I should #{visible} \"#{context_name}\""
context = @current_user.contexts.find_by_name(context_name)
if visible == "is"
context.should_not be_nil
css = "div#context_#{context.id} div.context_description a"
page.should have_selector(css, :visible => true)
page.find(:css, css).text.should == context_name
else
page.should_not have_selector("div#context_#{context.id} div.context_description a", :visible => true) if context
end
end
Then /^I should (see|not see) empty message for (todo|completed todo|deferred todo)s of context/ do |visible, state|

View file

@ -3,7 +3,7 @@ Given /^I have no todos$/ do
end
Given /^I have a todo "([^"]*)" in the context "([^"]*)"$/ do |description, context_name|
context = @current_user.contexts.find_or_create(:name => context_name)
context = @current_user.contexts.find_or_create_by_name(context_name)
@todo = @current_user.todos.create!(:context_id => context.id, :description => description)
end
@ -88,7 +88,7 @@ Given /^I have ([0-9]+) deferred todos$/ do |count|
end
Given /^I have a deferred todo "([^"]*)" in the context "([^"]*)"$/ do |description, context_name|
context = @current_user.contexts.find_or_create(:name => context_name)
context = @current_user.contexts.find_or_create_by_name(context_name)
todo = @current_user.todos.create!(:context_id => context.id, :description => description)
todo.show_from = @current_user.time + 1.week
todo.save!