discourse/spec/mailers/invite_mailer_spec.rb
Andy Waite 3e50313fdc Prepare for separation of RSpec helper files
Since rspec-rails 3, the default installation creates two helper files:
* `spec_helper.rb`
* `rails_helper.rb`

`spec_helper.rb` is intended as a way of running specs that do not
require Rails, whereas `rails_helper.rb` loads Rails (as Discourse's
current `spec_helper.rb` does).

For more information:

https://www.relishapp.com/rspec/rspec-rails/docs/upgrade#default-helper-files

In this commit, I've simply replaced all instances of `spec_helper` with
`rails_helper`, and renamed the original `spec_helper.rb`.

This brings the Discourse project closer to the standard usage of RSpec
in a Rails app.

At present, every spec relies on loading Rails, but there are likely
many that don't need to. In a future pull request, I hope to introduce a
separate, minimal `spec_helper.rb` which can be used in tests which
don't rely on Rails.
2015-12-01 20:39:42 +00:00

77 lines
2.1 KiB
Ruby

require "rails_helper"
describe InviteMailer do
describe "send_invite" do
context "invite to site" do
let(:invite) { Fabricate(:invite) }
let(:invite_mail) { InviteMailer.send_invite(invite) }
it 'renders the invitee email' do
expect(invite_mail.to).to eql([invite.email])
end
it 'renders the subject' do
expect(invite_mail.subject).to be_present
end
it 'renders site domain name in subject' do
expect(invite_mail.subject).to match(Discourse.current_hostname)
end
it 'renders the body' do
expect(invite_mail.body).to be_present
end
it 'renders the inviter email' do
expect(invite_mail.from).to eql([SiteSetting.notification_email])
end
it 'renders invite link' do
expect(invite_mail.body.encoded).to match("#{Discourse.base_url}/invites/#{invite.invite_key}")
end
end
context "invite to topic" do
let(:topic) { Fabricate(:topic, excerpt: "Topic invite support is now available in Discourse!") }
let(:invite) { topic.invite(topic.user, 'name@example.com') }
let(:invite_mail) { InviteMailer.send_invite(invite) }
it 'renders the invitee email' do
expect(invite_mail.to).to eql(['name@example.com'])
end
it 'renders the subject' do
expect(invite_mail.subject).to be_present
end
it 'renders topic title in subject' do
expect(invite_mail.subject).to match(topic.title)
end
it 'renders site domain name in subject' do
expect(invite_mail.subject).to match(Discourse.current_hostname)
end
it 'renders the body' do
expect(invite_mail.body).to be_present
end
it 'renders the inviter email' do
expect(invite_mail.from).to eql([SiteSetting.notification_email])
end
it 'renders invite link' do
expect(invite_mail.body.encoded).to match("#{Discourse.base_url}/invites/#{invite.invite_key}")
end
it 'renders topic title' do
expect(invite_mail.body.encoded).to match(topic.title)
end
end
end
end