-
Notifications
You must be signed in to change notification settings - Fork 67
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update email config and add email notification push on sync run statu…
…s change
- Loading branch information
1 parent
cb7a36f
commit 1c063e2
Showing
10 changed files
with
134 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,18 @@ | ||
# frozen_string_literal: true | ||
|
||
class SyncRunMailer < ApplicationMailer | ||
default from: ENV['SMTP_USERNAME'] | ||
default from: Rails.configuration.x.mail_from | ||
|
||
def status_email | ||
@sync_run = params[:sync_run] | ||
@sync = @sync_run.sync | ||
@sync_status = @sync_run.status | ||
mail(to: params[:recipient], subject: "Sync run status update") | ||
@source_connector_name = @sync_run.sync.source.name | ||
@destination_connector_name = @sync_run.sync.destination.name | ||
host = Rails.configuration.action_mailer.default_url_options[:host] | ||
@sync_run_url = "#{host}/activate/syncs/#{@sync.id}/run/#{@sync_run.id}" | ||
mail(to: params[:recipient], subject: "Sync run status update") do |format| | ||
format.html { render layout: false } | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
Premailer::Rails.config.merge!( | ||
adapter: :nokogiri, | ||
generate_text_part: false | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,42 @@ | ||
# frozen_string_literal: true | ||
|
||
require "rails_helper" | ||
|
||
RSpec.describe SyncRunMailer, type: :mailer do | ||
pending "add some examples to (or delete) #{__FILE__}" | ||
describe "#status_email" do | ||
let(:source) do | ||
create(:connector, connector_type: "source", connector_name: "Snowflake") | ||
end | ||
let(:destination) { create(:connector, connector_type: "destination") } | ||
let!(:catalog) { create(:catalog, connector: destination) } | ||
let(:sync) { create(:sync, source:, destination:) } | ||
let(:sync_run) do | ||
create(:sync_run, sync:, workspace: sync.workspace, source:, destination:, model: sync.model, status: "success") | ||
end | ||
let(:sync_run_pending) do | ||
create(:sync_run, sync:, workspace: sync.workspace, source:, destination:, model: sync.model, status: "pending") | ||
end | ||
let(:recipient) { "test@example.com" } | ||
let(:mail) { SyncRunMailer.with(sync_run:, recipient:).status_email } | ||
|
||
it "renders the headers" do | ||
expect(mail.subject).to eq("Sync run status update") | ||
expect(mail.to).to eq([recipient]) | ||
expect(mail.from).to eq(["noreply@multiwoven.com"]) | ||
end | ||
|
||
it "renders the body" do | ||
expect(mail.body.encoded).to match(sync_run.status) | ||
expect(mail.body.encoded).to match(sync.source.name) | ||
expect(mail.body.encoded).to match(sync.destination.name) | ||
host = Rails.configuration.action_mailer.default_url_options[:host] | ||
url = "#{host}/activate/syncs/#{sync.id}/run/#{sync_run.id}" | ||
expect(mail.body.encoded).to match(url) | ||
end | ||
|
||
it "assigns @sync_run_url" do | ||
expect(mail.body.encoded).to match(sync_run.sync.id.to_s) | ||
expect(mail.body.encoded).to match(sync_run.id.to_s) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters