ref: master
plugins/admin_notifications/test/functional/admin_notifications_plugin_public_controller_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 |
require 'test_helper' class AdminNotificationsPluginPublicControllerTest < ActionController::TestCase def setup @controller = AdminNotificationsPluginPublicController.new @person = create_user('person').person @environment = Environment.default @environment.enable_plugin('AdminNotificationsPlugin') @environment.save! login_as(@person.user.login) end should 'a logged in user be able to permanently hide notifications' do @notification = AdminNotificationsPlugin::Notification.create( :target => @environment, :message => "Message", :active => true, :type => "AdminNotificationsPlugin::DangerNotification" ) post :close_notification, :notification_id => @notification.id assert_equal "true", @response.body assert @notification.users.include?(@person.user) end should 'a logged in user be able to momentarily hide notifications' do @notification = AdminNotificationsPlugin::Notification.create( :target => @environment, :message => "Message", :active => true, :type => "AdminNotificationsPlugin::DangerNotification" ) @another_notification = AdminNotificationsPlugin::Notification.create( :target => @environment, :message => "Another Message", :active => true, :type => "AdminNotificationsPlugin::WarningNotification" ) post :hide_notification, :notification_id => @notification.id assert_equal "true", @response.body assert @controller.hide_notifications.include?(@notification.id) assert !@controller.hide_notifications.include?(@another_notification.id) end should 'not momentarily hide any notification if its id is not found' do @notification = AdminNotificationsPlugin::Notification.create( :target => @environment, :message => "Message", :active => true, :type => "AdminNotificationsPlugin::DangerNotification" ) post :hide_notification, :notification_id => nil assert_equal "false", @response.body assert !@controller.hide_notifications.include?(@notification.id) end end |