mirror of
https://github.com/TracksApp/tracks.git
synced 2025-12-16 23:30:12 +01:00
get selenium scenarios running again and add some scenarios for adding todos started
This commit is contained in:
parent
09830d044d
commit
ab2e51a51a
17 changed files with 135 additions and 69 deletions
|
|
@ -116,18 +116,20 @@ class TodosController < ApplicationController
|
|||
end
|
||||
end
|
||||
format.js do
|
||||
determine_down_count if @saved
|
||||
@contexts = current_user.contexts.find(:all) if @new_context_created
|
||||
@projects = current_user.projects.find(:all) if @new_project_created
|
||||
@initial_context_name = params['default_context_name']
|
||||
@initial_project_name = params['default_project_name']
|
||||
@default_tags = @todo.project.default_tags unless @todo.project.nil?
|
||||
@status_message = 'Added new next action'
|
||||
@status_message += ' to tickler' if @todo.deferred?
|
||||
@status_message += ' in pending state' if @todo.pending?
|
||||
@status_message += ' in hidden state' if @todo.hidden?
|
||||
@status_message = 'Added new project / ' + status_message if @new_project_created
|
||||
@status_message = 'Added new context / ' + status_message if @new_context_created
|
||||
if @saved
|
||||
determine_down_count
|
||||
@contexts = current_user.contexts.find(:all) if @new_context_created
|
||||
@projects = current_user.projects.find(:all) if @new_project_created
|
||||
@initial_context_name = params['default_context_name']
|
||||
@initial_project_name = params['default_project_name']
|
||||
@default_tags = @todo.project.default_tags unless @todo.project.nil?
|
||||
@status_message = 'Added new next action'
|
||||
@status_message += ' to tickler' if @todo.deferred?
|
||||
@status_message += ' in pending state' if @todo.pending?
|
||||
@status_message += ' in hidden state' if @todo.hidden?
|
||||
@status_message = 'Added new project / ' + @status_message if @new_project_created
|
||||
@status_message = 'Added new context / ' + @status_message if @new_context_created
|
||||
end
|
||||
render :action => 'create'
|
||||
end
|
||||
format.xml do
|
||||
|
|
@ -830,7 +832,7 @@ class TodosController < ApplicationController
|
|||
def determine_down_count
|
||||
source_view do |from|
|
||||
from.todo do
|
||||
@down_count = current_user.todos.active.not_hidden.count(:all)
|
||||
@down_count = current_user.todos.active.not_hidden.count
|
||||
end
|
||||
from.context do
|
||||
@down_count = current_user.contexts.find(@todo.context_id).todos.not_completed.count(:all)
|
||||
|
|
|
|||
|
|
@ -208,7 +208,11 @@ module TodosHelper
|
|||
return false if source_view_is(:todo) && @todo.hidden?
|
||||
return false if source_view_is(:context) && @todo.hidden? && !@todo.context.hidden?
|
||||
|
||||
return false if (source_view_is(:tag) && !@todo.tags.include?(@tag_name))
|
||||
return true if source_view_is(:tag) && (
|
||||
(@todo.pending? && @todo.tags.include?(@tag_name)) ||
|
||||
@todo.tags.include?(@tag_name) ||
|
||||
(@todo.starred? && @tag_name == Todo::STARRED_TAG_NAME))
|
||||
|
||||
return false if (source_view_is(:context) && !(@todo.context_id==@default_context.id) )
|
||||
|
||||
return true if source_view_is(:deferred) && @todo.deferred?
|
||||
|
|
@ -217,9 +221,12 @@ module TodosHelper
|
|||
return true if source_view_is(:project) && @todo.pending?
|
||||
return true if !source_view_is(:deferred) && @todo.active?
|
||||
|
||||
return true if source_view_is(:tag) && @todo.pending?
|
||||
return false
|
||||
end
|
||||
|
||||
def should_add_new_context
|
||||
return @new_context_created && !source_view_is(:project)
|
||||
end
|
||||
|
||||
def parent_container_type
|
||||
return 'tickler' if source_view_is :deferred
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ class Todo < ActiveRecord::Base
|
|||
:conditions => ["todos.state = ? OR (contexts.hide = ? AND (todos.state = ? OR todos.state = ? OR todos.state = ?))",
|
||||
'project_hidden', true, 'active', 'deferred', 'pending']
|
||||
named_scope :not_hidden,
|
||||
:joins => [:context, :project],
|
||||
:joins => [:context],
|
||||
:conditions => ['NOT(todos.state = ? OR (contexts.hide = ? AND (todos.state = ? OR todos.state = ? OR todos.state = ?)))',
|
||||
'project_hidden', true, 'active', 'deferred', 'pending']
|
||||
|
||||
|
|
|
|||
|
|
@ -1,10 +1,9 @@
|
|||
<% if @saved -%>
|
||||
TracksPages.page_notify('notice', "<%=@status_message%>", 5);
|
||||
hide_empty_message();
|
||||
TracksPages.hide_errors();
|
||||
TracksPages.set_page_badge(<%= @down_count %>);
|
||||
<% if should_show_new_item -%>
|
||||
<% if @new_context_created -%>
|
||||
<% if should_add_new_context -%>
|
||||
insert_new_context_with_new_todo();
|
||||
<% else -%>
|
||||
add_todo_to_existing_context();
|
||||
|
|
@ -16,15 +15,6 @@
|
|||
TracksPages.show_errors(html_for_error_messages());
|
||||
<% end -%>
|
||||
|
||||
function hide_empty_message() {
|
||||
<% if @todo %>
|
||||
$('#<%=empty_container_msg_div_id%>').hide();
|
||||
<% if (source_view_is :project and @todo.pending?) or (source_view_is :deferred) -%>
|
||||
$('#tickler-empty-nd').hide();
|
||||
<% end -%>
|
||||
<% end -%>
|
||||
}
|
||||
|
||||
function clear_form() {
|
||||
$('#todo-form-new-action').clearForm();
|
||||
TracksForm.set_context_name('<%=@initial_context_name%>');
|
||||
|
|
@ -34,14 +24,15 @@ function clear_form() {
|
|||
}
|
||||
|
||||
function insert_new_context_with_new_todo() {
|
||||
$('#no_todos_in_tag_view').slideUp(100);
|
||||
$('#display_box').prepend(html_for_new_context());
|
||||
}
|
||||
|
||||
function add_todo_to_existing_context() {
|
||||
<% if source_view_is_one_of(:todo, :deferred, :tag) -%>
|
||||
TodoItemsContainer.ensureVisibleWithEffectAppear("c<%=@todo.context_id%>");
|
||||
$('#<%=empty_container_msg_div_id%>').hide();
|
||||
<% end -%>
|
||||
$('#<%=empty_container_msg_div_id%>').hide();
|
||||
$('#<%=item_container_id(@todo)%>').append(html_for_new_todo());
|
||||
$('#<%= dom_id(@todo)%>').effect('highlight', {}, 2000 );
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,6 +21,10 @@ function show_empty_messages() {
|
|||
<% if empty_container_msg_div_id && todo_container_is_empty -%>
|
||||
$('#<%=empty_container_msg_div_id%>').slideDown(1000);
|
||||
<% end -%>
|
||||
|
||||
<% if source_view_is(:deferred) && @down_count==0 -%>
|
||||
$('#tickler-empty-nd').slideDown(100);
|
||||
<% end -%>
|
||||
}
|
||||
|
||||
function remove_todo_from_page() {
|
||||
|
|
|
|||
|
|
@ -21,7 +21,8 @@ config.action_controller.allow_forgery_protection = false
|
|||
# ActionMailer::Base.deliveries array.
|
||||
config.action_mailer.delivery_method = :test
|
||||
|
||||
config.gem 'cucumber', :lib => false, :version => '=0.9.8' unless File.directory?(File.join(Rails.root, 'vendor/plugins/cucumber-rails'))
|
||||
config.gem 'cucumber', :lib => false, :version => '<0.10.0' unless File.directory?(File.join(Rails.root, 'vendor/plugins/cucumber'))
|
||||
config.gem 'cucumber-rails', :lib => false, :version => '>=0.3.2' unless File.directory?(File.join(Rails.root, 'vendor/plugins/cucumber-rails'))
|
||||
config.gem 'gherkin', :lib => false, :version => '2.2.9' unless File.directory?(File.join(Rails.root, 'vendor/plugins/gherkin'))
|
||||
config.gem 'database_cleaner', :lib => false, :version => '>=0.5.0' unless File.directory?(File.join(Rails.root, 'vendor/plugins/database_cleaner'))
|
||||
config.gem 'webrat', :lib => false, :version => '>=0.7.0' unless File.directory?(File.join(Rails.root, 'vendor/plugins/webrat'))
|
||||
|
|
@ -20,16 +20,16 @@ Feature: Edit a context
|
|||
And he should see that a context named "OutAndAbout" is present
|
||||
|
||||
Scenario: Editing the context of a todo will remove the todo
|
||||
Given this scenario is pending
|
||||
Given this is a pending scenario
|
||||
|
||||
Scenario: Editing the description of a a todo will update that todo
|
||||
Given this scenario is pending
|
||||
Given this is a pending scenario
|
||||
|
||||
Scenario: Editing the context of the last todo will remove the todo and show empty message
|
||||
Given this scenario is pending
|
||||
Given this is a pending scenario
|
||||
|
||||
Scenario: Adding a todo to a hidden project will not show the todo
|
||||
Given this scenario is pending
|
||||
Given this is a pending scenario
|
||||
|
||||
Scenario: Adding a todo to a hidden context will show that todo
|
||||
Given this scenario is pending
|
||||
Given this is a pending scenario
|
||||
|
|
|
|||
|
|
@ -37,4 +37,4 @@ Feature: dependencies
|
|||
Then there should not be an error
|
||||
|
||||
Scenario: Deleting a predecessor will activate successors
|
||||
Given this scenario is pending
|
||||
Given this is a pending scenario
|
||||
|
|
|
|||
|
|
@ -58,7 +58,7 @@ Feature: Edit a next action from every page
|
|||
Given this is a pending scenario
|
||||
|
||||
Scenario: Editing the context of a todo to a new context will show new context
|
||||
Given this scenario is pending # for home and tickler and tag
|
||||
Given this is a pending scenario # for home and tickler and tag
|
||||
|
||||
Scenario: Making an error when editing a todo will show error message
|
||||
Given this scenario is pending
|
||||
Given this is a pending scenario
|
||||
|
|
|
|||
|
|
@ -83,19 +83,19 @@ Feature: Edit a project
|
|||
And I should see "12345678901234567890123456789012345678901234567890123456789012345678901234567890123456"
|
||||
|
||||
Scenario: Cancelling editing a project will restore project settings
|
||||
Given this scenario is pending
|
||||
Given this is a pending scenario
|
||||
|
||||
Scenario: Editing the description of a todo will update todo
|
||||
Given this scenario is pending
|
||||
Given this is a pending scenario
|
||||
|
||||
Scenario: Moving the todo to the tickler will move todo to tickler container
|
||||
Given this scenario is pending
|
||||
Given this is a pending scenario
|
||||
|
||||
Scenario: Moving the todo out of the tickler will move todo to active container
|
||||
Given this scenario is pending
|
||||
Given this is a pending scenario
|
||||
|
||||
Scenario: Making all todos inactive will show empty message
|
||||
Given this scenario is pending # empty message is in separate container
|
||||
Given this is a pending scenario # empty message is in separate container
|
||||
|
||||
# Ticket #1043
|
||||
@selenium @wip
|
||||
|
|
|
|||
|
|
@ -125,8 +125,21 @@ Feature: Add new next action from every page
|
|||
Scenario: Adding a todo to a hidden project does not show the todo
|
||||
Given this is a pending scenario
|
||||
|
||||
Scenario: Adding a todo with a new context shows the new context
|
||||
Given this is a pending scenario
|
||||
@selenium @wip
|
||||
Scenario Outline: Adding a todo with a new context shows the new context
|
||||
When I <action> the <page>
|
||||
And I submit a new <todo> with description "do at new context" and the tags "starred" in the context "New"
|
||||
Then a confirmation for adding a new context "New" should be asked
|
||||
And the container for the context "New" should <visible>
|
||||
And the badge should show <badge>
|
||||
|
||||
Scenarios:
|
||||
| action | page | todo | badge | visible |
|
||||
| go to | home page | action | 2 | be visible |
|
||||
| go to | tickler page | deferred action | 1 | be visible |
|
||||
| visit | project page for "test project" | action | 2 | not be visible |
|
||||
| visit | context page for "test context" | action | 1 | not be visible |
|
||||
| visit | tag page for "starred" | action | 1 | be visible |
|
||||
|
||||
Scenario: Adding a todo to a hidden context does not show the todo
|
||||
Given this is a pending scenario
|
||||
|
|
|
|||
|
|
@ -64,7 +64,7 @@ Feature: Show statistics
|
|||
And I should see "to show the actions from week 0 and further"
|
||||
|
||||
Scenario: I can edit the todos selected from a chart
|
||||
Given this scenario is pending
|
||||
Given this is a pending scenario
|
||||
|
||||
Scenario: Marking a todo selected from a chart as complete will remove it from the page
|
||||
Given this scenario is pending
|
||||
Given this is a pending scenario
|
||||
|
|
|
|||
|
|
@ -2,6 +2,11 @@ Given /^I have no todos$/ do
|
|||
Todo.delete_all
|
||||
end
|
||||
|
||||
Given /^I have a todo "(.*)"$/ do |description|
|
||||
context = @current_user.contexts.create!(:name => "context A")
|
||||
@current_user.todos.create!(:context_id => context.id, :description => description)
|
||||
end
|
||||
|
||||
Given /^I have ([0-9]+) todos$/ do |count|
|
||||
context = @current_user.contexts.create!(:name => "context A")
|
||||
count.to_i.downto 1 do |i|
|
||||
|
|
@ -16,6 +21,11 @@ Given /^I have ([0-9]+) deferred todos$/ do |count|
|
|||
end
|
||||
end
|
||||
|
||||
Given /^I have a deferred todo "(.*)"$/ do |description|
|
||||
context = @current_user.contexts.create!(:name => "context B")
|
||||
@current_user.todos.create!(:context_id => context.id, :description => description, :show_from => @current_user.time + 1.week)
|
||||
end
|
||||
|
||||
Given /^I have ([0-9]+) completed todos$/ do |count|
|
||||
context = @current_user.contexts.create!(:name => "context C")
|
||||
count.to_i.downto 1 do |i|
|
||||
|
|
@ -66,12 +76,6 @@ When /^I expand the dependencies of "([^\"]*)"$/ do |todo_name|
|
|||
selenium.click(expand_img_locator)
|
||||
end
|
||||
|
||||
Then /^I should see ([0-9]+) todos$/ do |count|
|
||||
count.to_i.downto 1 do |i|
|
||||
match_xpath "div["
|
||||
end
|
||||
end
|
||||
|
||||
When /I change the (.*) field of "([^\"]*)" to "([^\"]*)"$/ do |field, todo_name, new_value|
|
||||
todo = @current_user.todos.find_by_description(todo_name)
|
||||
todo.should_not be_nil
|
||||
|
|
@ -88,6 +92,24 @@ When /^I submit a new action with description "([^"]*)"$/ do |description|
|
|||
submit_next_action_form
|
||||
end
|
||||
|
||||
When /^I submit a new action with description "([^"]*)" and the tags "([^"]*)" in the context "([^"]*)"$/ do |description, tags, context_name|
|
||||
fill_in "todo[description]", :with => description
|
||||
fill_in "tag_list", :with => tags
|
||||
|
||||
js="$('#todo_context_name').val('');"
|
||||
selenium.get_eval "(function() {with(this) {#{js}}}).call(selenium.browserbot.getCurrentWindow());"
|
||||
fill_in "todo_context_name", :with => context_name
|
||||
submit_next_action_form
|
||||
end
|
||||
|
||||
When /^I submit a new deferred action with description "([^"]*)" and the tags "([^"]*)" in the context "([^"]*)"$/ do |description, tags, context_name|
|
||||
fill_in "todo[description]", :with => description
|
||||
fill_in "context_name", :with => context_name
|
||||
fill_in "tag_list", :with => tags
|
||||
fill_in "todo[show_from]", :with => format_date(@current_user.time + 1.week)
|
||||
submit_next_action_form
|
||||
end
|
||||
|
||||
When /^I submit multiple actions with using$/ do |multiple_actions|
|
||||
fill_in "todo[multiple_todos]", :with => multiple_actions
|
||||
submit_multiple_next_action_form
|
||||
|
|
@ -120,6 +142,12 @@ When /^I edit the dependency of "([^"]*)" to '([^'']*)'$/ do |todo_name, deps|
|
|||
selenium.click("//div[@id='edit_todo_#{todo.id}']//button[@id='submit_todo_#{todo.id}']", :wait_for => :ajax, :javascript_framework => :jquery)
|
||||
end
|
||||
|
||||
Then /^I should see ([0-9]+) todos$/ do |count|
|
||||
count.to_i.downto 1 do |i|
|
||||
match_xpath "div["
|
||||
end
|
||||
end
|
||||
|
||||
Then /^there should not be an error$/ do
|
||||
# form should be gone and thus not errors visible
|
||||
selenium.is_visible("edit_todo_#{@dep_todo.id}").should == false
|
||||
|
|
@ -159,3 +187,23 @@ end
|
|||
Then /^the number of actions should be (\d+)$/ do |count|
|
||||
@current_user.todos.count.should == count.to_i
|
||||
end
|
||||
|
||||
Then /^the container for the context "([^"]*)" should be visible$/ do |context_name|
|
||||
context = @current_user.contexts.find_by_name(context_name)
|
||||
context.should_not be_nil
|
||||
xpath = "xpath=//div[@id=\"c#{context.id}\"]"
|
||||
selenium.wait_for_element(xpath, :timeout_in_seconds => 5)
|
||||
selenium.is_visible(xpath).should be_true
|
||||
end
|
||||
|
||||
Then /^the container for the context "([^"]*)" should not be visible$/ do |context_name|
|
||||
context = @current_user.contexts.find_by_name(context_name)
|
||||
context.should_not be_nil
|
||||
xpath = "xpath=//div[@id=\"c#{context.id}\"]"
|
||||
selenium.wait_for :wait_for => :ajax, :javascript_framework => :jquery
|
||||
selenium.is_element_present(xpath).should be_false
|
||||
end
|
||||
|
||||
Then /^a confirmation for adding a new context "([^"]*)" should be asked$/ do |context_name|
|
||||
selenium.get_confirmation.should == "New context \"#{context_name}\" will be also created. Are you sure?"
|
||||
end
|
||||
|
|
|
|||
|
|
@ -14,6 +14,13 @@ module TracksStepHelper
|
|||
def submit_new_project_form
|
||||
selenium.click("xpath=//form[@id='project_form']//button[@id='project_new_project_submit']", :wait_for => :ajax, :javascript_framework => :jquery)
|
||||
end
|
||||
|
||||
def format_date(date)
|
||||
# copy-and-past from ApplicationController::format_date
|
||||
return date ? date.in_time_zone(@current_user.prefs.time_zone).strftime("#{@current_user.prefs.date_format}") : ''
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
|
||||
World(TracksStepHelper)
|
||||
|
|
@ -11,10 +11,17 @@ Feature: Manage deferred todos
|
|||
And I have logged in as "testuser" with password "secret"
|
||||
|
||||
Scenario: Editing the description of a todo updated the todo
|
||||
Given this scenario is pending
|
||||
Given this is a pending scenario
|
||||
|
||||
Scenario: Editing the context of a todo moves it to the new context
|
||||
Given this scenario is pending
|
||||
Given this is a pending scenario
|
||||
|
||||
Scenario: Removing the show from date from a todo removes it from the tickler
|
||||
Given this scenario is pending
|
||||
Given this is a pending scenario
|
||||
|
||||
Scenario: Opening the tickler page shows me all deferred todos
|
||||
Given I have a deferred todo "not yet now"
|
||||
And I have a todo "now is a good time"
|
||||
When I go to the tickler page
|
||||
Then I should see "not yet now"
|
||||
And I should not see "now is a good time"
|
||||
|
|
|
|||
|
|
@ -1,10 +0,0 @@
|
|||
setup :fixtures => :all
|
||||
login :as => 'admin'
|
||||
open "/tickler"
|
||||
assert_context_count_incremented do
|
||||
type "todo_description", "a new action"
|
||||
type "todo_context_name", "Brand new context"
|
||||
type "todo_show_from", "1/1/2030"
|
||||
click "css=#todo-form-new-action .submit_box button"
|
||||
assert_confirmation "New context \"Brand new context\" will be also created. Are you sure?"
|
||||
end
|
||||
|
|
@ -1,4 +0,0 @@
|
|||
setup :fixtures => :all
|
||||
login :as => 'admin'
|
||||
open "/tickler/"
|
||||
assert_element_present "todo_15"
|
||||
Loading…
Add table
Add a link
Reference in a new issue