Commit 1414c2864df4e2d73c8b01f1b7c0c437ee2279b5
1 parent
852945bf
Exists in
master
and in
29 other branches
environment_notifications: fix broken tests
The plugin still has some structural problems
Showing
6 changed files
with
25 additions
and
16 deletions
Show diff stats
plugins/environment_notification/controllers/environment_notification_plugin_admin_controller.rb
1 | class EnvironmentNotificationPluginAdminController < AdminController | 1 | class EnvironmentNotificationPluginAdminController < AdminController |
2 | + | ||
3 | + helper EnvironmentNotificationHelper | ||
4 | + include EnvironmentNotificationHelper | ||
5 | + | ||
2 | before_filter :admin_required, :except => [:close_notification, :hide_notification] | 6 | before_filter :admin_required, :except => [:close_notification, :hide_notification] |
7 | + | ||
3 | def index | 8 | def index |
4 | @notifications = environment.environment_notifications.order('updated_at DESC') | 9 | @notifications = environment.environment_notifications.order('updated_at DESC') |
5 | end | 10 | end |
plugins/environment_notification/controllers/public/environment_notification_plugin_public_controller.rb
1 | class EnvironmentNotificationPluginPublicController < PublicController | 1 | class EnvironmentNotificationPluginPublicController < PublicController |
2 | + | ||
3 | + helper EnvironmentNotificationHelper | ||
4 | + | ||
2 | def notifications_with_popup | 5 | def notifications_with_popup |
3 | @hide_notifications = hide_notifications | 6 | @hide_notifications = hide_notifications |
4 | if params[:previous_path] | 7 | if params[:previous_path] |
@@ -7,4 +10,5 @@ class EnvironmentNotificationPluginPublicController < PublicController | @@ -7,4 +10,5 @@ class EnvironmentNotificationPluginPublicController < PublicController | ||
7 | @previous_path = nil | 10 | @previous_path = nil |
8 | end | 11 | end |
9 | end | 12 | end |
13 | + | ||
10 | end | 14 | end |
plugins/environment_notification/lib/environment_notification_helper.rb
1 | module EnvironmentNotificationHelper | 1 | module EnvironmentNotificationHelper |
2 | + | ||
3 | + def hide_notifications | ||
4 | + invalid_id = -1 | ||
5 | + hide_notifications_ids = [invalid_id] | ||
6 | + hide_notifications_ids = JSON.parse(cookies[:hide_notifications]) unless cookies[:hide_notifications].blank? | ||
7 | + hide_notifications_ids | ||
8 | + end | ||
9 | + | ||
2 | def self.substitute_variables(message, user) | 10 | def self.substitute_variables(message, user) |
3 | if user | 11 | if user |
4 | message = message.gsub("%{email}", user.person.email).gsub("%{name}", user.person.name) | 12 | message = message.gsub("%{email}", user.person.email).gsub("%{name}", user.person.name) |
@@ -6,4 +14,5 @@ module EnvironmentNotificationHelper | @@ -6,4 +14,5 @@ module EnvironmentNotificationHelper | ||
6 | 14 | ||
7 | message | 15 | message |
8 | end | 16 | end |
9 | -end | ||
10 | \ No newline at end of file | 17 | \ No newline at end of file |
18 | + | ||
19 | +end |
plugins/environment_notification/lib/environment_notification_plugin.rb
1 | class EnvironmentNotificationPlugin < Noosfero::Plugin | 1 | class EnvironmentNotificationPlugin < Noosfero::Plugin |
2 | 2 | ||
3 | - include ActionView::Helpers::JavaScriptHelper | ||
4 | - include ActionView::Helpers::TagHelper | ||
5 | - | ||
6 | def self.plugin_name | 3 | def self.plugin_name |
7 | "Environment Notifications Plugin" | 4 | "Environment Notifications Plugin" |
8 | end | 5 | end |
@@ -22,7 +19,10 @@ class EnvironmentNotificationPlugin < Noosfero::Plugin | @@ -22,7 +19,10 @@ class EnvironmentNotificationPlugin < Noosfero::Plugin | ||
22 | end | 19 | end |
23 | 20 | ||
24 | def body_beginning | 21 | def body_beginning |
25 | - expanded_template('environment_notification_plugin_admin/show_notification.html.erb') | 22 | + lambda do |
23 | + extend EnvironmentNotificationHelper | ||
24 | + render template: 'environment_notification_plugin_admin/show_notification' | ||
25 | + end | ||
26 | end | 26 | end |
27 | 27 | ||
28 | def admin_panel_links | 28 | def admin_panel_links |
plugins/environment_notification/lib/ext/application_controller.rb
@@ -1,10 +0,0 @@ | @@ -1,10 +0,0 @@ | ||
1 | -require_dependency 'application_controller' | ||
2 | - | ||
3 | -class ApplicationController | ||
4 | - def hide_notifications | ||
5 | - invalid_id = -1 | ||
6 | - hide_notifications_ids = [invalid_id] | ||
7 | - hide_notifications_ids = JSON.parse(cookies[:hide_notifications]) unless cookies[:hide_notifications].blank? | ||
8 | - hide_notifications_ids | ||
9 | - end | ||
10 | -end |
plugins/environment_notification/test/functional/account_controller_test.rb
1 | require File.expand_path(File.dirname(__FILE__)) + '/../../../../test/test_helper' | 1 | require File.expand_path(File.dirname(__FILE__)) + '/../../../../test/test_helper' |
2 | require 'account_controller' | 2 | require 'account_controller' |
3 | 3 | ||
4 | -class AccountController; def rescue_action(e) raise e end; | 4 | +class AccountController |
5 | + include EnvironmentNotificationHelper | ||
5 | end | 6 | end |
6 | 7 | ||
7 | class AccountControllerTest < ActionController::TestCase | 8 | class AccountControllerTest < ActionController::TestCase |
-
mentioned in commit b14e4201c0b8d4e9eae1bd8bbb266161405e8e7d
-
mentioned in commit b14e688877270d7fcd301ee07c81cb5e846a13e6