From 2c47b27a8738edab31892bf23a810faac3791d91 Mon Sep 17 00:00:00 2001 From: Reinier Balt Date: Wed, 20 Oct 2010 09:00:04 +0200 Subject: [PATCH] start fixing sorting of projects --- app/views/projects/actionize.js.erb | 2 ++ app/views/projects/actionize.js.rjs | 6 ------ app/views/projects/alphabetize.js.erb | 2 ++ app/views/projects/alphabetize.js.rjs | 6 ------ features/manage_list_of_projects.feature | 16 ++++++++++++++-- features/step_definitions/project_list_steps.rb | 13 ++++++++++++- features/support/selenium.rb | 4 ++-- public/javascripts/application.js | 2 +- 8 files changed, 33 insertions(+), 18 deletions(-) create mode 100644 app/views/projects/actionize.js.erb delete mode 100644 app/views/projects/actionize.js.rjs create mode 100644 app/views/projects/alphabetize.js.erb delete mode 100644 app/views/projects/alphabetize.js.rjs diff --git a/app/views/projects/actionize.js.erb b/app/views/projects/actionize.js.erb new file mode 100644 index 00000000..7701cf3b --- /dev/null +++ b/app/views/projects/actionize.js.erb @@ -0,0 +1,2 @@ +new_html = "<%= escape_javascript(render(:partial => 'project_listing', :collection => @projects)) %>"; +$("#list-<%=@state%>-projects").html(new_html); \ No newline at end of file diff --git a/app/views/projects/actionize.js.rjs b/app/views/projects/actionize.js.rjs deleted file mode 100644 index ccb10451..00000000 --- a/app/views/projects/actionize.js.rjs +++ /dev/null @@ -1,6 +0,0 @@ -list_id = "list-#{@state}-projects" -page.replace_html list_id, - :partial => 'project_listing', - :collection => @projects -page.sortable list_id, get_listing_sortable_options(list_id) - \ No newline at end of file diff --git a/app/views/projects/alphabetize.js.erb b/app/views/projects/alphabetize.js.erb new file mode 100644 index 00000000..7701cf3b --- /dev/null +++ b/app/views/projects/alphabetize.js.erb @@ -0,0 +1,2 @@ +new_html = "<%= escape_javascript(render(:partial => 'project_listing', :collection => @projects)) %>"; +$("#list-<%=@state%>-projects").html(new_html); \ No newline at end of file diff --git a/app/views/projects/alphabetize.js.rjs b/app/views/projects/alphabetize.js.rjs deleted file mode 100644 index ccb10451..00000000 --- a/app/views/projects/alphabetize.js.rjs +++ /dev/null @@ -1,6 +0,0 @@ -list_id = "list-#{@state}-projects" -page.replace_html list_id, - :partial => 'project_listing', - :collection => @projects -page.sortable list_id, get_listing_sortable_options(list_id) - \ No newline at end of file diff --git a/features/manage_list_of_projects.feature b/features/manage_list_of_projects.feature index 66730c08..9141eace 100644 --- a/features/manage_list_of_projects.feature +++ b/features/manage_list_of_projects.feature @@ -2,7 +2,7 @@ Feature: Manage the list of projects In order to keep tracks and manage of all my projects As a Tracks user - I want to manage the list of projects + I want to manage my list of projects Background: Given the following user record @@ -79,5 +79,17 @@ Feature: Manage the list of projects And I submit a new project with name "finish cucumber tests" and select take me to the project Then I should be on the "finish cucumber tests" project page + @selenium, @wip Scenario: Sorting the project alphabetically - Scenario: Sorting the project by number of task \ No newline at end of file + When I go to the projects page + Then the project "manage me" should be above the project "a project name starting with a" + When I sort the list alphabetically + Then the project "a project name starting with a" should be above the project "manage me" + + @selenium, @wip + Scenario: Sorting the project by number of task + Given I have a project "test" with 2 todos + When I go to the projects page + Then the project "manage me" should be above the project "test" + When I sort the list by number of tasks + Then the project "test" should be above the project "manage me" diff --git a/features/step_definitions/project_list_steps.rb b/features/step_definitions/project_list_steps.rb index 209b2353..534f84f9 100644 --- a/features/step_definitions/project_list_steps.rb +++ b/features/step_definitions/project_list_steps.rb @@ -22,7 +22,7 @@ When /^I drag the project "([^"]*)" below "([^"]*)"$/ do |project_drag, project_ selenium.mouse_down_at(drag_project_handle_xpath,"2,2") selenium.mouse_move_at(drop_project_container_xpath,coord_string) - # selenium.mouse_over(drop_project_container_xpath) + # no need to simulate mouse_over for this test selenium.mouse_up_at(drop_project_container_xpath,coord_string) end @@ -38,6 +38,17 @@ When /^I submit a new project with name "([^"]*)" and select take me to the proj selenium.wait_for_page_to_load(5000) # follow the redirect end +When /^I sort the list alphabetically$/ do + click_link "Alphabetically" + selenium.get_confirmation.should == "Are you sure that you want to sort these projects alphabetically? This will replace the existing sort order." + +end + +When /^I sort the list by number of tasks$/ do + click_link "By number of tasks" + selenium.get_confirmation.should == "Are you sure that you want to sort these projects by the number of tasks? This will replace the existing sort order." +end + Then /^the project "([^"]*)" should be above the project "([^"]*)"$/ do |project_high, project_low| high_id = @current_user.projects.find_by_name(project_high).id low_id = @current_user.projects.find_by_name(project_low).id diff --git a/features/support/selenium.rb b/features/support/selenium.rb index a66782d2..bccc9082 100644 --- a/features/support/selenium.rb +++ b/features/support/selenium.rb @@ -6,12 +6,12 @@ if ENV["RAILS_ENV"] == "selenium" config.application_environment = :selenium # use only if you run a separate rails test server instance and do not # want webrat to start one for you - # config.application_port = 3001 + config.application_port = 3001 config.selenium_browser_startup_timeout = 30 # use only if you run a separate selenium server instance and do not # want webrat to start one for you - # config.selenium_server_address = "localhost" + config.selenium_server_address = "localhost" # config.selenium_server_port = "4444" end diff --git a/public/javascripts/application.js b/public/javascripts/application.js index 8bc28b20..cc6d068c 100644 --- a/public/javascripts/application.js +++ b/public/javascripts/application.js @@ -560,7 +560,7 @@ $(document).ready(function() { if(confirm('Are you sure that you want to sort these projects alphabetically? This will replace the existing sort order.')){ alphaSort = $(this).parents('.alpha_sort'); alphaSort.block({message:null}); - $.post(this.href, {}, function(){alphaSort.unblock()}, 'script'); + $.post(this.href, {async: true}, function(){alphaSort.unblock()}, 'script'); } });