Commit 3177eee3f70df13c5011ffefc191e1ef0c10a845
1 parent
b2c228b4
Exists in
community_notifications
adds functional tests
Showing
5 changed files
with
225 additions
and
60 deletions
Show diff stats
plugins/environment_notification/controllers/public/environment_notification_plugin_public_controller.rb
| @@ -16,7 +16,7 @@ class EnvironmentNotificationPluginPublicController < PublicController | @@ -16,7 +16,7 @@ class EnvironmentNotificationPluginPublicController < PublicController | ||
| 16 | result = false | 16 | result = false |
| 17 | 17 | ||
| 18 | if logged_in? | 18 | if logged_in? |
| 19 | - @notification = EnvironmentNotificationPlugin::EnvironmentNotification.find(params[:notification_id]) | 19 | + @notification = EnvironmentNotificationPlugin::EnvironmentNotification.find_by_id(params[:notification_id]) |
| 20 | 20 | ||
| 21 | if @notification | 21 | if @notification |
| 22 | @notification.users << current_user | 22 | @notification.users << current_user |
| @@ -31,7 +31,7 @@ class EnvironmentNotificationPluginPublicController < PublicController | @@ -31,7 +31,7 @@ class EnvironmentNotificationPluginPublicController < PublicController | ||
| 31 | result = false | 31 | result = false |
| 32 | 32 | ||
| 33 | if logged_in? | 33 | if logged_in? |
| 34 | - @notification = EnvironmentNotificationPlugin::EnvironmentNotification.find(params[:notification_id]) | 34 | + @notification = EnvironmentNotificationPlugin::EnvironmentNotification.find_by_id(params[:notification_id]) |
| 35 | 35 | ||
| 36 | if @notification | 36 | if @notification |
| 37 | current_notificaions = [] | 37 | current_notificaions = [] |
plugins/environment_notification/test/functional/environment_notification_plugin_admin_controller_test.rb
| @@ -50,7 +50,7 @@ class EnvironmentNotificationPluginAdminControllerTest < ActionController::TestC | @@ -50,7 +50,7 @@ class EnvironmentNotificationPluginAdminControllerTest < ActionController::TestC | ||
| 50 | should 'an admin be able to edit a notification' do | 50 | should 'an admin be able to edit a notification' do |
| 51 | @environment.add_admin(@person) | 51 | @environment.add_admin(@person) |
| 52 | @notification = EnvironmentNotificationPlugin::EnvironmentNotification.create( | 52 | @notification = EnvironmentNotificationPlugin::EnvironmentNotification.create( |
| 53 | - :environment_id => @environment.id, | 53 | + :target => @environment, |
| 54 | :message => "Message", | 54 | :message => "Message", |
| 55 | :active => true, | 55 | :active => true, |
| 56 | :type => "EnvironmentNotificationPlugin::DangerNotification" | 56 | :type => "EnvironmentNotificationPlugin::DangerNotification" |
| @@ -69,7 +69,7 @@ class EnvironmentNotificationPluginAdminControllerTest < ActionController::TestC | @@ -69,7 +69,7 @@ class EnvironmentNotificationPluginAdminControllerTest < ActionController::TestC | ||
| 69 | 69 | ||
| 70 | should 'an user not to be able to edit a notification' do | 70 | should 'an user not to be able to edit a notification' do |
| 71 | @notification = EnvironmentNotificationPlugin::EnvironmentNotification.create( | 71 | @notification = EnvironmentNotificationPlugin::EnvironmentNotification.create( |
| 72 | - :environment_id => @environment.id, | 72 | + :target => @environment, |
| 73 | :message => "Message", | 73 | :message => "Message", |
| 74 | :active => true, | 74 | :active => true, |
| 75 | :type => "EnvironmentNotificationPlugin::DangerNotification" | 75 | :type => "EnvironmentNotificationPlugin::DangerNotification" |
| @@ -88,7 +88,7 @@ class EnvironmentNotificationPluginAdminControllerTest < ActionController::TestC | @@ -88,7 +88,7 @@ class EnvironmentNotificationPluginAdminControllerTest < ActionController::TestC | ||
| 88 | should 'an admin be able to destroy a notification' do | 88 | should 'an admin be able to destroy a notification' do |
| 89 | @environment.add_admin(@person) | 89 | @environment.add_admin(@person) |
| 90 | @notification = EnvironmentNotificationPlugin::EnvironmentNotification.create( | 90 | @notification = EnvironmentNotificationPlugin::EnvironmentNotification.create( |
| 91 | - :environment_id => @environment.id, | 91 | + :target => @environment, |
| 92 | :message => "Message", | 92 | :message => "Message", |
| 93 | :active => true, | 93 | :active => true, |
| 94 | :type => "EnvironmentNotificationPlugin::DangerNotification" | 94 | :type => "EnvironmentNotificationPlugin::DangerNotification" |
| @@ -99,7 +99,7 @@ class EnvironmentNotificationPluginAdminControllerTest < ActionController::TestC | @@ -99,7 +99,7 @@ class EnvironmentNotificationPluginAdminControllerTest < ActionController::TestC | ||
| 99 | 99 | ||
| 100 | should 'an user not to be able to destroy a notification' do | 100 | should 'an user not to be able to destroy a notification' do |
| 101 | @notification = EnvironmentNotificationPlugin::EnvironmentNotification.create( | 101 | @notification = EnvironmentNotificationPlugin::EnvironmentNotification.create( |
| 102 | - :environment_id => @environment.id, | 102 | + :target => @environment, |
| 103 | :message => "Message", | 103 | :message => "Message", |
| 104 | :active => true, | 104 | :active => true, |
| 105 | :type => "EnvironmentNotificationPlugin::DangerNotification" | 105 | :type => "EnvironmentNotificationPlugin::DangerNotification" |
| @@ -113,7 +113,7 @@ class EnvironmentNotificationPluginAdminControllerTest < ActionController::TestC | @@ -113,7 +113,7 @@ class EnvironmentNotificationPluginAdminControllerTest < ActionController::TestC | ||
| 113 | should 'an admin be able to change Notification status' do | 113 | should 'an admin be able to change Notification status' do |
| 114 | @environment.add_admin(@person) | 114 | @environment.add_admin(@person) |
| 115 | @notification = EnvironmentNotificationPlugin::EnvironmentNotification.create( | 115 | @notification = EnvironmentNotificationPlugin::EnvironmentNotification.create( |
| 116 | - :environment_id => @environment.id, | 116 | + :target => @environment, |
| 117 | :message => "Message", | 117 | :message => "Message", |
| 118 | :active => true, | 118 | :active => true, |
| 119 | :type => "EnvironmentNotificationPlugin::DangerNotification" | 119 | :type => "EnvironmentNotificationPlugin::DangerNotification" |
| @@ -127,7 +127,7 @@ class EnvironmentNotificationPluginAdminControllerTest < ActionController::TestC | @@ -127,7 +127,7 @@ class EnvironmentNotificationPluginAdminControllerTest < ActionController::TestC | ||
| 127 | 127 | ||
| 128 | should 'an user not be able to change Notification status' do | 128 | should 'an user not be able to change Notification status' do |
| 129 | @notification = EnvironmentNotificationPlugin::EnvironmentNotification.create( | 129 | @notification = EnvironmentNotificationPlugin::EnvironmentNotification.create( |
| 130 | - :environment_id => @environment.id, | 130 | + :target => @environment, |
| 131 | :message => "Message", | 131 | :message => "Message", |
| 132 | :active => true, | 132 | :active => true, |
| 133 | :type => "EnvironmentNotificationPlugin::DangerNotification" | 133 | :type => "EnvironmentNotificationPlugin::DangerNotification" |
| @@ -139,48 +139,4 @@ class EnvironmentNotificationPluginAdminControllerTest < ActionController::TestC | @@ -139,48 +139,4 @@ class EnvironmentNotificationPluginAdminControllerTest < ActionController::TestC | ||
| 139 | assert @notification.active | 139 | assert @notification.active |
| 140 | end | 140 | end |
| 141 | 141 | ||
| 142 | - should 'a logged in user be able to permanently hide notifications' do | ||
| 143 | - @notification = EnvironmentNotificationPlugin::EnvironmentNotification.create( | ||
| 144 | - :environment_id => @environment.id, | ||
| 145 | - :message => "Message", | ||
| 146 | - :active => true, | ||
| 147 | - :type => "EnvironmentNotificationPlugin::DangerNotification" | ||
| 148 | - ) | ||
| 149 | - post :close_notification, :notification_id => @notification.id | ||
| 150 | - assert_equal "true", @response.body | ||
| 151 | - assert @notification.users.include?(@person.user) | ||
| 152 | - end | ||
| 153 | - | ||
| 154 | - should 'a logged in user be able to momentarily hide notifications' do | ||
| 155 | - @notification = EnvironmentNotificationPlugin::EnvironmentNotification.create( | ||
| 156 | - :environment_id => @environment.id, | ||
| 157 | - :message => "Message", | ||
| 158 | - :active => true, | ||
| 159 | - :type => "EnvironmentNotificationPlugin::DangerNotification" | ||
| 160 | - ) | ||
| 161 | - | ||
| 162 | - @another_notification = EnvironmentNotificationPlugin::EnvironmentNotification.create( | ||
| 163 | - :environment_id => @environment.id, | ||
| 164 | - :message => "Another Message", | ||
| 165 | - :active => true, | ||
| 166 | - :type => "EnvironmentNotificationPlugin::WarningNotification" | ||
| 167 | - ) | ||
| 168 | - post :hide_notification, :notification_id => @notification.id | ||
| 169 | - assert_equal "true", @response.body | ||
| 170 | - assert @controller.hide_notifications.include?(@notification.id) | ||
| 171 | - assert !@controller.hide_notifications.include?(@another_notification.id) | ||
| 172 | - end | ||
| 173 | - | ||
| 174 | - should 'not momentarily hide any notification if its id is not found' do | ||
| 175 | - @notification = EnvironmentNotificationPlugin::EnvironmentNotification.create( | ||
| 176 | - :environment_id => @environment.id, | ||
| 177 | - :message => "Message", | ||
| 178 | - :active => true, | ||
| 179 | - :type => "EnvironmentNotificationPlugin::DangerNotification" | ||
| 180 | - ) | ||
| 181 | - | ||
| 182 | - post :hide_notification, :notification_id => nil | ||
| 183 | - assert_equal "false", @response.body | ||
| 184 | - assert !@controller.hide_notifications.include?(@notification.id) | ||
| 185 | - end | ||
| 186 | end | 142 | end |
plugins/environment_notification/test/functional/environment_notification_plugin_myprofile_controller_test.rb
0 → 100644
| @@ -0,0 +1,142 @@ | @@ -0,0 +1,142 @@ | ||
| 1 | +require File.expand_path(File.dirname(__FILE__)) + '/../../../../test/test_helper' | ||
| 2 | +require( | ||
| 3 | + File.expand_path(File.dirname(__FILE__)) + | ||
| 4 | + '/../../controllers/environment_notification_plugin_myprofile_controller' | ||
| 5 | +) | ||
| 6 | + | ||
| 7 | +class EnvironmentNotificationPluginMyprofileControllerTest < ActionController::TestCase | ||
| 8 | + def setup | ||
| 9 | + @controller = EnvironmentNotificationPluginMyprofileController.new | ||
| 10 | + @request = ActionController::TestRequest.new | ||
| 11 | + @response = ActionController::TestResponse.new | ||
| 12 | + @person = create_user('person').person | ||
| 13 | + @community = fast_create(Community) | ||
| 14 | + | ||
| 15 | + environment = Environment.default | ||
| 16 | + environment.enable_plugin('EnvironmentNotificationPlugin') | ||
| 17 | + environment.save! | ||
| 18 | + | ||
| 19 | + login_as(@person.user.login) | ||
| 20 | + EnvironmentNotificationPluginMyprofileController.any_instance.stubs(:profile).returns(@community) | ||
| 21 | + end | ||
| 22 | + | ||
| 23 | + attr_accessor :person | ||
| 24 | + | ||
| 25 | + should 'profile admin be able to create a notification' do | ||
| 26 | + @community.add_admin(@person) | ||
| 27 | + post :new, :controller => "environment_notification_plugin_myprofile_controller", | ||
| 28 | + :notifications => { | ||
| 29 | + :message => "Message", | ||
| 30 | + :active => true, | ||
| 31 | + :type => "EnvironmentNotificationPlugin::DangerNotification" | ||
| 32 | + } | ||
| 33 | + assert_redirected_to :action => 'index' | ||
| 34 | + notification = EnvironmentNotificationPlugin::EnvironmentNotification.last | ||
| 35 | + assert_equal "Message", notification.message | ||
| 36 | + assert notification.active | ||
| 37 | + assert_equal "EnvironmentNotificationPlugin::DangerNotification", notification.type | ||
| 38 | + end | ||
| 39 | + | ||
| 40 | + should 'a regular user not to be able to create a notification' do | ||
| 41 | + post :new, :notifications => { | ||
| 42 | + :message => "Message", | ||
| 43 | + :active => true, | ||
| 44 | + :type => "EnvironmentNotificationPlugin::DangerNotification" | ||
| 45 | + } | ||
| 46 | + assert_redirected_to :root | ||
| 47 | + assert_nil EnvironmentNotificationPlugin::EnvironmentNotification.last | ||
| 48 | + end | ||
| 49 | + | ||
| 50 | + should 'profile admin be able to edit a notification' do | ||
| 51 | + @community.add_admin(@person) | ||
| 52 | + @notification = EnvironmentNotificationPlugin::EnvironmentNotification.create( | ||
| 53 | + :target => @community, | ||
| 54 | + :message => "Message", | ||
| 55 | + :active => true, | ||
| 56 | + :type => "EnvironmentNotificationPlugin::DangerNotification" | ||
| 57 | + ) | ||
| 58 | + post :edit, :id => @notification.id, :notifications => { | ||
| 59 | + :message => "Edited Message", | ||
| 60 | + :active => false, | ||
| 61 | + :type => "EnvironmentNotificationPlugin::WarningNotification" | ||
| 62 | + } | ||
| 63 | + @notification = EnvironmentNotificationPlugin::EnvironmentNotification.last | ||
| 64 | + assert_redirected_to :action => 'index' | ||
| 65 | + assert_equal "Edited Message", @notification.message | ||
| 66 | + assert !@notification.active | ||
| 67 | + assert_equal "EnvironmentNotificationPlugin::WarningNotification", @notification.type | ||
| 68 | + end | ||
| 69 | + | ||
| 70 | + should 'a regular user not be able to edit a notification' do | ||
| 71 | + @notification = EnvironmentNotificationPlugin::EnvironmentNotification.create( | ||
| 72 | + :target => @community, | ||
| 73 | + :message => "Message", | ||
| 74 | + :active => true, | ||
| 75 | + :type => "EnvironmentNotificationPlugin::DangerNotification" | ||
| 76 | + ) | ||
| 77 | + post :edit, :notifications => { | ||
| 78 | + :message => "Edited Message", | ||
| 79 | + :active => false, | ||
| 80 | + :type => "EnvironmentNotificationPlugin::DangerNotification" | ||
| 81 | + } | ||
| 82 | + @notification.reload | ||
| 83 | + assert_redirected_to :root | ||
| 84 | + assert_equal "Message", @notification.message | ||
| 85 | + assert @notification.active | ||
| 86 | + end | ||
| 87 | + | ||
| 88 | + should 'a profile admin be able to destroy a notification' do | ||
| 89 | + @community.add_admin(@person) | ||
| 90 | + @notification = EnvironmentNotificationPlugin::EnvironmentNotification.create( | ||
| 91 | + :target => @community, | ||
| 92 | + :message => "Message", | ||
| 93 | + :active => true, | ||
| 94 | + :type => "EnvironmentNotificationPlugin::DangerNotification" | ||
| 95 | + ) | ||
| 96 | + delete :destroy, :id => @notification.id | ||
| 97 | + assert_nil EnvironmentNotificationPlugin::EnvironmentNotification.find_by_id(@notification.id) | ||
| 98 | + end | ||
| 99 | + | ||
| 100 | + should 'a regular user not be able to destroy a notification' do | ||
| 101 | + @notification = EnvironmentNotificationPlugin::EnvironmentNotification.create( | ||
| 102 | + :target => @community, | ||
| 103 | + :message => "Message", | ||
| 104 | + :active => true, | ||
| 105 | + :type => "EnvironmentNotificationPlugin::DangerNotification" | ||
| 106 | + ) | ||
| 107 | + delete :destroy, :id => @notification.id | ||
| 108 | + | ||
| 109 | + assert_redirected_to :root | ||
| 110 | + assert_not_nil EnvironmentNotificationPlugin::EnvironmentNotification.find_by_id(@notification.id) | ||
| 111 | + end | ||
| 112 | + | ||
| 113 | + should 'a profile admin be able to change Notification status' do | ||
| 114 | + @community.add_admin(@person) | ||
| 115 | + @notification = EnvironmentNotificationPlugin::EnvironmentNotification.create( | ||
| 116 | + :target => @community, | ||
| 117 | + :message => "Message", | ||
| 118 | + :active => true, | ||
| 119 | + :type => "EnvironmentNotificationPlugin::DangerNotification" | ||
| 120 | + ) | ||
| 121 | + post :change_status, :id => @notification.id | ||
| 122 | + assert_redirected_to :action => 'index' | ||
| 123 | + | ||
| 124 | + @notification.reload | ||
| 125 | + assert !@notification.active | ||
| 126 | + end | ||
| 127 | + | ||
| 128 | + should 'a regular user not be able to change Notification status' do | ||
| 129 | + @notification = EnvironmentNotificationPlugin::EnvironmentNotification.create( | ||
| 130 | + :target => @community, | ||
| 131 | + :message => "Message", | ||
| 132 | + :active => true, | ||
| 133 | + :type => "EnvironmentNotificationPlugin::DangerNotification" | ||
| 134 | + ) | ||
| 135 | + post :change_status, :id => @notification.id | ||
| 136 | + assert_redirected_to :root | ||
| 137 | + | ||
| 138 | + @notification.reload | ||
| 139 | + assert @notification.active | ||
| 140 | + end | ||
| 141 | + | ||
| 142 | +end |
plugins/environment_notification/test/functional/environment_notification_plugin_public_controller_test.rb
0 → 100644
| @@ -0,0 +1,67 @@ | @@ -0,0 +1,67 @@ | ||
| 1 | +require File.expand_path(File.dirname(__FILE__)) + '/../../../../test/test_helper' | ||
| 2 | +require( | ||
| 3 | + File.expand_path(File.dirname(__FILE__)) + | ||
| 4 | + '/../../controllers/public/environment_notification_plugin_public_controller' | ||
| 5 | +) | ||
| 6 | + | ||
| 7 | +class EnvironmentNotificationPluginPublicControllerTest < ActionController::TestCase | ||
| 8 | + def setup | ||
| 9 | + @controller = EnvironmentNotificationPluginPublicController.new | ||
| 10 | + @request = ActionController::TestRequest.new | ||
| 11 | + @response = ActionController::TestResponse.new | ||
| 12 | + @person = create_user('person').person | ||
| 13 | + | ||
| 14 | + @environment = Environment.default | ||
| 15 | + @environment.enable_plugin('EnvironmentNotificationPlugin') | ||
| 16 | + @environment.save! | ||
| 17 | + | ||
| 18 | + login_as(@person.user.login) | ||
| 19 | + end | ||
| 20 | + | ||
| 21 | + # attr_accessor :person | ||
| 22 | + | ||
| 23 | + should 'a logged in user be able to permanently hide notifications' do | ||
| 24 | + @notification = EnvironmentNotificationPlugin::EnvironmentNotification.create( | ||
| 25 | + :target => @environment, | ||
| 26 | + :message => "Message", | ||
| 27 | + :active => true, | ||
| 28 | + :type => "EnvironmentNotificationPlugin::DangerNotification" | ||
| 29 | + ) | ||
| 30 | + post :close_notification, :notification_id => @notification.id | ||
| 31 | + assert_equal "true", @response.body | ||
| 32 | + assert @notification.users.include?(@person.user) | ||
| 33 | + end | ||
| 34 | + | ||
| 35 | + should 'a logged in user be able to momentarily hide notifications' do | ||
| 36 | + @notification = EnvironmentNotificationPlugin::EnvironmentNotification.create( | ||
| 37 | + :target => @environment, | ||
| 38 | + :message => "Message", | ||
| 39 | + :active => true, | ||
| 40 | + :type => "EnvironmentNotificationPlugin::DangerNotification" | ||
| 41 | + ) | ||
| 42 | + | ||
| 43 | + @another_notification = EnvironmentNotificationPlugin::EnvironmentNotification.create( | ||
| 44 | + :target => @environment, | ||
| 45 | + :message => "Another Message", | ||
| 46 | + :active => true, | ||
| 47 | + :type => "EnvironmentNotificationPlugin::WarningNotification" | ||
| 48 | + ) | ||
| 49 | + post :hide_notification, :notification_id => @notification.id | ||
| 50 | + assert_equal "true", @response.body | ||
| 51 | + assert @controller.hide_notifications.include?(@notification.id) | ||
| 52 | + assert !@controller.hide_notifications.include?(@another_notification.id) | ||
| 53 | + end | ||
| 54 | + | ||
| 55 | + should 'not momentarily hide any notification if its id is not found' do | ||
| 56 | + @notification = EnvironmentNotificationPlugin::EnvironmentNotification.create( | ||
| 57 | + :target => @environment, | ||
| 58 | + :message => "Message", | ||
| 59 | + :active => true, | ||
| 60 | + :type => "EnvironmentNotificationPlugin::DangerNotification" | ||
| 61 | + ) | ||
| 62 | + | ||
| 63 | + post :hide_notification, :notification_id => nil | ||
| 64 | + assert_equal "false", @response.body | ||
| 65 | + assert !@controller.hide_notifications.include?(@notification.id) | ||
| 66 | + end | ||
| 67 | +end |
plugins/environment_notification/test/functional/home_controller_test.rb
| @@ -21,7 +21,7 @@ class HomeControllerTest < ActionController::TestCase | @@ -21,7 +21,7 @@ class HomeControllerTest < ActionController::TestCase | ||
| 21 | should 'an active notification be displayed on home page for a logged in user' do | 21 | should 'an active notification be displayed on home page for a logged in user' do |
| 22 | login_as(@person.user.login) | 22 | login_as(@person.user.login) |
| 23 | @notification = EnvironmentNotificationPlugin::EnvironmentNotification.create( | 23 | @notification = EnvironmentNotificationPlugin::EnvironmentNotification.create( |
| 24 | - :environment_id => @environment.id, | 24 | + :target => @environment, |
| 25 | :message => "Hello, this is a Notification Message", | 25 | :message => "Hello, this is a Notification Message", |
| 26 | :active => true, | 26 | :active => true, |
| 27 | :type => "EnvironmentNotificationPlugin::DangerNotification" | 27 | :type => "EnvironmentNotificationPlugin::DangerNotification" |
| @@ -33,7 +33,7 @@ class HomeControllerTest < ActionController::TestCase | @@ -33,7 +33,7 @@ class HomeControllerTest < ActionController::TestCase | ||
| 33 | 33 | ||
| 34 | should 'an active notification not be displayed on home page for unlogged user' do | 34 | should 'an active notification not be displayed on home page for unlogged user' do |
| 35 | @notification = EnvironmentNotificationPlugin::EnvironmentNotification.create( | 35 | @notification = EnvironmentNotificationPlugin::EnvironmentNotification.create( |
| 36 | - :environment_id => @environment.id, | 36 | + :target => @environment, |
| 37 | :message => "Hello, this is a Notification Message", | 37 | :message => "Hello, this is a Notification Message", |
| 38 | :active => true, | 38 | :active => true, |
| 39 | :type => "EnvironmentNotificationPlugin::DangerNotification" | 39 | :type => "EnvironmentNotificationPlugin::DangerNotification" |
| @@ -44,7 +44,7 @@ class HomeControllerTest < ActionController::TestCase | @@ -44,7 +44,7 @@ class HomeControllerTest < ActionController::TestCase | ||
| 44 | 44 | ||
| 45 | should 'an active notification be displayed on home page for unlogged user' do | 45 | should 'an active notification be displayed on home page for unlogged user' do |
| 46 | @notification = EnvironmentNotificationPlugin::EnvironmentNotification.create( | 46 | @notification = EnvironmentNotificationPlugin::EnvironmentNotification.create( |
| 47 | - :environment_id => @environment.id, | 47 | + :target => @environment, |
| 48 | :message => "Hello, this is a Notification Message", | 48 | :message => "Hello, this is a Notification Message", |
| 49 | :display_to_all_users => true, | 49 | :display_to_all_users => true, |
| 50 | :active => true, | 50 | :active => true, |
| @@ -56,14 +56,14 @@ class HomeControllerTest < ActionController::TestCase | @@ -56,14 +56,14 @@ class HomeControllerTest < ActionController::TestCase | ||
| 56 | 56 | ||
| 57 | should 'only display the notification with display_to_all_users option for unlogged user ' do | 57 | should 'only display the notification with display_to_all_users option for unlogged user ' do |
| 58 | @notification1 = EnvironmentNotificationPlugin::EnvironmentNotification.create( | 58 | @notification1 = EnvironmentNotificationPlugin::EnvironmentNotification.create( |
| 59 | - :environment_id => @environment.id, | 59 | + :target => @environment, |
| 60 | :message => "Hello, this is an old Notification Message", | 60 | :message => "Hello, this is an old Notification Message", |
| 61 | :active => true, | 61 | :active => true, |
| 62 | :type => "EnvironmentNotificationPlugin::DangerNotification" | 62 | :type => "EnvironmentNotificationPlugin::DangerNotification" |
| 63 | ) | 63 | ) |
| 64 | 64 | ||
| 65 | @notification2 = EnvironmentNotificationPlugin::EnvironmentNotification.create( | 65 | @notification2 = EnvironmentNotificationPlugin::EnvironmentNotification.create( |
| 66 | - :environment_id => @environment.id, | 66 | + :target => @environment, |
| 67 | :message => "Hello, this is a new Notification Message", | 67 | :message => "Hello, this is a new Notification Message", |
| 68 | :display_to_all_users => true, | 68 | :display_to_all_users => true, |
| 69 | :active => true, | 69 | :active => true, |
| @@ -78,7 +78,7 @@ class HomeControllerTest < ActionController::TestCase | @@ -78,7 +78,7 @@ class HomeControllerTest < ActionController::TestCase | ||
| 78 | 78 | ||
| 79 | should 'an inactive notification not be displayed on home page' do | 79 | should 'an inactive notification not be displayed on home page' do |
| 80 | @notification = EnvironmentNotificationPlugin::EnvironmentNotification.create( | 80 | @notification = EnvironmentNotificationPlugin::EnvironmentNotification.create( |
| 81 | - :environment_id => @environment.id, | 81 | + :target => @environment, |
| 82 | :message => "Hello, this is a Notification Message", | 82 | :message => "Hello, this is a Notification Message", |
| 83 | :active => false, | 83 | :active => false, |
| 84 | :type => "EnvironmentNotificationPlugin::DangerNotification" | 84 | :type => "EnvironmentNotificationPlugin::DangerNotification" |
| @@ -91,7 +91,7 @@ class HomeControllerTest < ActionController::TestCase | @@ -91,7 +91,7 @@ class HomeControllerTest < ActionController::TestCase | ||
| 91 | should 'an active notification not be displayed to a logged in user after been closed by him' do | 91 | should 'an active notification not be displayed to a logged in user after been closed by him' do |
| 92 | login_as(@person.user.login) | 92 | login_as(@person.user.login) |
| 93 | @notification = EnvironmentNotificationPlugin::EnvironmentNotification.create( | 93 | @notification = EnvironmentNotificationPlugin::EnvironmentNotification.create( |
| 94 | - :environment_id => @environment.id, | 94 | + :target => @environment, |
| 95 | :message => "Hello, this is a Notification Message", | 95 | :message => "Hello, this is a Notification Message", |
| 96 | :active => true, | 96 | :active => true, |
| 97 | :type => "EnvironmentNotificationPlugin::DangerNotification" | 97 | :type => "EnvironmentNotificationPlugin::DangerNotification" |
| @@ -106,7 +106,7 @@ class HomeControllerTest < ActionController::TestCase | @@ -106,7 +106,7 @@ class HomeControllerTest < ActionController::TestCase | ||
| 106 | should 'a notification be displayed with a Popup' do | 106 | should 'a notification be displayed with a Popup' do |
| 107 | login_as(@person.user.login) | 107 | login_as(@person.user.login) |
| 108 | @notification = EnvironmentNotificationPlugin::EnvironmentNotification.create( | 108 | @notification = EnvironmentNotificationPlugin::EnvironmentNotification.create( |
| 109 | - :environment_id => @environment.id, | 109 | + :target => @environment, |
| 110 | :message => "Message", | 110 | :message => "Message", |
| 111 | :display_popup => true, | 111 | :display_popup => true, |
| 112 | :active => true, | 112 | :active => true, |