Switch handling logic of no_self_notified setting

pull/6827/head
Hagen Schink 10 years ago
parent 045f6564b5
commit 590bc1c434
  1. 2
      app/controllers/meeting_contents_controller.rb
  2. 20
      spec/controllers/meeting_contents_controller_spec.rb
  3. 2
      spec/mailers/meeting_mailer_spec.rb

@ -84,7 +84,7 @@ class MeetingContentsController < ApplicationController
def notify
unless @content.new_record?
recipients = @content.meeting.participants.collect{|p| p.mail}.reject{|r| r == @content.meeting.author.mail}
recipients << @content.meeting.author.mail if @content.meeting.author.preference[:no_self_notified]
recipients << @content.meeting.author.mail unless @content.meeting.author.preference[:no_self_notified]
recipients.each do |recipient|
MeetingMailer.content_for_review(@content, @content_type, recipient).deliver
end

@ -42,31 +42,33 @@ describe MeetingContentsController do
controller.instance_variable_set(:@content_type, 'meeting_agenda')
end
shared_examples_for 'delivered by mail' do
before { put "notify", meeting_id: meeting.id }
it { expect(ActionMailer::Base.deliveries.count).to eql(mail_count) }
end
describe "PUT" do
describe "notify" do
context "when author no_self_notified property is true" do
before do
author.pref[:no_self_notified] = true
author.save!
put "notify", :meeting_id => meeting.id
end
it 'should send mail to all meeting participants' do
expect(ActionMailer::Base.deliveries.count).to eql(3)
it_behaves_like 'delivered by mail' do
let(:mail_count) { 2 }
end
end
context "when author no_self_notified property is false" do
before do
author.pref[:no_self_notified] = false
author.save
put "notify", :meeting_id => meeting.id
author.save!
end
it 'should send mail to all meeting participants except author' do
expect(ActionMailer::Base.deliveries.count).to eql(2)
it_behaves_like 'delivered by mail' do
let(:mail_count) { 3 }
end
end
end

@ -32,7 +32,7 @@ describe MeetingMailer do
end
before(:each) do
author.pref[:no_self_notified] = true
author.pref[:no_self_notified] = false
author.save!
meeting.participants.merge([meeting.participants.build(user: watcher1, invited: true, attended: false),
meeting.participants.build(user: watcher1, invited: true, attended: false)])

Loading…
Cancel
Save