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