Skip to content

Commit

Permalink
Merge branch 'master' of github.com:railsgirlslondon/railsgirls-londo…
Browse files Browse the repository at this point in the history
…n into staging
  • Loading branch information
despo committed Sep 25, 2013
2 parents 12c357f + 26e5f57 commit fcb8816
Show file tree
Hide file tree
Showing 6 changed files with 70 additions and 1 deletion.
7 changes: 7 additions & 0 deletions app/mailers/event_mailer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,13 @@ def confirm_attendance event, registration, invitation
send_email(subject)
end

def invitation_reminder event, registration, invitation
setup event, registration, invitation

subject = "Rails Girls #{@event.city_name} - Please RSVP your attendance"
send_email(subject)
end

private

def attach_ical_file event
Expand Down
6 changes: 6 additions & 0 deletions app/models/extentions/invitable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@ def invite invitee
invitations.create invitee: invitee
end

def send_reminders
invitations.pending.each do |invitation|
invitation.send_reminder
end
end

def has_available_slots?
available_slots and available_slots > invitations.accepted.count
end
Expand Down
6 changes: 6 additions & 0 deletions app/models/invitation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ class Invitation < ActiveRecord::Base
i.waiting_list_was == true }

scope :accepted, -> { where(attending: true) }
scope :pending_response, -> { where(attending: nil, waiting_list: nil) }

scope :waiting_list, -> { where(waiting_list: true).order('invitations.updated_at ASC') }

default_scope -> { order('updated_at DESC') }
Expand All @@ -30,6 +32,10 @@ def send_confirmation
invitable.email :confirm_attendance, self.invitee, self
end

def send_reminder
invitable.email :invitation_reminder, self.invitee, self
end

def to_param
self.token
end
Expand Down
23 changes: 23 additions & 0 deletions app/views/event_mailer/invitation_reminder.html.haml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
%h3{style: "border-bottom: 1px solid #E5E5E5; color: #434950; font-size: 26px; font-weight: 400; line-height: 30px; padding-bottom: 10px; margin-bottom: 15px;" }
Hi
#{@registration.first_name},

.content
.left.inline{ style: "width: 100%; min-width: 260px; display: inline-block;" }
%p.lead{ style: "font-size: 18px; color: #333333; padding-bottom: 10px; line-height: 22px;"}
We noticed that you have not yet RSVPed in order to claim your place at our #{@event.title if @event.title.present?} workshop!
.title{ style: "border-left: 4px solid #E5E5E5; font-size: 26.5px; margin: 0px 0 11px 0; padding: 0 10px;" }= @event.dates
=link_to "View details", full_url_for(city_event_url(@city, @event)), style: "color: #E0330C; text-decoration: none; border-bottom: 1px dotted #E0330C; "

%p.lead{ style: "font-size: 18px; color: #333333; padding-bottom: 10px; line-height: 22px;"}
Please note your place will be reallocated if you don't respond by <strong> #{@event.rsvp_end_date.strftime("%A")} the #{@event.rsvp_end_date.day.ordinalize} of #{@event.rsvp_end_date.strftime("%B %Y")}</strong>.

%div{style: "background-color: #F7F7F7; border-radius: 5px; box-shadow: 1px 1px 0 rgba(250, 250, 250, 0.5) inset, -1px -1px 2px rgba(250, 250, 250, 0.1) inset; font-size: 18px; padding: 12px 19px; text-align: center; margin: 31px 0 25px; border: 1px solid #dddddd;"}
=link_to "Confirm your attendance", full_url_for(invitation_url(@invitation)), style: "color: #eb5d42; text-decoration: none; font-weight: 500; text-shadow: 0 1px 0 rgba(255, 255, 255, 0.7)"

.right.inline{ style: "width: 100%; min-width: 180px; margin-top: 25px; display: inline-block;" }
=image_tag attachments['london-girl.png'].url, width: '180px'
%div{style: "margin: 15px 0; "}
%highlight{ style: "color: #333333; text-align: center; font-weight: 500; font-size: 13px" }You learn designing, prototyping and coding with the help of our coaches.
%p.lead{ style: "font-size: 15px; color: #4E5563; margin-top: 25px;" }
%strong Hope to see you at the workshop!
17 changes: 17 additions & 0 deletions spec/mailers/event_mailer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,23 @@
include_examples "an event email"
end

context "invitation_reminder email" do
let(:subject) {
"Rails Girls #{event.city_name} - Please RSVP your attendance"
}

before do
EventMailer.invitation_reminder(event, invitation.invitee, invitation).deliver
end

it "sends an invitation reminder email" do
expect(html_body).to include(invitation.invitee.first_name)
expect(html_body).to include(invitation_url(invitation))
end

include_examples "an event email"
end

context "confirmation email" do
let(:subject) {
"RG#{event.city_name.slice(0)} - You are confirmed for #{event.title} #{event.dates}"
Expand Down
12 changes: 11 additions & 1 deletion spec/models/invitation_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
context "scopes" do

let!(:attending) { 3.times.map { Fabricate(:accepted_invitation, invitable: meeting) }.reverse }
let!(:no_reponse) { 2.times.map { Fabricate(:invitation, invitable: meeting) } }
let!(:no_response) { 2.times.map { Fabricate(:invitation, invitable: meeting) } }
let!(:waiting_list) { 5.times.map { Fabricate(:waiting_invitation, invitable: meeting) } }

it "#accepted" do
Expand All @@ -19,6 +19,10 @@
it "#waiting_list" do
meeting.invitations.waiting_list.should eq waiting_list
end

it "#pending_response" do
meeting.invitations.pending_response.should eq no_response.reverse
end
end

context "hooks" do
Expand Down Expand Up @@ -65,5 +69,11 @@

invitation.send_confirmation
end

it "#send_reminder" do
invitation.invitable.should_receive(:email).with(:invitation_reminder, invitation.invitee, invitation)

invitation.send_reminder
end
end
end

0 comments on commit fcb8816

Please sign in to comment.