From ae4ce272fff740f50e3fdaa661afd5410cff36ed Mon Sep 17 00:00:00 2001 From: Carsten Otto Date: Thu, 2 Apr 2015 17:00:55 +0200 Subject: [PATCH 1/3] update form with new context name --- app/assets/javascripts/tracks.js.erb | 2 +- app/views/contexts/update.js.erb | 1 + features/context_edit.feature | 9 ++++++++- features/step_definitions/todo_steps.rb | 5 +++++ 4 files changed, 15 insertions(+), 2 deletions(-) diff --git a/app/assets/javascripts/tracks.js.erb b/app/assets/javascripts/tracks.js.erb index 1974af86..acb910c9 100644 --- a/app/assets/javascripts/tracks.js.erb +++ b/app/assets/javascripts/tracks.js.erb @@ -659,7 +659,7 @@ var ContextListPage = { $.post(relative_to_root('contexts/'+context_id), { 'context[name]': value, '_method': 'put' - }, highlight); + }, highlight, 'script'); return value; }, setup_behavior: function() { diff --git a/app/views/contexts/update.js.erb b/app/views/contexts/update.js.erb index 209f44e4..cf0ae85f 100644 --- a/app/views/contexts/update.js.erb +++ b/app/views/contexts/update.js.erb @@ -18,6 +18,7 @@ var <%=object_name%> = { <% else -%> <%=object_name%>.replace_context_form_with_updated_context(); <% end -%> + TracksForm.set_context_name("<%= escape_javascript(@context.name)%>"); }, remove_and_re_add_context: function() { $('#<%=dom_id(@context, 'container')%>').slideUp(500, function() { diff --git a/features/context_edit.feature b/features/context_edit.feature index eb7c042f..91cdfd24 100644 --- a/features/context_edit.feature +++ b/features/context_edit.feature @@ -21,6 +21,13 @@ Feature: Edit a context Then I should see that a context named "Errands" is not present And I should see that a context named "OutAndAbout" is present + # Ticket #1796 + @javascript + Scenario: I can change the name of the context and it should update the new todo form + When I go to the context page for "@pc" + And I edit the context name in place to be "OutAndAbout" + Then the context field of the new todo form should contain "OutAndAbout" + @javascript Scenario: Editing the context of a todo will remove the todo When I go to the the context page for "@pc" @@ -102,4 +109,4 @@ Feature: Edit a context When I go to the "test" context And I mark "deferred todo 1" as complete Then I should see empty message for todos of context - And I should see empty message for deferred todos of context \ No newline at end of file + And I should see empty message for deferred todos of context diff --git a/features/step_definitions/todo_steps.rb b/features/step_definitions/todo_steps.rb index 83ed2975..60182ac8 100644 --- a/features/step_definitions/todo_steps.rb +++ b/features/step_definitions/todo_steps.rb @@ -119,6 +119,11 @@ Then /^the project field of the new todo form should contain "([^"]*)"$/ do |pro expect(project_name).to eq(page.find(:xpath, xpath).value) end +Then /^the context field of the new todo form should contain "([^"]*)"$/ do |context_name| + xpath= "//form[@id='todo-form-new-action']/input[@id='todo_context_name']" + expect(page.find(:xpath, xpath).value).to eq(context_name) +end + Then /^the default context of the new todo form should be "([^"]*)"$/ do |context_name| xpath= "//form[@id='todo-form-new-action']/input[@id='todo_context_name']" expect(context_name).to eq(page.find(:xpath, xpath).value) From f8f7762b94e3b436d3583b93aed23c6a04daf66b Mon Sep 17 00:00:00 2001 From: Carsten Otto Date: Mon, 13 Apr 2015 22:15:39 +0200 Subject: [PATCH 2/3] also update default_project_name New actions are created with the project as defined in default_project_name. This value needs to be updated as shown in #1789. --- app/assets/javascripts/tracks.js.erb | 6 +----- app/views/projects/update.js.erb | 2 +- app/views/projects/update_project_name.js.erb | 2 +- app/views/todos/create.js.erb | 2 +- features/project_edit.feature | 10 ++++++++++ 5 files changed, 14 insertions(+), 8 deletions(-) diff --git a/app/assets/javascripts/tracks.js.erb b/app/assets/javascripts/tracks.js.erb index acb910c9..e2d64157 100644 --- a/app/assets/javascripts/tracks.js.erb +++ b/app/assets/javascripts/tracks.js.erb @@ -13,9 +13,6 @@ var TracksForm = { } toggleLink.parent().toggleClass('hide_form'); }, - set_project_name: function (name) { - $('input#todo_project_name').val(name); - }, set_project_name_for_multi_add: function (name) { $('#multi_todo_project_name').val(name); }, @@ -30,9 +27,8 @@ var TracksForm = { $('input[name=default_context_name]').val(name); }, set_project_name_and_default_project_name: function (name) { - TracksForm.set_project_name(''); + $('input#todo_project_name').val(name); $('#default_project_name_id').val(name); - $('#project_name').html(name); }, set_tag_list_and_default_tag_list: function (name) { $('input#tag_list').val(name); diff --git a/app/views/projects/update.js.erb b/app/views/projects/update.js.erb index 72df2f52..f34249f6 100644 --- a/app/views/projects/update.js.erb +++ b/app/views/projects/update.js.erb @@ -34,7 +34,7 @@ var <%=object_name%> = { update_project_page: function() { <%=object_name%>.remove_project_edit_form(); <%=object_name%>.update_and_show_project_settings(); - TracksForm.set_project_name("<%= escape_javascript(@project.name)%>"); + TracksForm.set_project_name_and_default_project_name("<%= escape_javascript(@project.name)%>"); $("h2 span#project_name").html("<%= escape_javascript(@project.name)%>"); <% if @project.default_context %> TracksForm.set_context_name_and_default_context_name("<%= escape_javascript(@project.default_context.name)%>"); diff --git a/app/views/projects/update_project_name.js.erb b/app/views/projects/update_project_name.js.erb index ba027a88..0f232804 100644 --- a/app/views/projects/update_project_name.js.erb +++ b/app/views/projects/update_project_name.js.erb @@ -1,4 +1,4 @@ <% if @saved -%> TracksPages.page_inform('<%=t('projects.status_project_name_changed')%>'); - TracksForm.set_project_name("<%= escape_javascript(@project.name)%>"); + TracksForm.set_project_name_and_default_project_name("<%= escape_javascript(@project.name)%>"); <% end %> \ No newline at end of file diff --git a/app/views/todos/create.js.erb b/app/views/todos/create.js.erb index 2caaa66b..e7d35b4a 100644 --- a/app/views/todos/create.js.erb +++ b/app/views/todos/create.js.erb @@ -28,7 +28,7 @@ $('#todo-form-new-action').clearForm(); $('#todo-form-new-action').clearDeps(); TracksForm.set_context_name('<%=escape_javascript @initial_context_name%>'); - TracksForm.set_project_name('<%=escape_javascript @initial_project_name%>'); + TracksForm.set_project_name_and_default_project_name('<%=escape_javascript @initial_project_name%>'); TracksForm.set_tag_list_and_default_tag_list('<%=escape_javascript @initial_tags%>'); $('#todo-form-new-action input:text:first').focus(); $('#new_todo_starred_link .todo_star').removeClass('starred'); diff --git a/features/project_edit.feature b/features/project_edit.feature index 83b09738..df3f3cbd 100644 --- a/features/project_edit.feature +++ b/features/project_edit.feature @@ -58,6 +58,16 @@ Feature: Edit a project Then the project title should be "cherries" And the project field of the new todo form should contain "cherries" + # Ticket #1789 + @javascript + Scenario: I can change the name of the project and it should still allow me to add new actions + Given I have a project "bananas" + When I go to the "bananas" project + And I edit the project name to "cherries" + And I edit the default context to "@pc" + And I submit a new action with description "a new next action" + Then I should see the todo "a new next action" + @javascript Scenario: I can change the default context of the project and it should update the new todo form Given I have a project "bananas" with 1 todos From 426b0fca20c378ab583cd6deb52240b6b97ba46e Mon Sep 17 00:00:00 2001 From: Carsten Otto Date: Mon, 25 May 2015 11:57:10 +0200 Subject: [PATCH 3/3] also update default_context_name New actions are created with the context as defined in default_context_name. This value needs to be updated as shown in #1789. --- app/views/contexts/update.js.erb | 2 +- features/context_edit.feature | 8 ++++++++ features/step_definitions/context_steps.rb | 1 + 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/app/views/contexts/update.js.erb b/app/views/contexts/update.js.erb index cf0ae85f..0b7b89ca 100644 --- a/app/views/contexts/update.js.erb +++ b/app/views/contexts/update.js.erb @@ -18,7 +18,7 @@ var <%=object_name%> = { <% else -%> <%=object_name%>.replace_context_form_with_updated_context(); <% end -%> - TracksForm.set_context_name("<%= escape_javascript(@context.name)%>"); + TracksForm.set_context_name_and_default_context_name("<%= escape_javascript(@context.name)%>"); }, remove_and_re_add_context: function() { $('#<%=dom_id(@context, 'container')%>').slideUp(500, function() { diff --git a/features/context_edit.feature b/features/context_edit.feature index 91cdfd24..6a3a1e4a 100644 --- a/features/context_edit.feature +++ b/features/context_edit.feature @@ -28,6 +28,14 @@ Feature: Edit a context And I edit the context name in place to be "OutAndAbout" Then the context field of the new todo form should contain "OutAndAbout" + # Ticket #1789 + @javascript + Scenario: I can change the name of the context and it should still allow me to add new actions + When I go to the context page for "@pc" + And I edit the context name in place to be "OutAndAbout" + And I submit a new action with description "a new next action" + Then I should see the todo "a new next action" + @javascript Scenario: Editing the context of a todo will remove the todo When I go to the the context page for "@pc" diff --git a/features/step_definitions/context_steps.rb b/features/step_definitions/context_steps.rb index 6d4719a5..e1c05153 100644 --- a/features/step_definitions/context_steps.rb +++ b/features/step_definitions/context_steps.rb @@ -54,6 +54,7 @@ When /^I edit the context name in place to be "([^\"]*)"$/ do |new_context_name| page.find("span#context_name").click fill_in "value", :with => new_context_name click_button "Ok" + wait_for_ajax end Then /^I should see the context name is "([^\"]*)"$/ do |context_name|