diff --git a/app/controllers/todos_controller.rb b/app/controllers/todos_controller.rb index 1c5aa43a..bddd5ebb 100644 --- a/app/controllers/todos_controller.rb +++ b/app/controllers/todos_controller.rb @@ -3,12 +3,12 @@ class TodosController < ApplicationController skip_before_filter :login_required, :only => [:index, :calendar, :tag] prepend_before_filter :login_or_feed_token_required, :only => [:index, :calendar, :tag] append_before_filter :find_and_activate_ready, :only => [:index, :list_deferred] + append_before_filter :set_group_view_by, :only => [:index, :tag] protect_from_forgery :except => :check_deferred def index @source_view = params['_source_view'] || 'todo' - @group_view_by = cookies['group_view_by'] || 'context' init_data_for_sidebar unless mobile? @@ -885,6 +885,10 @@ class TodosController < ApplicationController private + def set_group_view_by + @group_view_by = params['group_view_by'] || cookies['group_view_by'] || 'context' + end + def do_mobile_todo_redirection if cookies[:mobile_url] old_path = cookies[:mobile_url] @@ -934,8 +938,6 @@ class TodosController < ApplicationController @single_tag = @tag_expr.size == 1 && @tag_expr[0].size == 1 @tag_name = @tag_expr[0][0] @tag_title = @single_tag ? @tag_name : tag_title(@tag_expr) - - @group_view_by = cookies['group_view_by'] || 'context' end def get_ids_from_tag_expr(tag_expr) diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index f9acfdab..46e6a1ae 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -73,7 +73,6 @@
  • <%= navigation_link( t('layouts.navigation.stats'), stats_path, :title => t('layouts.navigation.stats_title')) %>

  • <%= group_view_by_menu_entry %> - <%= show_empty_containers_menu_entry %>
  • <%= t('layouts.navigation.admin') %> diff --git a/features/step_definitions/container_steps.rb b/features/step_definitions/container_steps.rb index 449ab792..198abbd4 100644 --- a/features/step_definitions/container_steps.rb +++ b/features/step_definitions/container_steps.rb @@ -8,6 +8,16 @@ When /^I collapse the context container of "([^"]*)"$/ do |context_name| toggle.click end +When(/^I collapse the project container of "(.*?)"$/) do |project_name| + project = @current_user.projects.where(:name => project_name).first + project.should_not be_nil + + xpath = "//a[@id='toggle_p#{project.id}']" + toggle = page.find(:xpath, xpath) + toggle.should be_visible + toggle.click +end + When /^I toggle all collapsed context containers$/ do click_link 'Toggle collapsed contexts' end @@ -46,24 +56,14 @@ Then /^the container for the context "([^"]*)" should be visible$/ do |context_n step "I should see the container for context \"#{context_name}\"" end -Then /^I should see "([^"]*)" in the context container for "([^"]*)"$/ do |todo_description, context_name| +Then /^I should (see|not see) "([^"]*)" in the context container for "([^"]*)"$/ do |visible, todo_description, context_name| context = @current_user.contexts.where(:name => context_name).first context.should_not be_nil todo = @current_user.todos.where(:description => todo_description).first todo.should_not be_nil xpath = "//div[@id=\"c#{context.id}\"]//div[@id='line_todo_#{todo.id}']" - page.should have_xpath(xpath) -end - -Then /^I should not see "([^"]*)" in the context container for "([^"]*)"$/ do |todo_description, context_name| - context = @current_user.contexts.where(:name => context_name).first - context.should_not be_nil - todo = @current_user.todos.where(:description => todo_description).first - todo.should_not be_nil - - xpath = "//div[@id=\"c#{context.id}\"]//div[@id='line_todo_#{todo.id}']" - page.should_not have_xpath(xpath) + page.send( visible=='see' ? :should : :should_not, have_xpath(xpath)) end ####### Deferred ####### @@ -120,6 +120,18 @@ Then /^I should see "([^"]*)" in project container for "([^"]*)"$/ do |todo_desc page.should have_xpath(xpath) end +Then(/^I should see "(.*?)" in the project container for "(.*?)"$/) do |todo_description, project_name| + step "I should see \"#{todo_description}\" in project container for \"#{project_name}\"" +end + +Then /^I should not see the project container for "([^"]*)"$/ do |project_name| + project = @current_user.projects.where(:name => project_name).first + project.should_not be_nil + + xpath = "//div[@id='p#{project.id}']" + page.should_not have_xpath(xpath, :visible => true) +end + ####### Completed ####### Then /^I should (not see|see) "([^"]*)" in the (completed|done today|done this week|done this month) container$/ do |visible, todo_description, container| diff --git a/features/step_definitions/generic_steps.rb b/features/step_definitions/generic_steps.rb index 91b82213..673eb0b1 100644 --- a/features/step_definitions/generic_steps.rb +++ b/features/step_definitions/generic_steps.rb @@ -2,7 +2,7 @@ Given /this is a pending scenario/ do pending end -Given /^I set the locale to "([^"]*)"$/ do |locale| +Given(/^I set the locale to "([^"]*)"$/) do |locale| @locale = locale end @@ -15,12 +15,16 @@ Given /^the date is "(.*?)"$/ do |date| Timecop.travel(date) end +Given(/^I have selected the view for group by project$/) do + @group_view_by='projects' +end + Then /the badge should show (.*)/ do |number| badge = find("span#badge_count").text.to_i badge.should == number.to_i end -Then /^I should see an error flash message saying "([^"]*)"$/ do |message| +Then(/^I should see an error flash message saying "([^"]*)"$/) do |message| xpath = "//div[@id='message_holder']/h4[@id='flash']" page.should have_xpath(xpath, :visible => true) diff --git a/features/support/paths.rb b/features/support/paths.rb index 4abe836b..6038f3fd 100644 --- a/features/support/paths.rb +++ b/features/support/paths.rb @@ -6,8 +6,10 @@ module NavigationHelpers # step definition in web_steps.rb # def path_to(page_name) - options = @mobile_interface ? {:format => :m} : {} - options = {:locale => @locale}.merge(options) if @locale + options = {} + options[:format] = :m if @mobile_interface + options[:locale] = @locale if @locale + options[:group_view_by] = @group_view_by if @group_view_by @source_view = nil case page_name diff --git a/features/toggle_context_containers.feature b/features/toggle_containers.feature similarity index 52% rename from features/toggle_context_containers.feature rename to features/toggle_containers.feature index 1d018fca..f221047b 100644 --- a/features/toggle_context_containers.feature +++ b/features/toggle_containers.feature @@ -1,7 +1,7 @@ -Feature: Toggle the context containers +Feature: Toggle the containers In order to only see the todos relevant on this moment As a Tracks user - I want to toggle the contexts so the todos in that context are not shown + I want to toggle the containers so the todos in that container (context or project) are not shown Background: Given the following user record @@ -38,8 +38,30 @@ Feature: Toggle the context containers And I should not see the todo "test 2" And I should not see the todo "test 3" + @javascript @wip + Scenario: I can toggle a project container + Given I have the following contexts + | context | hide | + | @ipad | false | + | @home | false | + | @boss | false | + And I have a project "collapse those containers" that has the following todos + | description | context | + | test 1 | @ipad | + | test 2 | @home | + | test 3 | @boss | + And I have selected the view for group by project + When I go to the home page + Then I should see "test 1" in the project container for "collapse those containers" + And I should see "test 2" in the project container for "collapse those containers" + And I should see "test 3" in the project container for "collapse those containers" + When I collapse the project container of "collapse those containers" + Then I should not see the todo "test 1" + And I should not see the todo "test 2" + And I should not see the todo "test 3" + @javascript - Scenario: I can hide all collapsed containers + Scenario: I can hide all collapsed context containers Given I have the following contexts | context | hide | | @ipad | false | @@ -64,3 +86,28 @@ Feature: Toggle the context containers Then I should not see the context container for "@home" And I should not see the context container for "@boss" And I should not see the context container for "@ipad" + + @javascript @wip + Scenario: I can hide all collapsed project containers + Given I have the following contexts + | context | hide | + | @ipad | false | + And I have a project "collapse those containers" that has the following todos + | description | context | + | test 1 | @ipad | + And I have a project "collapse those other containers" that has the following todos + | description | context | + | test 2 | @ipad | + And I have selected the view for group by project + When I go to the home page + Then I should see "test 1" in the project container for "collapse those containers" + And I should see "test 2" in the project container for "collapse those other containers" + When I collapse the project container of "collapse those containers" + Then I should not see the todo "test 1" + And I should see the todo "test 2" + When I collapse the project container of "collapse those other containers" + Then I should not see the todo "test 1" + And I should not see the todo "test 2" + When I toggle all collapsed context containers + Then I should not see the project container for "collapse those containers" + Then I should not see the project container for "collapse those other containers"