mirror of
https://github.com/Growstuff/growstuff.git
synced 2026-10-25 08:18:24 -04:00
Removing unused notifications code
This commit is contained in:
1 parent
bccd83c706
commit
12c1002dc6
3 files changed
-91
No files matched your search
@@ -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
|
||||
@@ -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
|
||||
@@ -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
|
||||
Reference in new issue
Block a user