mirror of
https://github.com/openSUSE/osem.git
synced 2026-08-16 13:14:03 +00:00
Merge pull request #926 from sonalkr132/mailer-tests
Mailer fixes and tests
This commit is contained in:
commit
86449eea67
6 changed files with 91 additions and 7 deletions
|
|
@ -36,7 +36,7 @@ class Mailbot < ActionMailer::Base
|
|||
end
|
||||
|
||||
def conference_date_update_mail(conference)
|
||||
User.joins(:subscriptions).merge(conference.subscriptions) do |user|
|
||||
User.joins(:subscriptions).merge(conference.subscriptions).each do |user|
|
||||
build_email(conference,
|
||||
user.email,
|
||||
conference.email_settings.conference_dates_updated_subject,
|
||||
|
|
@ -45,7 +45,7 @@ class Mailbot < ActionMailer::Base
|
|||
end
|
||||
|
||||
def conference_registration_date_update_mail(conference)
|
||||
User.joins(:subscriptions).merge(conference.subscriptions).uniq.joins('INNER JOIN registrations ON registrations.user_id != users.id').merge(conference.registrations) do |user|
|
||||
User.joins(:subscriptions).merge(conference.subscriptions).uniq.joins('INNER JOIN registrations ON registrations.user_id != users.id').merge(conference.registrations).each do |user|
|
||||
build_email(conference,
|
||||
user.email,
|
||||
conference.email_settings.conference_registration_dates_updated_subject,
|
||||
|
|
@ -54,7 +54,7 @@ class Mailbot < ActionMailer::Base
|
|||
end
|
||||
|
||||
def send_email_on_venue_updated(conference)
|
||||
User.joins(:subscriptions).merge(conference.subscriptions) do |user|
|
||||
User.joins(:subscriptions).merge(conference.subscriptions).each do |user|
|
||||
build_email(conference,
|
||||
user.email,
|
||||
conference.email_settings.venue_updated_subject,
|
||||
|
|
@ -63,7 +63,7 @@ class Mailbot < ActionMailer::Base
|
|||
end
|
||||
|
||||
def send_on_schedule_public(conference)
|
||||
User.joins(:subscriptions).merge(conference.subscriptions) do |user|
|
||||
User.joins(:subscriptions).merge(conference.subscriptions).each do |user|
|
||||
build_email(conference,
|
||||
user.email,
|
||||
conference.email_settings.program_schedule_public_subject,
|
||||
|
|
@ -72,7 +72,7 @@ class Mailbot < ActionMailer::Base
|
|||
end
|
||||
|
||||
def send_on_cfp_dates_updates(conference)
|
||||
User.joins(:subscriptions).merge(conference.subscriptions) do |user|
|
||||
User.joins(:subscriptions).merge(conference.subscriptions).each do |user|
|
||||
build_email(conference,
|
||||
user.email,
|
||||
conference.email_settings.cfp_dates_updated_subject,
|
||||
|
|
|
|||
|
|
@ -1,4 +1,6 @@
|
|||
class EmailSettings < ActiveRecord::Base
|
||||
belongs_to :conference
|
||||
|
||||
def get_values(conference, user, event = nil)
|
||||
h = {
|
||||
'email' => user.email,
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ User <%= @comment.user.name %> posted a new comment for event <%= @event.title %
|
|||
|
||||
"<%= @comment.body %>"
|
||||
|
||||
To reply to this comment, please go to <%= h( admin_conference_event_url(@conference.short_title, @event)) %>
|
||||
To reply to this comment, please go to <%= h(admin_conference_program_event_url(@conference.short_title, @event, only_path: false)) %>
|
||||
|
||||
Best wishes,
|
||||
<%= @conference.title %> Team
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@
|
|||
= f.input :send_on_rejected, label: "Send an email when the proposal is rejected?", :input_html => {"data-name"=>"email_settings_rejected_subject", "class"=>"send_on_radio"}
|
||||
= f.input :rejected_subject
|
||||
= f.input :rejected_body, :input_html => { :rows => 10, :cols => 20 }
|
||||
%a.btn.btn-link.control_label.load_template{"data-template"=>"Dear {name},\n\nThank you for your submission {eventtitle} for the conference {conference}.\nAfter careful consideration we are sorry to inform you that your submissionhas been rejected.\n\n\nBest wishes\n\n{conference} Team",
|
||||
%a.btn.btn-link.control_label.load_template{"data-template"=>"Dear {name},\n\nThank you for your submission {eventtitle} for the conference {conference}.\nAfter careful consideration we are sorry to inform you that your submission has been rejected.\n\n\nBest wishes\n\n{conference} Team",
|
||||
"data-name"=>"email_settings_rejected_body"} Load Template
|
||||
%a.btn.btn-link.control_label.template_help_link{"data-name"=>"rejected_help"} Show Help
|
||||
= render partial: 'help', locals: {id: 'rejected_help', show_event_variables: true}
|
||||
|
|
|
|||
82
spec/mailers/mailbot_spec.rb
Normal file
82
spec/mailers/mailbot_spec.rb
Normal file
|
|
@ -0,0 +1,82 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe Mailbot do
|
||||
let(:conference) { create(:conference) }
|
||||
let!(:email_settings) { create(:email_settings, conference: conference) }
|
||||
let(:user) { create(:user, email: 'user@example.com') }
|
||||
|
||||
before { conference.contact.update_attributes(email: 'conf@domain.com') }
|
||||
|
||||
context 'onboarding and proposal' do
|
||||
let(:event_user) { create(:submitter, user: user) }
|
||||
let(:event) { create(:event, program: conference.program, event_users: [event_user]) }
|
||||
|
||||
shared_examples 'mailer actions' do
|
||||
it 'assigns the email subject' do
|
||||
expect(mail.subject).to eq 'Lorem Ipsum Dolsum'
|
||||
end
|
||||
|
||||
it 'assigns the email receiver, sender, reply_to' do
|
||||
expect(mail.to).to eq ['user@example.com']
|
||||
expect(mail.from).to eq ['conf@domain.com']
|
||||
expect(mail.reply_to).to eq ['conf@domain.com']
|
||||
end
|
||||
|
||||
it 'assigns the email body' do
|
||||
expect(mail.body).to eq 'Lorem ipsum dolor sit amet, consectetuer adipiscing elit'
|
||||
end
|
||||
end
|
||||
|
||||
describe '.registration_mail' do
|
||||
include_examples 'mailer actions' do
|
||||
let(:mail) { Mailbot.registration_mail conference, user }
|
||||
end
|
||||
end
|
||||
|
||||
describe '.acceptance_mail' do
|
||||
before do
|
||||
conference.email_settings.update_attributes(send_on_accepted: true,
|
||||
accepted_subject: 'Lorem Ipsum Dolsum',
|
||||
accepted_body: 'Lorem ipsum dolor sit amet, consectetuer adipiscing elit')
|
||||
end
|
||||
|
||||
include_examples 'mailer actions' do
|
||||
let(:mail) { Mailbot.acceptance_mail event }
|
||||
end
|
||||
end
|
||||
|
||||
describe '.rejection_mail' do
|
||||
before do
|
||||
conference.email_settings.update_attributes(send_on_rejected: true,
|
||||
rejected_subject: 'Lorem Ipsum Dolsum',
|
||||
rejected_body: 'Lorem ipsum dolor sit amet, consectetuer adipiscing elit')
|
||||
end
|
||||
|
||||
include_examples 'mailer actions' do
|
||||
let(:mail) { Mailbot.rejection_mail event }
|
||||
end
|
||||
end
|
||||
|
||||
describe '.confirm_reminder_mail' do
|
||||
before do
|
||||
conference.email_settings.update_attributes(send_on_confirmed_without_registration: true,
|
||||
confirmed_without_registration_subject: 'Lorem Ipsum Dolsum',
|
||||
confirmed_without_registration_body: 'Lorem ipsum dolor sit amet, consectetuer adipiscing elit')
|
||||
end
|
||||
|
||||
include_examples 'mailer actions' do
|
||||
let(:mail) { Mailbot.confirm_reminder_mail event }
|
||||
end
|
||||
end
|
||||
|
||||
describe '.build_email' do
|
||||
include_examples 'mailer actions' do
|
||||
let(:mail) { Mailbot.build_email conference, 'user@example.com', 'Lorem Ipsum Dolsum', 'Lorem ipsum dolor sit amet, consectetuer adipiscing elit' }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context 'update notifications' do
|
||||
it 'is a pending test'
|
||||
end
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue