diff --git a/tracks/config/environments/test.rb b/tracks/config/environments/test.rb index 2badd1b6..e7847b9d 100644 --- a/tracks/config/environments/test.rb +++ b/tracks/config/environments/test.rb @@ -22,3 +22,7 @@ config.action_mailer.delivery_method = :test # config.instantiated_fixtures = false # config.pre_loaded_fixtures = false SALT = "change-me" unless defined?( SALT ).nil? + +config.after_initialize do + require 'test/selenium_helper' +end \ No newline at end of file diff --git a/tracks/test/selenium/context_listing/delete.rsel b/tracks/test/selenium/context_listing/delete.rsel index 19141175..e16221fe 100644 --- a/tracks/test/selenium/context_listing/delete.rsel +++ b/tracks/test/selenium/context_listing/delete.rsel @@ -1,5 +1,5 @@ setup :fixtures => :all -include_partial 'login/login', :username => 'admin', :password => 'abracadabra' +login :as => 'admin' open "/contexts" click "css=#context_3 .buttons img.delete_item" assert_confirmation "Are you sure that you want to delete the context 'email'?" diff --git a/tracks/test/selenium/context_listing/edit_then_delete.rsel b/tracks/test/selenium/context_listing/edit_then_delete.rsel index 0ebbb40f..bbe03939 100644 --- a/tracks/test/selenium/context_listing/edit_then_delete.rsel +++ b/tracks/test/selenium/context_listing/edit_then_delete.rsel @@ -1,5 +1,5 @@ setup :fixtures => :all -include_partial 'login/login', :username => 'admin', :password => 'abracadabra' +login :as => 'admin' open "/contexts" click "css=#context_3 .buttons img.edit_item" wait_for_visible "edit_context_3" diff --git a/tracks/test/selenium/context_listing/edit_twice.rsel b/tracks/test/selenium/context_listing/edit_twice.rsel index 7babed64..20b42026 100644 --- a/tracks/test/selenium/context_listing/edit_twice.rsel +++ b/tracks/test/selenium/context_listing/edit_twice.rsel @@ -1,5 +1,5 @@ setup :fixtures => :all -include_partial 'login/login', :username => 'admin', :password => 'abracadabra' +login :as => 'admin' open "/contexts" click "css=#context_3 .buttons img.edit_item" wait_for_visible "edit_context_3" diff --git a/tracks/test/selenium/home/mark_todo_complete_1.rsel b/tracks/test/selenium/home/mark_todo_complete_1.rsel index ad3d1616..35194bde 100644 --- a/tracks/test/selenium/home/mark_todo_complete_1.rsel +++ b/tracks/test/selenium/home/mark_todo_complete_1.rsel @@ -1,4 +1,5 @@ setup :fixtures => :all -include_partial 'login/login', :username => 'admin', :password => 'abracadabra' +login :as => 'admin' +open '/' click "xpath=//div[@id='c1'] //div[@id='todo_9'] //input[@class='item-checkbox']" wait_for_element_present "xpath=//div[@id='completed'] //div[@id='todo_9']" diff --git a/tracks/test/selenium/home/mark_todo_complete_2.rsel b/tracks/test/selenium/home/mark_todo_complete_2.rsel index 1d5af6f4..dcb66769 100644 --- a/tracks/test/selenium/home/mark_todo_complete_2.rsel +++ b/tracks/test/selenium/home/mark_todo_complete_2.rsel @@ -1,5 +1,6 @@ setup :fixtures => :all -include_partial 'login/login', :username => 'admin', :password => 'abracadabra' +login :as => 'admin' +open '/' click "xpath=//div[@id='c5'] //div[@id='todo_5'] //input[@class='item-checkbox']" wait_for_element_present "xpath=//div[@id='completed'] //div[@id='todo_5']" wait_for_not_visible 'c5' diff --git a/tracks/test/selenium/home/mark_todo_complete_3.rsel b/tracks/test/selenium/home/mark_todo_complete_3.rsel index c5d75bba..ae444663 100644 --- a/tracks/test/selenium/home/mark_todo_complete_3.rsel +++ b/tracks/test/selenium/home/mark_todo_complete_3.rsel @@ -1,4 +1,5 @@ setup :fixtures => :all -include_partial 'login/login', :username => 'jane', :password => 'sesame' +login :as => 'jane' +open '/' click_and_wait "xpath=//div[@id='c10'] //div[@id='todo_16'] //input[@class='item-checkbox']" assert_title "TRACKS::Project: Attend RailsConf" diff --git a/tracks/test/selenium/home/mark_todo_incomplete.rsel b/tracks/test/selenium/home/mark_todo_incomplete.rsel index 64db1846..d0a159ac 100644 --- a/tracks/test/selenium/home/mark_todo_incomplete.rsel +++ b/tracks/test/selenium/home/mark_todo_incomplete.rsel @@ -1,5 +1,6 @@ setup :fixtures => :all -include_partial 'login/login', :username => 'admin', :password => 'abracadabra' +login :as => 'admin' +open '/' click "xpath=//div[@id='completed'] //div[@id='todo_3'] //input[@class='item-checkbox']" wait_for_element_present "xpath=//div[@id='c4'] //div[@id='todo_3']" assert_not_visible "c4empty-nd" diff --git a/tracks/test/selenium/login/login_failure.rsel b/tracks/test/selenium/login/login_failure.rsel index 4b1240b4..39d38c46 100644 --- a/tracks/test/selenium/login/login_failure.rsel +++ b/tracks/test/selenium/login/login_failure.rsel @@ -1,8 +1,8 @@ - open :controller => 'login', :action => 'logout' - open :controller => 'login' - assert_title 'exact:TRACKS::Login' - type "user_login", "admin" - type "user_password", "incorrect_password" - click_and_wait "login" - assert_title 'exact:TRACKS::Login' - verify_text_present 'Login unsuccessful' +open :controller => 'login', :action => 'logout' +open :controller => 'login' +assert_title 'exact:TRACKS::Login' +type "user_login", "admin" +type "user_password", "incorrect_password" +click_and_wait "login" +assert_title 'exact:TRACKS::Login' +verify_text_present 'Login unsuccessful' diff --git a/tracks/test/selenium/login/login_success.rsel b/tracks/test/selenium/login/login_success.rsel index a218872f..7c7257d6 100644 --- a/tracks/test/selenium/login/login_success.rsel +++ b/tracks/test/selenium/login/login_success.rsel @@ -1,8 +1,7 @@ - - open :controller => 'login', :action => 'logout' - open :controller => 'login' - assert_title 'exact:TRACKS::Login' - type "user_login", "admin" - type "user_password", "abracadabra" - click_and_wait "login" - assert_title 'exact:TRACKS::List tasks' \ No newline at end of file +open :controller => 'login', :action => 'logout' +open :controller => 'login' +assert_title 'exact:TRACKS::Login' +type "user_login", "admin" +type "user_password", "abracadabra" +click_and_wait "login" +assert_title 'exact:TRACKS::List tasks' \ No newline at end of file diff --git a/tracks/test/selenium/notes/link_to_note.rsel b/tracks/test/selenium/notes/link_to_note.rsel index ef966df3..4c0e3e4d 100644 --- a/tracks/test/selenium/notes/link_to_note.rsel +++ b/tracks/test/selenium/notes/link_to_note.rsel @@ -1,5 +1,5 @@ setup :fixtures => :all -include_partial 'login/login', :username => 'admin', :password => 'abracadabra' +login :as => 'admin' open "/projects/Build_a_working_time_machine" click_and_wait "css=#note_1 .link_to_notes" assert_element_present "note_1" diff --git a/tracks/test/selenium/notes/see_all_notes.rsel b/tracks/test/selenium/notes/see_all_notes.rsel index 2b06ecbd..83b9f52c 100644 --- a/tracks/test/selenium/notes/see_all_notes.rsel +++ b/tracks/test/selenium/notes/see_all_notes.rsel @@ -1,5 +1,5 @@ setup :fixtures => :all -include_partial 'login/login', :username => 'admin', :password => 'abracadabra' +login :as => 'admin' open "/notes/" assert_element_present "note_1" assert_element_present "note_2" diff --git a/tracks/test/selenium/project_detail/activate_deferred_todo.rsel b/tracks/test/selenium/project_detail/activate_deferred_todo.rsel index 37968542..619a54ae 100644 --- a/tracks/test/selenium/project_detail/activate_deferred_todo.rsel +++ b/tracks/test/selenium/project_detail/activate_deferred_todo.rsel @@ -1,6 +1,6 @@ setup :fixtures => :all next_available_todo_id = 18 -include_partial 'login/login', :username => 'admin', :password => 'abracadabra' +login :as => 'admin' open "/projects/Build_a_working_time_machine" include_partial 'project_detail/add_deferred_todo' open "/projects/Build_a_working_time_machine" diff --git a/tracks/test/selenium/project_detail/activate_last_deferred_todo.rsel b/tracks/test/selenium/project_detail/activate_last_deferred_todo.rsel index 398769a2..43731f5e 100644 --- a/tracks/test/selenium/project_detail/activate_last_deferred_todo.rsel +++ b/tracks/test/selenium/project_detail/activate_last_deferred_todo.rsel @@ -1,5 +1,5 @@ setup :fixtures => :all -include_partial 'login/login', :username => 'admin', :password => 'abracadabra' +login :as => 'admin' open "/projects/Build_a_working_time_machine" click "edit_icon_todo_15" wait_for_element_present "show_from_todo_15" diff --git a/tracks/test/selenium/project_detail/change_project_status.rsel b/tracks/test/selenium/project_detail/change_project_status.rsel index d08e8e55..8824365f 100644 --- a/tracks/test/selenium/project_detail/change_project_status.rsel +++ b/tracks/test/selenium/project_detail/change_project_status.rsel @@ -1,5 +1,5 @@ setup :fixtures => :all -include_partial 'login/login', :username => 'admin', :password => 'abracadabra' +login :as => 'admin' open '/projects/Build_a_working_time_machine' assert_checked 'project_state_active', 'ignored' assert_attribute 'css=#project_status .active span', 'class', 'active_state' diff --git a/tracks/test/selenium/project_detail/create_deferred_todo.rsel b/tracks/test/selenium/project_detail/create_deferred_todo.rsel index 8719ae65..df87d9ed 100644 --- a/tracks/test/selenium/project_detail/create_deferred_todo.rsel +++ b/tracks/test/selenium/project_detail/create_deferred_todo.rsel @@ -1,5 +1,5 @@ setup :fixtures => :all -include_partial 'login/login', :username => 'admin', :password => 'abracadabra' +login :as => 'admin' open "/projects/Make_more_money_than_Billy_Gates" include_partial 'project_detail/add_deferred_todo' assert_not_visible "tickler-empty-nd" \ No newline at end of file diff --git a/tracks/test/selenium/project_detail/defer_todo.rsel b/tracks/test/selenium/project_detail/defer_todo.rsel index b3cc9cac..8dae5b8c 100644 --- a/tracks/test/selenium/project_detail/defer_todo.rsel +++ b/tracks/test/selenium/project_detail/defer_todo.rsel @@ -1,5 +1,5 @@ setup :fixtures => :all -include_partial 'login/login', :username => 'admin', :password => 'abracadabra' +login :as => 'admin' open "/projects/Build_a_working_time_machine" click "edit_icon_todo_5" wait_for_element_present "show_from_todo_5" diff --git a/tracks/test/selenium/project_detail/mark_deferred_todo_complete.rsel b/tracks/test/selenium/project_detail/mark_deferred_todo_complete.rsel index 7962fabb..2af7d7ab 100644 --- a/tracks/test/selenium/project_detail/mark_deferred_todo_complete.rsel +++ b/tracks/test/selenium/project_detail/mark_deferred_todo_complete.rsel @@ -1,5 +1,5 @@ setup :fixtures => :all -include_partial 'login/login', :username => 'admin', :password => 'abracadabra' +login :as => 'admin' open "/projects/Build_a_working_time_machine" include_partial 'project_detail/add_deferred_todo' click "xpath=//div[@id='tickler'] //div[@id='todo_15'] //input[@class='item-checkbox']" diff --git a/tracks/test/selenium/project_detail/mark_last_deferred_todo_complete.rsel b/tracks/test/selenium/project_detail/mark_last_deferred_todo_complete.rsel index ba1daf2e..9a87704c 100644 --- a/tracks/test/selenium/project_detail/mark_last_deferred_todo_complete.rsel +++ b/tracks/test/selenium/project_detail/mark_last_deferred_todo_complete.rsel @@ -1,5 +1,5 @@ setup :fixtures => :all -include_partial 'login/login', :username => 'admin', :password => 'abracadabra' +login :as => 'admin' open "/projects/Build_a_working_time_machine" click "xpath=//div[@id='tickler'] //div[@id='todo_15'] //input[@class='item-checkbox']" wait_for_visible "tickler-empty-nd" diff --git a/tracks/test/selenium/project_listing/delete.rsel b/tracks/test/selenium/project_listing/delete.rsel index 3aa9071a..ad9eac16 100644 --- a/tracks/test/selenium/project_listing/delete.rsel +++ b/tracks/test/selenium/project_listing/delete.rsel @@ -1,5 +1,5 @@ setup :fixtures => :all -include_partial 'login/login', :username => 'admin', :password => 'abracadabra' +login :as => 'admin' open "/projects" click "css=#project_2 .buttons img.delete_item" assert_confirmation "Are you sure that you want to delete the project 'Make more money than Billy Gates'?" diff --git a/tracks/test/selenium/project_listing/edit_then_delete.rsel b/tracks/test/selenium/project_listing/edit_then_delete.rsel index 696c7118..69a7aa73 100644 --- a/tracks/test/selenium/project_listing/edit_then_delete.rsel +++ b/tracks/test/selenium/project_listing/edit_then_delete.rsel @@ -1,5 +1,5 @@ setup :fixtures => :all -include_partial 'login/login', :username => 'admin', :password => 'abracadabra' +login :as => 'admin' open "/projects" click "css=#project_2 .buttons img.edit_item" wait_for_visible "edit_project_2" diff --git a/tracks/test/selenium/project_listing/edit_twice.rsel b/tracks/test/selenium/project_listing/edit_twice.rsel index 2b4a2b36..d1293b44 100644 --- a/tracks/test/selenium/project_listing/edit_twice.rsel +++ b/tracks/test/selenium/project_listing/edit_twice.rsel @@ -1,5 +1,5 @@ setup :fixtures => :all -include_partial 'login/login', :username => 'admin', :password => 'abracadabra' +login :as => 'admin' open "/projects" click "css=#project_2 .buttons img.edit_item" wait_for_visible "edit_project_2" diff --git a/tracks/test/selenium/tags/find_tagged.rsel b/tracks/test/selenium/tags/find_tagged.rsel index 1b01a05a..0afe8225 100644 --- a/tracks/test/selenium/tags/find_tagged.rsel +++ b/tracks/test/selenium/tags/find_tagged.rsel @@ -1,5 +1,5 @@ setup :fixtures => :all -include_partial 'login/login', :username => 'admin', :password => 'abracadabra' +login :as => 'admin' open "/todos/tag/foo" wait_for_element_present "xpath=//div[@id='c1'] //h2" wait_for_text 'badge_count', '2' \ No newline at end of file diff --git a/tracks/test/selenium/tickler/see_all_deferred.rsel b/tracks/test/selenium/tickler/see_all_deferred.rsel index 27fd4648..f68939fa 100644 --- a/tracks/test/selenium/tickler/see_all_deferred.rsel +++ b/tracks/test/selenium/tickler/see_all_deferred.rsel @@ -1,4 +1,4 @@ setup :fixtures => :all -include_partial 'login/login', :username => 'admin', :password => 'abracadabra' +login :as => 'admin' open "/tickler/" assert_element_present "todo_15" diff --git a/tracks/test/selenium_helper.rb b/tracks/test/selenium_helper.rb new file mode 100644 index 00000000..0b2ad47d --- /dev/null +++ b/tracks/test/selenium_helper.rb @@ -0,0 +1,18 @@ +class SeleniumHelperController < ActionController::Base + def login + if params[:as] + session['user_id'] = User.find_by_login(params[:as].to_s) + end + render :text => "Logged in as #{params[:as]}" + end +end + +ActionController::Routing::Routes.add_route '/selenium_helper/login', :controller => 'selenium_helper', :action => 'login' + +module SeleniumOnRails::TestBuilderActions + def login options = {} + options = {options => nil} unless options.is_a? Hash + opts = {:controller => 'selenium_helper', :action => 'login'}.merge(options) + open opts + end +end diff --git a/tracks/test/test_helper.rb b/tracks/test/test_helper.rb index 30c729ec..5ec9b469 100644 --- a/tracks/test/test_helper.rb +++ b/tracks/test/test_helper.rb @@ -111,6 +111,4 @@ class ActionController::IntegrationTest assert_response_and_body 401, "401 Unauthorized: Only admin users are allowed access to this function." end - - end \ No newline at end of file