From bbf6cdf702d99937179f5007ace8be042ac1ae22 Mon Sep 17 00:00:00 2001 From: Reinier Balt Date: Wed, 18 Sep 2013 10:38:20 +0200 Subject: [PATCH] fix failing cucumber scenario's and update gems --- Gemfile.lock | 4 ++-- app/controllers/projects_controller.rb | 4 ++-- app/controllers/todos_controller.rb | 12 +++++++----- app/helpers/todos_helper.rb | 7 +++++++ app/views/todos/update.js.erb | 4 ++-- features/context_edit.feature | 9 ++++----- features/support/env.rb | 2 +- lib/tasks/cucumber.rake | 14 +++++++------- 8 files changed, 32 insertions(+), 24 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index cbb2c71a..0c356e36 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -57,7 +57,7 @@ GEM xpath (~> 2.0) childprocess (0.3.9) ffi (~> 1.0, >= 1.0.11) - codeclimate-test-reporter (0.0.8) + codeclimate-test-reporter (0.0.9) simplecov (>= 0.7.1, < 1.0.0) coffee-rails (4.0.0) coffee-script (>= 2.2.0) @@ -137,7 +137,7 @@ GEM rspec-expectations (2.14.2) diff-lcs (>= 1.1.3, < 2.0) rubyzip (0.9.9) - safe_yaml (0.9.5) + safe_yaml (0.9.7) sanitize (2.0.6) nokogiri (>= 1.4.4) sass (3.2.10) diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index 996bede7..f599883f 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -136,8 +136,8 @@ class ProjectsController < ApplicationController limit(current_user.prefs.show_number_completed). includes(Todo::DEFAULT_INCLUDES) unless @max_completed == 0 - @count = @not_done_todos.size - @down_count = @count + @deferred_todos.size + @pending_todos.size + @down_count = @not_done_todos.size + @deferred_todos.size + @pending_todos.size + @count=@down_count @next_project = current_user.projects.next_from(@project) @previous_project = current_user.projects.previous_from(@project) @default_tags = @project.default_tags diff --git a/app/controllers/todos_controller.rb b/app/controllers/todos_controller.rb index c3796077..9bbd781b 100644 --- a/app/controllers/todos_controller.rb +++ b/app/controllers/todos_controller.rb @@ -123,6 +123,8 @@ class TodosController < ApplicationController determine_down_count @contexts = current_user.contexts @projects = current_user.projects + @context = @todo.context + @project = @todo.project @initial_context_name = params['default_context_name'] @initial_project_name = params['default_project_name'] @initial_tags = params['initial_tag_list'] @@ -1163,18 +1165,18 @@ end def update_context @context_changed = false if params['todo']['context_id'].blank? && params['context_name'].present? - context = current_user.contexts.where(:name => params['context_name'].strip).first - unless context + @context = current_user.contexts.where(:name => params['context_name'].strip).first + if @context.nil? @new_context = current_user.contexts.build @new_context.name = params['context_name'].strip @new_context.save @new_context_created = true @new_container = @new_context @not_done_todos = [@todo] - context = @new_context + @context = @new_context end - params["todo"]["context_id"] = context.id - @context_changed = @original_item_context_id != params["todo"]["context_id"] = context.id + params["todo"]["context_id"] = @context.id + @context_changed = @original_item_context_id != params["todo"]["context_id"] = @context.id end end diff --git a/app/helpers/todos_helper.rb b/app/helpers/todos_helper.rb index fe75c760..a5eeb3bc 100644 --- a/app/helpers/todos_helper.rb +++ b/app/helpers/todos_helper.rb @@ -575,6 +575,13 @@ module TodosHelper return false end + def should_show_empty_container + source_view do |page| + page.context { return @remaining_in_context == 0 } + end + return @down_count==0 + end + def project_container_id(todo) return "p#{todo.project_id}" unless todo.project.nil? return "without_project_container" diff --git a/app/views/todos/update.js.erb b/app/views/todos/update.js.erb index 7cd718c4..5f7b3ce0 100644 --- a/app/views/todos/update.js.erb +++ b/app/views/todos/update.js.erb @@ -42,7 +42,7 @@ function remove_todo(next_steps) { function add_to_existing_container(next_steps) { $('#<%= item_container_id(@todo) %>_items').append(html_for_todo()); - <% if source_view_is_one_of(:project,:calendar) -%> + <% if source_view_is_one_of(:calendar) -%> next_steps.go(); <% if (@target_context_count==1) || ( (@todo.deferred? || @todo.pending?) && @remaining_deferred_or_pending_count == 1) -%> $("#<%= empty_container_msg_div_id %>").slideUp(100); @@ -83,7 +83,7 @@ function highlight_updated_todo(next_steps) { } function update_empty_container(next_steps) { - <% if @down_count==0 -%> + <% if should_show_empty_container -%> $('div#no_todos_in_view').slideDown(400, function(){ next_steps.go(); }); <% else -%> $('div#no_todos_in_view').fadeOut(100, function(){ next_steps.go(); }); diff --git a/features/context_edit.feature b/features/context_edit.feature index 86878e7f..eb7c042f 100644 --- a/features/context_edit.feature +++ b/features/context_edit.feature @@ -12,17 +12,16 @@ Feature: Edit a context And I have a project called "test project" And I have 2 todos in project "test project" in context "@pc" with tags "starred" prefixed by "test_project " - @javascript + @javascript Scenario: In place edit of context name - Given I have a context called "Errands" - When I go to the context page for "Errands" + When I go to the context page for "@pc" And I edit the context name in place to be "OutAndAbout" Then I should see the context name is "OutAndAbout" When I go to the contexts page Then I should see that a context named "Errands" is not present And I should see that a context named "OutAndAbout" is present - @javascript + @javascript Scenario: Editing the context of a todo will remove the todo When I go to the the context page for "@pc" Then the badge should show 2 @@ -37,7 +36,7 @@ Feature: Edit a context Then I should not see the todo "test_project todo 1" And I should see "changed" - @javascript + @javascript Scenario: Editing the context of the last todo will remove the todo and show empty message When I go to the the context page for "@pc" And I edit the context of "test_project todo 1" to "@laptop" diff --git a/features/support/env.rb b/features/support/env.rb index a4100006..376c2cf3 100644 --- a/features/support/env.rb +++ b/features/support/env.rb @@ -45,7 +45,7 @@ end # # Before('@no-txn,@selenium,@culerity,@celerity,@javascript') do # # { :except => [:widgets] } may not do what you expect here -# # as tCucumber::Rails::Database.javascript_strategy overrides +# # as Cucumber::Rails::Database.javascript_strategy overrides # # this setting. # DatabaseCleaner.strategy = :truncation # end diff --git a/lib/tasks/cucumber.rake b/lib/tasks/cucumber.rake index 83f79471..9f53ce49 100644 --- a/lib/tasks/cucumber.rake +++ b/lib/tasks/cucumber.rake @@ -1,6 +1,6 @@ # IMPORTANT: This file is generated by cucumber-rails - edit at your own peril. -# It is recommended to regenerate this file in the future when you upgrade to a -# newer version of cucumber-rails. Consider adding your own code to a new file +# It is recommended to regenerate this file in the future when you upgrade to a +# newer version of cucumber-rails. Consider adding your own code to a new file # instead of editing this one. Cucumber will automatically load all features/**/*.rb # files. @@ -14,19 +14,19 @@ begin require 'cucumber/rake/task' namespace :cucumber do - Cucumber::Rake::Task.new({:ok => 'db:test:prepare'}, 'Run features that should pass') do |t| + Cucumber::Rake::Task.new({:ok => 'test:prepare'}, 'Run features that should pass') do |t| t.binary = vendored_cucumber_bin # If nil, the gem's binary is used. t.fork = true # You may get faster startup if you set this to false t.profile = 'default' end - Cucumber::Rake::Task.new({:wip => 'db:test:prepare'}, 'Run features that are being worked on') do |t| + Cucumber::Rake::Task.new({:wip => 'test:prepare'}, 'Run features that are being worked on') do |t| t.binary = vendored_cucumber_bin t.fork = true # You may get faster startup if you set this to false t.profile = 'wip' end - Cucumber::Rake::Task.new({:rerun => 'db:test:prepare'}, 'Record failing features and run only them if any exist') do |t| + Cucumber::Rake::Task.new({:rerun => 'test:prepare'}, 'Record failing features and run only them if any exist') do |t| t.binary = vendored_cucumber_bin t.fork = true # You may get faster startup if you set this to false t.profile = 'rerun' @@ -50,8 +50,8 @@ begin STDERR.puts "*** The 'features' task is deprecated. See rake -T cucumber ***" end - # In case we don't have ActiveRecord, append a no-op task that we can depend upon. - task 'db:test:prepare' do + # In case we don't have the generic Rails test:prepare hook, append a no-op task that we can depend upon. + task 'test:prepare' do end task :stats => 'cucumber:statsetup'