Fixes #549 "on homepage the count of all actions is should update when moving an action to tickler". Thanks lrbalt!

git-svn-id: http://www.rousette.org.uk/svn/tracks-repos/trunk@580 a4c988fc-2ded-0310-b66e-134b36920a42
This commit is contained in:
lukemelia 2007-09-08 12:33:05 +00:00
parent c2ae4ab9b8
commit fca5e5b88f
5 changed files with 36 additions and 89 deletions

View file

@ -16,7 +16,7 @@ class Project < ActiveRecord::Base
state :active
state :hidden, :enter => :hide_todos, :exit => :unhide_todos
state :completed#, :enter => Proc.new { |p| p.completed_at = Time.now.utc }, :exit => Proc.new { |p| p.completed_at = nil }
state :completed, :enter => Proc.new { |p| p.completed_at = Time.now.utc }, :exit => Proc.new { |p| p.completed_at = nil }
event :activate do
transitions :to => :active, :from => [:hidden, :completed]

View file

@ -22,6 +22,7 @@ if @saved
page.insert_html :bottom, "c#{@todo.context_id}items", :partial => 'todos/todo', :locals => { :parent_container_type => parent_container_type }
end
page.replace_html("badge_count", @remaining_undone_in_context) if source_view_is :context
page.replace_html("badge_count", @down_count) if source_view_is :todo
page.delay(0.5) do
page.call "todoItems.ensureContainerHeight", "c#{@original_item_context_id}items"
if source_view_is(:todo) && @todo.active?

View file

@ -4,24 +4,11 @@
ActiveRecord::Schema.define(:version => 36) do
create_table "bow_wows", :force => true do |t|
t.column "name", :string
t.column "created_at", :datetime, :null => false
t.column "updated_at", :datetime, :null => false
end
create_table "cats", :force => true do |t|
t.column "name", :string
t.column "cat_type", :string
t.column "created_at", :datetime, :null => false
t.column "updated_at", :datetime, :null => false
end
create_table "contexts", :force => true do |t|
t.column "name", :string, :default => "", :null => false
t.column "hide", :integer, :limit => 4, :default => 0, :null => false
t.column "position", :integer, :default => 0, :null => false
t.column "user_id", :integer, :default => 0, :null => false
t.column "name", :string, :default => "", :null => false
t.column "position", :integer, :null => false
t.column "hide", :boolean, :default => false
t.column "user_id", :integer, :default => 1
t.column "created_at", :datetime
t.column "updated_at", :datetime
end
@ -29,48 +16,9 @@ ActiveRecord::Schema.define(:version => 36) do
add_index "contexts", ["user_id"], :name => "index_contexts_on_user_id"
add_index "contexts", ["user_id", "name"], :name => "index_contexts_on_user_id_and_name"
create_table "eaters_foodstuffs", :force => true do |t|
t.column "foodstuff_id", :integer
t.column "eater_id", :integer
t.column "some_attribute", :integer, :default => 0
t.column "eater_type", :string
t.column "created_at", :datetime, :null => false
t.column "updated_at", :datetime, :null => false
end
create_table "fish", :force => true do |t|
t.column "name", :string
t.column "speed", :integer
t.column "created_at", :datetime, :null => false
t.column "updated_at", :datetime, :null => false
end
create_table "frogs", :force => true do |t|
t.column "name", :string
t.column "created_at", :datetime, :null => false
t.column "updated_at", :datetime, :null => false
end
create_table "keep_your_enemies_close", :force => true do |t|
t.column "enemy_id", :integer
t.column "enemy_type", :string
t.column "protector_id", :integer
t.column "protector_type", :string
t.column "created_at", :datetime, :null => false
t.column "updated_at", :datetime, :null => false
end
create_table "little_whale_pupils", :force => true do |t|
t.column "whale_id", :integer
t.column "aquatic_pupil_id", :integer
t.column "aquatic_pupil_type", :string
t.column "created_at", :datetime, :null => false
t.column "updated_at", :datetime, :null => false
end
create_table "notes", :force => true do |t|
t.column "user_id", :integer, :default => 0, :null => false
t.column "project_id", :integer, :default => 0, :null => false
t.column "user_id", :integer, :null => false
t.column "project_id", :integer, :null => false
t.column "body", :text
t.column "created_at", :datetime
t.column "updated_at", :datetime
@ -95,15 +43,8 @@ ActiveRecord::Schema.define(:version => 36) do
t.column "value", :binary
end
create_table "petfoods", :id => false, :force => true do |t|
t.column "the_petfood_primary_key", :integer, :null => false
t.column "name", :string
t.column "created_at", :datetime, :null => false
t.column "updated_at", :datetime, :null => false
end
create_table "preferences", :force => true do |t|
t.column "user_id", :integer, :default => 0, :null => false
t.column "user_id", :integer, :null => false
t.column "date_format", :string, :limit => 40, :default => "%d/%m/%Y", :null => false
t.column "week_starts", :integer, :default => 0, :null => false
t.column "show_number_completed", :integer, :default => 5, :null => false
@ -125,8 +66,8 @@ ActiveRecord::Schema.define(:version => 36) do
create_table "projects", :force => true do |t|
t.column "name", :string, :default => "", :null => false
t.column "position", :integer, :default => 0, :null => false
t.column "user_id", :integer, :default => 0, :null => false
t.column "position", :integer, :null => false
t.column "user_id", :integer, :default => 1
t.column "description", :text
t.column "state", :string, :limit => 20, :default => "active", :null => false
t.column "created_at", :datetime
@ -144,7 +85,7 @@ ActiveRecord::Schema.define(:version => 36) do
t.column "updated_at", :datetime
end
add_index "sessions", ["session_id"], :name => "sessions_session_id_index"
add_index "sessions", ["session_id"], :name => "index_sessions_on_session_id"
create_table "taggings", :force => true do |t|
t.column "taggable_id", :integer
@ -164,16 +105,16 @@ ActiveRecord::Schema.define(:version => 36) do
add_index "tags", ["name"], :name => "index_tags_on_name"
create_table "todos", :force => true do |t|
t.column "context_id", :integer, :default => 0, :null => false
t.column "description", :string, :limit => 100, :default => "", :null => false
t.column "context_id", :integer, :null => false
t.column "project_id", :integer
t.column "description", :string, :default => "", :null => false
t.column "notes", :text
t.column "created_at", :datetime
t.column "due", :date
t.column "completed_at", :datetime
t.column "project_id", :integer
t.column "user_id", :integer, :default => 0, :null => false
t.column "user_id", :integer, :default => 1
t.column "show_from", :date
t.column "state", :string, :limit => 20, :default => "immediate", :null => false
t.column "state", :string, :limit => 20, :default => "immediate", :null => false
end
add_index "todos", ["user_id", "state"], :name => "index_todos_on_user_id_and_state"
@ -183,10 +124,10 @@ ActiveRecord::Schema.define(:version => 36) do
add_index "todos", ["user_id", "context_id"], :name => "index_todos_on_user_id_and_context_id"
create_table "users", :force => true do |t|
t.column "login", :string, :limit => 80
t.column "login", :string, :limit => 80, :default => "", :null => false
t.column "crypted_password", :string, :limit => 40
t.column "token", :string
t.column "is_admin", :integer, :limit => 4, :default => 0, :null => false
t.column "is_admin", :boolean, :default => false, :null => false
t.column "first_name", :string
t.column "last_name", :string
t.column "auth_type", :string, :default => "database", :null => false
@ -197,16 +138,4 @@ ActiveRecord::Schema.define(:version => 36) do
add_index "users", ["login"], :name => "index_users_on_login"
create_table "whales", :force => true do |t|
t.column "name", :string
t.column "created_at", :datetime, :null => false
t.column "updated_at", :datetime, :null => false
end
create_table "wild_boars", :force => true do |t|
t.column "name", :string
t.column "created_at", :datetime, :null => false
t.column "updated_at", :datetime, :null => false
end
end

View file

@ -103,6 +103,14 @@ class TodosControllerTest < Test::Rails::TestCase
assert_nil t.project_id
end
def test_update_todo_to_deferred_is_reflected_in_badge_count
login_as(:admin_user)
get :index
assert_equal 10, assigns['count']
xhr :post, :update, :id => 1, :_source_view => 'todo', "context_name"=>"library", "project_name"=>"Make more money than Billy Gates", "todo"=>{"id"=>"1", "notes"=>"", "description"=>"Call Warren Buffet to find out how much he makes per day", "due"=>"30/11/2006", "show_from"=>"30/11/2030"}, "tag_list"=>"foo bar"
assert_equal 9, assigns['down_count']
end
def test_update_todo
t = Todo.find(1)
@request.session['user_id'] = users(:admin_user).id

View file

@ -0,0 +1,9 @@
setup :fixtures => :all
login :as => 'admin'
open "/"
click "edit_icon_todo_9"
wait_for_element_present "show_from_todo_9"
type "show_from_todo_9", "1/1/2030"
click "css=#submit_todo_9"
wait_for_element_not_present "todo_9"
assert_text 'badge_count', '9'