diff --git a/Rakefile b/Rakefile index cb3b081..2f48986 100644 --- a/Rakefile +++ b/Rakefile @@ -6,9 +6,9 @@ require 'spree/testing_support/common_rake' RSpec::Core::RakeTask.new -task :default => [:spec] +task default: [:spec] -desc "Generates a dummy app for testing" +desc 'Generates a dummy app for testing' task :test_app do ENV['LIB_NAME'] = 'spree_email_to_friend' Rake::Task['common:test_app'].invoke diff --git a/app/controllers/spree/email_sender_controller.rb b/app/controllers/spree/email_sender_controller.rb index 0839237..a8ac8ea 100644 --- a/app/controllers/spree/email_sender_controller.rb +++ b/app/controllers/spree/email_sender_controller.rb @@ -6,7 +6,7 @@ class Spree::EmailSenderController < Spree::StoreController def send_mail if request.get? - @mail_to_friend = Spree::MailToFriend.new(:sender_email => spree_current_user.try(:email)) + @mail_to_friend = Spree::MailToFriend.new(sender_email: spree_current_user.try(:email)) else mail_to_friend end @@ -19,9 +19,9 @@ def mail_to_friend @mail_to_friend.host = request.env['HTTP_HOST'] respond_to do |format| format.html do - captcha_passed = !Spree::Captcha::Config[:use_captcha] || verify_recaptcha(:private_key => Spree::Captcha::Config[:private_key]) + captcha_passed = !Spree::Captcha::Config[:use_captcha] || verify_recaptcha(private_key: Spree::Captcha::Config[:private_key]) if @mail_to_friend.valid? && captcha_passed - flash[:notice] = Spree.t('email_to_friend.mail_sent_to', :email => @mail_to_friend.recipients.join(", ")).html_safe + flash[:notice] = Spree.t('email_to_friend.mail_sent_to', email: @mail_to_friend.recipients.join(', ')) send_message(@object, @mail_to_friend) @@ -30,7 +30,7 @@ def mail_to_friend redirect_to @object else - render :action => :send_mail + render action: :send_mail end end end @@ -58,5 +58,4 @@ def find_object # Display 404 page if object is not found. raise ActiveRecord::RecordNotFound if @object.nil? end - end diff --git a/app/mailers/spree/to_friend_mailer.rb b/app/mailers/spree/to_friend_mailer.rb index 87e085c..f4d5d18 100644 --- a/app/mailers/spree/to_friend_mailer.rb +++ b/app/mailers/spree/to_friend_mailer.rb @@ -1,5 +1,5 @@ class Spree::ToFriendMailer < ActionMailer::Base - default :from => Spree::Config[:mails_from] || '' + default from: Spree::Config[:mails_from] || '' def mail_to_friend(object, mail) diff --git a/app/models/spree/captcha_configuration.rb b/app/models/spree/captcha_configuration.rb index b50af5f..2eb49ba 100644 --- a/app/models/spree/captcha_configuration.rb +++ b/app/models/spree/captcha_configuration.rb @@ -1,9 +1,9 @@ class Spree::CaptchaConfiguration < Spree::Preferences::Configuration - THEMES = ['red', 'white', 'blackglass', 'clean', 'custom'] + THEMES = %w(red white blackglass clean custom) - # this keys works for localhost - preference :private_key, :string, :default => '6LfIsgEAAAAAAGfB6Z0lEUtdL3GVuBkRa9cYlMZz' - preference :public_key, :string, :default => '6LfIsgEAAAAAALpT20eiC3RslZQmmCbiNS-AUvSe' - preference :theme, :string, :default => 'red' - preference :use_captcha, :boolean, :default => true + # These keys works for localhost. + preference :private_key, :string, default: '6LfIsgEAAAAAAGfB6Z0lEUtdL3GVuBkRa9cYlMZz' + preference :public_key, :string, default: '6LfIsgEAAAAAALpT20eiC3RslZQmmCbiNS-AUvSe' + preference :theme, :string, default: 'red' + preference :use_captcha, :boolean, default: true end diff --git a/app/models/spree/mail_to_friend.rb b/app/models/spree/mail_to_friend.rb index 7871516..6601e49 100644 --- a/app/models/spree/mail_to_friend.rb +++ b/app/models/spree/mail_to_friend.rb @@ -5,11 +5,11 @@ class Spree::MailToFriend EMAILREGEX = /\A[-a-z0-9_+\.]+\@([-a-z0-9]+\.)+[a-z0-9]{2,8}\z/i - validates :subject, :sender_name, :presence => true - validates :recipient_name, :presence => true, :unless => :is_multi - validates :sender_email, :format => { :with => EMAILREGEX } - validates :recipients, :length => {:minimum => 1, :message => Spree.t(:recipients, scope: :validation) } - validates :invalid_recipients, :length => {:maximum => 0, :message => Spree.t(:invalid_recipients, scope: :validation) } + validates :subject, :sender_name, presence: true + validates :recipient_name, presence: true, unless: :is_multi + validates :sender_email, format: { with: EMAILREGEX } + validates :recipients, length: {minimum: 1, message: Spree.t(:recipients, scope: :validation) } + validates :invalid_recipients, length: {maximum: 0, message: Spree.t(:invalid_recipients, scope: :validation) } def initialize(opts = {}) @sender_email = opts[:sender_email] || ' ' diff --git a/app/overrides/add_captcha_settings_to_admin_configurations_menu.rb b/app/overrides/add_captcha_settings_to_admin_configurations_menu.rb index c8e6e19..0df7e9f 100644 --- a/app/overrides/add_captcha_settings_to_admin_configurations_menu.rb +++ b/app/overrides/add_captcha_settings_to_admin_configurations_menu.rb @@ -1,5 +1,5 @@ -Deface::Override.new(:virtual_path => "spree/admin/shared/_configuration_menu", - :name => "add_captcha_admin_option", - :insert_bottom => "[data-hook='admin_configurations_sidebar_menu']", - :text => "<%= configurations_sidebar_menu_item Spree.t('captcha.captcha_settings'), edit_admin_captcha_settings_path %>", - :disabled => false) \ No newline at end of file +Deface::Override.new(virtual_path: "spree/admin/shared/_configuration_menu", + name: "add_captcha_admin_option", + insert_bottom: "[data-hook='admin_configurations_sidebar_menu']", + text: "<%= configurations_sidebar_menu_item Spree.t('captcha.captcha_settings'), edit_admin_captcha_settings_path %>", + disabled: false) diff --git a/app/overrides/add_email_to_friend_link_to_products.rb b/app/overrides/add_email_to_friend_link_to_products.rb index dfb2e26..5d336c3 100644 --- a/app/overrides/add_email_to_friend_link_to_products.rb +++ b/app/overrides/add_email_to_friend_link_to_products.rb @@ -1,8 +1,6 @@ -Deface::Override.new(:virtual_path => "spree/products/show", - :name => "converted_product_description_351026984", - :insert_bottom => "[data-hook='product_description'], #product_description[data-hook]", - :text => "

- <%= link_to Spree.t('email_to_friend.send_to_friend'), email_to_friend_url('product', @product) %> -

", - :disabled => false, - :original => "23a81432df67f93cad7563f7b118d6f901b8e42b") +Deface::Override.new(virtual_path: "spree/products/show", + name: "converted_product_description_351026984", + insert_bottom: "[data-hook='product_description'], #product_description[data-hook]", + text: "

<%= link_to Spree.t('email_to_friend.send_to_friend'), email_to_friend_path('product', @product) %>

", + disabled: false, + original: "23a81432df67f93cad7563f7b118d6f901b8e42b") diff --git a/app/views/spree/admin/captcha_settings/edit.html.erb b/app/views/spree/admin/captcha_settings/edit.html.erb index b707353..914c83d 100755 --- a/app/views/spree/admin/captcha_settings/edit.html.erb +++ b/app/views/spree/admin/captcha_settings/edit.html.erb @@ -1,10 +1,10 @@ -<%= render :partial => 'spree/admin/shared/configuration_menu' %> +<%= render partial: 'spree/admin/shared/configuration_menu' %> <% content_for :page_title do %> <%= Spree.t('captcha.captcha_settings') %> <% end %> -<%= form_tag(admin_captcha_settings_path, :method => :put) do |f| -%> +<%= form_tag(admin_captcha_settings_path, method: :put) do |f| -%>
@@ -24,17 +24,17 @@

- <%= text_field_tag('preferences[public_key]', Spree::Captcha::Config[:public_key], :size => 40) %> + <%= text_field_tag('preferences[public_key]', Spree::Captcha::Config[:public_key], size: 40) %>

- <%= text_field_tag('preferences[private_key]', Spree::Captcha::Config[:private_key], :size => 40) %> + <%= text_field_tag('preferences[private_key]', Spree::Captcha::Config[:private_key], size: 40) %>

- <%= select_tag('preferences[theme]', options_for_select(Spree::CaptchaConfiguration::THEMES, Spree::Captcha::Config[:theme]), class: "select2") %> + <%= select_tag('preferences[theme]', options_for_select(Spree::CaptchaConfiguration::THEMES, Spree::Captcha::Config[:theme]), class: 'select2') %>
diff --git a/app/views/spree/email_sender/send_mail.html.erb b/app/views/spree/email_sender/send_mail.html.erb index 05778f5..9a20c73 100755 --- a/app/views/spree/email_sender/send_mail.html.erb +++ b/app/views/spree/email_sender/send_mail.html.erb @@ -1,7 +1,7 @@ -

<%= Spree.t('email_to_friend.tell_about', :product => @object.name) %>

+

<%= Spree.t('email_to_friend.tell_about', product: @object.name) %>

-<%= form_for(@mail_to_friend, :url => email_to_friend_path(params[:type], @object)) do |f| -%> - <%= render 'spree/shared/error_messages', :target => @mail_to_friend %> +<%= form_for(@mail_to_friend, url: email_to_friend_path(params[:type], @object)) do |f| -%> + <%= render 'spree/shared/error_messages', target: @mail_to_friend %>

<%= f.label(:sender_name, Spree.t('email_to_friend.sender_name')) %>
<%= f.text_field(:sender_name) %> @@ -23,9 +23,9 @@ <%= f.text_area(:message) %>

<% if Spree::Captcha::Config[:use_captcha] %> - <%= recaptcha_tags :public_key => Spree::Captcha::Config[:public_key], :display => {:theme => Spree::Captcha::Config[:theme]} %> + <%= recaptcha_tags public_key: Spree::Captcha::Config[:public_key], display: { theme: Spree::Captcha::Config[:theme] } %> <% end %>

<%= f.submit Spree.t('email_to_friend.send_message') %>

-<% end -%> \ No newline at end of file +<% end -%> diff --git a/app/views/spree/to_friend_mailer/mail_to_friend.text.erb b/app/views/spree/to_friend_mailer/mail_to_friend.text.erb index b6c5cf7..b016219 100644 --- a/app/views/spree/to_friend_mailer/mail_to_friend.text.erb +++ b/app/views/spree/to_friend_mailer/mail_to_friend.text.erb @@ -1,3 +1,2 @@ <% object_sym = @object.class.name.tableize %> -<%= render :partial => "#{object_sym}/mail_to_friend", - :locals => {:object => @object, :mail => @mail} %> +<%= render partial: "#{object_sym}/mail_to_friend", locals: { object: @object, mail: @mail } %> diff --git a/lib/spree_email_to_friend/engine.rb b/lib/spree_email_to_friend/engine.rb index 9efb6e4..31e6844 100644 --- a/lib/spree_email_to_friend/engine.rb +++ b/lib/spree_email_to_friend/engine.rb @@ -9,16 +9,16 @@ class Engine < Rails::Engine config.autoload_paths += %W(#{config.root}/lib) - initializer "spree.email_to_friend.preferences", :after => "spree.environment" do |app| + initializer 'spree.email_to_friend.preferences', after: 'spree.environment' do |app| Spree::Captcha::Config = Spree::CaptchaConfiguration.new end def self.activate - Dir.glob(File.join(File.dirname(__FILE__), "../../app/**/*_decorator*.rb")) do |c| + Dir.glob(File.join(File.dirname(__FILE__), '../../app/**/*_decorator*.rb')) do |c| Rails.configuration.cache_classes ? require(c) : load(c) end - Dir.glob(File.join(File.dirname(__FILE__), "../../app/overrides/*.rb")) do |c| + Dir.glob(File.join(File.dirname(__FILE__), '../../app/overrides/*.rb')) do |c| Rails.configuration.cache_classes ? require(c) : load(c) end end