From 7bce774daaf02ffe65bb2598602f100d23edbe4d Mon Sep 17 00:00:00 2001 From: Reinier Balt Date: Tue, 1 May 2012 09:39:53 +0200 Subject: [PATCH] get context list scenario passing --- app/controllers/application_controller.rb | 23 ++++--------------- app/controllers/contexts_controller.rb | 2 +- app/helpers/application_helper.rb | 6 ++--- app/views/contexts/_context_form.html.erb | 6 ++--- app/views/contexts/_context_listing.html.erb | 2 +- features/context_list.feature | 6 ----- features/step_definitions/context_steps.rb | 10 +++++++- .../step_definitions/todo_create_steps.rb | 4 ++-- test/functional/contexts_controller_test.rb | 6 +++++ 9 files changed, 29 insertions(+), 36 deletions(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index eec99129..71620089 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -72,32 +72,19 @@ class ApplicationController < ActionController::Base render :text => message, :status => status end - # def rescue_action(exception) - # log_error(exception) if logger - # respond_to do |format| - # format.html do - # notify :warning, "An error occurred on the server." - # render :action => "index" - # end - # format.js { render :action => 'error' } - # format.xml { render :text => 'An error occurred on the server.' + $! } - # end - # end - # Returns a count of next actions in the given context or project The result # is count and a string descriptor, correctly pluralised if there are no # actions or multiple actions # - def count_undone_todos_phrase(todos_parent, string="actions") + def count_undone_todos_phrase(todos_parent) count = count_undone_todos(todos_parent) deferred_count = count_deferred_todos(todos_parent) if count == 0 && deferred_count > 0 - word = deferred_count == 1 ? string.singularize : string.pluralize - word = "deferred " + word - return (deferred_count.to_s + " " + word).html_safe + word = "#{I18n.t('common.deferred')} #{I18n.t('common.actions_midsentence', :count => deferred_count)}" + return "#{deferred_count.to_s} #{word}".html_safe else - word = count == 1 ? string.singularize : string.pluralize - return (count.to_s + " " + word).html_safe + word = I18n.t('common.actions_midsentence', :count => count) + return "#{count.to_s} #{word}".html_safe end end diff --git a/app/controllers/contexts_controller.rb b/app/controllers/contexts_controller.rb index e4db6e16..6be16f2c 100644 --- a/app/controllers/contexts_controller.rb +++ b/app/controllers/contexts_controller.rb @@ -12,6 +12,7 @@ class ContextsController < ApplicationController @active_contexts = current_user.contexts.active @hidden_contexts = current_user.contexts.hidden @new_context = current_user.contexts.build + init_not_done_counts(['context']) # save all contexts here as @new_context will add an empty one to current_user.contexts @all_contexts = @active_contexts + @hidden_contexts @@ -196,7 +197,6 @@ class ContextsController < ApplicationController @no_hidden_contexts = @hidden_contexts.empty? @active_count = @active_contexts.size @hidden_count = @hidden_contexts.size - init_not_done_counts(['context']) render end end diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index d559a4a2..38ee306d 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -101,17 +101,17 @@ module ApplicationHelper # actions or multiple actions # def count_undone_todos_phrase(todos_parent) - controller.count_undone_todos_phrase(todos_parent) + controller.count_undone_todos_phrase(todos_parent).html_safe end def count_undone_todos_phrase_text(todos_parent) - count_undone_todos_phrase(todos_parent).gsub(" "," ") + count_undone_todos_phrase(todos_parent).gsub(" "," ").html_safe end def count_undone_todos_and_notes_phrase(project) s = count_undone_todos_phrase(project) s += ", #{t('common.note', :count => project.note_count)}" unless project.note_count == 0 - s + s.html_safe end def link_to_context(context, descriptor = sanitize(context.name)) diff --git a/app/views/contexts/_context_form.html.erb b/app/views/contexts/_context_form.html.erb index a73a2782..228be0c8 100644 --- a/app/views/contexts/_context_form.html.erb +++ b/app/views/contexts/_context_form.html.erb @@ -1,15 +1,13 @@ <% context = context_form -@context = context -%> -<% form_for(context, :html => { +<%= form_for(context, :html => { :id => dom_id(context, 'edit_form'), :class => "inline-form edit-project-form", :method => :put }) do -%> -
<%= error_messages_for("project") %>
- +
<%= get_list_of_error_messages_for(context) %>

<%= text_field('context', 'name', :class => 'context-name', :tabindex => next_tab_index) %>
diff --git a/app/views/contexts/_context_listing.html.erb b/app/views/contexts/_context_listing.html.erb index 9266ddb9..06bd864f 100644 --- a/app/views/contexts/_context_listing.html.erb +++ b/app/views/contexts/_context_listing.html.erb @@ -10,7 +10,7 @@ suppress_delete_button ||= false <%= suppress_edit_button ? "" : link_to_edit_context(context, image_tag( "blank.png", :title => t('contexts.edit_context'), :class=>"edit_item")) -%> <%= suppress_drag_handle ? "" : image_tag('grip.png', :width => '7', :height => '16', :border => '0', :title => t('common.drag_handle'), :class => 'grip')-%>
- <%= link_to_context( context ) %> <%= " (" + count_undone_todos_phrase(context) + ")" %> + <%= link_to_context( context ) %> <%= raw " (#{count_undone_todos_phrase(context)})" %>