Commit 1414c2864df4e2d73c8b01f1b7c0c437ee2279b5

Authored by Braulio Bhavamitra
1 parent 852945bf

environment_notifications: fix broken tests

The plugin still has some structural problems
plugins/environment_notification/controllers/environment_notification_plugin_admin_controller.rb
1 1 class EnvironmentNotificationPluginAdminController < AdminController
  2 +
  3 + helper EnvironmentNotificationHelper
  4 + include EnvironmentNotificationHelper
  5 +
2 6 before_filter :admin_required, :except => [:close_notification, :hide_notification]
  7 +
3 8 def index
4 9 @notifications = environment.environment_notifications.order('updated_at DESC')
5 10 end
... ...
plugins/environment_notification/controllers/public/environment_notification_plugin_public_controller.rb
1 1 class EnvironmentNotificationPluginPublicController < PublicController
  2 +
  3 + helper EnvironmentNotificationHelper
  4 +
2 5 def notifications_with_popup
3 6 @hide_notifications = hide_notifications
4 7 if params[:previous_path]
... ... @@ -7,4 +10,5 @@ class EnvironmentNotificationPluginPublicController &lt; PublicController
7 10 @previous_path = nil
8 11 end
9 12 end
  13 +
10 14 end
... ...
plugins/environment_notification/lib/environment_notification_helper.rb
1 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 10 def self.substitute_variables(message, user)
3 11 if user
4 12 message = message.gsub("%{email}", user.person.email).gsub("%{name}", user.person.name)
... ... @@ -6,4 +14,5 @@ module EnvironmentNotificationHelper
6 14  
7 15 message
8 16 end
9   -end
10 17 \ No newline at end of file
  18 +
  19 +end
... ...
plugins/environment_notification/lib/environment_notification_plugin.rb
1 1 class EnvironmentNotificationPlugin < Noosfero::Plugin
2 2  
3   - include ActionView::Helpers::JavaScriptHelper
4   - include ActionView::Helpers::TagHelper
5   -
6 3 def self.plugin_name
7 4 "Environment Notifications Plugin"
8 5 end
... ... @@ -22,7 +19,10 @@ class EnvironmentNotificationPlugin &lt; Noosfero::Plugin
22 19 end
23 20  
24 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 26 end
27 27  
28 28 def admin_panel_links
... ...
plugins/environment_notification/lib/ext/application_controller.rb
... ... @@ -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 1 require File.expand_path(File.dirname(__FILE__)) + '/../../../../test/test_helper'
2 2 require 'account_controller'
3 3  
4   -class AccountController; def rescue_action(e) raise e end;
  4 +class AccountController
  5 + include EnvironmentNotificationHelper
5 6 end
6 7  
7 8 class AccountControllerTest < ActionController::TestCase
... ...