displays captcha only on new, not edit
This commit is contained in:
@@ -1,4 +1,8 @@
|
||||
module RecaptchaHelper
|
||||
|
||||
def recaptchable?
|
||||
@debate.new_record?
|
||||
end
|
||||
|
||||
def recaptcha_keys?
|
||||
Recaptcha.configuration.public_key.present? &&
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
<% if recaptcha_keys? %>
|
||||
<% if recaptchable? and recaptcha_keys? %>
|
||||
<%= recaptcha_tags ajax: true, hl: I18n.locale %>
|
||||
<% end %>
|
||||
@@ -2,6 +2,20 @@ require 'rails_helper'
|
||||
|
||||
describe RecaptchaHelper do
|
||||
|
||||
describe '#recaptchable?' do
|
||||
|
||||
it 'should be true if new record' do
|
||||
assign(:debate, build(:debate))
|
||||
expect(helper.recaptchable?).to be true
|
||||
end
|
||||
|
||||
it 'should be false if existing record' do
|
||||
assign(:debate, create(:debate))
|
||||
expect(helper.recaptchable?).to be false
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
describe "#recaptcha_keys?" do
|
||||
|
||||
it "should be true if Recaptcha keys are configured" do
|
||||
|
||||
Reference in New Issue
Block a user