From 64d3e802f273c0950a213e87bbd7e70e537a3fce Mon Sep 17 00:00:00 2001 From: Reinier Balt Date: Wed, 19 Jun 2013 16:41:44 +0200 Subject: [PATCH 1/3] fix #1406. fix #1431. set recurring_period first before setting other attributes --- app/controllers/recurring_todos_controller.rb | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app/controllers/recurring_todos_controller.rb b/app/controllers/recurring_todos_controller.rb index 35c10872..57abbd14 100644 --- a/app/controllers/recurring_todos_controller.rb +++ b/app/controllers/recurring_todos_controller.rb @@ -101,7 +101,10 @@ class RecurringTodosController < ApplicationController p.attributes['end_date']=parse_date_per_user_prefs(p.attributes['end_date']) p.attributes['start_from']=parse_date_per_user_prefs(p.attributes['start_from']) - @recurring_todo = current_user.recurring_todos.build(p.selector_attributes) + # make sure we set :recurring_period first, since other setters depend on it being set + # TODO: move logic into model + @recurring_todo = current_user.recurring_todos.build(:recurring_period => params[:recurring_period]) + @recurring_todo.assign_attributes(p.selector_attributes) @recurring_todo.update_attributes(p.attributes) if p.project_specified_by_name? From 1ae6e13f1d47e1a9a6c3283d486a6a9826037932 Mon Sep 17 00:00:00 2001 From: Reinier Balt Date: Wed, 19 Jun 2013 16:50:02 +0200 Subject: [PATCH 2/3] update gems --- Gemfile.lock | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index dfe64343..870e3750 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -42,7 +42,7 @@ GEM builder (3.0.4) bullet (4.6.0) uniform_notifier - cache_digests (0.3.0) + cache_digests (0.3.1) actionpack (>= 3.2) thread_safe capybara (2.1.0) @@ -97,11 +97,13 @@ GEM treetop (~> 1.4.8) metaclass (0.0.1) mime-types (1.23) + mini_portile (0.5.0) mocha (0.14.0) metaclass (~> 0.0.1) - multi_json (1.7.6) + multi_json (1.7.7) mysql2 (0.3.11) - nokogiri (1.5.10) + nokogiri (1.6.0) + mini_portile (~> 0.5.0) polyglot (0.3.3) rack (1.4.5) rack-cache (1.2) @@ -137,8 +139,8 @@ GEM diff-lcs (>= 1.1.3, < 2.0) rubyzip (0.9.9) safe_yaml (0.9.3) - sanitize (2.0.3) - nokogiri (>= 1.4.4, < 1.6) + sanitize (2.0.4) + nokogiri (~> 1.6.0) sass (3.2.9) sass-rails (3.2.6) railties (~> 3.2.0) From f4908f2b7bae7231bee42c7135233949a891c0ba Mon Sep 17 00:00:00 2001 From: Reinier Balt Date: Wed, 19 Jun 2013 17:47:51 +0200 Subject: [PATCH 3/3] fix cache invariant for grouped todos in context and project view --- app/helpers/application_helper.rb | 4 ++++ app/views/contexts/_context.html.erb | 2 +- app/views/projects/_project.html.erb | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 5747573e..4fd7697e 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -294,5 +294,9 @@ module ApplicationHelper }) end + def source_view_key + # uses @project.id or @context.id depending on source_view + source_view_is_one_of(:project, :context) ? "#{@source_view}-#{eval("@#{@source_view}.id")}" : @source_view + end end diff --git a/app/views/contexts/_context.html.erb b/app/views/contexts/_context.html.erb index ceb8d908..7bab6ffa 100644 --- a/app/views/contexts/_context.html.erb +++ b/app/views/contexts/_context.html.erb @@ -2,7 +2,7 @@ @not_done = @not_done_todos.select {|t| t.context_id == context.id } # invalidate the cache every day because of staleness or # rendering of "due in x days" that change without touching updated at of the todo -cache [context, @source_view, current_user.date.strftime("%Y%m%d"), @tag_name] do +cache [context, source_view_key, current_user.date.strftime("%Y%m%d"), @tag_name] do -%> <%= render :partial => 'todos/collection', diff --git a/app/views/projects/_project.html.erb b/app/views/projects/_project.html.erb index 3a8b2246..70102cec 100644 --- a/app/views/projects/_project.html.erb +++ b/app/views/projects/_project.html.erb @@ -2,7 +2,7 @@ @not_done = @not_done_todos.select {|t| t.project_id == project.id } # invalidate the cache every day because of staleness or # rendering of "due in x days" that change without touching updated at of the todo -cache [project, @source_view, current_user.date.strftime("%Y%m%d"), @tag_name] do +cache [project, source_view_key, current_user.date.strftime("%Y%m%d"), @tag_name] do -%> <%= title = source_view_is(:project) ? t('projects.actions_in_project_title') : show_project_name(project)