From 4b19db09dec108146df43fd2338796170037cf64 Mon Sep 17 00:00:00 2001 From: Andrea Vanini Date: Wed, 17 Nov 2021 23:03:04 +0100 Subject: [PATCH] Add failing spec --- spec/concerns/models/subscriber_spec.rb | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/spec/concerns/models/subscriber_spec.rb b/spec/concerns/models/subscriber_spec.rb index c81e3ad..0684ff3 100644 --- a/spec/concerns/models/subscriber_spec.rb +++ b/spec/concerns/models/subscriber_spec.rb @@ -17,6 +17,17 @@ expect(test_instance.subscriptions.latest_order.first).to eq(subscription_2) expect(test_instance.subscriptions.latest_order.to_a).to eq(ActivityNotification::Subscription.filtered_by_target(test_instance).latest_order.to_a) end + + it "has many subscriptions with custom association name" do + ActivityNotification.config.subscription_table_name = 'notifications_subscriptions' + + subscription_1 = create(:subscription, target: test_instance, key: 'subscription_key_1') + subscription_2 = create(:subscription, target: test_instance, key: 'subscription_key_2', created_at: subscription_1.created_at + 10.second) + expect(test_instance.notifications_subscriptions.count).to eq(2) + expect(test_instance.notifications_subscriptions.earliest_order.first).to eq(subscription_1) + expect(test_instance.notifications_subscriptions.latest_order.first).to eq(subscription_2) + expect(test_instance.notifications_subscriptions.latest_order.to_a).to eq(ActivityNotification::Subscription.filtered_by_target(test_instance).latest_order.to_a) + end end describe "as public class methods" do