diff --git a/app/controllers/public/contact_controller.rb b/app/controllers/public/contact_controller.rb index dc16cd0..2b99d48 100644 --- a/app/controllers/public/contact_controller.rb +++ b/app/controllers/public/contact_controller.rb @@ -1,5 +1,7 @@ class ContactController < PublicController + before_filter :login_required + needs_profile inverse_captcha :field => 'e_mail' diff --git a/test/functional/contact_controller_test.rb b/test/functional/contact_controller_test.rb index 7e84918..377692d 100644 --- a/test/functional/contact_controller_test.rb +++ b/test/functional/contact_controller_test.rb @@ -15,6 +15,8 @@ class ContactControllerTest < Test::Unit::TestCase @profile = create_user('contact_test_user').person @enterprise = Enterprise.create!(:identifier => 'contact_test_enterprise', :name => 'Test contact enteprise') + + login_as('contact_test_user') end attr_reader :profile, :enterprise @@ -50,13 +52,11 @@ class ContactControllerTest < Test::Unit::TestCase end should 'fill email if user logged in' do - login_as(profile.identifier) get :new, :profile => enterprise.identifier assert_tag :tag => 'input', :attributes => {:name => 'contact[email]', :value => profile.email} end should 'fill name if user logged in' do - login_as(profile.identifier) get :new, :profile => enterprise.identifier assert_tag :tag => 'input', :attributes => {:name => 'contact[name]', :value => profile.name} end @@ -111,5 +111,11 @@ class ContactControllerTest < Test::Unit::TestCase assert_response :success assert_template 'new' end - + + should 'not allow if not logged' do + logout + get :new, :profile => profile.identifier + assert_response :redirect + assert_redirected_to :controller => 'account', :action => 'login' + end end -- libgit2 0.21.2