From 61c9d3ca636df171228640065a75a0ea312e39ef Mon Sep 17 00:00:00 2001 From: Collin Jilbert Date: Wed, 29 Nov 2023 06:34:25 -0600 Subject: [PATCH 1/3] add issue/bug and PR templates --- .github/ISSUE_TEMPLATE/issue_template.md | 57 ++++++++++++++++++++++++ .github/pull_request_template.md | 28 ++++++++++++ 2 files changed, 85 insertions(+) create mode 100644 .github/ISSUE_TEMPLATE/issue_template.md create mode 100644 .github/pull_request_template.md diff --git a/.github/ISSUE_TEMPLATE/issue_template.md b/.github/ISSUE_TEMPLATE/issue_template.md new file mode 100644 index 00000000..9705f211 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/issue_template.md @@ -0,0 +1,57 @@ +--- +name: 🐞 Bug +about: File a bug/issue +title: '[BUG] ' +labels: Bug, Needs Triage +assignees: '' + +--- + +## Bug Report + +**Describe the Bug:** +<!-- A clear and concise description of the bug --> + +**To Reproduce:** +<!-- Steps to reproduce the behavior --> + +1. Step 1 +2. Step 2 +3. ... + +**Expected Behavior:** +<!-- A clear and concise description of what you expected to happen --> + +**Actual Behavior:** +<!-- A clear and concise description of what actually happened --> + +**Screenshots (if applicable):** +<!-- If applicable, add screenshots to help explain your problem --> + +**Environment:** +- Noticed gem version: <!-- Specify the version of the Noticed gem where the bug occurred --> +- Ruby version: <!-- Specify the version of Ruby you are using --> +- Rails version: <!-- Specify the version of Rails you are using --> +- Operating System: <!-- Specify your operating system --> + +**Additional Context:** +<!-- Add any other context about the problem here --> + +**Possible Fix:** +<!-- If you have suggestions on how to fix the bug, you can provide them here --> + +**Steps to Reproduce with Fix (if available):** +<!-- If you have a fix, outline the steps to reproduce the bug using your fix --> + +**Related Issues:** +<!-- If applicable, reference any related GitHub issues or pull requests --> + +**Labels to Apply:** +<!-- Suggest labels that should be applied to this issue --> + +**Checklist:** +<!-- Make sure all of these items are completed before submitting the issue --> + +- [ ] I have searched for similar issues and couldn't find any +- [ ] I have checked the documentation for relevant information +- [ ] I have included all the required information \ No newline at end of file diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md new file mode 100644 index 00000000..293a0f4f --- /dev/null +++ b/.github/pull_request_template.md @@ -0,0 +1,28 @@ +## Pull Request + +**Summary:** +<!-- Provide a brief summary of the changes in this pull request --> + +**Related Issue:** +<!-- If applicable, reference the GitHub issue that this pull request resolves --> + +**Description:** +<!-- Elaborate on the changes made in this pull request. What motivated these changes? --> + +**Testing:** +<!-- Describe the steps you've taken to test the changes. Include relevant information for other contributors to verify the modifications --> + +**Screenshots (if applicable):** +<!-- Include any relevant screenshots or GIFs that demonstrate the changes --> + +**Checklist:** +<!-- Make sure all of these items are completed before submitting the pull request --> + +- [ ] Code follows the project's coding standards +- [ ] Tests have been added or updated to cover the changes +- [ ] Documentation has been updated (if applicable) +- [ ] All existing tests pass +- [ ] Conforms to the contributing guidelines + +**Additional Notes:** +<!-- Any additional information or notes for the reviewers --> \ No newline at end of file From 86893cd4c2bf7b4f27145c4f2c01ea929b402656 Mon Sep 17 00:00:00 2001 From: Ryan Romanchuk <rromanchuk@gmail.com> Date: Mon, 15 Jan 2024 08:05:50 -0600 Subject: [PATCH 2/3] This would raise undefined (#358) --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index b87f062f..e6c9ec00 100644 --- a/README.md +++ b/README.md @@ -314,7 +314,7 @@ end Delivery methods have access to the following methods and attributes: -* `notification` - The instance of the Notification. You can call methods on the notification to let the user easily override formatting and other functionality of the delivery method. +* `record` - The instance of the Notification. You can call methods on the notification to let the user easily override formatting and other functionality of the delivery method. * `options` - Any configuration options on the `deliver_by` line. * `recipient` - The object who should receive the notification. This is typically a User, Account, or other ActiveRecord model. * `params` - The params passed into the notification. This is details about the event that happened. For example, a user commenting on a post would have params of `{ user: User.first }` From ffa31e713cf27ca3a9f7b642b6acaf4222d7310e Mon Sep 17 00:00:00 2001 From: Danylo Yemchenko <yemchenko.dan@hey.com> Date: Mon, 15 Jan 2024 16:57:08 +0200 Subject: [PATCH 3/3] Fix NoMethodError when using method with Pathname as FCM credentials (#350) --- lib/noticed/delivery_methods/fcm.rb | 11 +++++------ test/delivery_methods/fcm_test.rb | 20 +++++++++++++++++++- 2 files changed, 24 insertions(+), 7 deletions(-) diff --git a/lib/noticed/delivery_methods/fcm.rb b/lib/noticed/delivery_methods/fcm.rb index c18cde28..14edb34a 100644 --- a/lib/noticed/delivery_methods/fcm.rb +++ b/lib/noticed/delivery_methods/fcm.rb @@ -36,15 +36,14 @@ def cleanup_invalid_token(device_token) def credentials @credentials ||= begin option = options[:credentials] - credentials_hash = case option + credentials_to_parse = option.is_a?(Symbol) ? notification.send(option) : option + credentials_hash = case credentials_to_parse when Hash - option + credentials_to_parse when Pathname - load_json(option) + load_json(credentials_to_parse) when String - load_json(Rails.root.join(option)) - when Symbol - notification.send(option) + load_json(Rails.root.join(credentials_to_parse)) else Rails.application.credentials.fcm end diff --git a/test/delivery_methods/fcm_test.rb b/test/delivery_methods/fcm_test.rb index fd7e4a8e..a17940d4 100644 --- a/test/delivery_methods/fcm_test.rb +++ b/test/delivery_methods/fcm_test.rb @@ -7,6 +7,14 @@ def fcm_credentials {project_id: "api-12345"} end + def fcm_credentials_as_pathname + Rails.root.join("config/credentials/fcm.json") + end + + def fcm_credentials_as_string + "config/credentials/fcm.json" + end + def format_notification(device_token) { token: device_token, @@ -44,11 +52,21 @@ class FcmTest < ActiveSupport::TestCase assert_equal credentials_hash, Noticed::DeliveryMethods::Fcm.new.assign_args(notification_class: "FcmExample", options: {credentials: "config/credentials/fcm.json"}).credentials end - test "when credentials option is a symbol, it returns the return value of the method" do + test "when credentials option is a symbol and return value of a method is a hash, it returns the hash" do credentials_hash = {project_id: "api-12345"} assert_equal credentials_hash, Noticed::DeliveryMethods::Fcm.new.assign_args(notification_class: "FcmExample", options: {credentials: :fcm_credentials}).credentials end + test "when credentials option is a symbol and return value of a method is a Pathname object, it returns the file contents" do + credentials_hash = {project_id: "api-12345"} + assert_equal credentials_hash, Noticed::DeliveryMethods::Fcm.new.assign_args(notification_class: "FcmExample", options: {credentials: :fcm_credentials_as_pathname}).credentials + end + + test "when credentials option is a symbol and return value of a method is a string, it returns the file contents" do + credentials_hash = {project_id: "api-12345"} + assert_equal credentials_hash, Noticed::DeliveryMethods::Fcm.new.assign_args(notification_class: "FcmExample", options: {credentials: :fcm_credentials_as_string}).credentials + end + test "project_id returns the project id value from the credentials" do assert_equal "api-12345", Noticed::DeliveryMethods::Fcm.new.assign_args(notification_class: "FcmExample", options: {credentials: :fcm_credentials}).project_id end