-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into Pralishentity_specific_analytics
- Loading branch information
Showing
16 changed files
with
131 additions
and
25 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
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
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
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 |
---|---|---|
|
@@ -81,6 +81,15 @@ error_api_action_one: | |
email: [email protected] | ||
api_namespace: one | ||
|
||
error_api_action_one_with_api_resource_data: | ||
type: ErrorApiAction | ||
action_type: send_email | ||
include_api_resource_data: true | ||
payload_mapping: | ||
redirect_url: | ||
email: [email protected] | ||
api_namespace: one | ||
|
||
error_api_action_two: | ||
type: ErrorApiAction | ||
action_type: redirect | ||
|
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,29 @@ | ||
require "test_helper" | ||
|
||
class ApiActionMailerTest < ActionMailer::TestCase | ||
test 'sends email without api_resource if not included in api action' do | ||
@api_action_1 = api_actions(:error_api_action_one) | ||
@api_action_1.update(email_subject: "") | ||
@api_action_2 = ErrorApiAction.create(@api_action_1.attributes.merge(custom_message: @api_action_1.custom_message.to_s, parent_id: @api_action_1.id, meta_data: { api_resource: { errors: "Error Occured!", properties: {"Null"=>"", "Array"=>"", "Number"=>"", "Object"=>{"a"=>"b", "c"=>"d"}, "String"=>"", "Boolean"=>"false"} }, namespace: { name: "Namespace1" } }).except("id", "created_at", "updated_at", "api_namespace_id")) | ||
|
||
email = ApiActionMailer.send_email(@api_action_2) | ||
assert_emails 1 do | ||
email.deliver_later | ||
end | ||
refute_includes email.body, @api_action_2.meta_data["api_resource"]["properties"] | ||
assert_equal "#{@api_action_2.type} #{@api_action_2.api_namespace_action&.api_namespace&.name.pluralize} v#{@api_action_2.api_namespace_action&.api_namespace&.version}", email.subject | ||
end | ||
|
||
test 'sends email with api_resource if included in api action' do | ||
@api_action_1 = api_actions(:error_api_action_one_with_api_resource_data) | ||
@api_action_1.update(email_subject: "") | ||
@api_action_2 = ErrorApiAction.create(@api_action_1.attributes.merge(custom_message: @api_action_1.custom_message.to_s, parent_id: @api_action_1.id, meta_data: { api_resource: { errors: "Error Occured!", properties: {"Null"=>"", "Array"=>"", "Number"=>"", "Object"=>{"a"=>"b", "c"=>"d"}, "String"=>"", "Boolean"=>"false"} }, namespace: { name: "Namespace1" } }).except("id", "created_at", "updated_at", "api_namespace_id")) | ||
|
||
email = ApiActionMailer.send_email(@api_action_2) | ||
assert_emails 1 do | ||
email.deliver_later | ||
end | ||
assert_includes CGI.unescapeHTML(email.body.to_s), @api_action_2.meta_data["api_resource"]["properties"].to_s | ||
assert_equal "#{@api_action_2.type} #{@api_action_2.api_namespace_action&.api_namespace&.name.pluralize} v#{@api_action_2.api_namespace_action&.api_namespace&.version}", email.subject | ||
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