Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More upgrades to move up to Rails 6 #183

Open
wants to merge 7 commits into
base: rails-upgrade
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,12 @@ end

group :test do
gem 'capybara-email', '~> 3.0'
gem 'poltergeist'
gem 'generator_spec', '~> 0.9.3'
gem 'launchy'
gem 'coveralls', require: false
gem 'rspec-retry'
gem 'falcon'
gem 'falcon-capybara'
end

# Database Configuration
Expand Down
2 changes: 1 addition & 1 deletion app/views/refinery/inquiries/inquiries/_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,6 @@

<div class="actions">
<%= f.submit t('.send') %>
<%= link_to t('.privacy_policy'), "/privacy-policy", :id => "privacy_link" if Refinery::Inquiries.show_contact_privacy_link %>
<%= link_to t('.privacy_policy'), Refinery::Inquiries.privacy_link, id: "privacy_link" if Refinery::Inquiries.show_contact_privacy_link %>
</div>
<% end %>
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<%=raw t('.greeting') %>,

<%=raw t('.you_recieved_new_inquiry') %>
<%=raw t('.you_received_new_inquiry') %>

<%=raw t('.inquiry_starts') %>

Expand Down
2 changes: 1 addition & 1 deletion config/locales/bg.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ bg:
inquiry_mailer:
notification:
greeting: Здравейте
you_recieved_new_inquiry: Току що получихте ново запитване през Вашия уебсайт.
you_received_new_inquiry: Току що получихте ново запитване през Вашия уебсайт.
inquiry_starts: --- Начало на запитването ---
inquiry_ends: --- Край на запитването ---
from: От
Expand Down
2 changes: 1 addition & 1 deletion config/locales/cs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ cs:
inquiry_mailer:
notification:
greeting: Ahoj
you_recieved_new_inquiry: Právě jsi obdržel nový dotaz na webové stránce.
you_received_new_inquiry: Právě jsi obdržel nový dotaz na webové stránce.
inquiry_starts: --- začátek dotazu ---
inquiry_ends: --- konec dotazu ---
from: Od
Expand Down
2 changes: 1 addition & 1 deletion config/locales/de.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ de:
inquiry_mailer:
notification:
greeting: Hallo
you_recieved_new_inquiry: Sie haben eine neue Kontaktanfrage über Ihre Webseite erhalten.
you_received_new_inquiry: Sie haben eine neue Kontaktanfrage über Ihre Webseite erhalten.
inquiry_starts: --- Anfang der Kontaktanfrage ---
inquiry_ends: --- Ende der Kontaktanfrage ---
from: Von
Expand Down
2 changes: 1 addition & 1 deletion config/locales/en-GB.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ en-GB:
inquiry_mailer:
notification:
greeting: Hi there
you_recieved_new_inquiry: You just received a new enquiry on your website.
you_received_new_inquiry: You just received a new enquiry on your website.
inquiry_starts: --- enquiry starts ---
inquiry_ends: --- enquiry ends ---
from: From
Expand Down
2 changes: 1 addition & 1 deletion config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ en:
inquiry_mailer:
notification:
greeting: Hi there
you_recieved_new_inquiry: You just received a new inquiry on your website.
you_received_new_inquiry: You just received a new inquiry on your website.
inquiry_starts: --- inquiry starts ---
inquiry_ends: --- inquiry ends ---
from: From
Expand Down
2 changes: 1 addition & 1 deletion config/locales/es.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ es:
inquiry_mailer:
notification:
greeting: Hola
you_recieved_new_inquiry: Has recibido una nueva consulta en tu web.
you_received_new_inquiry: Has recibido una nueva consulta en tu web.
inquiry_starts: --- comienzo de la consulta ---
inquiry_ends: --- fin de la consulta ---
from: De
Expand Down
2 changes: 1 addition & 1 deletion config/locales/fr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ fr:
inquiry_mailer:
notification:
greeting: Bonjour
you_recieved_new_inquiry: Vous avez reçu une nouvelle requête sur votre site.
you_received_new_inquiry: Vous avez reçu une nouvelle requête sur votre site.
inquiry_starts: --- Début des requêtes ---
inquiry_ends: --- Fin des requêtes ---
from: De
Expand Down
2 changes: 1 addition & 1 deletion config/locales/it.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ it:
inquiry_mailer:
notification:
greeting: Ciao a tutti
you_recieved_new_inquiry: Hai appena ricevuto una nuova richiesta sul tuo sito.
you_received_new_inquiry: Hai appena ricevuto una nuova richiesta sul tuo sito.
inquiry_starts: --- inizio del messaggio ---
inquiry_ends: --- fine del messaggio ---
from: Da
Expand Down
2 changes: 1 addition & 1 deletion config/locales/lt.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ lt:
inquiry_mailer:
notification:
greeting: Sveiki
you_recieved_new_inquiry: Jūs katik gavote naują užklausą savo svetainėje.
you_received_new_inquiry: Jūs katik gavote naują užklausą savo svetainėje.
inquiry_starts: --- užklausa prasideda ---
inquiry_ends: --- užklausa baigiasi ---
from: Nuo
Expand Down
2 changes: 1 addition & 1 deletion config/locales/lv.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ lv:
inquiry_mailer:
notification:
greeting: Sveiki
you_recieved_new_inquiry: Jūs nupat saņēmāt jaunu pieprasījumu savā mājaslapā.
you_received_new_inquiry: Jūs nupat saņēmāt jaunu pieprasījumu savā mājaslapā.
inquiry_starts: --- pieprasījuma sākums ---
inquiry_ends: --- pieprasījuma beigas ---
from: 'No'
Expand Down
2 changes: 1 addition & 1 deletion config/locales/nb.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ nb:
inquiry_mailer:
notification:
greeting: Hei
you_recieved_new_inquiry: Du har mottatt en ny forespørsel på nettsiden din.
you_received_new_inquiry: Du har mottatt en ny forespørsel på nettsiden din.
inquiry_starts: --- Start på forespørsel ---
inquiry_ends: --- Slutt på forespørsel ---
from: Fra
Expand Down
2 changes: 1 addition & 1 deletion config/locales/nl.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ nl:
inquiry_mailer:
notification:
greeting: Hallo
you_recieved_new_inquiry: Je hebt een nieuwe vraag ontvangen via je website.
you_received_new_inquiry: Je hebt een nieuwe vraag ontvangen via je website.
inquiry_starts: --- begin van de vraag ---
inquiry_ends: --- einde van de vraag ---
from: Van
Expand Down
2 changes: 1 addition & 1 deletion config/locales/pl.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ pl:
inquiry_mailer:
notification:
greeting: Cześć
you_recieved_new_inquiry: Z Twojej strony ktoś właśnie nowe zapytanie.
you_received_new_inquiry: Z Twojej strony ktoś właśnie nowe zapytanie.
inquiry_starts: --- początek zapytania ---
inquiry_ends: --- koniec zapytania ---
from: Od
Expand Down
2 changes: 1 addition & 1 deletion config/locales/pt-BR.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ pt-BR:
inquiry_mailer:
notification:
greeting: Olá
you_recieved_new_inquiry: Você recebeu um novo contato pelo website.
you_received_new_inquiry: Você recebeu um novo contato pelo website.
inquiry_starts: --- começo da mensagem ---
inquiry_ends: --- fim da mensagem ---
from: De
Expand Down
2 changes: 1 addition & 1 deletion config/locales/ru.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ ru:
inquiry_mailer:
notification:
greeting: Здравствуйте
you_recieved_new_inquiry: Вы только что получили новый запрос со своего сайта
you_received_new_inquiry: Вы только что получили новый запрос со своего сайта
inquiry_starts: --- начало запроса ---
inquiry_ends: --- конец запроса ---
from: От
Expand Down
2 changes: 1 addition & 1 deletion config/locales/sk.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ sk:
inquiry_mailer:
notification:
greeting: Ahoj
you_recieved_new_inquiry: Práve si obdržal novú otázku na webovej stránke.
you_received_new_inquiry: Práve si obdržal novú otázku na webovej stránke.
inquiry_starts: --- začiatok otázky ---
inquiry_ends: --- koniec otázky ---
from: Od
Expand Down
2 changes: 1 addition & 1 deletion config/locales/sl.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ sl:
inquiry_mailer:
notification:
greeting: Pozdravljeni
you_recieved_new_inquiry: Na vaši spletni strani ste prejeli ste novo povpraševanje.
you_received_new_inquiry: Na vaši spletni strani ste prejeli ste novo povpraševanje.
inquiry_starts: --- začetek povpraševanja ---
inquiry_ends: --- konec povpraševanja ---
from: Od
Expand Down
2 changes: 1 addition & 1 deletion config/locales/sv.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ sv:
inquiry_mailer:
notification:
greeting: Hej!
you_recieved_new_inquiry: Du har just mottagit en ny förfrågan på din webbplats.
you_received_new_inquiry: Du har just mottagit en ny förfrågan på din webbplats.
inquiry_starts: --- förfrågan börjar ---
inquiry_ends: --- förfrågan slutar ---
from: Från
Expand Down
2 changes: 1 addition & 1 deletion config/locales/zh-CN.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ zh-CN:
inquiry_mailer:
notification:
greeting: 您好
you_recieved_new_inquiry: 你刚从你的网站收到一条新的咨询.
you_received_new_inquiry: 你刚从你的网站收到一条新的咨询.
inquiry_starts: --- 咨询开始处 ---
inquiry_ends: --- 咨询结束处 ---
from: 表单
Expand Down
2 changes: 1 addition & 1 deletion config/locales/zh-TW.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ zh-TW:
inquiry_mailer:
notification:
greeting: 您好
you_recieved_new_inquiry: 你剛從你的網站收到一條新的咨詢.
you_received_new_inquiry: 你剛從你的網站收到一條新的咨詢.
inquiry_starts: --- 咨詢開始處 ---
inquiry_ends: --- 咨詢結束處 ---
from: 表單
Expand Down
2 changes: 2 additions & 0 deletions lib/refinery/inquiries/configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,13 @@ module Inquiries
config_accessor :show_placeholders
config_accessor :show_flash_notice
config_accessor :send_notifications_for_inquiries_marked_as_spam
config_accessor :privacy_link
config_accessor :from_name
config_accessor :post_path, :page_path_new, :page_path_thank_you
config_accessor :filter_spam, :recaptcha_site_key

self.show_contact_privacy_link = true
self.privacy_link = "/privacy-policy"
self.show_company_field = false
self.show_phone_number_field = true
self.show_placeholders = true
Expand Down
21 changes: 12 additions & 9 deletions lib/refinery/inquiries/spam_filter.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# frozen_string_literal: true

require 'httpclient'
require 'uri'
require 'English'

module Refinery
module Inquiries
Expand All @@ -16,7 +19,7 @@ def call
@valid = true
@inquiry.save
else
@inquiry.errors.add(:base, ::I18n.t(:captcha_invalid, scope: "refinery.inquiries.spam_filter"))
@inquiry.errors.add(:base, ::I18n.t(:captcha_invalid, scope: 'refinery.inquiries.spam_filter'))
end
elsif simple_filter?
@inquiry.save
Expand Down Expand Up @@ -54,18 +57,18 @@ def recaptcha_validated?
private

def recaptcha?
Inquiries.recaptcha_site_key.present?
Inquiries.recaptcha_site_key.present?
end

GOOGLE_SITEVERIFY_URL = "https://www.google.com/recaptcha/api/siteverify".freeze
GOOGLE_SITEVERIFY_URL = 'https://www.google.com/recaptcha/api/siteverify'
def recaptcha_success?
http = HTTPClient.new
response = http.get(
GOOGLE_SITEVERIFY_URL,
secret: Rails.application.secrets.recaptcha_secret_key,
response: @params["g-recaptcha-response"]
secret: Rails.application.credentials[:recaptcha][:secret_key],
response: @params['g-recaptcha-response']
)
JSON.parse(response.body)["success"] == true
JSON.parse(response.body)['success'] == true
end

def simple_filter?
Expand All @@ -82,16 +85,16 @@ def send_notification_email!
begin
InquiryMailer.notification(@inquiry, @request).deliver_now
rescue
Rails.logger.warn "There was an error delivering an inquiry notification.\n#{$!}\n"
Rails.logger.warn "There was an error delivering an inquiry notification.\n#{$ERROR_INFO}"
end
end

def send_confirmation_email!
if Setting.send_confirmation?
begin
InquiryMailer.confirmation(@inquiry, @request).deliver_now
rescue
Rails.logger.warn "There was an error delivering an inquiry confirmation:\n#{$!}\n"
rescue StandardError
Rails.logger.warn "There was an error delivering an inquiry confirmation:\n#{$ERROR_INFO}\n"
end
end
end
Expand Down
5 changes: 3 additions & 2 deletions refinerycms-inquiries.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

Gem::Specification.new do |s|
s.name = %q{refinerycms-inquiries}
s.version = %q{4.0.0}
s.version = %q{4.1.0}
s.summary = %q{Inquiry handling functionality for the Refinery CMS project.}
s.description = %q{Inquiry handling functionality extracted from Refinery CMS to allow you to have a contact form and manage inquiries in the Refinery backend.}
s.homepage = %q{http://refinerycms.com}
Expand All @@ -14,7 +14,8 @@ Gem::Specification.new do |s|
s.files = `git ls-files`.split("\n")
s.test_files = `git ls-files -- spec/*`.split("\n")

s.add_dependency 'refinerycms-core', '~> 4.0'
s.add_dependency 'refinerycms-core', '~> 4.1'
s.add_dependency 'rails', '~>6.1'
s.add_dependency 'mobility'
s.add_dependency 'refinerycms-settings', '~> 4.0'
s.add_dependency 'filters_spam', '~> 0.2'
Expand Down
6 changes: 3 additions & 3 deletions spec/factories/inquiry.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

FactoryBot.define do
factory :inquiry, class: "Refinery::Inquiries::Inquiry" do
name "Refinery"
email "[email protected]"
message "Hello..."
name { "Refinery" }
email { "[email protected]" }
message { "Hello..." }
end
end
Loading