changes current_user for managed_user

This commit is contained in:
rgarcia
2015-10-13 13:58:01 +02:00
parent c07bf7e212
commit bca26b2b50
4 changed files with 17 additions and 11 deletions

View File

@@ -3,6 +3,8 @@ class Management::BaseController < ActionController::Base
before_action :verify_manager before_action :verify_manager
helper_method :managed_user
private private
def verify_manager def verify_manager
@@ -13,8 +15,8 @@ class Management::BaseController < ActionController::Base
@current_manager ||= Manager.find(session["manager_id"]) if session["manager_id"] @current_manager ||= Manager.find(session["manager_id"]) if session["manager_id"]
end end
def current_user def managed_user
@current_user ||= Verification::Management::ManagedUser.find(session[:document_type], session[:document_number]) @managed_user ||= Verification::Management::ManagedUser.find(session[:document_type], session[:document_number])
end end
end end

View File

@@ -38,6 +38,10 @@ class Management::ProposalsController < Management::BaseController
end end
end end
def current_user
managed_user
end
#Duplicated in application_controller. Move to a concenrn. #Duplicated in application_controller. Move to a concenrn.
def set_proposal_votes(proposals) def set_proposal_votes(proposals)
@proposal_votes = current_user ? current_user.proposal_votes(proposals) : {} @proposal_votes = current_user ? current_user.proposal_votes(proposals) : {}

View File

@@ -1,24 +1,24 @@
<% if current_user.document_number.present? %> <% if managed_user.document_number.present? %>
<span class="account-info right"> <span class="account-info right">
<% if current_user.level_two_or_three_verified? %> <% if managed_user.level_two_or_three_verified? %>
<%= t("management.account_info.identified_label") %> <%= t("management.account_info.identified_label") %>
<% end %> <% end %>
<% if current_user.username.present? %> <% if managed_user.username.present? %>
<%= t("management.account_info.username_label") %> <%= t("management.account_info.username_label") %>
<strong><%= current_user.username %></strong> <strong><%= managed_user.username %></strong>
<% end %> <% end %>
<% if current_user.email.present? %> <% if managed_user.email.present? %>
<%= t("management.account_info.email_label") %> <%= t("management.account_info.email_label") %>
<strong><%= current_user.email %></strong> <strong><%= managed_user.email %></strong>
<% end %> <% end %>
<%= t("management.account_info.document_type_label") %> <%= t("management.account_info.document_type_label") %>
<strong><%= humanize_document_type(current_user.document_type) %></strong> <strong><%= humanize_document_type(managed_user.document_type) %></strong>
<%= t("management.account_info.document_number_label") %> <%= t("management.account_info.document_number_label") %>
<strong><%= current_user.document_number %></strong> <strong><%= managed_user.document_number %></strong>
<%= link_to(t("management.account_info.logout"), logout_management_users_path, method: :delete) %> <%= link_to(t("management.account_info.logout"), logout_management_users_path, method: :delete) %>
</span> </span>

View File

@@ -29,7 +29,7 @@ module CommonActions
end end
def login_managed_user(user) def login_managed_user(user)
allow_any_instance_of(Management::BaseController).to receive(:current_user).and_return(user) allow_any_instance_of(Management::BaseController).to receive(:managed_user).and_return(user)
end end
def confirm_email def confirm_email