Commit e9c593fa21d3aff3057780961d1617004341f934
1 parent
3177eee3
Exists in
community_notifications
Functional tests
Signed-off-by: Gabriel Silva <gabriel93.silva@gmail.com>
Showing
4 changed files
with
68 additions
and
59 deletions
Show diff stats
plugins/environment_notification/controllers/environment_notification_plugin_admin_controller.rb
plugins/environment_notification/controllers/environment_notification_plugin_myprofile_controller.rb
plugins/environment_notification/lib/notification_manager.rb
plugins/environment_notification/test/functional/environment_notification_plugin_myprofile_controller_test.rb
... | ... | @@ -24,65 +24,70 @@ class EnvironmentNotificationPluginMyprofileControllerTest < ActionController::T |
24 | 24 | |
25 | 25 | should 'profile admin be able to create a notification' do |
26 | 26 | @community.add_admin(@person) |
27 | - post :new, :controller => "environment_notification_plugin_myprofile_controller", | |
27 | + post :new, :profile => @community.identifier, | |
28 | 28 | :notifications => { |
29 | 29 | :message => "Message", |
30 | 30 | :active => true, |
31 | 31 | :type => "EnvironmentNotificationPlugin::DangerNotification" |
32 | 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 | |
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 | 38 | end |
39 | 39 | |
40 | 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 | |
41 | + post :new, :profile => @community.identifier, | |
42 | + :notifications => { | |
43 | + :message => "Message", | |
44 | + :active => true, | |
45 | + :type => "EnvironmentNotificationPlugin::DangerNotification" | |
46 | + } | |
47 | + | |
48 | + assert_redirected_to :root | |
49 | + assert_nil EnvironmentNotificationPlugin::EnvironmentNotification.last | |
48 | 50 | end |
49 | 51 | |
50 | - should 'profile admin be able to edit a notification' do | |
52 | + should 'profile admin be able to edit a notification' do | |
51 | 53 | @community.add_admin(@person) |
52 | 54 | @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 | |
55 | + :target => @community, | |
56 | + :message => "Message", | |
57 | + :active => true, | |
58 | + :type => "EnvironmentNotificationPlugin::DangerNotification" | |
59 | + ) | |
60 | + | |
61 | + post :edit, :profile => @community.identifier, :id => @notification.id, | |
62 | + :notifications => { | |
63 | + :message => "Edited Message", | |
64 | + :active => false, | |
65 | + :type => "EnvironmentNotificationPlugin::WarningNotification" | |
66 | + } | |
67 | + @notification = EnvironmentNotificationPlugin::EnvironmentNotification.last | |
68 | + assert_redirected_to :action => 'index' | |
69 | + assert_equal "Edited Message", @notification.message | |
70 | + assert !@notification.active | |
71 | + assert_equal "EnvironmentNotificationPlugin::WarningNotification", @notification.type | |
68 | 72 | end |
69 | 73 | |
70 | 74 | should 'a regular user not be able to edit a notification' do |
71 | 75 | @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 | |
76 | + :target => @community, | |
77 | + :message => "Message", | |
78 | + :active => true, | |
79 | + :type => "EnvironmentNotificationPlugin::DangerNotification" | |
80 | + ) | |
81 | + post :edit, :profile => @community.identifier, | |
82 | + :notifications => { | |
83 | + :message => "Edited Message", | |
84 | + :active => false, | |
85 | + :type => "EnvironmentNotificationPlugin::DangerNotification" | |
86 | + } | |
87 | + @notification.reload | |
88 | + assert_redirected_to :root | |
89 | + assert_equal "Message", @notification.message | |
90 | + assert @notification.active | |
86 | 91 | end |
87 | 92 | |
88 | 93 | should 'a profile admin be able to destroy a notification' do |
... | ... | @@ -93,7 +98,7 @@ class EnvironmentNotificationPluginMyprofileControllerTest < ActionController::T |
93 | 98 | :active => true, |
94 | 99 | :type => "EnvironmentNotificationPlugin::DangerNotification" |
95 | 100 | ) |
96 | - delete :destroy, :id => @notification.id | |
101 | + delete :destroy, :profile => @community.identifier, :id => @notification.id | |
97 | 102 | assert_nil EnvironmentNotificationPlugin::EnvironmentNotification.find_by_id(@notification.id) |
98 | 103 | end |
99 | 104 | |
... | ... | @@ -104,10 +109,10 @@ class EnvironmentNotificationPluginMyprofileControllerTest < ActionController::T |
104 | 109 | :active => true, |
105 | 110 | :type => "EnvironmentNotificationPlugin::DangerNotification" |
106 | 111 | ) |
107 | - delete :destroy, :id => @notification.id | |
112 | + delete :destroy, :profile => @community.identifier, :id => @notification.id | |
108 | 113 | |
109 | - assert_redirected_to :root | |
110 | - assert_not_nil EnvironmentNotificationPlugin::EnvironmentNotification.find_by_id(@notification.id) | |
114 | + assert_redirected_to :root | |
115 | + assert_not_nil EnvironmentNotificationPlugin::EnvironmentNotification.find_by_id(@notification.id) | |
111 | 116 | end |
112 | 117 | |
113 | 118 | should 'a profile admin be able to change Notification status' do |
... | ... | @@ -118,11 +123,11 @@ class EnvironmentNotificationPluginMyprofileControllerTest < ActionController::T |
118 | 123 | :active => true, |
119 | 124 | :type => "EnvironmentNotificationPlugin::DangerNotification" |
120 | 125 | ) |
121 | - post :change_status, :id => @notification.id | |
122 | - assert_redirected_to :action => 'index' | |
126 | + post :change_status, :profile => @community.identifier, :id => @notification.id | |
127 | + assert_redirected_to :action => 'index' | |
123 | 128 | |
124 | - @notification.reload | |
125 | - assert !@notification.active | |
129 | + @notification.reload | |
130 | + assert !@notification.active | |
126 | 131 | end |
127 | 132 | |
128 | 133 | should 'a regular user not be able to change Notification status' do |
... | ... | @@ -132,11 +137,11 @@ class EnvironmentNotificationPluginMyprofileControllerTest < ActionController::T |
132 | 137 | :active => true, |
133 | 138 | :type => "EnvironmentNotificationPlugin::DangerNotification" |
134 | 139 | ) |
135 | - post :change_status, :id => @notification.id | |
136 | - assert_redirected_to :root | |
140 | + post :change_status, :profile => @community.identifier, :id => @notification.id | |
141 | + assert_redirected_to :root | |
137 | 142 | |
138 | - @notification.reload | |
139 | - assert @notification.active | |
143 | + @notification.reload | |
144 | + assert @notification.active | |
140 | 145 | end |
141 | 146 | |
142 | 147 | end | ... | ... |