activity_notification 2.1.3 → 2.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +13 -1
  3. data/Gemfile +0 -2
  4. data/activity_notification.gemspec +1 -1
  5. data/docs/Functions.md +2 -2
  6. data/docs/Setup.md +176 -63
  7. data/gemfiles/Gemfile.rails-5.0 +1 -0
  8. data/gemfiles/Gemfile.rails-5.1 +1 -0
  9. data/gemfiles/Gemfile.rails-5.2 +1 -0
  10. data/gemfiles/Gemfile.rails-6.0 +0 -2
  11. data/lib/activity_notification/apis/notification_api.rb +7 -0
  12. data/lib/activity_notification/common.rb +4 -1
  13. data/lib/activity_notification/models/concerns/notifiable.rb +10 -10
  14. data/lib/activity_notification/models/concerns/swagger/notification_schema.rb +34 -34
  15. data/lib/activity_notification/models/concerns/swagger/subscription_schema.rb +17 -17
  16. data/lib/activity_notification/optional_targets/action_cable_api_channel.rb +1 -1
  17. data/lib/activity_notification/optional_targets/action_cable_channel.rb +1 -1
  18. data/lib/activity_notification/orm/dynamoid.rb +10 -3
  19. data/lib/activity_notification/orm/dynamoid/notification.rb +48 -13
  20. data/lib/activity_notification/orm/dynamoid/subscription.rb +1 -1
  21. data/lib/activity_notification/orm/mongoid.rb +10 -3
  22. data/lib/activity_notification/orm/mongoid/notification.rb +4 -4
  23. data/lib/activity_notification/roles/acts_as_notifiable.rb +2 -1
  24. data/lib/activity_notification/version.rb +1 -1
  25. data/spec/concerns/models/notifiable_spec.rb +35 -35
  26. data/spec/config_spec.rb +26 -15
  27. data/spec/rails_app/app/controllers/users_controller.rb +5 -0
  28. data/spec/rails_app/app/javascript/App.vue +8 -72
  29. data/spec/rails_app/app/javascript/components/DeviseTokenAuth.vue +3 -4
  30. data/spec/rails_app/app/javascript/components/Top.vue +2 -3
  31. data/spec/rails_app/app/javascript/packs/spa.js +6 -3
  32. data/spec/rails_app/app/javascript/router/index.js +73 -0
  33. data/spec/rails_app/app/javascript/store/{auth.js → index.js} +0 -0
  34. data/spec/rails_app/app/models/dummy/dummy_group.rb +8 -0
  35. data/spec/rails_app/app/models/dummy/dummy_notifiable_target.rb +8 -0
  36. data/spec/rails_app/app/models/user.rb +2 -1
  37. data/spec/rails_app/config/application.rb +4 -1
  38. data/spec/rails_app/config/dynamoid.rb +11 -3
  39. data/spec/rails_app/config/environments/production.rb +3 -0
  40. data/spec/rails_app/config/initializers/activity_notification.rb +3 -3
  41. data/spec/rails_app/config/routes.rb +5 -1
  42. data/spec/rails_app/db/seeds.rb +9 -2
  43. data/spec/roles/acts_as_notifiable_spec.rb +5 -5
  44. metadata +6 -10
@@ -90,15 +90,15 @@ module ActivityNotification
90
90
  }
91
91
  }
92
92
  key :example, {
93
- "action_cable_channel": {
94
- "subscribing": true,
95
- "subscribed_at": Time.current,
96
- "unsubscribed_at": nil
93
+ action_cable_channel: {
94
+ subscribing: true,
95
+ subscribed_at: Time.current,
96
+ unsubscribed_at: nil
97
97
  },
98
- "slack": {
99
- "subscribing": false,
100
- "subscribed_at": nil,
101
- "unsubscribed_at": Time.current
98
+ slack: {
99
+ subscribing: false,
100
+ subscribed_at: nil,
101
+ unsubscribed_at: Time.current
102
102
  }
103
103
  }
104
104
  end
@@ -114,11 +114,11 @@ module ActivityNotification
114
114
  key :type, :object
115
115
  key :description, "Associated target model in your application"
116
116
  key :example, {
117
- "id": 1,
118
- "email": "ichiro@example.com",
119
- "name": "Ichiro",
120
- "created_at": Time.current,
121
- "updated_at": Time.current
117
+ id: 1,
118
+ email: "ichiro@example.com",
119
+ name: "Ichiro",
120
+ created_at: Time.current,
121
+ updated_at: Time.current
122
122
  }
123
123
  end
124
124
  end
@@ -145,11 +145,11 @@ module ActivityNotification
145
145
  }
146
146
  }
147
147
  key :example, {
148
- "action_cable_channel": {
149
- "subscribing": true
148
+ action_cable_channel: {
149
+ subscribing: true
150
150
  },
151
- "slack": {
152
- "subscribing": false
151
+ slack: {
152
+ subscribing: false
153
153
  }
154
154
  }
155
155
  end
@@ -26,7 +26,7 @@ module ActivityNotification
26
26
  # @return [Boolean] Whether Action Cable notification API is allowed
27
27
  def notification_action_cable_api_allowed?(notification)
28
28
  notification.target.notification_action_cable_allowed?(notification.notifiable, notification.key) &&
29
- notification.notifiable.notification_action_cable_api_allowed?(notification.target, notification.key)
29
+ notification.notifiable.notifiable_action_cable_api_allowed?(notification.target, notification.key)
30
30
  end
31
31
 
32
32
  # Format message to broadcast
@@ -44,7 +44,7 @@ module ActivityNotification
44
44
  # @return [Boolean] Whether Action Cable notification is allowed
45
45
  def notification_action_cable_allowed?(notification)
46
46
  notification.target.notification_action_cable_allowed?(notification.notifiable, notification.key) &&
47
- notification.notifiable.notification_action_cable_allowed?(notification.target, notification.key)
47
+ notification.notifiable.notifiable_action_cable_allowed?(notification.target, notification.key)
48
48
  end
49
49
 
50
50
  # Format message to broadcast
@@ -22,8 +22,8 @@ module ActivityNotification
22
22
  association_name = name.to_s.singularize.underscore
23
23
  composite_field = "#{association_name}_key".to_sym
24
24
  field composite_field, :string
25
- associated_record_field = "#{association_name}_record".to_sym
26
- field associated_record_field, :string if ActivityNotification.config.store_with_associated_records && _options[:store_with_associated_records]
25
+ associated_record_field = "stored_#{association_name}".to_sym
26
+ field associated_record_field, :raw if ActivityNotification.config.store_with_associated_records && _options[:store_with_associated_records]
27
27
 
28
28
  self.instance_eval do
29
29
  define_method(name) do |reload = false|
@@ -43,7 +43,14 @@ module ActivityNotification
43
43
  self.send("#{composite_field}=", nil)
44
44
  else
45
45
  self.send("#{composite_field}=", "#{new_instance.class.name}#{ActivityNotification.config.composite_key_delimiter}#{new_instance.id}")
46
- self.send("#{associated_record_field}=", new_instance.to_json) if ActivityNotification.config.store_with_associated_records && _options[:store_with_associated_records]
46
+ associated_record_json = new_instance.as_json(_options[:as_json_options] || {})
47
+ # Cast Time and DateTime field to String to handle Dynamoid unsupported type error
48
+ if associated_record_json.present?
49
+ associated_record_json.each do |k, v|
50
+ associated_record_json[k] = v.to_s if v.is_a?(Time) || v.is_a?(DateTime)
51
+ end
52
+ end
53
+ self.send("#{associated_record_field}=", associated_record_json) if ActivityNotification.config.store_with_associated_records && _options[:store_with_associated_records]
47
54
  end
48
55
  self.instance_variable_set("@#{name}", nil)
49
56
  end
@@ -20,17 +20,17 @@ module ActivityNotification
20
20
  # Belongs to target instance of this notification as polymorphic association using composite key.
21
21
  # @scope instance
22
22
  # @return [Object] Target instance of this notification
23
- belongs_to_composite_xdb_record :target, store_with_associated_records: true
23
+ belongs_to_composite_xdb_record :target, store_with_associated_records: true, as_json_options: { methods: [:printable_type, :printable_target_name] }
24
24
 
25
25
  # Belongs to notifiable instance of this notification as polymorphic association using composite key.
26
26
  # @scope instance
27
27
  # @return [Object] Notifiable instance of this notification
28
- belongs_to_composite_xdb_record :notifiable, store_with_associated_records: true
28
+ belongs_to_composite_xdb_record :notifiable, store_with_associated_records: true, as_json_options: { methods: [:printable_type] }
29
29
 
30
30
  # Belongs to group instance of this notification as polymorphic association using composite key.
31
31
  # @scope instance
32
32
  # @return [Object] Group instance of this notification
33
- belongs_to_composite_xdb_record :group
33
+ belongs_to_composite_xdb_record :group, store_with_associated_records: true, as_json_options: { methods: [:printable_type, :printable_group_name] }
34
34
 
35
35
  field :key, :string
36
36
  field :parameters, :raw, default: {}
@@ -64,14 +64,54 @@ module ActivityNotification
64
64
  # Belongs to :otifier instance of this notification.
65
65
  # @scope instance
66
66
  # @return [Object] Notifier instance of this notification
67
- belongs_to_composite_xdb_record :notifier, store_with_associated_records: true
67
+ belongs_to_composite_xdb_record :notifier, store_with_associated_records: true, as_json_options: { methods: [:printable_type, :printable_notifier_name] }
68
+
69
+ # Additional fields to store from instance method when config.store_with_associated_records is enabled
70
+ if ActivityNotification.config.store_with_associated_records
71
+ field :stored_notifiable_path, :string
72
+ field :stored_printable_notifiable_name, :string
73
+ field :stored_group_member_notifier_count, :integer
74
+ field :stored_group_notification_count, :integer
75
+ field :stored_group_members, :array
76
+
77
+ # Returns prepared notification object to store
78
+ # @return [Object] prepared notification object to store
79
+ def prepare_to_store
80
+ self.stored_notifiable_path = notifiable_path
81
+ self.stored_printable_notifiable_name = printable_notifiable_name
82
+ if group_owner?
83
+ self.stored_group_notification_count = 0
84
+ self.stored_group_member_notifier_count = 0
85
+ self.stored_group_members = []
86
+ end
87
+ self
88
+ end
89
+
90
+ # Call after store action with stored notification
91
+ def after_store
92
+ if group_owner?
93
+ self.stored_group_notification_count = group_notification_count
94
+ self.stored_group_member_notifier_count = group_member_notifier_count
95
+ self.stored_group_members = group_members.as_json
96
+ self.stored_group_members.each do |group_member|
97
+ # Cast Time and DateTime field to String to handle Dynamoid unsupported type error
98
+ group_member.each do |k, v|
99
+ group_member[k] = v.to_s if v.is_a?(Time) || v.is_a?(DateTime)
100
+ end
101
+ end
102
+ save
103
+ else
104
+ group_owner.after_store
105
+ end
106
+ end
107
+ end
68
108
 
69
109
  # Mandatory global secondary index to query effectively
70
- global_secondary_index hash_key: :target_key, range_key: :created_at, projected_attributes: :all
71
- global_secondary_index hash_key: :group_owner_id, range_key: :created_at, projected_attributes: :all
110
+ global_secondary_index name: :index_target_key_created_at, hash_key: :target_key, range_key: :created_at, projected_attributes: :all
111
+ global_secondary_index name: :index_group_owner_id_created_at, hash_key: :group_owner_id, range_key: :created_at, projected_attributes: :all
72
112
  # Optional global secondary index to sort by created_at
73
- global_secondary_index hash_key: :notifier_key, range_key: :created_at, projected_attributes: :all
74
- global_secondary_index hash_key: :notifiable_key, range_key: :created_at, projected_attributes: :all
113
+ global_secondary_index name: :index_notifier_key_created_at, hash_key: :notifier_key, range_key: :created_at, projected_attributes: :all
114
+ global_secondary_index name: :index_notifiable_key_created_at, hash_key: :notifiable_key, range_key: :created_at, projected_attributes: :all
75
115
 
76
116
  validates :target, presence: true
77
117
  validates :notifiable, presence: true
@@ -122,11 +162,6 @@ module ActivityNotification
122
162
  raise ActivityNotification::DeleteRestrictionError, error_text
123
163
  end
124
164
 
125
- # Returns prepared notification object to store
126
- # @return [Object] prepared notification object to store
127
- # def prepare_to_store
128
- # end
129
-
130
165
  protected
131
166
 
132
167
  # Returns count of group members of the unopened notification.
@@ -28,7 +28,7 @@ module ActivityNotification
28
28
  field :unsubscribed_to_email_at, :datetime
29
29
  field :optional_targets, :raw, default: {}
30
30
 
31
- global_secondary_index hash_key: :target_key, range_key: :created_at, projected_attributes: :all
31
+ global_secondary_index name: :index_target_key_created_at, hash_key: :target_key, range_key: :created_at, projected_attributes: :all
32
32
 
33
33
  validates :target, presence: true
34
34
  validates :key, presence: true, uniqueness: { scope: :target_key }
@@ -24,8 +24,8 @@ module ActivityNotification
24
24
  id_field, type_field = "#{association_name}_id", "#{association_name}_type"
25
25
  field id_field, type: String
26
26
  field type_field, type: String
27
- associated_record_field = "#{association_name}_record"
28
- field associated_record_field, type: String if ActivityNotification.config.store_with_associated_records && _options[:store_with_associated_records]
27
+ associated_record_field = "stored_#{association_name}"
28
+ field associated_record_field, type: Hash if ActivityNotification.config.store_with_associated_records && _options[:store_with_associated_records]
29
29
 
30
30
  self.instance_eval do
31
31
  define_method(name) do |reload = false|
@@ -43,7 +43,14 @@ module ActivityNotification
43
43
  if new_instance.nil? then instance_id, instance_type = nil, nil else instance_id, instance_type = new_instance.id, new_instance.class.name end
44
44
  self.send("#{id_field}=", instance_id)
45
45
  self.send("#{type_field}=", instance_type)
46
- self.send("#{associated_record_field}=", new_instance.to_json) if ActivityNotification.config.store_with_associated_records && _options[:store_with_associated_records]
46
+ associated_record_json = new_instance.as_json(_options[:as_json_options] || {})
47
+ # Cast Hash $oid field to String id to handle BSON::String::IllegalKey
48
+ if associated_record_json.present?
49
+ associated_record_json.each do |k, v|
50
+ associated_record_json[k] = v['$oid'] if v.is_a?(Hash) && v.has_key?('$oid')
51
+ end
52
+ end
53
+ self.send("#{associated_record_field}=", associated_record_json) if ActivityNotification.config.store_with_associated_records && _options[:store_with_associated_records]
47
54
  self.instance_variable_set("@#{name}", nil)
48
55
  end
49
56
  end
@@ -19,17 +19,17 @@ module ActivityNotification
19
19
  # Belongs to target instance of this notification as polymorphic association.
20
20
  # @scope instance
21
21
  # @return [Object] Target instance of this notification
22
- belongs_to_polymorphic_xdb_record :target, store_with_associated_records: true
22
+ belongs_to_polymorphic_xdb_record :target, store_with_associated_records: true, as_json_options: { methods: [:printable_type, :printable_target_name] }
23
23
 
24
24
  # Belongs to notifiable instance of this notification as polymorphic association.
25
25
  # @scope instance
26
26
  # @return [Object] Notifiable instance of this notification
27
- belongs_to_polymorphic_xdb_record :notifiable, store_with_associated_records: true
27
+ belongs_to_polymorphic_xdb_record :notifiable, store_with_associated_records: true, as_json_options: { methods: [:printable_type] }
28
28
 
29
29
  # Belongs to group instance of this notification as polymorphic association.
30
30
  # @scope instance
31
31
  # @return [Object] Group instance of this notification
32
- belongs_to_polymorphic_xdb_record :group
32
+ belongs_to_polymorphic_xdb_record :group, as_json_options: { methods: [:printable_type, :printable_group_name] }
33
33
 
34
34
  field :key, type: String
35
35
  field :parameters, type: Hash, default: {}
@@ -53,7 +53,7 @@ module ActivityNotification
53
53
  # Belongs to :otifier instance of this notification.
54
54
  # @scope instance
55
55
  # @return [Object] Notifier instance of this notification
56
- belongs_to_polymorphic_xdb_record :notifier, store_with_associated_records: true
56
+ belongs_to_polymorphic_xdb_record :notifier, store_with_associated_records: true, as_json_options: { methods: [:printable_type, :printable_notifier_name] }
57
57
 
58
58
  validates :target, presence: true
59
59
  validates :notifiable, presence: true
@@ -265,7 +265,8 @@ module ActivityNotification
265
265
 
266
266
  options[:printable_notifiable_name] ||= options.delete(:printable_name)
267
267
  configured_params
268
- .merge set_acts_as_parameters_for_target(target_type, [:targets, :group, :group_expiry_delay, :parameters, :email_allowed, :action_cable_allowed, :action_cable_api_allowed], options, "notification_")
268
+ .merge set_acts_as_parameters_for_target(target_type, [:targets, :group, :group_expiry_delay, :parameters, :email_allowed], options, "notification_")
269
+ .merge set_acts_as_parameters_for_target(target_type, [:action_cable_allowed, :action_cable_api_allowed], options, "notifiable_")
269
270
  .merge set_acts_as_parameters_for_target(target_type, [:notifier, :notifiable_path, :printable_notifiable_name, :optional_targets], options)
270
271
  end
271
272
 
@@ -1,3 +1,3 @@
1
1
  module ActivityNotification
2
- VERSION = "2.1.3"
2
+ VERSION = "2.1.4"
3
3
  end
@@ -21,7 +21,7 @@ shared_examples_for :notifiable do
21
21
  expect(described_class._notifier).to eq({})
22
22
  expect(described_class._notification_parameters).to eq({})
23
23
  expect(described_class._notification_email_allowed).to eq({})
24
- expect(described_class._notification_action_cable_allowed).to eq({})
24
+ expect(described_class._notifiable_action_cable_allowed).to eq({})
25
25
  expect(described_class._notifiable_path).to eq({})
26
26
  expect(described_class._printable_notifiable_name).to eq({})
27
27
  end
@@ -410,130 +410,130 @@ shared_examples_for :notifiable do
410
410
  end
411
411
  end
412
412
 
413
- describe "#notification_action_cable_allowed?" do
413
+ describe "#notifiable_action_cable_allowed?" do
414
414
  context "without any configuration" do
415
415
  it "returns ActivityNotification.config.action_cable_enabled" do
416
- expect(test_instance.notification_action_cable_allowed?(test_target, 'dummy_key'))
416
+ expect(test_instance.notifiable_action_cable_allowed?(test_target, 'dummy_key'))
417
417
  .to eq(ActivityNotification.config.action_cable_enabled)
418
418
  end
419
419
 
420
420
  it "returns false as default" do
421
- expect(test_instance.notification_action_cable_allowed?(test_target, 'dummy_key')).to be_falsey
421
+ expect(test_instance.notifiable_action_cable_allowed?(test_target, 'dummy_key')).to be_falsey
422
422
  end
423
423
  end
424
424
 
425
425
  context "configured with overridden method" do
426
426
  it "returns specified value" do
427
427
  module AdditionalMethods
428
- def notification_action_cable_allowed_for_users?(target, key)
428
+ def notifiable_action_cable_allowed_for_users?(target, key)
429
429
  true
430
430
  end
431
431
  end
432
432
  test_instance.extend(AdditionalMethods)
433
- expect(test_instance.notification_action_cable_allowed?(test_target, 'dummy_key')).to eq(true)
433
+ expect(test_instance.notifiable_action_cable_allowed?(test_target, 'dummy_key')).to eq(true)
434
434
  end
435
435
  end
436
436
 
437
437
  context "configured with a field" do
438
438
  it "returns specified value" do
439
- described_class._notification_action_cable_allowed[:users] = true
440
- expect(test_instance.notification_action_cable_allowed?(test_target, 'dummy_key')).to eq(true)
439
+ described_class._notifiable_action_cable_allowed[:users] = true
440
+ expect(test_instance.notifiable_action_cable_allowed?(test_target, 'dummy_key')).to eq(true)
441
441
  end
442
442
 
443
443
  it "returns specified symbol without arguments" do
444
444
  module AdditionalMethods
445
- def custom_notification_action_cable_allowed?
445
+ def custom_notifiable_action_cable_allowed?
446
446
  true
447
447
  end
448
448
  end
449
449
  test_instance.extend(AdditionalMethods)
450
- described_class._notification_action_cable_allowed[:users] = :custom_notification_action_cable_allowed?
451
- expect(test_instance.notification_action_cable_allowed?(test_target, 'dummy_key')).to eq(true)
450
+ described_class._notifiable_action_cable_allowed[:users] = :custom_notifiable_action_cable_allowed?
451
+ expect(test_instance.notifiable_action_cable_allowed?(test_target, 'dummy_key')).to eq(true)
452
452
  end
453
453
 
454
454
  it "returns specified symbol with target and key arguments" do
455
455
  module AdditionalMethods
456
- def custom_notification_action_cable_allowed?(target, key)
456
+ def custom_notifiable_action_cable_allowed?(target, key)
457
457
  true
458
458
  end
459
459
  end
460
460
  test_instance.extend(AdditionalMethods)
461
- described_class._notification_action_cable_allowed[:users] = :custom_notification_action_cable_allowed?
462
- expect(test_instance.notification_action_cable_allowed?(test_target, 'dummy_key')).to eq(true)
461
+ described_class._notifiable_action_cable_allowed[:users] = :custom_notifiable_action_cable_allowed?
462
+ expect(test_instance.notifiable_action_cable_allowed?(test_target, 'dummy_key')).to eq(true)
463
463
  end
464
464
 
465
465
  it "returns specified lambda with single notifiable argument" do
466
- described_class._notification_action_cable_allowed[:users] = ->(notifiable){ true }
467
- expect(test_instance.notification_action_cable_allowed?(test_target, 'dummy_key')).to eq(true)
466
+ described_class._notifiable_action_cable_allowed[:users] = ->(notifiable){ true }
467
+ expect(test_instance.notifiable_action_cable_allowed?(test_target, 'dummy_key')).to eq(true)
468
468
  end
469
469
 
470
470
  it "returns specified lambda with notifiable, target and key arguments" do
471
- described_class._notification_action_cable_allowed[:users] = ->(notifiable, target, key){ true }
472
- expect(test_instance.notification_action_cable_allowed?(test_target, 'dummy_key')).to eq(true)
471
+ described_class._notifiable_action_cable_allowed[:users] = ->(notifiable, target, key){ true }
472
+ expect(test_instance.notifiable_action_cable_allowed?(test_target, 'dummy_key')).to eq(true)
473
473
  end
474
474
  end
475
475
  end
476
476
 
477
- describe "#notification_action_cable_api_allowed?" do
477
+ describe "#notifiable_action_cable_api_allowed?" do
478
478
  context "without any configuration" do
479
479
  it "returns ActivityNotification.config.action_cable_api_enabled" do
480
- expect(test_instance.notification_action_cable_api_allowed?(test_target, 'dummy_key'))
480
+ expect(test_instance.notifiable_action_cable_api_allowed?(test_target, 'dummy_key'))
481
481
  .to eq(ActivityNotification.config.action_cable_api_enabled)
482
482
  end
483
483
 
484
484
  it "returns false as default" do
485
- expect(test_instance.notification_action_cable_api_allowed?(test_target, 'dummy_key')).to be_falsey
485
+ expect(test_instance.notifiable_action_cable_api_allowed?(test_target, 'dummy_key')).to be_falsey
486
486
  end
487
487
  end
488
488
 
489
489
  context "configured with overridden method" do
490
490
  it "returns specified value" do
491
491
  module AdditionalMethods
492
- def notification_action_cable_api_allowed_for_users?(target, key)
492
+ def notifiable_action_cable_api_allowed_for_users?(target, key)
493
493
  true
494
494
  end
495
495
  end
496
496
  test_instance.extend(AdditionalMethods)
497
- expect(test_instance.notification_action_cable_api_allowed?(test_target, 'dummy_key')).to eq(true)
497
+ expect(test_instance.notifiable_action_cable_api_allowed?(test_target, 'dummy_key')).to eq(true)
498
498
  end
499
499
  end
500
500
 
501
501
  context "configured with a field" do
502
502
  it "returns specified value" do
503
- described_class._notification_action_cable_api_allowed[:users] = true
504
- expect(test_instance.notification_action_cable_api_allowed?(test_target, 'dummy_key')).to eq(true)
503
+ described_class._notifiable_action_cable_api_allowed[:users] = true
504
+ expect(test_instance.notifiable_action_cable_api_allowed?(test_target, 'dummy_key')).to eq(true)
505
505
  end
506
506
 
507
507
  it "returns specified symbol without arguments" do
508
508
  module AdditionalMethods
509
- def custom_notification_action_cable_api_allowed?
509
+ def custom_notifiable_action_cable_api_allowed?
510
510
  true
511
511
  end
512
512
  end
513
513
  test_instance.extend(AdditionalMethods)
514
- described_class._notification_action_cable_api_allowed[:users] = :custom_notification_action_cable_api_allowed?
515
- expect(test_instance.notification_action_cable_api_allowed?(test_target, 'dummy_key')).to eq(true)
514
+ described_class._notifiable_action_cable_api_allowed[:users] = :custom_notifiable_action_cable_api_allowed?
515
+ expect(test_instance.notifiable_action_cable_api_allowed?(test_target, 'dummy_key')).to eq(true)
516
516
  end
517
517
 
518
518
  it "returns specified symbol with target and key arguments" do
519
519
  module AdditionalMethods
520
- def custom_notification_action_cable_api_allowed?(target, key)
520
+ def custom_notifiable_action_cable_api_allowed?(target, key)
521
521
  true
522
522
  end
523
523
  end
524
524
  test_instance.extend(AdditionalMethods)
525
- described_class._notification_action_cable_api_allowed[:users] = :custom_notification_action_cable_api_allowed?
526
- expect(test_instance.notification_action_cable_api_allowed?(test_target, 'dummy_key')).to eq(true)
525
+ described_class._notifiable_action_cable_api_allowed[:users] = :custom_notifiable_action_cable_api_allowed?
526
+ expect(test_instance.notifiable_action_cable_api_allowed?(test_target, 'dummy_key')).to eq(true)
527
527
  end
528
528
 
529
529
  it "returns specified lambda with single notifiable argument" do
530
- described_class._notification_action_cable_api_allowed[:users] = ->(notifiable){ true }
531
- expect(test_instance.notification_action_cable_api_allowed?(test_target, 'dummy_key')).to eq(true)
530
+ described_class._notifiable_action_cable_api_allowed[:users] = ->(notifiable){ true }
531
+ expect(test_instance.notifiable_action_cable_api_allowed?(test_target, 'dummy_key')).to eq(true)
532
532
  end
533
533
 
534
534
  it "returns specified lambda with notifiable, target and key arguments" do
535
- described_class._notification_action_cable_api_allowed[:users] = ->(notifiable, target, key){ true }
536
- expect(test_instance.notification_action_cable_api_allowed?(test_target, 'dummy_key')).to eq(true)
535
+ described_class._notifiable_action_cable_api_allowed[:users] = ->(notifiable, target, key){ true }
536
+ expect(test_instance.notifiable_action_cable_api_allowed?(test_target, 'dummy_key')).to eq(true)
537
537
  end
538
538
  end
539
539
  end