From 6d92aa6d12b875b4987666da98658191ae426892 Mon Sep 17 00:00:00 2001 From: randx Date: Sun, 24 Jun 2012 10:01:42 +0300 Subject: [PATCH] Fix IssueObserver current_user assign. Refactored observers --- app/controllers/application_controller.rb | 10 +++++++++- app/{models => observers}/activity_observer.rb | 0 app/{models => observers}/issue_observer.rb | 0 app/{models => observers}/key_observer.rb | 0 app/{models => observers}/mailer_observer.rb | 0 app/{models => observers}/project_observer.rb | 0 app/{models => observers}/user_observer.rb | 0 7 files changed, 9 insertions(+), 1 deletion(-) rename app/{models => observers}/activity_observer.rb (100%) rename app/{models => observers}/issue_observer.rb (100%) rename app/{models => observers}/key_observer.rb (100%) rename app/{models => observers}/mailer_observer.rb (100%) rename app/{models => observers}/project_observer.rb (100%) rename app/{models => observers}/user_observer.rb (100%) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 0c31788e..9a0f95bf 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -1,8 +1,12 @@ class ApplicationController < ActionController::Base before_filter :authenticate_user! before_filter :reject_blocked! - before_filter :set_current_user_for_mailer, :check_token_auth + before_filter :set_current_user_for_mailer + before_filter :check_token_auth + before_filter :set_current_user_for_observers + protect_from_forgery + helper_method :abilities, :can? rescue_from Gitlab::Gitolite::AccessDenied do |exception| @@ -58,6 +62,10 @@ class ApplicationController < ActionController::Base MailerObserver.current_user = current_user end + def set_current_user_for_observers + IssueObserver.current_user = current_user + end + def abilities @abilities ||= Six.new end diff --git a/app/models/activity_observer.rb b/app/observers/activity_observer.rb similarity index 100% rename from app/models/activity_observer.rb rename to app/observers/activity_observer.rb diff --git a/app/models/issue_observer.rb b/app/observers/issue_observer.rb similarity index 100% rename from app/models/issue_observer.rb rename to app/observers/issue_observer.rb diff --git a/app/models/key_observer.rb b/app/observers/key_observer.rb similarity index 100% rename from app/models/key_observer.rb rename to app/observers/key_observer.rb diff --git a/app/models/mailer_observer.rb b/app/observers/mailer_observer.rb similarity index 100% rename from app/models/mailer_observer.rb rename to app/observers/mailer_observer.rb diff --git a/app/models/project_observer.rb b/app/observers/project_observer.rb similarity index 100% rename from app/models/project_observer.rb rename to app/observers/project_observer.rb diff --git a/app/models/user_observer.rb b/app/observers/user_observer.rb similarity index 100% rename from app/models/user_observer.rb rename to app/observers/user_observer.rb