From ed778922b32c16a74a5fdd68b5b182a6da6ef43f Mon Sep 17 00:00:00 2001 From: AntonioTerceiro Date: Wed, 30 Jul 2008 20:50:50 +0000 Subject: [PATCH] ActionItem519: making tests reference the new login button --- test/integration/login_to_the_application_test.rb | 9 +++++---- test/integration/user_registers_at_the_application_test.rb | 12 ++++-------- test/test_helper.rb | 21 +++++++++++++++++++++ 3 files changed, 30 insertions(+), 12 deletions(-) diff --git a/test/integration/login_to_the_application_test.rb b/test/integration/login_to_the_application_test.rb index ac2d475..5e8128c 100644 --- a/test/integration/login_to_the_application_test.rb +++ b/test/integration/login_to_the_application_test.rb @@ -5,15 +5,16 @@ class LoginToTheApplicationTest < ActionController::IntegrationTest def test_anonymous_user_logins_to_application get '/' - assert_tag :tag => 'a', :attributes => { :href => '/account/login_popup' } - assert_no_tag :tag => 'a', :attributes => { :href => '/account/logout' } + + assert_can_login + assert_cannot_logout get '/account/login_popup' assert_response :success login('ze', 'test') - assert_no_tag :tag => 'a', :attributes => { :href => '/account/login_popup' } - assert_tag :tag => 'a', :attributes => { :href => '/account/logout' } + assert_cannot_login + assert_can_logout end diff --git a/test/integration/user_registers_at_the_application_test.rb b/test/integration/user_registers_at_the_application_test.rb index 2a9b067..1b375c1 100644 --- a/test/integration/user_registers_at_the_application_test.rb +++ b/test/integration/user_registers_at_the_application_test.rb @@ -5,10 +5,8 @@ class UserRegistersAtTheApplicationTest < ActionController::IntegrationTest def test_successfull_registration get '/' - assert_tag :tag => 'a', :attributes => { :href => '/account/login_popup' } - - get '/account/login_popup' - assert_tag :tag => 'a', :attributes => { :href => '/account/signup'} + assert_can_login + assert_can_signup get '/account/signup' assert_response :success @@ -28,10 +26,8 @@ class UserRegistersAtTheApplicationTest < ActionController::IntegrationTest assert User.find_by_login('ze') # just to make sure that 'ze' already exists get '/' - assert_tag :tag => 'a', :attributes => { :href => '/account/login_popup'} - - get '/account/login_popup' - assert_tag :tag => 'a', :attributes => { :href => '/account/signup'} + assert_can_login + assert_can_signup get '/account/signup' assert_response :success diff --git a/test/test_helper.rb b/test/test_helper.rb index 8da1a67..906b28a 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -214,6 +214,27 @@ class Test::Unit::TestCase end class ActionController::IntegrationTest + def assert_can_login + assert_tag :tag => 'a', :attributes => { :id => 'link_login' } + end + + def assert_can_signup + assert_tag :tag => 'a', :attributes => { :href => '/account/signup'} + end + + def assert_cannot_logout + assert_no_tag :tag => 'a', :attributes => { :href => '/account/logout' } + end + + def assert_cannot_login + assert_no_tag :tag => 'a', :attributes => { :id => 'link_login' } + end + + def assert_can_logout + assert_tag :tag => 'a', :attributes => { :href => '/account/logout' } + end + + def login(username, password) post '/account/login', :user => { :login => username, :password => password } assert_response :redirect -- libgit2 0.21.2