From 1d22f08670f68fe912c67f7936bccbf0f11ca6b0 Mon Sep 17 00:00:00 2001 From: lukemelia Date: Wed, 13 Dec 2006 08:31:48 +0000 Subject: [PATCH] Divide UserController into a UserController and a PreferencesController. Divide FeedController into a FeedController and a FeedlistController. Pull up layout and login filter into ApplicationController and override as needed. Ignored new tmp directories. git-svn-id: http://www.rousette.org.uk/svn/tracks-repos/trunk@376 a4c988fc-2ded-0310-b66e-134b36920a42 --- tracks/app/controllers/admin_controller.rb | 2 - tracks/app/controllers/application.rb | 3 + tracks/app/controllers/backend_controller.rb | 2 + tracks/app/controllers/context_controller.rb | 2 - tracks/app/controllers/feed_controller.rb | 15 ++-- tracks/app/controllers/feedlist_controller.rb | 11 +++ tracks/app/controllers/login_controller.rb | 2 + tracks/app/controllers/mobile_controller.rb | 1 - tracks/app/controllers/note_controller.rb | 4 - .../app/controllers/preferences_controller.rb | 25 ++++++ tracks/app/controllers/project_controller.rb | 3 - tracks/app/controllers/todo_controller.rb | 3 +- tracks/app/controllers/user_controller.rb | 7 +- tracks/app/helpers/feed_helper.rb | 20 ----- tracks/app/helpers/feedlist_helper.rb | 23 ++++++ tracks/app/helpers/preferences_helper.rb | 2 + tracks/app/views/feedlist/index.rhtml | 82 +++++++++++++++++++ tracks/app/views/layouts/standard.rhtml | 4 +- .../edit.rhtml} | 4 +- .../index.rhtml} | 2 +- tracks/app/views/user/change_auth_type.rhtml | 2 +- tracks/app/views/user/change_password.rhtml | 2 +- tracks/config/routes.rb | 2 +- .../functional/preferences_controller_test.rb | 50 +++++++++++ .../test/functional/user_controller_test.rb | 33 +------- 25 files changed, 218 insertions(+), 88 deletions(-) create mode 100644 tracks/app/controllers/feedlist_controller.rb create mode 100644 tracks/app/controllers/preferences_controller.rb create mode 100644 tracks/app/helpers/feedlist_helper.rb create mode 100644 tracks/app/helpers/preferences_helper.rb create mode 100644 tracks/app/views/feedlist/index.rhtml rename tracks/app/views/{user/preference_edit_form.rhtml => preferences/edit.rhtml} (96%) rename tracks/app/views/{user/preferences.rhtml => preferences/index.rhtml} (95%) create mode 100644 tracks/test/functional/preferences_controller_test.rb diff --git a/tracks/app/controllers/admin_controller.rb b/tracks/app/controllers/admin_controller.rb index 7130060a..66b0e68e 100644 --- a/tracks/app/controllers/admin_controller.rb +++ b/tracks/app/controllers/admin_controller.rb @@ -1,8 +1,6 @@ class AdminController < ApplicationController - before_filter :login_required before_filter :admin_login_required - layout 'standard' def index @user_pages, @users = paginate :users, :order => 'login ASC', :per_page => 10 diff --git a/tracks/app/controllers/application.rb b/tracks/app/controllers/application.rb index 577dad22..eb9fd098 100644 --- a/tracks/app/controllers/application.rb +++ b/tracks/app/controllers/application.rb @@ -13,8 +13,11 @@ class ApplicationController < ActionController::Base helper :application include LoginSystem + layout 'standard' + before_filter :set_session_expiration before_filter :get_current_user + prepend_before_filter :login_required after_filter :set_charset diff --git a/tracks/app/controllers/backend_controller.rb b/tracks/app/controllers/backend_controller.rb index 200c3129..8bb073fa 100644 --- a/tracks/app/controllers/backend_controller.rb +++ b/tracks/app/controllers/backend_controller.rb @@ -2,6 +2,8 @@ class BackendController < ApplicationController wsdl_service_name 'Backend' web_service_api TodoApi web_service_scaffold :invoke + skip_before_filter :login_required + def new_todo(username, token, context_id, description) check_token_against_user_word(username, token) diff --git a/tracks/app/controllers/context_controller.rb b/tracks/app/controllers/context_controller.rb index 2c5c0dad..94743dff 100644 --- a/tracks/app/controllers/context_controller.rb +++ b/tracks/app/controllers/context_controller.rb @@ -2,10 +2,8 @@ class ContextController < ApplicationController helper :todo - prepend_before_filter :login_required before_filter :init, :except => [:create, :destroy, :order] before_filter :init_todos, :only => :show - layout "standard", :except => :date_preview def index list diff --git a/tracks/app/controllers/feed_controller.rb b/tracks/app/controllers/feed_controller.rb index b0007f48..9ca503d3 100644 --- a/tracks/app/controllers/feed_controller.rb +++ b/tracks/app/controllers/feed_controller.rb @@ -3,19 +3,14 @@ class FeedController < ApplicationController helper :feed - session :disabled => true, :except => 'index' # Prevents session control from interfering with feed + layout nil - before_filter :check_token_against_user_word, :except => 'index' - prepend_before_filter :login_required, :only => 'index' + session :disabled => true # Prevents session control from interfering with feed + + skip_before_filter :login_required + before_filter :check_token_against_user_word before_filter :prepare_for_feed, :only => [:rss, :text, :ical] - - def index - @page_title = 'TRACKS::Feeds' - init_data_for_sidebar - render :layout => 'standard' - end - # Build an RSS feed def rss headers["Content-Type"] = "text/xml; charset=utf-8" diff --git a/tracks/app/controllers/feedlist_controller.rb b/tracks/app/controllers/feedlist_controller.rb new file mode 100644 index 00000000..383125e7 --- /dev/null +++ b/tracks/app/controllers/feedlist_controller.rb @@ -0,0 +1,11 @@ +class FeedlistController < ApplicationController + + helper :feedlist + + def index + @page_title = 'TRACKS::Feeds' + init_data_for_sidebar + render :layout => 'standard' + end + +end diff --git a/tracks/app/controllers/login_controller.rb b/tracks/app/controllers/login_controller.rb index 3e59293a..2b393ae3 100644 --- a/tracks/app/controllers/login_controller.rb +++ b/tracks/app/controllers/login_controller.rb @@ -1,6 +1,8 @@ class LoginController < ApplicationController + layout 'login' skip_before_filter :set_session_expiration + skip_before_filter :login_required open_id_consumer if Tracks::Config.auth_schemes.include?('open_id') def login diff --git a/tracks/app/controllers/mobile_controller.rb b/tracks/app/controllers/mobile_controller.rb index bed6582f..a587730d 100644 --- a/tracks/app/controllers/mobile_controller.rb +++ b/tracks/app/controllers/mobile_controller.rb @@ -2,7 +2,6 @@ class MobileController < ApplicationController layout 'mobile' - prepend_before_filter :login_required before_filter :init, :except => :update # Plain list of all next actions, paginated 6 per page diff --git a/tracks/app/controllers/note_controller.rb b/tracks/app/controllers/note_controller.rb index 309e5629..5614aafb 100644 --- a/tracks/app/controllers/note_controller.rb +++ b/tracks/app/controllers/note_controller.rb @@ -1,9 +1,5 @@ class NoteController < ApplicationController - prepend_before_filter :login_required - - layout "standard" - def index @all_notes = @user.notes @page_title = "TRACKS::All notes" diff --git a/tracks/app/controllers/preferences_controller.rb b/tracks/app/controllers/preferences_controller.rb new file mode 100644 index 00000000..89ae0a51 --- /dev/null +++ b/tracks/app/controllers/preferences_controller.rb @@ -0,0 +1,25 @@ +class PreferencesController < ApplicationController + + def index + @page_title = "TRACKS::Preferences" + @prefs = @user.preference + end + + def edit + @page_title = "TRACKS::Edit Preferences" + @prefs = @user.preference + + render :object => @prefs + end + + def update + user_success = @user.update_attributes(params['user']) + prefs_success = @user.preference.update_attributes(params['prefs']) + if user_success && prefs_success + redirect_to :action => 'index' + else + render :action => 'edit' + end + end + +end \ No newline at end of file diff --git a/tracks/app/controllers/project_controller.rb b/tracks/app/controllers/project_controller.rb index e70b74fb..e3bd4998 100644 --- a/tracks/app/controllers/project_controller.rb +++ b/tracks/app/controllers/project_controller.rb @@ -1,12 +1,9 @@ class ProjectController < ApplicationController helper :todo - prepend_before_filter :login_required before_filter :init, :except => [:create, :destroy, :order, :toggle_project_done] before_filter :init_todos, :only => :show - layout "standard", :except => :date_preview - def index list render_action "list" diff --git a/tracks/app/controllers/todo_controller.rb b/tracks/app/controllers/todo_controller.rb index d75df8f7..75df0f9f 100644 --- a/tracks/app/controllers/todo_controller.rb +++ b/tracks/app/controllers/todo_controller.rb @@ -2,9 +2,8 @@ class TodoController < ApplicationController helper :todo - prepend_before_filter :login_required append_before_filter :init, :except => [ :destroy, :completed, :completed_archive, :check_tickler ] - layout "standard", :except => :date_preview + layout 'standard', :except => :date_preview # Main method for listing tasks # Set page title, and fill variables with contexts and done and not-done tasks diff --git a/tracks/app/controllers/user_controller.rb b/tracks/app/controllers/user_controller.rb index f0c50fe1..dc9bd57e 100644 --- a/tracks/app/controllers/user_controller.rb +++ b/tracks/app/controllers/user_controller.rb @@ -1,6 +1,5 @@ class UserController < ApplicationController - layout 'standard' - prepend_before_filter :login_required + if Tracks::Config.auth_schemes.include?('open_id') open_id_consumer before_filter :begin_open_id_auth, :only => :update_auth_type @@ -68,7 +67,7 @@ class UserController < ApplicationController def update_password if do_change_password_for(@user) - redirect_to :controller => 'user', :action => 'preferences' + redirect_to :controller => 'preferences' else redirect_to :controller => 'user', :action => 'change_password' notify :warning, "There was a problem saving the password. Please retry." @@ -97,7 +96,7 @@ class UserController < ApplicationController @user.auth_type = params[:user][:auth_type] if @user.save notify :notice, "Authentication type updated." - redirect_to :controller => 'user', :action => 'preferences' + redirect_to :controller => 'preferences' else notify :warning, "There was a problem updating your authentication type: #{ @user.errors.full_messages.join(', ')}" redirect_to :controller => 'user', :action => 'change_auth_type' diff --git a/tracks/app/helpers/feed_helper.rb b/tracks/app/helpers/feed_helper.rb index 61eb7063..e9581f5f 100644 --- a/tracks/app/helpers/feed_helper.rb +++ b/tracks/app/helpers/feed_helper.rb @@ -66,24 +66,4 @@ module FeedHelper sprintf("%s%s%s%s", @request.protocol, @request.host, @request.port_string, url_for(:controller => 'todo', :action => 'show', :id => todo.id)) end - def rss_feed_link(options = {}) - image_tag = image_tag("feed-icon.png", :size => "16X16", :border => 0, :class => "rss-icon") - linkoptions = {:controller => 'feed', :action => 'rss', :login => "#{@user.login}", :token => "#{@user.word}"} - linkoptions.merge!(options) - link_to(image_tag, linkoptions, :title => "RSS feed") - end - - def text_feed_link(options = {}) - linkoptions = {:controller => 'feed', :action => 'text', :login => "#{@user.login}", :token => "#{@user.word}"} - linkoptions.merge!(options) - link_to('TXT', linkoptions, :title => "Plain text feed" ) - end - - def ical_feed_link(options = {}) - linkoptions = {:controller => 'feed', :action => 'ical', :login => "#{@user.login}", :token => "#{@user.word}"} - linkoptions.merge!(options) - link_to('iCal', linkoptions, :title => "iCal feed") - end - - end diff --git a/tracks/app/helpers/feedlist_helper.rb b/tracks/app/helpers/feedlist_helper.rb new file mode 100644 index 00000000..7ef3735b --- /dev/null +++ b/tracks/app/helpers/feedlist_helper.rb @@ -0,0 +1,23 @@ +module FeedlistHelper + + def rss_feed_link(options = {}) + image_tag = image_tag("feed-icon.png", :size => "16X16", :border => 0, :class => "rss-icon") + linkoptions = {:controller => 'feed', :action => 'rss', :login => "#{@user.login}", :token => "#{@user.word}"} + linkoptions.merge!(options) + link_to(image_tag, linkoptions, :title => "RSS feed") + end + + def text_feed_link(options = {}) + linkoptions = {:controller => 'feed', :action => 'text', :login => "#{@user.login}", :token => "#{@user.word}"} + linkoptions.merge!(options) + link_to('TXT', linkoptions, :title => "Plain text feed" ) + end + + def ical_feed_link(options = {}) + linkoptions = {:controller => 'feed', :action => 'ical', :login => "#{@user.login}", :token => "#{@user.word}"} + linkoptions.merge!(options) + link_to('iCal', linkoptions, :title => "iCal feed") + end + + +end diff --git a/tracks/app/helpers/preferences_helper.rb b/tracks/app/helpers/preferences_helper.rb new file mode 100644 index 00000000..8838ec68 --- /dev/null +++ b/tracks/app/helpers/preferences_helper.rb @@ -0,0 +1,2 @@ +module PreferencesHelper +end diff --git a/tracks/app/views/feedlist/index.rhtml b/tracks/app/views/feedlist/index.rhtml new file mode 100644 index 00000000..4a1b6f0e --- /dev/null +++ b/tracks/app/views/feedlist/index.rhtml @@ -0,0 +1,82 @@ +
+
+
+

Legend:

+
+
<%= image_tag("feed-icon.png", :size => "16X16", :border => 0)%>
RSS Feed
+
TXT
Plain Text Feed
+
iCal
iCal feed
+
+

Note: All feeds show only actions that have not been marked as done.

+
+
    +
  • + <%= rss_feed_link({ :limit => 15 }) %> + <%= text_feed_link({ :limit => 15 }) %> + <%= ical_feed_link({ :limit => 15 }) %> + Last 15 actions +
  • +
  • + <%= rss_feed_link %> + <%= text_feed_link %> + <%= ical_feed_link %> + All actions +
  • +
  • + <%= rss_feed_link({ :due => 0 }) %> + <%= text_feed_link({ :due => 0 }) %> + <%= ical_feed_link({ :due => 0 }) %> + Actions due today or earlier +
  • +
  • + <%= rss_feed_link({ :due => 6 }) %> + <%= text_feed_link({ :due => 6 }) %> + <%= ical_feed_link({ :due => 6 }) %> + Actions due in 7 days or earlier +
  • +
  • + <%= rss_feed_link({ :done => 7 }) %> + <%= text_feed_link({ :done => 7 }) %> + Actions completed in the last 7 days +
  • +
  • + <%= rss_feed_link({ :action => 'list_contexts_only', :feedtype => 'rss' }) %> + <%= text_feed_link({ :action => 'list_contexts_only', :feedtype => 'text' }) %> + All Contexts +
  • +
  • + <%= rss_feed_link({ :action => 'list_projects_only', :feedtype => 'rss' }) %> + <%= text_feed_link({ :action => 'list_projects_only', :feedtype => 'text' }) %> + All Projects +
  • +
  • Feeds for uncompleted actions in a specific context:

    +
      + <% for context in @contexts %> +
    • + <%= rss_feed_link({ :context => context }) %> + <%= text_feed_link({ :context => context }) %> + <%= ical_feed_link({ :context => context }) %> + Next actions in <%=h context.name %> +
    • + <% end %> +
    +
  • +
  • Feeds for uncompleted actions in a specific project:

    +
      + <% for project in @projects %> +
    • + <%= rss_feed_link({ :project => project }) %> + <%= text_feed_link({ :project => project }) %> + <%= ical_feed_link({ :project => project }) %> + Next actions for <%=h project.name %> +
    • + <% end %> +
    +
  • +
+
+
+ +
+ <%= render "sidebar/sidebar" %> +
\ No newline at end of file diff --git a/tracks/app/views/layouts/standard.rhtml b/tracks/app/views/layouts/standard.rhtml index 5abc5afe..495b2571 100644 --- a/tracks/app/views/layouts/standard.rhtml +++ b/tracks/app/views/layouts/standard.rhtml @@ -46,11 +46,11 @@
  • <%= navigation_link( "Tickler", {:controller => "todo", :action => "tickler"}, :title => "Tickler" ) %>
  • <%= navigation_link( "Done", {:controller => "todo", :action => "completed"}, {:accesskey=>"d", :title=>"Completed"} ) %>
  • <%= navigation_link( "Notes", {:controller => "note", :action => "index"}, {:accesskey => "o", :title => "Show all notes"} ) %>
  • -
  • <%= navigation_link( "Preferences", {:controller => "user", :action => "preferences"}, {:accesskey => "u", :title => "Show my preferences"} ) %>
  • +
  • <%= navigation_link( "Preferences", {:controller => "preferences", :action => "index"}, {:accesskey => "u", :title => "Show my preferences"} ) %>
  • <% if @user.is_admin? -%>
  • <%= navigation_link("Admin", {:controller => "admin", :action => "index"}, {:accesskey => "a", :title => "Add or delete users"} ) %>
  • <% end -%> -
  • <%= navigation_link(image_tag("feed-icon.png", :size => "16X16", :border => 0), {:controller => "feed", :action => "index"}, :title => "See a list of available feeds" ) %>
  • +
  • <%= navigation_link(image_tag("feed-icon.png", :size => "16X16", :border => 0), {:controller => "feedlist", :action => "index"}, :title => "See a list of available feeds" ) %>
  • diff --git a/tracks/app/views/user/preference_edit_form.rhtml b/tracks/app/views/preferences/edit.rhtml similarity index 96% rename from tracks/app/views/user/preference_edit_form.rhtml rename to tracks/app/views/preferences/edit.rhtml index c480f429..3897c615 100644 --- a/tracks/app/views/user/preference_edit_form.rhtml +++ b/tracks/app/views/preferences/edit.rhtml @@ -19,7 +19,7 @@
    - <% form_tag :action => 'update_preferences' do %> + <% form_tag :action => 'update' do %> @@ -62,7 +62,7 @@ <%= row_with_select_field("verbose_action_descriptors") %> - +
    <%= submit_tag "Update" %><%= link_to "Cancel", :controller => 'user', :action => 'preferences' %><%= link_to "Cancel", :action => 'index' %>
    <% end %> diff --git a/tracks/app/views/user/preferences.rhtml b/tracks/app/views/preferences/index.rhtml similarity index 95% rename from tracks/app/views/user/preferences.rhtml rename to tracks/app/views/preferences/index.rhtml index dd64e765..ced88bbe 100644 --- a/tracks/app/views/user/preferences.rhtml +++ b/tracks/app/views/preferences/index.rhtml @@ -26,7 +26,7 @@
  • Verbose action descriptors: <%= @prefs.verbose_action_descriptors %>
  • - <%= link_to "Edit preferences »", { :controller => 'user', :action => 'edit_preferences'}, :class => 'edit_link' %> + <%= link_to "Edit preferences »", { :controller => 'preferences', :action => 'edit'}, :class => 'edit_link' %>

    Your token

    diff --git a/tracks/app/views/user/change_auth_type.rhtml b/tracks/app/views/user/change_auth_type.rhtml index 7a099158..d9ec6e4b 100644 --- a/tracks/app/views/user/change_auth_type.rhtml +++ b/tracks/app/views/user/change_auth_type.rhtml @@ -9,7 +9,7 @@ <% form_tag :action => 'update_auth_type' do %>
    <%= select('user', 'auth_type', Tracks::Config.auth_schemes.collect {|p| [ p, p ] }) %>
    -
    <%= submit_tag 'Change Authentication Type' %> <%= link_to 'Cancel', :action => 'preferences' %>
    +
    <%= submit_tag 'Change Authentication Type' %> <%= link_to 'Cancel', :controller => 'preferences' %>
    <%= observe_field( :user_auth_type, :function => "$('open_id').style.display = value == 'open_id' ? 'block' : 'none'") %> diff --git a/tracks/app/views/user/change_password.rhtml b/tracks/app/views/user/change_password.rhtml index eef0579d..3d43cb1e 100644 --- a/tracks/app/views/user/change_password.rhtml +++ b/tracks/app/views/user/change_password.rhtml @@ -17,7 +17,7 @@ <%= password_field "updateuser", "password_confirmation", :size => 40 %> - <%= link_to 'Cancel', :action => 'preferences' %> + <%= link_to 'Cancel', :controller => 'preferences' %> <%= submit_tag 'Change password' %> diff --git a/tracks/config/routes.rb b/tracks/config/routes.rb index 30421dfa..90140c0c 100644 --- a/tracks/config/routes.rb +++ b/tracks/config/routes.rb @@ -63,7 +63,7 @@ ActionController::Routing::Routes.draw do |map| map.connect 'notes', :controller => 'note', :action => 'index' # Feed Routes - map.connect 'feeds', :controller => 'feed', :action => 'index' + map.connect 'feeds', :controller => 'feedlist', :action => 'index' map.connect 'feed/:action/:login/:token', :controller => 'feed' # Install the default route as the lowest priority. diff --git a/tracks/test/functional/preferences_controller_test.rb b/tracks/test/functional/preferences_controller_test.rb new file mode 100644 index 00000000..1add241f --- /dev/null +++ b/tracks/test/functional/preferences_controller_test.rb @@ -0,0 +1,50 @@ +require File.dirname(__FILE__) + '/../test_helper' +require 'preferences_controller' +require 'preference' + +# Re-raise errors caught by the controller. +class PreferencesController; def rescue_action(e) raise e end; end + +class PreferencesControllerTest < Test::Unit::TestCase + fixtures :users + + def setup + assert_equal "test", ENV['RAILS_ENV'] + assert_equal "change-me", Tracks::Config.salt + @controller = PreferencesController.new + @request = ActionController::TestRequest.new + @response = ActionController::TestResponse.new + end + + def test_preferences + get :index # should fail because no login + assert_redirected_to :controller => 'login', :action => 'login' + @request.session['user_id'] = users(:admin_user).id # log in the admin user + get :index + assert_response :success + assert_equal assigns['page_title'], "TRACKS::Preferences" + assert_not_nil assigns['prefs'] + end + + def test_edit_preferences + get :edit # should fail because no login + assert_redirected_to :controller => 'login', :action => 'login' + @request.session['user_id'] = users(:admin_user).id # log in the admin user + get :edit + assert_response :success + assert_equal assigns['page_title'], "TRACKS::Edit Preferences" + assert_not_nil assigns['prefs'] + assert_template 'preferences/edit' + end + + def test_update_preferences + @request.session['user_id'] = users(:admin_user).id # log in the admin user + post :update, {:user => { :first_name => 'Jane', :last_name => 'Doe'}, :prefs => { :date_format => "%m-%d-%Y", :week_starts => "0", :show_number_completed => "10", :show_completed_projects_in_sidebar => "false", :show_hidden_contexts_in_sidebar => "false", :staleness_starts => "14", :due_style => "1", :admin_email => "my.email@domain.com" }} + updated_admin_user = User.find(users(:admin_user).id) + assert_not_nil updated_admin_user.preference + assert_equal 'Jane', updated_admin_user.first_name + assert_equal 'Doe', updated_admin_user.last_name + assert_redirected_to :action => 'index' + end + +end diff --git a/tracks/test/functional/user_controller_test.rb b/tracks/test/functional/user_controller_test.rb index 937a657e..16f511e5 100644 --- a/tracks/test/functional/user_controller_test.rb +++ b/tracks/test/functional/user_controller_test.rb @@ -15,37 +15,6 @@ class UserControllerTest < Test::Unit::TestCase @request = ActionController::TestRequest.new @response = ActionController::TestResponse.new end - - def test_preferences - get :preferences # should fail because no login - assert_redirected_to :controller => 'login', :action => 'login' - @request.session['user_id'] = users(:admin_user).id # log in the admin user - get :preferences - assert_response :success - assert_equal assigns['page_title'], "TRACKS::Preferences" - assert_not_nil assigns['prefs'] - end - - def test_edit_preferences - get :edit_preferences # should fail because no login - assert_redirected_to :controller => 'login', :action => 'login' - @request.session['user_id'] = users(:admin_user).id # log in the admin user - get :edit_preferences - assert_response :success - assert_equal assigns['page_title'], "TRACKS::Edit Preferences" - assert_not_nil assigns['prefs'] - assert_template 'user/preference_edit_form' - end - - def test_update_preferences - @request.session['user_id'] = users(:admin_user).id # log in the admin user - post :update_preferences, {:user => { :first_name => 'Jane', :last_name => 'Doe'}, :prefs => { :date_format => "%m-%d-%Y", :week_starts => "0", :show_number_completed => "10", :show_completed_projects_in_sidebar => "false", :show_hidden_contexts_in_sidebar => "false", :staleness_starts => "14", :due_style => "1", :admin_email => "my.email@domain.com" }} - updated_admin_user = User.find(users(:admin_user).id) - assert_not_nil updated_admin_user.preference - assert_equal 'Jane', updated_admin_user.first_name - assert_equal 'Doe', updated_admin_user.last_name - assert_redirected_to :action => 'preferences' - end def test_update_password_successful get :change_password # should fail because no login @@ -56,7 +25,7 @@ class UserControllerTest < Test::Unit::TestCase assert_response :success assert_equal assigns['page_title'], "TRACKS::Change password" post :update_password, :updateuser => {:password => 'newpassword', :password_confirmation => 'newpassword'} - assert_redirected_to :controller => 'user', :action => 'preferences' + assert_redirected_to :controller => 'preferences' @updated_user = User.find(users(:admin_user).id) assert_equal @updated_user.password, Digest::SHA1.hexdigest("#{Tracks::Config.salt}--newpassword--") assert_equal flash[:notice], "Password updated."