ref: master
plugins/push_notification/test/unit/observers_test.rb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
require 'test_helper' require_relative '../helpers/observers_test_helper' class ObserversTest < ActiveSupport::TestCase include ObserversTestHelper def setup environment = Environment.default environment.enable_plugin(PushNotificationPlugin) end should 'send notification when creating a comment' do PushNotificationPlugin.any_instance.expects(:send_to_users) person = fast_create(Person) article = fast_create(Article, :profile_id => person.id) Comment.create!(:author => person, :title => 'test comment', :body => 'body!', :source => article) end should 'send notification when adding a friend' do PushNotificationPlugin.any_instance.expects(:send_to_users) create_add_friend_task end should 'send notification when friendship is accepted' do PushNotificationPlugin.any_instance.expects(:send_to_users).twice create_add_friend_task.finish end should 'send notification when friendship is refused' do PushNotificationPlugin.any_instance.expects(:send_to_users).twice create_add_friend_task.cancel end should 'send notification when adding a member to a community' do PushNotificationPlugin.any_instance.expects(:send_to_users) create_add_member_task end should 'send notification when accepting a member in a community' do PushNotificationPlugin.any_instance.expects(:send_to_users).twice create_add_member_task.finish end should 'send notification when rejecting a member in a community' do PushNotificationPlugin.any_instance.expects(:send_to_users).twice create_add_member_task.cancel end should 'send notification when suggesting an article' do PushNotificationPlugin.any_instance.expects(:send_to_users).twice create_suggest_article_task end should 'send notification when accepting suggested article' do PushNotificationPlugin.any_instance.expects(:send_to_users).times(5) create_suggest_article_task.finish end should 'send notification when rejecting suggested article' do PushNotificationPlugin.any_instance.expects(:send_to_users).times(4) create_suggest_article_task.cancel end should 'send notification when an article needs to be approved' do PushNotificationPlugin.any_instance.expects(:send_to_users) create_approve_article_task end should 'send notification when an article is approved' do PushNotificationPlugin.any_instance.expects(:send_to_users).times(3) create_approve_article_task.finish end should 'send notification when an article is not approved' do PushNotificationPlugin.any_instance.expects(:send_to_users).times(2) create_approve_article_task.cancel end should 'send notification when an article is created' do PushNotificationPlugin.any_instance.expects(:send_to_users).twice community = fast_create(Community) person = fast_create(Person) Article.create!(:name => 'great article', :profile => community) Article.create!(:name => 'great article', :profile => person) end end |