Initial commit
This commit is contained in:
70
spec/mailers/admin_mailer_spec.rb
Normal file
70
spec/mailers/admin_mailer_spec.rb
Normal file
@@ -0,0 +1,70 @@
|
||||
require "rails_helper"
|
||||
|
||||
RSpec.describe AdminMailer do
|
||||
describe ".new_video" do
|
||||
let(:project) { build(:project, account: build(:account, name: "Test Account")) }
|
||||
let(:video) { create(:video, project: project) }
|
||||
let(:mail) { AdminMailer.new_video(video) }
|
||||
|
||||
it "renders the headers" do
|
||||
expect(mail.subject).to eq("[New Video] Test Account has uploaded a new video")
|
||||
expect(mail.to).to eq(["bray@bigmedia.ai", "lee@bigmedia.ai"])
|
||||
expect(mail.from).to eq(["support@bigmedia.ai"])
|
||||
end
|
||||
|
||||
it "renders the body" do
|
||||
expect(mail.body.encoded).to match(video_video_analyses_path(video, locale: I18n.locale))
|
||||
end
|
||||
end
|
||||
|
||||
describe ".updated_video_edl_file" do
|
||||
let(:project) { build(:project, account: build(:account, name: "Test Account")) }
|
||||
let(:video) { create(:video, project: project) }
|
||||
let(:mail) { AdminMailer.updated_video_edl_file(video) }
|
||||
|
||||
it "renders the headers" do
|
||||
expect(mail.subject).to eq("[Updated Video EDL File] Test Account has updated the EDL file for video_file.mp4")
|
||||
expect(mail.to).to eq(["bray@bigmedia.ai", "lee@bigmedia.ai"])
|
||||
expect(mail.from).to eq(["support@bigmedia.ai"])
|
||||
end
|
||||
|
||||
it "renders the body" do
|
||||
expect(mail.body.encoded).to match(video_video_analyses_path(video, locale: I18n.locale))
|
||||
expect(mail.body.encoded).to include "An EDL file has been updated"
|
||||
end
|
||||
end
|
||||
|
||||
describe ".updated_video_graphics_only_edl_file" do
|
||||
let(:project) { build(:project, account: build(:account, name: "Test Account")) }
|
||||
let(:video) { create(:video, project: project) }
|
||||
let(:mail) { AdminMailer.updated_video_graphics_only_edl_file(video) }
|
||||
|
||||
it "renders the headers" do
|
||||
expect(mail.subject).to eq("[Updated Video Graphics Only EDL File] Test Account has updated the Graphics Only EDL file for video_file.mp4")
|
||||
expect(mail.to).to eq(["bray@bigmedia.ai", "lee@bigmedia.ai"])
|
||||
expect(mail.from).to eq(["support@bigmedia.ai"])
|
||||
end
|
||||
|
||||
it "renders the body" do
|
||||
expect(mail.body.encoded).to match(video_video_analyses_path(video, locale: I18n.locale))
|
||||
expect(mail.body.encoded).to include "A Graphics Only EDL file has been updated"
|
||||
end
|
||||
end
|
||||
|
||||
describe ".updated_video_audio_only_edl_file" do
|
||||
let(:project) { build(:project, account: build(:account, name: "Test Account")) }
|
||||
let(:video) { create(:video, project: project) }
|
||||
let(:mail) { AdminMailer.updated_video_audio_only_edl_file(video) }
|
||||
|
||||
it "renders the headers" do
|
||||
expect(mail.subject).to eq("[Updated Video Audio Only EDL File] Test Account has updated the Audio Only EDL file for video_file.mp4")
|
||||
expect(mail.to).to eq(["bray@bigmedia.ai", "lee@bigmedia.ai"])
|
||||
expect(mail.from).to eq(["support@bigmedia.ai"])
|
||||
end
|
||||
|
||||
it "renders the body" do
|
||||
expect(mail.body.encoded).to match(video_video_analyses_path(video, locale: I18n.locale))
|
||||
expect(mail.body.encoded).to include "An Audio Only EDL file has been updated"
|
||||
end
|
||||
end
|
||||
end
|
||||
7
spec/mailers/previews/admin_preview.rb
Normal file
7
spec/mailers/previews/admin_preview.rb
Normal file
@@ -0,0 +1,7 @@
|
||||
class AdminPreview < ActionMailer::Preview
|
||||
def new_video
|
||||
video = FactoryBot.build_stubbed(:video)
|
||||
|
||||
AdminMailer.new_video(video)
|
||||
end
|
||||
end
|
||||
27
spec/mailers/previews/user_preview.rb
Normal file
27
spec/mailers/previews/user_preview.rb
Normal file
@@ -0,0 +1,27 @@
|
||||
class UserPreview < ActionMailer::Preview
|
||||
def password_reset
|
||||
UserMailer.password_reset(user)
|
||||
end
|
||||
|
||||
def project_invitation
|
||||
UserMailer.project_invitation(user, project, user_is_new: true)
|
||||
end
|
||||
|
||||
def welcome
|
||||
UserMailer.welcome(user)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def account
|
||||
OpenStruct.new(name: "Preview Account")
|
||||
end
|
||||
|
||||
def user
|
||||
OpenStruct.new(email: "preview@test.com", password_reset_token: "123abc", account: account)
|
||||
end
|
||||
|
||||
def project
|
||||
OpenStruct.new(name: "Preview Project", account: account)
|
||||
end
|
||||
end
|
||||
61
spec/mailers/user_mailer_spec.rb
Normal file
61
spec/mailers/user_mailer_spec.rb
Normal file
@@ -0,0 +1,61 @@
|
||||
require "rails_helper"
|
||||
|
||||
describe UserMailer do
|
||||
describe "password_reset" do
|
||||
let(:user) { create(:user) }
|
||||
let(:mail) { UserMailer.password_reset(user) }
|
||||
|
||||
it "renders the headers" do
|
||||
expect(mail.subject).to eq("Password reset")
|
||||
expect(mail.to).to eq([user.email])
|
||||
expect(mail.from).to eq(["support@bigmedia.ai"])
|
||||
end
|
||||
|
||||
it "renders the body" do
|
||||
expect(mail.body.encoded).to match(edit_password_reset_path(id: user.password_reset_token))
|
||||
end
|
||||
end
|
||||
|
||||
describe "project_invitation" do
|
||||
let(:user) { create(:user) }
|
||||
let(:project) { create(:project) }
|
||||
let(:mail) { UserMailer.project_invitation(user, project) }
|
||||
|
||||
it "renders the headers" do
|
||||
expect(mail.subject).to eq("You've been added to a project in the ME Suite")
|
||||
expect(mail.to).to eq([user.email])
|
||||
expect(mail.from).to eq(["support@bigmedia.ai"])
|
||||
end
|
||||
|
||||
it "renders the body" do
|
||||
expect(mail.body.encoded).to match(user.primary_account.name)
|
||||
expect(mail.body.encoded).to match(project.name)
|
||||
expect(mail.body.encoded).not_to match(edit_password_reset_url(id: user.password_reset_token, host: AppHost.new.domain_with_port))
|
||||
end
|
||||
|
||||
context "when user is new" do
|
||||
let(:mail) { UserMailer.project_invitation(user, project, user_is_new: true) }
|
||||
|
||||
it "includes a link to set the user password" do
|
||||
expect(mail.body.encoded).to match(edit_password_reset_url(id: user.password_reset_token, host: AppHost.new.domain_with_port))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "welcome" do
|
||||
let(:user) { create(:user) }
|
||||
let(:account) { create(:account) }
|
||||
let(:mail) { UserMailer.welcome(user, account) }
|
||||
|
||||
it "renders the headers" do
|
||||
expect(mail.subject).to eq("Welcome to BiG")
|
||||
expect(mail.to).to eq([user.email])
|
||||
expect(mail.from).to eq(["support@bigmedia.ai"])
|
||||
end
|
||||
|
||||
it "renders the body" do
|
||||
expect(mail.body.encoded).to match(user.primary_account.name)
|
||||
expect(mail.body.encoded).to match(edit_password_reset_url(id: user.password_reset_token, host: AppHost.new.domain_with_port))
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user