Fixes #650. Make sure that the edit form uses the right default context after changing it. Also adds selenium test for it

git-svn-id: http://www.rousette.org.uk/svn/tracks-repos/trunk@756 a4c988fc-2ded-0310-b66e-134b36920a42
This commit is contained in:
lrbalt 2008-03-20 19:04:07 +00:00
parent 0e7a85befd
commit 26da8bad1b
6 changed files with 28 additions and 0 deletions

View file

@ -113,6 +113,7 @@ class ProjectsController < ApplicationController
elsif boolean_param('update_status')
render :action => 'update_status'
elsif boolean_param('update_default_context')
@initial_context_name = @project.default_context.name
render :action => 'update_default_context'
else
render :text => success_text || 'Success'

View file

@ -74,6 +74,7 @@ class TodosController < ApplicationController
determine_down_count if @saved
@contexts = current_user.contexts.find(:all) if @new_context_created
@projects = current_user.projects.find(:all) if @new_project_created
@initial_context_name = params['default_context_name']
render :action => 'create'
end
format.xml do

View file

@ -2,6 +2,7 @@ if @project.default_context.nil?
page.notify :notice, "Removed default context", 5.0
else
if source_view_is :project
page['default_context_name_id'].value = @project.default_context.name
page['todo_context_name'].value = @project.default_context.name
end
page.notify :notice, "Set project's default context to #{@project.default_context.name}", 5.0

View file

@ -52,6 +52,7 @@ Event.observe($('todo_project_name'), "click", projectAutoCompleter.activate.bin
Event.observe($('todo_project_name'), "blur", selectDefaultContext.bind($('todo_project_name')));
</script>
<input id="default_context_name_id" name="default_context_name" type="hidden" value="<%=@initial_context_name-%>" />
<label for="todo_context_name">Context</label>
<input id="todo_context_name" name="context_name" autocomplete="off" tabindex="4" size="30" type="text" value="<%= @initial_context_name %>" />
<div class="page_name_auto_complete" id="context_list" style="display:none"></div>

View file

@ -7,6 +7,7 @@ if @saved
page.notify :notice, status_message, 5.0
page['badge_count'].replace_html @down_count
page.send :record, "Form.reset('todo-form-new-action');Form.focusFirstElement('todo-form-new-action')"
page['todo_context_name'].value = @initial_context_name
page << "updateContextNamesForAutoComplete(#{context_names_for_autocomplete})" if @new_context_created
page << "projectAutoCompleter.options.array = #{project_names_for_autocomplete}" if @new_project_created
if should_show_new_item()

View file

@ -0,0 +1,23 @@
setup :fixtures => :all
login :as => 'admin'
open "/projects/2"
# change default context
type "project[default_context_name]", "errand"
click "commit"
wait_for_visible "flash"
# add actions
type "todo_description", "test1"
click "css=#todo-form-new-action .submit_box button"
wait_for_visible "flash"
wait_for_not_visible "flash"
type "todo_description", "test2"
click "css=#todo-form-new-action .submit_box button"
# check that context errand now contains 2 todos
open "/contexts/4"
assert_text "badge_count", "2"