mirror of
https://github.com/TracksApp/tracks.git
synced 2026-01-29 04:06:11 +01:00
Fix #553 (context/action does not appear via ajax when creating first action/context for a user). A couple of new selenium tests support this fix.
git-svn-id: http://www.rousette.org.uk/svn/tracks-repos/trunk@581 a4c988fc-2ded-0310-b66e-134b36920a42
This commit is contained in:
parent
fca5e5b88f
commit
565a8a83be
4 changed files with 40 additions and 8 deletions
|
|
@ -58,14 +58,28 @@ Event.observe($('todo_project_name'), "blur", selectDefaultContext.bind($('todo_
|
|||
<div class="page_name_auto_complete" id="context_list" style="display:none"></div>
|
||||
|
||||
<script type="text/javascript">
|
||||
contextNamesForAutoComplete = <%= context_names_for_autocomplete %>;
|
||||
if (contextNamesForAutoComplete.length > 1 || contextNamesForAutoComplete[0].length > 0) {
|
||||
contextAutoCompleter = new Autocompleter.Local('todo_context_name', 'context_list', contextNamesForAutoComplete, {choices:100,autoSelect:false});
|
||||
$('todo_context_name').projectDefaultContextsMap = eval('(' + <%= @default_project_context_name_map %> + ')');
|
||||
Event.observe($('todo_context_name'), "focus", function(){ $('todo_context_name').editedByTracksUser = true; });
|
||||
Event.observe($('todo_context_name'), "focus", contextAutoCompleter.activate.bind(contextAutoCompleter));
|
||||
Event.observe($('todo_context_name'), "click", contextAutoCompleter.activate.bind(contextAutoCompleter));
|
||||
var contextAutoCompleter;
|
||||
function intializeNamesForAutoComplete(contextNamesForAutoComplete) {
|
||||
if (contextNamesForAutoComplete.length == 0 || contextNamesForAutoComplete[0].length == 0) {
|
||||
return;
|
||||
}
|
||||
contextAutoCompleter = new Autocompleter.Local('todo_context_name', 'context_list', contextNamesForAutoComplete, {choices:100,autoSelect:false});
|
||||
$('todo_context_name').projectDefaultContextsMap = eval('(' + <%= @default_project_context_name_map %> + ')');
|
||||
Event.observe($('todo_context_name'), "focus", function(){ $('todo_context_name').editedByTracksUser = true; });
|
||||
Event.observe($('todo_context_name'), "focus", contextAutoCompleter.activate.bind(contextAutoCompleter));
|
||||
Event.observe($('todo_context_name'), "click", contextAutoCompleter.activate.bind(contextAutoCompleter));
|
||||
}
|
||||
function updateContextNamesForAutoComplete(contextNamesForAutoComplete) {
|
||||
if (contextAutoCompleter) // if we're already initialized
|
||||
{
|
||||
contextAutoCompleter.options.array = contextNamesForAutoComplete
|
||||
}
|
||||
else
|
||||
{
|
||||
intializeNamesForAutoComplete(contextNamesForAutoComplete)
|
||||
}
|
||||
}
|
||||
intializeNamesForAutoComplete(<%= context_names_for_autocomplete %>);
|
||||
</script>
|
||||
|
||||
<label for="tag_list">Tags (separate with commas)</label>
|
||||
|
|
|
|||
|
|
@ -7,7 +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 << "contextAutoCompleter.options.array = #{context_names_for_autocomplete}" if @new_context_created
|
||||
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()
|
||||
if @new_context_created
|
||||
|
|
|
|||
9
tracks/test/selenium/home/create_first_todo.rsel
Normal file
9
tracks/test/selenium/home/create_first_todo.rsel
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
setup :fixtures => :users, :clear_tables => [:projects, :contexts, :todos]
|
||||
login :as => 'admin'
|
||||
open "/"
|
||||
store_eval "this.browserbot.getCurrentWindow().$$('.context').length", 'initial_context_count'
|
||||
type "todo_description", "a new action"
|
||||
type "todo_context_name", "Brand new context"
|
||||
click "css=#todo-form-new-action .submit_box button"
|
||||
store_eval "${initial_context_count} + 1", 'expected_context_count'
|
||||
wait_for_eval "this.browserbot.getCurrentWindow().$$('.context').length", "${expected_context_count}"
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
setup :fixtures => :all
|
||||
login :as => 'admin'
|
||||
open "/"
|
||||
store_eval "this.browserbot.getCurrentWindow().$$('.context').length", 'initial_context_count'
|
||||
type "todo_description", "a new action"
|
||||
type "todo_context_name", "Brand new context"
|
||||
click "css=#todo-form-new-action .submit_box button"
|
||||
store_eval "${initial_context_count} + 1", 'expected_context_count'
|
||||
wait_for_eval "this.browserbot.getCurrentWindow().$$('.context').length", "${expected_context_count}"
|
||||
Loading…
Add table
Add a link
Reference in a new issue