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