From 5a878b3e841cc4d173f5a1569080aae7dec3ce4f Mon Sep 17 00:00:00 2001 From: lukemelia Date: Thu, 22 Mar 2007 04:37:20 +0000 Subject: [PATCH] A few minor changes and bug fixes: * On first user signup, the user no longer needs to login and after signing up. They are automatically logged in. * The Projects page was showing the name of the last project listed in the new project form. It is now appropriately blank. * When trying to create a new action, an error was occurring trying to update tags if the action failed to save. We now only try to update tags if the action saved. I wonder if we should be using some sort of ActiveRecord transaction here. If anyone knows about this, please contact me. git-svn-id: http://www.rousette.org.uk/svn/tracks-repos/trunk@481 a4c988fc-2ded-0310-b66e-134b36920a42 --- tracks/app/controllers/projects_controller.rb | 1 + tracks/app/controllers/todos_controller.rb | 6 ++++-- tracks/app/controllers/users_controller.rb | 4 +++- tracks/app/views/projects/index.rhtml | 1 + tracks/test/selenium/login/first_run_shows_signup.rsel | 2 -- tracks/test/selenium/project_listing/edit_then_delete.rsel | 2 ++ 6 files changed, 11 insertions(+), 5 deletions(-) diff --git a/tracks/app/controllers/projects_controller.rb b/tracks/app/controllers/projects_controller.rb index 4fd22e59..9fc59708 100644 --- a/tracks/app/controllers/projects_controller.rb +++ b/tracks/app/controllers/projects_controller.rb @@ -136,6 +136,7 @@ class ProjectsController < ApplicationController @active_projects = @projects.select{ |p| p.active? } @hidden_projects = @projects.select{ |p| p.hidden? } @completed_projects = @projects.select{ |p| p.completed? } + @new_project = @user.projects.build render end end diff --git a/tracks/app/controllers/todos_controller.rb b/tracks/app/controllers/todos_controller.rb index 391b7dec..1a862639 100644 --- a/tracks/app/controllers/todos_controller.rb +++ b/tracks/app/controllers/todos_controller.rb @@ -65,8 +65,10 @@ class TodosController < ApplicationController end @saved = @todo.save - @todo.tag_with(params[:tag_list],@user) - @todo.reload + if @saved + @todo.tag_with(params[:tag_list],@user) + @todo.reload + end respond_to do |wants| wants.html { redirect_to :action => "index" } diff --git a/tracks/app/controllers/users_controller.rb b/tracks/app/controllers/users_controller.rb index da371e1d..3821815b 100644 --- a/tracks/app/controllers/users_controller.rb +++ b/tracks/app/controllers/users_controller.rb @@ -80,11 +80,13 @@ class UsersController < ApplicationController return end - user.is_admin = true if User.no_users_yet? + first_user_signing_up = User.no_users_yet? + user.is_admin = true if first_user_signing_up if user.save @user = User.authenticate(user.login, params['user']['password']) @user.create_preference @user.save + session['user_id'] = @user.id if first_user_signing_up notify :notice, "Signup successful for user #{@user.login}." redirect_back_or_home end diff --git a/tracks/app/views/projects/index.rhtml b/tracks/app/views/projects/index.rhtml index 3ccebf1c..350b68f6 100644 --- a/tracks/app/views/projects/index.rhtml +++ b/tracks/app/views/projects/index.rhtml @@ -9,6 +9,7 @@ <%= render :partial => 'project_state_group', :object => @completed_projects, :locals => { :state => 'completed'} %> +<% @project = @new_project -%>
<%= link_to_function("Create a new project »", "Element.toggle('project_new');Form.focusFirstElement('project-form');", diff --git a/tracks/test/selenium/login/first_run_shows_signup.rsel b/tracks/test/selenium/login/first_run_shows_signup.rsel index 8f3f00ce..64d328c0 100644 --- a/tracks/test/selenium/login/first_run_shows_signup.rsel +++ b/tracks/test/selenium/login/first_run_shows_signup.rsel @@ -5,6 +5,4 @@ type "user_login", "admin" type "user_password", "abracadabra" type "user_password_confirmation", "abracadabra" click_and_wait "signup" -assert_title 'exact:TRACKS::Login' -include_partial 'login/login', :username => 'admin', :password => 'abracadabra' assert_title 'exact:TRACKS::List tasks' diff --git a/tracks/test/selenium/project_listing/edit_then_delete.rsel b/tracks/test/selenium/project_listing/edit_then_delete.rsel index a2549d16..696c7118 100644 --- a/tracks/test/selenium/project_listing/edit_then_delete.rsel +++ b/tracks/test/selenium/project_listing/edit_then_delete.rsel @@ -8,6 +8,8 @@ type "//div[@id='edit_project_2'] //input[@name='project[name]']", "become a bil click "//div[@id='edit_project_2'] //input[@value='Update']" wait_for_not_visible "edit_project_2" wait_for_visible "project_2" +wait_for_visible "flash" +wait_for_not_visible "flash" click "css=#project_2 .buttons img.delete_item" assert_confirmation "Are you sure that you want to delete the project 'become a billionaire'?" wait_for_visible "flash"