Skip to content

Commit

Permalink
SC-78 Evaluator journey: accessing evaluation from a link (#2022)
Browse files Browse the repository at this point in the history
  • Loading branch information
edwin-jebaraj authored Jan 20, 2025
2 parents 6f71b4b + 2238832 commit b5d4542
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 0 deletions.
6 changes: 6 additions & 0 deletions app/controllers/cms_entry_points_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@ def record_ga? = false
def home_page
policy = policy(:cms_portal)

if session[:email_evaluator_link].present?
email_evaluator_link = session[:email_evaluator_link]
session.delete(:email_evaluator_link)
return email_evaluator_link
end

return support_root_path if policy.access_proc_ops_portal?
return engagement_root_path if policy.access_e_and_o_portal?
return support_case_statistics_path if policy.access_statistics?
Expand Down
10 changes: 10 additions & 0 deletions app/services/create_user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ def call

update_user! if current_user
update_support_agent! if current_support_agent.present?
update_support_evaluator! if current_support_evaluator.present?

if member_of_a_supported_establishment? || internal_staff_member?
current_user || create_user!
Expand Down Expand Up @@ -77,6 +78,15 @@ def update_support_agent!
track_event("CreateUser/AgentUpdated", agent_id: current_support_agent.id)
end

def current_support_evaluator
Support::Evaluator.where("lower(email) = lower(?)", email)
end

def update_support_evaluator!
current_support_evaluator.update!(dsi_uid: user_id)
track_event("CreateUser/EvaluatorUpdated", evaluator_email: email)
end

# @return [User, nil]
def current_user
User.find_by(dfe_sign_in_uid: user_id)
Expand Down
11 changes: 11 additions & 0 deletions spec/services/specify/create_user_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -196,5 +196,16 @@
end
end
end

context "when there's a support evaluator" do
let(:dfe_sign_in_uid) { "evaluator-uid" }
let(:email) { "evaluator@example.com" }
let!(:support_evaluator) { create(:support_evaluator, email: email.downcase) }

it "updates the support evaluator to have the dsi uid of the user" do
service.call
expect(support_evaluator.reload.dsi_uid).to eq(dfe_sign_in_uid)
end
end
end
end

0 comments on commit b5d4542

Please sign in to comment.