send email when admin unflags post (#7580)

* send email when admin unflags post

* Improved email acquisition code, minor changes to sent email

* Refactor getGoupUrl into its own method

* added unit test for getGroupUrl

* improved test and getGroupUrl
This commit is contained in:
Shervin Sarain
2016-06-08 05:22:33 +02:00
committed by Blade Barringer
parent 00491670e0
commit 8490b481f6
3 changed files with 65 additions and 25 deletions

View File

@@ -5,6 +5,7 @@ import nodemailer from 'nodemailer';
import Bluebird from 'bluebird';
import requireAgain from 'require-again';
import logger from '../../../../../website/server/libs/api-v3/logger';
import { TAVERN_ID } from '../../../../../website/server/models/group';
function defer () {
let resolve;
@@ -137,6 +138,23 @@ describe('emails', () => {
});
});
describe('getGroupUrl', () => {
it('returns correct url if group is the tavern', () => {
let getGroupUrl = require(pathToEmailLib).getGroupUrl;
expect(getGroupUrl({_id: TAVERN_ID, type: 'guild'})).to.eql('/#/options/groups/tavern');
});
it('returns correct url if group is a guild', () => {
let getGroupUrl = require(pathToEmailLib).getGroupUrl;
expect(getGroupUrl({_id: 'random _id', type: 'guild'})).to.eql('/#/options/groups/guilds/random _id');
});
it('returns correct url if group is a party', () => {
let getGroupUrl = require(pathToEmailLib).getGroupUrl;
expect(getGroupUrl({_id: 'random _id', type: 'party'})).to.eql('party');
});
});
describe('sendTxnEmail', () => {
beforeEach(() => {
sandbox.stub(request, 'post');