diff --git a/app/helpers/notifications_helper.rb b/app/helpers/notifications_helper.rb deleted file mode 100644 index 2e551b3cb..000000000 --- a/app/helpers/notifications_helper.rb +++ /dev/null @@ -1,11 +0,0 @@ -module NotificationsHelper - def reply_link(notification) - if notification.post - # comment on the post in question - new_comment_url(post_id: notification.post.id) - else - # by default, reply link sends a PM in return - notification_reply_url(notification) - end - end -end diff --git a/app/mailers/notifier.rb b/app/mailers/notifier.rb deleted file mode 100644 index 0386450f1..000000000 --- a/app/mailers/notifier.rb +++ /dev/null @@ -1,56 +0,0 @@ -class Notifier < ApplicationMailer - include NotificationsHelper - default from: "Growstuff <#{ENV['GROWSTUFF_EMAIL']}>" - - def verifier - unless ENV['RAILS_SECRET_TOKEN'] - raise "RAILS_SECRET_TOKEN environment variable"\ - "not set - have you created config/application.yml?" - end - - ActiveSupport::MessageVerifier.new(ENV['RAILS_SECRET_TOKEN']) - end - - def notify(notification) - @notification = notification - @reply_link = reply_link(@notification) - - # Encrypting - message = { member_id: @notification.recipient.id, type: :send_notification_email } - @signed_message = verifier.generate(message) - - mail(to: @notification.recipient.email, - subject: @notification.subject) - end - - def planting_reminder(member) - @member = member - - @plantings = @member.plantings.order(planted_at: :desc).first(5) - @harvests = @member.harvests.order(harvested_at: :desc).first(5) - - # Encrypting - message = { member_id: @member.id, type: :send_planting_reminder } - @signed_message = verifier.generate(message) - - mail(to: @member.email, subject: "What have you planted lately?") if @member.send_planting_reminder - end - - def new_crop_request(member, request) - @member = member - @request = request - mail(to: @member.email, subject: "#{@request.requester.login_name} has requested #{@request.name} as a new crop") - end - - def crop_request_approved(member, crop) - @member = member - @crop = crop - mail(to: @member.email, subject: "#{crop.name.capitalize} has been approved") - end - - def crop_request_rejected(member, crop) - @member = member - @crop = crop - mail(to: @member.email, subject: "#{crop.name.capitalize} has been rejected") - end -end diff --git a/spec/helpers/notifications_helper_spec.rb b/spec/helpers/notifications_helper_spec.rb deleted file mode 100644 index 68262fb9e..000000000 --- a/spec/helpers/notifications_helper_spec.rb +++ /dev/null @@ -1,24 +0,0 @@ -require 'rails_helper' - -describe NotificationsHelper do - describe "reply_link" do - let(:member) { FactoryBot.create(:member) } - - it "replies to PMs with PMs" do - notification = FactoryBot.create(:notification, recipient_id: member.id, post_id: nil) - link = helper.reply_link(notification) - link.should_not be_nil - link.should eq notification_reply_url(notification) - end - - it "replies to post comments with post comments" do - notification = FactoryBot.create(:notification, recipient_id: member.id) - - link = helper.reply_link(notification) - link.should_not be_nil - link.should eq new_comment_url( - post_id: notification.post.id - ) - end - end -end