-
-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- #1511 OK this is awkwardly named, but it is the first tiny step towards allowing us to manage multiple order notification emails without the silly comma separated value.
- Loading branch information
Showing
8 changed files
with
52 additions
and
3 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 |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# frozen_string_literal: true | ||
|
||
class Marketplace | ||
class OrderNotificationMethod < Record | ||
self.table_name = :marketplace_order_notification_methods | ||
location(parent: :marketplace) | ||
belongs_to :marketplace, inverse_of: :order_notification_methods | ||
|
||
has_encrypted :contact_location | ||
validates :contact_location, presence: true | ||
end | ||
end |
10 changes: 10 additions & 0 deletions
10
db/migrate/20230615002110_add_marketplace_order_notification_methods.rb
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,10 @@ | ||
class AddMarketplaceOrderNotificationMethods < ActiveRecord::Migration[7.0] | ||
def change | ||
create_table :marketplace_order_notification_methods, id: :uuid do |t| | ||
t.references :marketplace, type: :uuid, foreign_key: {to_table: :furnitures} | ||
t.string :contact_method, default: :email, null: false | ||
t.string :contact_location_ciphertext, null: false | ||
t.timestamps | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,22 @@ | ||
require "rails_helper" | ||
|
||
RSpec.describe Marketplace::Order::ReceivedMailer, type: :mailer do | ||
let(:marketplace) { build(:marketplace, notify_emails: "[email protected],[email protected]") } | ||
let(:marketplace) { create(:marketplace, notify_emails: "[email protected],[email protected]") } | ||
let(:order) { build(:marketplace_order, placed_at: 1.hour.ago, marketplace: marketplace) } | ||
|
||
describe "#notification" do | ||
subject(:notification) { described_class.notification(order) } | ||
|
||
it { is_expected.to be_to(marketplace.notify_emails.split(",")) } | ||
|
||
context "when the marketplace has a order notification contact location" do | ||
before do | ||
marketplace.order_notification_methods.create(contact_location: "[email protected]") | ||
end | ||
|
||
it { is_expected.to be_to(marketplace.notify_emails.split(",") + marketplace.order_notification_methods.map(&:contact_location)) } | ||
end | ||
|
||
it { is_expected.to have_subject(t(".notification.subject", marketplace_name: order.marketplace_name, order_id: order.id)) } | ||
|
||
specify do | ||
|
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,5 @@ | ||
require "rails_helper" | ||
|
||
RSpec.describe Marketplace::OrderNotificationMethod, type: :model do | ||
it { is_expected.to belong_to(:marketplace).inverse_of(:order_notification_methods) } | ||
end |