mirror of
https://github.com/TracksApp/tracks.git
synced 2026-02-03 06:21:49 +01:00
Reorganize Selenium tests into Test Suites and continue work on Ajax interactions for deferred actions section of Project Page.
Note that I'm currently only able to successfully run Seleniunm tests on Firefox (Mac & PC). I'm not successful on Safari or IE7. git-svn-id: http://www.rousette.org.uk/svn/tracks-repos/trunk@388 a4c988fc-2ded-0310-b66e-134b36920a42
This commit is contained in:
parent
bde8a0bde0
commit
10a4ead296
22 changed files with 95 additions and 37 deletions
|
|
@ -126,7 +126,7 @@ class TodoController < ApplicationController
|
|||
@item = check_user_return_item
|
||||
@original_item_context_id = @item.context_id
|
||||
@original_item_project_id = @item.project_id
|
||||
|
||||
@original_item_was_deferred = @item.deferred?
|
||||
if params['item']['project_id'].blank? && !params['project_name'].blank? && params['project_name'] != 'None'
|
||||
project = @user.projects.find_by_name(params['project_name'].strip)
|
||||
unless project
|
||||
|
|
@ -161,6 +161,7 @@ class TodoController < ApplicationController
|
|||
|
||||
@saved = @item.update_attributes params["item"]
|
||||
@context_changed = @original_item_context_id != @item.context_id
|
||||
@item_was_activated_from_deferred_state = @original_item_was_deferred && @item.active?
|
||||
if @context_changed then @remaining_undone_in_context = @user.contexts.find(@original_item_context_id).not_done_todos.length; end
|
||||
@project_changed = @original_item_project_id != @item.project_id
|
||||
if (@project_changed && !@original_item_project_id.nil?) then @remaining_undone_in_project = @user.projects.find(@original_item_project_id).not_done_todos.length; end
|
||||
|
|
@ -272,11 +273,12 @@ class TodoController < ApplicationController
|
|||
@down_count = Todo.count_by_sql(['SELECT COUNT(*) FROM todos, contexts WHERE todos.context_id = contexts.id and todos.user_id = ? and todos.state = ? and contexts.hide = ?', @user.id, 'active', false])
|
||||
end
|
||||
from.context do
|
||||
@down_count = @user.contexts.find(@item.context_id).todos.count_in_state(:active)
|
||||
@down_count = @user.contexts.find(@item.context_id).not_done_todo_count
|
||||
end
|
||||
from.project do
|
||||
unless @item.project_id == nil
|
||||
@down_count = @user.projects.find(@item.project_id).todos.count_in_state(:active)
|
||||
@down_count = @user.projects.find(@item.project_id).not_done_todo_count
|
||||
@deferred_count = @user.projects.find(@item.project_id).deferred_todo_count
|
||||
end
|
||||
end
|
||||
from.deferred do
|
||||
|
|
@ -291,11 +293,11 @@ class TodoController < ApplicationController
|
|||
@completed_count = Todo.count_by_sql(['SELECT COUNT(*) FROM todos, contexts WHERE todos.context_id = contexts.id and todos.user_id = ? and todos.state = ? and contexts.hide = ?', @user.id, 'completed', false])
|
||||
end
|
||||
from.context do
|
||||
@completed_count = @user.contexts.find(@item.context_id).todos.count_in_state(:completed)
|
||||
@completed_count = @user.contexts.find(@item.context_id).done_todo_count
|
||||
end
|
||||
from.project do
|
||||
unless @item.project_id == nil
|
||||
@completed_count = @user.projects.find(@item.project_id).todos.count_in_state(:completed)
|
||||
@completed_count = @user.projects.find(@item.project_id).done_todo_count
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ if @saved
|
|||
page.insert_html :top, "completed", :partial => 'todo/item', :locals => { :parent_container_type => "completed" }
|
||||
page.visual_effect :highlight, dom_id(@item, 'line'), {'startcolor' => "'#99ff99'"}
|
||||
page[empty_container_msg_div_id].show if @down_count == 0 && !empty_container_msg_div_id.nil?
|
||||
page.show 'tickler-empty-nd' if source_view_is(:project)
|
||||
page.show 'tickler-empty-nd' if source_view_is(:project) && @deferred_count == 0
|
||||
page.hide 'empty-d' # If we've checked something as done, completed items can't be empty
|
||||
end
|
||||
if @remaining_undone_in_context == 0 && source_view_is(:todo)
|
||||
|
|
|
|||
|
|
@ -43,6 +43,12 @@ if @saved
|
|||
page.insert_html :bottom, "tickler", :partial => 'todo/item', :locals => { :parent_container_type => parent_container_type }
|
||||
page['tickler-empty-nd'].hide
|
||||
page.replace_html "badge_count", @remaining_undone_in_project
|
||||
elsif @item_was_activated_from_deferred_state
|
||||
page[@item].remove
|
||||
page['tickler-empty-nd'].show if (@deferred_count == 0)
|
||||
page.insert_html :bottom, "p#{@item.project_id}", :partial => 'todo/item', :locals => { :parent_container_type => parent_container_type }
|
||||
page["p#{@item.project_id}empty-nd"].hide
|
||||
page.replace_html "badge_count", @remaining_undone_in_project
|
||||
else
|
||||
page.replace dom_id(@item), :partial => 'todo/item', :locals => { :parent_container_type => parent_container_type }
|
||||
page.visual_effect :highlight, dom_id(@item), :duration => 3
|
||||
|
|
|
|||
|
|
@ -44,5 +44,9 @@ module Tracks
|
|||
self.todos.count_in_state(:completed)
|
||||
end
|
||||
|
||||
def deferred_todo_count
|
||||
self.todos.count_in_state(:deferred)
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
|
|
|||
14
tracks/test/fixtures/todos.yml
vendored
14
tracks/test/fixtures/todos.yml
vendored
|
|
@ -186,3 +186,17 @@ end
|
|||
due: ~
|
||||
completed_at: ~
|
||||
user_id: 1
|
||||
|
||||
15:
|
||||
id: 15
|
||||
context_id: 6
|
||||
project_id: 1
|
||||
description: Select Delorean model
|
||||
notes: ~
|
||||
state: deferred
|
||||
created_at: <%= today %>
|
||||
due: ~
|
||||
completed_at: ~
|
||||
show_from: <%= next_week %>
|
||||
user_id: 1
|
||||
|
||||
|
|
|
|||
|
|
@ -22,14 +22,14 @@ class ProjectControllerTest < TodoContainerControllerTestBase
|
|||
p = projects(:timemachine)
|
||||
get :show, :url_friendly_name => p.url_friendly_name
|
||||
assert_not_nil assigns['deferred']
|
||||
assert_equal 0, assigns['deferred'].size
|
||||
assert_equal 1, assigns['deferred'].size
|
||||
|
||||
t = p.not_done_todos[0]
|
||||
t.show_from = 1.days.from_now.to_date
|
||||
t.save!
|
||||
|
||||
get :show, :url_friendly_name => p.url_friendly_name
|
||||
assert_equal 1, assigns['deferred'].size
|
||||
assert_equal 2, assigns['deferred'].size
|
||||
end
|
||||
|
||||
def test_create_project_via_ajax_increments_number_of_projects
|
||||
|
|
|
|||
|
|
@ -49,6 +49,14 @@ class TodoControllerTest < Test::Unit::TestCase
|
|||
assert_equal 1, assigns['context_not_done_counts'][contexts(:lab).id]
|
||||
end
|
||||
|
||||
def test_deferred_count_for_project_source_view
|
||||
@request.session['user_id'] = users(:admin_user).id
|
||||
xhr :post, :toggle_check, :id => 5, :_source_view => 'project'
|
||||
assert_equal 1, assigns['deferred_count']
|
||||
xhr :post, :toggle_check, :id => 15, :_source_view => 'project'
|
||||
assert_equal 0, assigns['deferred_count']
|
||||
end
|
||||
|
||||
def test_destroy_item
|
||||
@request.session['user_id'] = users(:admin_user).id
|
||||
xhr :post, :destroy, :id => 1, :_source_view => 'todo'
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
setup :fixtures => :all
|
||||
include_partial 'login', :username => 'admin', :password => 'abracadabra'
|
||||
include_partial 'login/login', :username => 'admin', :password => 'abracadabra'
|
||||
click "xpath=//div[@id='c1'] //div[@id='todo_9'] //input[@class='item-checkbox']"
|
||||
wait_for_element_present "xpath=//div[@id='completed'] //div[@id='todo_9']"
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
setup :fixtures => :all
|
||||
include_partial 'login', :username => 'admin', :password => 'abracadabra'
|
||||
include_partial 'login/login', :username => 'admin', :password => 'abracadabra'
|
||||
click "xpath=//div[@id='c5'] //div[@id='todo_5'] //input[@class='item-checkbox']"
|
||||
wait_for_element_present "xpath=//div[@id='completed'] //div[@id='todo_5']"
|
||||
wait_for_not_visible 'c5'
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
setup :fixtures => :all
|
||||
include_partial 'login', :username => 'admin', :password => 'abracadabra'
|
||||
include_partial 'login/login', :username => 'admin', :password => 'abracadabra'
|
||||
click "xpath=//div[@id='completed'] //div[@id='todo_3'] //input[@class='item-checkbox']"
|
||||
wait_for_element_present "xpath=//div[@id='c4'] //div[@id='todo_3']"
|
||||
assert_not_visible "c4empty-nd"
|
||||
|
|
@ -1,10 +0,0 @@
|
|||
setup :fixtures => :all
|
||||
include_partial 'login', :username => 'admin', :password => 'abracadabra'
|
||||
open "/project/Build_a_working_time_machine"
|
||||
type "todo_description", "choose era"
|
||||
type "todo_show_from", "1/1/2030"
|
||||
click "//input[@value='Add item']"
|
||||
wait_for_element_present "xpath=//div[@id='tickler'] //div[@class='item-container']"
|
||||
open "/project/Build_a_working_time_machine"
|
||||
click "xpath=//div[@id='tickler'] //input[@class='item-checkbox']"
|
||||
wait_for_visible "tickler-empty-nd"
|
||||
|
|
@ -1,8 +1,4 @@
|
|||
setup :fixtures => :all
|
||||
include_partial 'login', :username => 'admin', :password => 'abracadabra'
|
||||
open "/project/Build_a_working_time_machine"
|
||||
type "todo_description", "choose era"
|
||||
type "todo_show_from", "1/1/2030"
|
||||
click "//input[@value='Add item']"
|
||||
wait_for_element_present "xpath=//div[@id='tickler'] //div[@class='item-container']"
|
||||
assert_not_visible "tickler-empty-nd"
|
||||
type "todo_description", "choose era"
|
||||
type "todo_show_from", "1/1/2030"
|
||||
click "//input[@value='Add item']"
|
||||
wait_for_element_present "xpath=//div[@id='tickler'] //div[@class='item-container']"
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
setup :fixtures => :all
|
||||
include_partial 'login/login', :username => 'admin', :password => 'abracadabra'
|
||||
open "/project/Build_a_working_time_machine"
|
||||
include_partial 'project_detail/add_deferred_todo'
|
||||
open "/project/Build_a_working_time_machine"
|
||||
click "edit_icon_todo_15"
|
||||
wait_for_element_present "show_from_todo_15"
|
||||
type "show_from_todo_15", ""
|
||||
click "//input[@value='Update']"
|
||||
wait_for_element_present "xpath=//div[@id='p1'] //div[@id='todo_15']"
|
||||
assert_not_visible "tickler-empty-nd"
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
setup :fixtures => :all
|
||||
include_partial 'login/login', :username => 'admin', :password => 'abracadabra'
|
||||
open "/project/Build_a_working_time_machine"
|
||||
open "/project/Build_a_working_time_machine"
|
||||
click "edit_icon_todo_15"
|
||||
wait_for_element_present "show_from_todo_15"
|
||||
type "show_from_todo_15", ""
|
||||
click "//input[@value='Update']"
|
||||
wait_for_element_present "xpath=//div[@id='p1'] //div[@id='todo_15']"
|
||||
wait_for_visible "tickler-empty-nd"
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
setup :fixtures => :all
|
||||
include_partial 'login/login', :username => 'admin', :password => 'abracadabra'
|
||||
open "/project/Build_a_working_time_machine"
|
||||
include_partial 'project_detail/add_deferred_todo'
|
||||
assert_not_visible "tickler-empty-nd"
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
setup :fixtures => :all
|
||||
include_partial 'login', :username => 'admin', :password => 'abracadabra'
|
||||
include_partial 'login/login', :username => 'admin', :password => 'abracadabra'
|
||||
open "/project/Build_a_working_time_machine"
|
||||
click "edit_icon_todo_5"
|
||||
wait_for_element_present "show_from_todo_5"
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
setup :fixtures => :all
|
||||
include_partial 'login/login', :username => 'admin', :password => 'abracadabra'
|
||||
open "/project/Build_a_working_time_machine"
|
||||
include_partial 'project_detail/add_deferred_todo'
|
||||
click "xpath=//div[@id='tickler'] //div[@id='todo_15'] //input[@class='item-checkbox']"
|
||||
wait_for_element_present "xpath=//div[@id='completed'] //div[@id='todo_15']"
|
||||
assert_not_visible "tickler-empty-nd"
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
setup :fixtures => :all
|
||||
include_partial 'login/login', :username => 'admin', :password => 'abracadabra'
|
||||
open "/project/Build_a_working_time_machine"
|
||||
click "xpath=//div[@id='tickler'] //div[@id='todo_15'] //input[@class='item-checkbox']"
|
||||
wait_for_visible "tickler-empty-nd"
|
||||
|
|
@ -75,12 +75,12 @@ class ProjectTest < Test::Unit::TestCase
|
|||
end
|
||||
|
||||
def test_delete_project_deletes_todos_within_it
|
||||
assert_equal 2, @timemachine.todos.count
|
||||
timemachine_todo_1_id = @timemachine.todos[0].id
|
||||
timemachine_todo_2_id = @timemachine.todos[1].id
|
||||
assert_equal 3, @timemachine.todos.count
|
||||
timemachine_todo_ids = @timemachine.todos.map{ |t| t.id }
|
||||
@timemachine.destroy
|
||||
assert !Todo.exists?(timemachine_todo_1_id)
|
||||
assert !Todo.exists?(timemachine_todo_2_id)
|
||||
timemachine_todo_ids.each do |t_id|
|
||||
assert !Todo.exists?(t_id)
|
||||
end
|
||||
end
|
||||
|
||||
def test_not_done_todos
|
||||
|
|
@ -100,11 +100,11 @@ class ProjectTest < Test::Unit::TestCase
|
|||
end
|
||||
|
||||
def test_deferred_todos
|
||||
assert_equal 0, @timemachine.deferred_todos.size
|
||||
assert_equal 1, @timemachine.deferred_todos.size
|
||||
t = @timemachine.not_done_todos[0]
|
||||
t.show_from = 1.days.from_now.to_date
|
||||
t.save!
|
||||
assert_equal 1, Project.find(@timemachine.id).deferred_todos.size
|
||||
assert_equal 2, Project.find(@timemachine.id).deferred_todos.size
|
||||
end
|
||||
|
||||
def test_url_friendly_name_for_name_with_spaces
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue