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)