activity_notification 1.6.0 → 1.6.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 24f6a30a0e5feec1ffcb217bf78fa3283f4e369b
4
- data.tar.gz: efc4c998546752ccc9bca15a2d6d35e93d9e13eb
3
+ metadata.gz: c4bddcd228924d6a594bb826a9e815a5bc31baed
4
+ data.tar.gz: 0d2e2517c32fab5cf3310d1f6261ee1a40323c52
5
5
  SHA512:
6
- metadata.gz: c30d75ab0300d5895d341fe7ca2f89b039a0cc5db82c9708b335409557aa49da457e81a74a29ad4c01b0d28f93a4abf5d7652effbaad4e0e58a337187361d743
7
- data.tar.gz: 81698f2ec06b1cc880555a1103e24348f00ab2209621e47c3b2336dc0fb747ee96f765decca07b5e6ac230455927616d393c748efa90f31f294fa3dc8d0f618a
6
+ metadata.gz: 3015810028cce0174fb091f46ded488310307e527b16b27f36bd72942112356373dbac8c9ed5e4ff2e2ebfb55fb4d33878003bf7f46165c2a0cfe0e822e355a2
7
+ data.tar.gz: 13bf2aa5ec658cbbc95236e3fd83a2c48ce513a12bc2daa07ee788757cdf5d6516d75fa7f7e5f2fd0a0b9c0dffdbaac02746cb214407a066496dfdd9079645b5
@@ -1,9 +1,21 @@
1
+ ## 1.6.1 / 2018-11-19
2
+ [Full Changelog](http://github.com/simukappu/activity_notification/compare/v1.6.0...v1.6.1)
3
+
4
+ Enhancements:
5
+
6
+ * Update README.md to describe how to customize email subject - [#93](https://github.com/simukappu/activity_notification/issues/93)
7
+
8
+ Bug Fixes:
9
+
10
+ * Fix *notify_all* method to handle single notifiable target models - [#88](https://github.com/simukappu/activity_notification/issues/88)
11
+
1
12
  ## 1.6.0 / 2018-11-11
2
13
  [Full Changelog](http://github.com/simukappu/activity_notification/compare/v1.5.1...v1.6.0)
3
14
 
4
15
  Enhancements:
5
16
 
6
17
  * Add simple default routes with devise integration - [#64](https://github.com/simukappu/activity_notification/issues/64)
18
+ * Add *:routing_scope* option to support routes with scope - [#56](https://github.com/simukappu/activity_notification/issues/56)
7
19
 
8
20
  Bug Fixes:
9
21
 
data/README.md CHANGED
@@ -72,11 +72,13 @@
72
72
  - [Mailer setup](#mailer-setup)
73
73
  - [Sender configuration](#sender-configuration)
74
74
  - [Email templates](#email-templates)
75
+ - [Email subject](#email-subject)
75
76
  - [i18n for email](#i18n-for-email)
76
77
  - [Batch email notification](#batch-email-notification)
77
78
  - [Batch mailer setup](#batch-mailer-setup)
78
79
  - [Batch sender configuration](#batch-sender-configuration)
79
80
  - [Batch email templates](#batch-email-templates)
81
+ - [Batch email subject](#batch-email-subject)
80
82
  - [i18n for batch email](#i18n-for-batch-email)
81
83
  - [Grouping notifications](#grouping-notifications)
82
84
  - [Subscription management](#subscription-management)
@@ -673,6 +675,34 @@ config.mailer_sender = ->(key){ key == 'inquiry.post' ? 'support@example.com' :
673
675
 
674
676
  If this template is missing, the gem will look for a partial in *default* as the target type which means *activity_notification/mailer/default/_default.html.(|erb|haml|slim|something_else)*.
675
677
 
678
+ #### Email subject
679
+
680
+ *activity_notification* will use `"Notification of #{@notification.notifiable.printable_type.downcase}"` as default email subject. If it is defined, *activity_notification* will resolve email subject from *overriding_notification_email_subject* method in notifiable models. You can customize email subject like this:
681
+
682
+ ```
683
+ class Comment < ActiveRecord::Base
684
+ belongs_to :article
685
+ belongs_to :user
686
+
687
+ acts_as_notifiable :users,
688
+ targets: ->(comment, key) {
689
+ ([comment.article.user] + comment.article.commented_users.to_a - [comment.user]).uniq
690
+ },
691
+ notifiable_path: :article_notifiable_path
692
+
693
+ def overriding_notification_email_subject(target, key)
694
+ if key == "comment.create"
695
+ "New comment to your article!"
696
+ else
697
+ "Notification for new comments!"
698
+ end
699
+ end
700
+ end
701
+
702
+ ```
703
+
704
+ If you use i18n for email, you can configure email subject in your locale files. See [i18n for email](#i18n-for-email).
705
+
676
706
  #### i18n for email
677
707
 
678
708
  The subject of notification email can be put in your locale *.yml* files as **mail_subject** field:
@@ -739,6 +769,12 @@ config.mailer_sender = ->(batch_key){ batch_key == 'batch.inquiry.post' ? 'suppo
739
769
 
740
770
  *activity_notification* will look for batch email template in the same way as email notification using *batch_key*.
741
771
 
772
+ #### Batch email subject
773
+
774
+ *activity_notification* will resolve batch email subject as the same way as [email subject](#email-subject) with *batch_key*.
775
+
776
+ If you use i18n for batch email, you can configure batch email subject in your locale files. See [i18n for batch email](#i18n-for-batch-email).
777
+
742
778
  #### i18n for batch email
743
779
 
744
780
  The subject of batch notification email also can be put in your locale *.yml* files as **mail_subject** field for *batch_key*.
@@ -189,7 +189,7 @@ module ActivityNotification
189
189
  # @option options [Hash<String, Hash>] :optional_targets ({}) Options for optional targets, keys are optional target name (:amazon_sns or :slack etc) and values are options
190
190
  # @return [Array<Notificaion>] Array of generated notifications
191
191
  def notify_all(targets, notifiable, options = {})
192
- targets.map { |target| target.notify_to(notifiable, options) }
192
+ targets.map { |target| notify_to(target, notifiable, options) }
193
193
  end
194
194
 
195
195
  # Generates notifications to one target.
@@ -1,3 +1,3 @@
1
1
  module ActivityNotification
2
- VERSION = "1.6.0"
2
+ VERSION = "1.6.1"
3
3
  end
@@ -0,0 +1,18 @@
1
+ unless ENV['AN_TEST_DB'] == 'mongodb'
2
+ class Dummy::DummyNotifiableTarget < ActiveRecord::Base
3
+ self.table_name = :users
4
+ acts_as_target
5
+ acts_as_notifiable :dummy_notifiable_targets, targets: -> (n, key) { Dummy::DummyNotifiableTarget.all }, tracked: true
6
+ end
7
+ else
8
+ class Dummy::DummyNotifiableTarget
9
+ include Mongoid::Document
10
+ include Mongoid::Timestamps
11
+ field :email, type: String, default: ""
12
+ field :name, type: String
13
+
14
+ include ActivityNotification::Models
15
+ acts_as_target
16
+ acts_as_notifiable :dummy_notifiable_targets, targets: -> (n, key) { Dummy::DummyNotifiableTarget.all }, tracked: true
17
+ end
18
+ end
@@ -83,6 +83,20 @@ describe ActivityNotification::ActsAsNotifiable do
83
83
  .to eq(@notifiable.notification_key_for_tracked_update)
84
84
  end
85
85
  end
86
+
87
+ context "when the target is also configured as notifiable" do
88
+ before do
89
+ ActivityNotification::Notification.filtered_by_type("Dummy::DummyNotifiableTarget").delete_all
90
+ Dummy::DummyNotifiableTarget.delete_all
91
+ @created_target = Dummy::DummyNotifiableTarget.create
92
+ @created_notifiable = Dummy::DummyNotifiableTarget.create
93
+ end
94
+
95
+ it "generates notifications to specified targets" do
96
+ expect(@created_target.notifications.filtered_by_instance(@created_notifiable).count).to eq(1)
97
+ expect(@created_notifiable.notifications.filtered_by_instance(@created_notifiable).count).to eq(1)
98
+ end
99
+ end
86
100
  end
87
101
 
88
102
  context "with :only option (creation only)" do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activity_notification
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.6.0
4
+ version: 1.6.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shota Yamazaki
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-11-11 00:00:00.000000000 Z
11
+ date: 2018-11-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: railties
@@ -417,6 +417,7 @@ files:
417
417
  - spec/rails_app/app/models/dummy/dummy_base.rb
418
418
  - spec/rails_app/app/models/dummy/dummy_group.rb
419
419
  - spec/rails_app/app/models/dummy/dummy_notifiable.rb
420
+ - spec/rails_app/app/models/dummy/dummy_notifiable_target.rb
420
421
  - spec/rails_app/app/models/dummy/dummy_notifier.rb
421
422
  - spec/rails_app/app/models/dummy/dummy_subscriber.rb
422
423
  - spec/rails_app/app/models/dummy/dummy_target.rb
@@ -573,6 +574,7 @@ test_files:
573
574
  - spec/rails_app/app/models/dummy/dummy_base.rb
574
575
  - spec/rails_app/app/models/dummy/dummy_group.rb
575
576
  - spec/rails_app/app/models/dummy/dummy_notifiable.rb
577
+ - spec/rails_app/app/models/dummy/dummy_notifiable_target.rb
576
578
  - spec/rails_app/app/models/dummy/dummy_notifier.rb
577
579
  - spec/rails_app/app/models/dummy/dummy_subscriber.rb
578
580
  - spec/rails_app/app/models/dummy/dummy_target.rb