Commit 6a3b50fcd6324e036c07422d9f19b437923edbac

Authored by Victor Costa
1 parent 30f29261

Do not display captcha in article suggestion from logged in users

app/controllers/my_profile/cms_controller.rb
@@ -358,7 +358,7 @@ class CmsController < MyProfileController @@ -358,7 +358,7 @@ class CmsController < MyProfileController
358 @task.user_agent = request.user_agent 358 @task.user_agent = request.user_agent
359 @task.referrer = request.referrer 359 @task.referrer = request.referrer
360 @task.requestor = current_person if logged_in? 360 @task.requestor = current_person if logged_in?
361 - if verify_recaptcha(:model => @task, :message => _('Please type the words correctly')) && @task.save 361 + if (logged_in? || verify_recaptcha(:model => @task, :message => _('Please type the words correctly'))) && @task.save
362 session[:notice] = _('Thanks for your suggestion. The community administrators were notified.') 362 session[:notice] = _('Thanks for your suggestion. The community administrators were notified.')
363 redirect_to @back_to 363 redirect_to @back_to
364 end 364 end
app/views/cms/suggest_an_article.html.erb
@@ -21,7 +21,7 @@ @@ -21,7 +21,7 @@
21 21
22 <%= hidden_field_tag('back_to', @back_to) %> 22 <%= hidden_field_tag('back_to', @back_to) %>
23 23
24 - <%= recaptcha_tags(:display => { :theme => 'clean' }, :ajax => true) %> 24 + <%= recaptcha_tags(:display => { :theme => 'clean' }, :ajax => true) unless logged_in? %>
25 25
26 <% button_bar do %> 26 <% button_bar do %>
27 <%= submit_button :save, _('Save') %> 27 <%= submit_button :save, _('Save') %>
test/functional/cms_controller_test.rb
@@ -1422,6 +1422,19 @@ class CmsControllerTest &lt; ActionController::TestCase @@ -1422,6 +1422,19 @@ class CmsControllerTest &lt; ActionController::TestCase
1422 assert_select '#task_email', 0 1422 assert_select '#task_email', 0
1423 end 1423 end
1424 1424
  1425 + should 'display captcha when suggest an article for not logged in users' do
  1426 + logout
  1427 + get :suggest_an_article, :profile => profile.identifier, :back_to => 'action_view'
  1428 +
  1429 + assert_select '#dynamic_recaptcha'
  1430 + end
  1431 +
  1432 + should 'not display captcha when suggest an article for logged in users' do
  1433 + get :suggest_an_article, :profile => profile.identifier, :back_to => 'action_view'
  1434 +
  1435 + assert_select '#dynamic_recaptcha', 0
  1436 + end
  1437 +
1425 should 'render TinyMce Editor on suggestion of article' do 1438 should 'render TinyMce Editor on suggestion of article' do
1426 logout 1439 logout
1427 get :suggest_an_article, :profile => profile.identifier 1440 get :suggest_an_article, :profile => profile.identifier