Commit c4375964727c6573a9eca1e7000e3e21ea31ccbc

Authored by Daniela Feitosa
Committed by Antonio Terceiro
1 parent e784be49

ActionItem1154: require login to send contact

app/controllers/public/contact_controller.rb
1 1 class ContactController < PublicController
2 2  
  3 + before_filter :login_required
  4 +
3 5 needs_profile
4 6  
5 7 inverse_captcha :field => 'e_mail'
... ...
test/functional/contact_controller_test.rb
... ... @@ -15,6 +15,8 @@ class ContactControllerTest &lt; Test::Unit::TestCase
15 15  
16 16 @profile = create_user('contact_test_user').person
17 17 @enterprise = Enterprise.create!(:identifier => 'contact_test_enterprise', :name => 'Test contact enteprise')
  18 +
  19 + login_as('contact_test_user')
18 20 end
19 21 attr_reader :profile, :enterprise
20 22  
... ... @@ -50,13 +52,11 @@ class ContactControllerTest &lt; Test::Unit::TestCase
50 52 end
51 53  
52 54 should 'fill email if user logged in' do
53   - login_as(profile.identifier)
54 55 get :new, :profile => enterprise.identifier
55 56 assert_tag :tag => 'input', :attributes => {:name => 'contact[email]', :value => profile.email}
56 57 end
57 58  
58 59 should 'fill name if user logged in' do
59   - login_as(profile.identifier)
60 60 get :new, :profile => enterprise.identifier
61 61 assert_tag :tag => 'input', :attributes => {:name => 'contact[name]', :value => profile.name}
62 62 end
... ... @@ -111,5 +111,11 @@ class ContactControllerTest &lt; Test::Unit::TestCase
111 111 assert_response :success
112 112 assert_template 'new'
113 113 end
114   -
  114 +
  115 + should 'not allow if not logged' do
  116 + logout
  117 + get :new, :profile => profile.identifier
  118 + assert_response :redirect
  119 + assert_redirected_to :controller => 'account', :action => 'login'
  120 + end
115 121 end
... ...