Commit ed778922b32c16a74a5fdd68b5b182a6da6ef43f

Authored by AntonioTerceiro
1 parent 6d5d8056

ActionItem519: making tests reference the new login button

git-svn-id: https://svn.colivre.coop.br/svn/noosfero/trunk@2343 3f533792-8f58-4932-b0fe-aaf55b0a4547
test/integration/login_to_the_application_test.rb
... ... @@ -5,15 +5,16 @@ class LoginToTheApplicationTest < ActionController::IntegrationTest
5 5  
6 6 def test_anonymous_user_logins_to_application
7 7 get '/'
8   - assert_tag :tag => 'a', :attributes => { :href => '/account/login_popup' }
9   - assert_no_tag :tag => 'a', :attributes => { :href => '/account/logout' }
  8 +
  9 + assert_can_login
  10 + assert_cannot_logout
10 11  
11 12 get '/account/login_popup'
12 13 assert_response :success
13 14  
14 15 login('ze', 'test')
15   - assert_no_tag :tag => 'a', :attributes => { :href => '/account/login_popup' }
16   - assert_tag :tag => 'a', :attributes => { :href => '/account/logout' }
  16 + assert_cannot_login
  17 + assert_can_logout
17 18  
18 19 end
19 20  
... ...
test/integration/user_registers_at_the_application_test.rb
... ... @@ -5,10 +5,8 @@ class UserRegistersAtTheApplicationTest < ActionController::IntegrationTest
5 5  
6 6 def test_successfull_registration
7 7 get '/'
8   - assert_tag :tag => 'a', :attributes => { :href => '/account/login_popup' }
9   -
10   - get '/account/login_popup'
11   - assert_tag :tag => 'a', :attributes => { :href => '/account/signup'}
  8 + assert_can_login
  9 + assert_can_signup
12 10  
13 11 get '/account/signup'
14 12 assert_response :success
... ... @@ -28,10 +26,8 @@ class UserRegistersAtTheApplicationTest < ActionController::IntegrationTest
28 26 assert User.find_by_login('ze') # just to make sure that 'ze' already exists
29 27  
30 28 get '/'
31   - assert_tag :tag => 'a', :attributes => { :href => '/account/login_popup'}
32   -
33   - get '/account/login_popup'
34   - assert_tag :tag => 'a', :attributes => { :href => '/account/signup'}
  29 + assert_can_login
  30 + assert_can_signup
35 31  
36 32 get '/account/signup'
37 33 assert_response :success
... ...
test/test_helper.rb
... ... @@ -214,6 +214,27 @@ class Test::Unit::TestCase
214 214 end
215 215  
216 216 class ActionController::IntegrationTest
  217 + def assert_can_login
  218 + assert_tag :tag => 'a', :attributes => { :id => 'link_login' }
  219 + end
  220 +
  221 + def assert_can_signup
  222 + assert_tag :tag => 'a', :attributes => { :href => '/account/signup'}
  223 + end
  224 +
  225 + def assert_cannot_logout
  226 + assert_no_tag :tag => 'a', :attributes => { :href => '/account/logout' }
  227 + end
  228 +
  229 + def assert_cannot_login
  230 + assert_no_tag :tag => 'a', :attributes => { :id => 'link_login' }
  231 + end
  232 +
  233 + def assert_can_logout
  234 + assert_tag :tag => 'a', :attributes => { :href => '/account/logout' }
  235 + end
  236 +
  237 +
217 238 def login(username, password)
218 239 post '/account/login', :user => { :login => username, :password => password }
219 240 assert_response :redirect
... ...