diff --git a/tracks/app/views/preferences/edit.rhtml b/tracks/app/views/preferences/edit.rhtml
index 7dcf3e5d..d307ec14 100644
--- a/tracks/app/views/preferences/edit.rhtml
+++ b/tracks/app/views/preferences/edit.rhtml
@@ -3,12 +3,13 @@
The preference settings should mostly be self-explanatory, but some hints are included below:
- first name and last name: Used for display purposes if set
- - time zone: your local time zone
- date format: the format in which you'd like dates to be shown. For example, for the date 31st January 2006, %d/%m/%Y will show 31/01/2006, %b-%e-%y will show Jan-31-06. See the strftime manual for more formatting options for the date.
+ - time zone: your local time zone
- week starts: day of the week shown as the start of the week on the popup calendar.
- due style: style in which due dates are shown, e.g. "Due in 3 days", "Due on Wednesday"
- show completed projects in sidebar: whether or not projects marked as complete are shown in the sidebar on the home page and elsewhere
- show hidden contexts in sidebar: whether or not contexts marked as hidden are shown in the sidebar on the home page and elsewhere
+ - show project on todo done: whether or not to redirect to the project page when an action associated with a project is marked complete
<% if @user.is_admin? %>
- admin email: email address for the admin user of Tracks (displayed on the signup page for users to contact to obtain an account)
<% end %>
@@ -47,15 +48,15 @@
table_row(pref_name, nowrap_label) { text_field('prefs', pref_name) }
end
%>
+ <%= row_with_text_field('date_format') %>
<%= table_row('time_zone', false) { time_zone_select('prefs','time_zone') } %>
- <%= row_with_text_field('date_format') %>
<%= row_with_select_field("week_starts", Preference.day_number_to_name_map.invert.sort{|a,b| a[1]<=>b[1]})%>
<%= row_with_select_field("due_style", [['Due in ___ days',0],['Due on _______',1]]) %>
<%= row_with_select_field("show_completed_projects_in_sidebar") %>
<%= row_with_select_field("show_hidden_projects_in_sidebar") %>
<%= row_with_select_field("show_hidden_contexts_in_sidebar") %>
-
+ <%= row_with_select_field("show_project_on_todo_done") %>
<% if @user.is_admin? %> <%= row_with_text_field('admin_email') %> <% end %>
<%= row_with_text_field('staleness_starts', true) %>
diff --git a/tracks/app/views/preferences/index.rhtml b/tracks/app/views/preferences/index.rhtml
index d78bcb44..78b90a16 100644
--- a/tracks/app/views/preferences/index.rhtml
+++ b/tracks/app/views/preferences/index.rhtml
@@ -5,13 +5,14 @@
- First name: <%= @user.first_name %>
- Last name: <%= @user.last_name %>
- - Time zone: <%= @prefs.tz %>
- - Date format: <%= @prefs.date_format %>
+ - Date format: <%= @prefs.date_format %> Your current date: <%= format_date Time.now.utc %>
+ - Time zone: <%= @prefs.tz %> Your current time: <%= user_time.strftime('%I:%M %p') %>
- Week starts on: <%= Preference.day_number_to_name_map[@prefs.week_starts] %>
- Show the last <%= @prefs.show_number_completed %> completed items on the home page
- Show completed projects in sidebar: <%= @prefs.show_completed_projects_in_sidebar %>
- Show hidden projects in sidebar: <%= @prefs.show_hidden_projects_in_sidebar %>
- Show hidden contexts in sidebar: <%= @prefs.show_hidden_contexts_in_sidebar %>
+ - Go to project page on todo complete: <%= @prefs.show_project_on_todo_done %>
- Staleness starts after <%= @prefs.staleness_starts %> days
- Due style:
<% if @prefs.due_style == "0" %>
diff --git a/tracks/app/views/todos/toggle_check.rjs b/tracks/app/views/todos/toggle_check.rjs
index f872965c..cc715f72 100644
--- a/tracks/app/views/todos/toggle_check.rjs
+++ b/tracks/app/views/todos/toggle_check.rjs
@@ -2,7 +2,7 @@ if @saved
page[@todo].remove
if @todo.completed?
# Don't try to insert contents into a non-existent container!
- unless @user.prefs.hide_completed_actions?
+ unless @prefs.hide_completed_actions?
page.insert_html :top, "completed", :partial => 'todos/todo', :locals => { :parent_container_type => "completed" }
page.visual_effect :highlight, dom_id(@todo, 'line'), {'startcolor' => "'#99ff99'"}
page[empty_container_msg_div_id].show if @down_count == 0 && !empty_container_msg_div_id.nil?
@@ -21,6 +21,9 @@ if @saved
end
page.hide "status"
page.replace_html "badge_count", @down_count
+ if @todo.completed? && !@todo.project_id.nil? && @prefs.show_project_on_todo_done && !source_view_is(:project)
+ page.redirect_to project_path(@todo.project_id)
+ end
else
page.replace_html "status", content_tag("div", content_tag("h2", "#{pluralize(@todo.errors.count, "error")} prohibited this record from being saved") + content_tag("p", "There were problems with the following fields:") + content_tag("ul", @todo.errors.each_full { |msg| content_tag("li", msg) }), "id" => "errorExplanation", "class" => "errorExplanation")
end
\ No newline at end of file
diff --git a/tracks/db/migrate/028_add_show_project_on_todo_done_preference.rb b/tracks/db/migrate/028_add_show_project_on_todo_done_preference.rb
new file mode 100644
index 00000000..48ca8bca
--- /dev/null
+++ b/tracks/db/migrate/028_add_show_project_on_todo_done_preference.rb
@@ -0,0 +1,9 @@
+class AddShowProjectOnTodoDonePreference < ActiveRecord::Migration
+ def self.up
+ add_column :preferences, :show_project_on_todo_done, :boolean, :default => false, :null => false
+ end
+
+ def self.down
+ remove_column :preferences, :show_project_on_todo_done
+ end
+end
diff --git a/tracks/db/schema.rb b/tracks/db/schema.rb
index 5afc62ac..ebc8cae2 100644
--- a/tracks/db/schema.rb
+++ b/tracks/db/schema.rb
@@ -2,7 +2,7 @@
# migrations feature of ActiveRecord to incrementally modify your database, and
# then regenerate this schema definition.
-ActiveRecord::Schema.define(:version => 27) do
+ActiveRecord::Schema.define(:version => 28) do
create_table "contexts", :force => true do |t|
t.column "name", :string, :default => "", :null => false
@@ -57,6 +57,7 @@ ActiveRecord::Schema.define(:version => 27) do
t.column "verbose_action_descriptors", :boolean, :default => false, :null => false
t.column "show_hidden_projects_in_sidebar", :boolean, :default => true, :null => false
t.column "time_zone", :string, :default => "London", :null => false
+ t.column "show_project_on_todo_done", :boolean, :default => false, :null => false
end
add_index "preferences", ["user_id"], :name => "index_preferences_on_user_id"
diff --git a/tracks/test/fixtures/contexts.yml b/tracks/test/fixtures/contexts.yml
index 7c3a5ca0..0dd32e5c 100644
--- a/tracks/test/fixtures/contexts.yml
+++ b/tracks/test/fixtures/contexts.yml
@@ -86,3 +86,21 @@ waitingfor:
user_id: 1
created_at: <%= today %>
updated_at: <%= today %>
+
+office_otheruser:
+ id: 10
+ name: office
+ position: 1
+ hide: false
+ user_id: 2
+ created_at: <%= today %>
+ updated_at: <%= today %>
+
+waitingfor_otheruser:
+ id: 11
+ name: waiting for
+ position: 2
+ hide: false
+ user_id: 2
+ created_at: <%= today %>
+ updated_at: <%= today %>
diff --git a/tracks/test/fixtures/preferences.yml b/tracks/test/fixtures/preferences.yml
index b0457a39..59f56760 100644
--- a/tracks/test/fixtures/preferences.yml
+++ b/tracks/test/fixtures/preferences.yml
@@ -14,6 +14,7 @@ admin_user_prefs:
refresh: 0
time_zone: "London"
verbose_action_descriptors: true
+ show_project_on_todo_done: false
other_user_prefs:
id: 2
@@ -30,3 +31,4 @@ other_user_prefs:
refresh: 0
time_zone: "London"
verbose_action_descriptors: false
+ show_project_on_todo_done: true
diff --git a/tracks/test/fixtures/projects.yml b/tracks/test/fixtures/projects.yml
index 16b2c75c..f3d90895 100644
--- a/tracks/test/fixtures/projects.yml
+++ b/tracks/test/fixtures/projects.yml
@@ -36,3 +36,13 @@ gardenclean:
user_id: 1
created_at: <%= today %>
updated_at: <%= today %>
+
+attendrailsconf:
+ id: 4
+ name: Attend RailsConf
+ description: ''
+ position: 1
+ state: 'active'
+ user_id: 2
+ created_at: <%= today %>
+ updated_at: <%= today %>
diff --git a/tracks/test/fixtures/todos.yml b/tracks/test/fixtures/todos.yml
index 2c7b6f89..1f9f3c42 100644
--- a/tracks/test/fixtures/todos.yml
+++ b/tracks/test/fixtures/todos.yml
@@ -200,3 +200,29 @@ end
show_from: <%= next_week %>
user_id: 1
+16:
+ id: 16
+ context_id: 10
+ project_id: 4
+ description: Buy tix
+ notes: ~
+ state: active
+ created_at: <%= today %>
+ due: ~
+ completed_at: ~
+ show_from: <%= next_week %>
+ user_id: 2
+
+
+17:
+ id: 17
+ context_id: 11
+ project_id: 4
+ description: Confirmation from pal
+ notes: ~
+ state: active
+ created_at: <%= today %>
+ due: ~
+ completed_at: ~
+ show_from: <%= next_week %>
+ user_id: 2
diff --git a/tracks/test/integration/context_xml_api_test.rb b/tracks/test/integration/context_xml_api_test.rb
index 12cd23ab..1bf22133 100644
--- a/tracks/test/integration/context_xml_api_test.rb
+++ b/tracks/test/integration/context_xml_api_test.rb
@@ -51,7 +51,7 @@ class ContextXmlApiTest < ActionController::IntegrationTest
def test_creates_new_context
initial_count = Context.count
authenticated_post_xml_to_context_create
- assert_response_and_body_matches 200, %r|^<\?xml version="1.0" encoding="UTF-8"\?>\n\n \d{4}+-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}Z\n 0\n \d+\n #{@@context_name}\n 1\n \d{4}+-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}Z\n\n$|
+ assert_response_and_body_matches 200, %r|^<\?xml version="1.0" encoding="UTF-8"\?>\n\n \d{4}+-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}Z\n 0\n \d+\n #{@@context_name}\n 3\n \d{4}+-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}Z\n\n$|
assert_equal initial_count + 1, Context.count
context1 = Context.find_by_name(@@context_name)
assert_not_nil context1, "expected context '#{@@context_name}' to be created"
diff --git a/tracks/test/selenium/home/mark_todo_complete_3.rsel b/tracks/test/selenium/home/mark_todo_complete_3.rsel
new file mode 100644
index 00000000..c5d75bba
--- /dev/null
+++ b/tracks/test/selenium/home/mark_todo_complete_3.rsel
@@ -0,0 +1,4 @@
+setup :fixtures => :all
+include_partial 'login/login', :username => 'jane', :password => 'sesame'
+click_and_wait "xpath=//div[@id='c10'] //div[@id='todo_16'] //input[@class='item-checkbox']"
+assert_title "TRACKS::Project: Attend RailsConf"
diff --git a/tracks/test/selenium/project_detail/activate_deferred_todo.rsel b/tracks/test/selenium/project_detail/activate_deferred_todo.rsel
index 6e1a5866..37968542 100644
--- a/tracks/test/selenium/project_detail/activate_deferred_todo.rsel
+++ b/tracks/test/selenium/project_detail/activate_deferred_todo.rsel
@@ -1,12 +1,13 @@
setup :fixtures => :all
+next_available_todo_id = 18
include_partial 'login/login', :username => 'admin', :password => 'abracadabra'
open "/projects/Build_a_working_time_machine"
include_partial 'project_detail/add_deferred_todo'
open "/projects/Build_a_working_time_machine"
-click "edit_icon_todo_15"
-wait_for_element_present "show_from_todo_15"
-type "show_from_todo_15", ""
+click "edit_icon_todo_#{next_available_todo_id}"
+wait_for_element_present "show_from_todo_#{next_available_todo_id}"
+type "show_from_todo_#{next_available_todo_id}", ""
click "//input[@value='Update']"
-wait_for_element_present "xpath=//div[@id='p1'] //div[@id='todo_15']"
+wait_for_element_present "xpath=//div[@id='p1'] //div[@id='todo_#{next_available_todo_id}']"
assert_not_visible "tickler-empty-nd"
assert_text 'badge_count', '3'
diff --git a/tracks/test/unit/preference_test.rb b/tracks/test/unit/preference_test.rb
index 669f172f..269d870f 100644
--- a/tracks/test/unit/preference_test.rb
+++ b/tracks/test/unit/preference_test.rb
@@ -14,5 +14,10 @@ class PreferenceTest < Test::Unit::TestCase
assert_equal 'London', @admin_user.preference.time_zone
assert_equal @admin_user.preference.tz, TimeZone['London']
end
+
+ def test_show_project_on_todo_done
+ assert @other_user.preference.show_project_on_todo_done
+ assert !@admin_user.preference.show_project_on_todo_done
+ end
end