From da2bee2e53f65c51127341c1cce7dc49c5424bf1 Mon Sep 17 00:00:00 2001
From: Reinier Balt
Date: Sun, 23 Dec 2012 23:16:22 +0100
Subject: [PATCH] start fiingx failing cucumber scenario's and some small fixes
new capybara introduces some failing scenario's
---
Gemfile | 10 +++++++---
Gemfile.lock | 6 +++---
app/views/shared/_footer.html.erb | 4 ++--
app/views/todos/create.js.erb | 2 +-
app/views/todos/update.js.erb | 2 +-
config/locales/en.yml | 2 +-
features/step_definitions/todo_edit_steps.rb | 4 +++-
features/support/world.rb | 21 ++++++++++++++++++++
features/view_done.feature | 2 +-
lib/tracks/done_todos.rb | 8 ++------
10 files changed, 42 insertions(+), 19 deletions(-)
diff --git a/Gemfile b/Gemfile
index f559bb35..e6bf9a75 100644
--- a/Gemfile
+++ b/Gemfile
@@ -3,7 +3,8 @@ source 'https://rubygems.org'
gem 'rails'
# you may comment out the database driver you will not be using.
-# This will prevent a native build of the driver. Building native drivers is not always possible on all hosters
+# This will prevent a native build of the driver. Building native drivers is not
+# always possible on all hosters
gem "sqlite3"
gem "mysql2"
@@ -54,10 +55,13 @@ end
group :test do
gem "factory_girl_rails"
gem "capybara"
- gem "selenium-webdriver" # Note that > 2.14 has problems: https://code.google.com/p/selenium/issues/detail?id=3075
- gem "database_cleaner"
gem "cucumber-rails", :require => false
+ gem "database_cleaner"
gem "aruba"
+
+ # Note that > 2.14 has problems, see:
+ # https://code.google.com/p/selenium/issues/detail?id=3075
+ gem "selenium-webdriver"
# uncomment to use the webkit option. This depends on Qt to be installed
#gem "capybara-webkit"
diff --git a/Gemfile.lock b/Gemfile.lock
index 38dc8f19..336cdd6d 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -115,7 +115,7 @@ GEM
gem_plugin (~> 0.2.3)
multi_json (1.5.0)
mysql2 (0.3.11)
- nokogiri (1.5.5)
+ nokogiri (1.5.6)
polyglot (0.3.3)
rack (1.4.1)
rack-cache (1.2)
@@ -152,7 +152,7 @@ GEM
rubyzip (0.9.9)
sanitize (2.0.3)
nokogiri (>= 1.4.4, < 1.6)
- sass (3.2.3)
+ sass (3.2.4)
sass-rails (3.2.5)
railties (~> 3.2.0)
sass (>= 3.1.10)
@@ -190,7 +190,7 @@ GEM
execjs (>= 0.3.0)
multi_json (~> 1.0, >= 1.0.2)
uniform_notifier (1.1.0)
- websocket (1.0.4)
+ websocket (1.0.6)
will_paginate (3.0.3)
xpath (1.0.0)
nokogiri (~> 1.3)
diff --git a/app/views/shared/_footer.html.erb b/app/views/shared/_footer.html.erb
index 2b9fbc5c..063c55c4 100644
--- a/app/views/shared/_footer.html.erb
+++ b/app/views/shared/_footer.html.erb
@@ -3,6 +3,6 @@
<%= t('common.wiki')%> |
<%= t('common.mailing_list')%> |
<%= t('common.website')%> |
- <%= t('common.contribute')%>
- <%= link_to(t('layouts.navigation.mobile'), todos_path(:format => 'm')) %>
+ <%= t('common.contribute')%> |
+ <%= link_to(t('layouts.navigation.mobile'), todos_path(:format => 'm')) %>
diff --git a/app/views/todos/create.js.erb b/app/views/todos/create.js.erb
index 29303bee..0db188aa 100644
--- a/app/views/todos/create.js.erb
+++ b/app/views/todos/create.js.erb
@@ -40,7 +40,7 @@ function add_todo_to_existing_context() {
<% unless source_view_is_one_of(:todo, :tag) && (@todo.deferred?||@todo.hidden?) -%>
$('#c<%= @todo.context_id %>').fadeIn(500, function() {});
$('#no_todos_in_view').slideUp(100);
- <%= "$('#tickler-empty-nd').slideUp(100);" if source_view_is(:deferred) && @todo.deferred? %>
+ <%= "$('#tickler-empty-nd').slideUp(100);".html_safe if source_view_is(:deferred) && @todo.deferred? %>
<% end -%>
<% end -%>
$('#<%=empty_container_msg_div_id%>').hide();
diff --git a/app/views/todos/update.js.erb b/app/views/todos/update.js.erb
index ddb7ed73..3340af77 100644
--- a/app/views/todos/update.js.erb
+++ b/app/views/todos/update.js.erb
@@ -72,7 +72,7 @@ function replace_todo(next_steps) {
function hide_context(next_steps) {
<% context_id = @context_changed ? @original_item_context_id : @todo.context_id -%>
$('#c<%= context_id %>').fadeOut(400, function(){ next_steps.go(); });
- <%= "$('#tickler-empty-nd').slideDown(400);" if source_view_is(:deferred) && @down_count == 0 %>
+ <%= "$('#tickler-empty-nd').slideDown(400);".html_safe if source_view_is(:deferred) && @down_count == 0 %>
}
function highlight_updated_todo(next_steps) {
diff --git a/config/locales/en.yml b/config/locales/en.yml
index ee968060..f9d65429 100644
--- a/config/locales/en.yml
+++ b/config/locales/en.yml
@@ -22,7 +22,7 @@ en:
api_docs: REST API Docs
feeds: Feeds
starred: Starred
- notes_title: Show all notes
+ notes_title: View all notes
review_title: Make review
stats: Statistics
tickler_title: Tickler
diff --git a/features/step_definitions/todo_edit_steps.rb b/features/step_definitions/todo_edit_steps.rb
index 320df3e2..089b5ea3 100644
--- a/features/step_definitions/todo_edit_steps.rb
+++ b/features/step_definitions/todo_edit_steps.rb
@@ -86,7 +86,9 @@ When /^I edit the description of "([^"]*)" to "([^"]*)"$/ do |action_description
todo.should_not be_nil
open_edit_form_for(todo)
- fill_in "todo_description", :with => new_description
+ within "form.edit_todo_form" do
+ fill_in "todo_description", :with => new_description
+ end
submit_edit_todo_form(todo)
end
diff --git a/features/support/world.rb b/features/support/world.rb
index 4f483855..60955bc0 100644
--- a/features/support/world.rb
+++ b/features/support/world.rb
@@ -1,5 +1,26 @@
module TracksStepHelper
+ def wait_until(timeout = 5)
+ timeout(timeout) { yield }
+ end
+
+ def timeout(seconds = 1, error_message = nil, &block)
+ start_time = Time.now
+
+ result = nil
+
+ until result
+ return result if result = yield
+
+ delay = seconds - (Time.now - start_time)
+ if delay <= 0
+ raise TimeoutError, error_message || "timed out"
+ end
+
+ sleep(0.05)
+ end
+ end
+
def open_edit_form_for(todo)
within "div#line_todo_#{todo.id}" do
find("a#icon_edit_todo_#{todo.id}").click
diff --git a/features/view_done.feature b/features/view_done.feature
index 4834d212..863f9f89 100644
--- a/features/view_done.feature
+++ b/features/view_done.feature
@@ -1,7 +1,7 @@
Feature: Show done
In order to see what I have completed
As an user
- I want see my done todos
+ I want to see my done todos
Background:
Given the following user record
diff --git a/lib/tracks/done_todos.rb b/lib/tracks/done_todos.rb
index 9649276d..7d4572b0 100644
--- a/lib/tracks/done_todos.rb
+++ b/lib/tracks/done_todos.rb
@@ -10,14 +10,10 @@ class DoneTodos
end
def self.done_this_week(todos, includes = {:include => Todo::DEFAULT_INCLUDES})
- start_of_this_week = Time.zone.now.beginning_of_week
- start_of_this_day = Time.zone.now.beginning_of_day
- todos.completed_before(start_of_this_day).completed_after(start_of_this_week).all(includes)
+ todos.completed_before(Time.zone.now.beginning_of_day).completed_after(Time.zone.now.beginning_of_week).all(includes)
end
def self.done_this_month(todos, includes = {:include => Todo::DEFAULT_INCLUDES})
- start_of_this_month = Time.zone.now.beginning_of_month
- start_of_this_week = Time.zone.now.beginning_of_week
- todos.completed_before(start_of_this_week).completed_after(start_of_this_month).all(includes)
+ todos.completed_before(Time.zone.now.beginning_of_week).completed_after(Time.zone.now.beginning_of_month).all(includes)
end
end