Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix unify feature #67

Merged
merged 4 commits into from
Apr 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions rails_root/app/controllers/home_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,11 @@
# Controller for the home page
class HomeController < ApplicationController
def index
@survey_responses = SurveyResponse.where(profile_id: 2) # FIXME: use code below when other part works
# @survey_profile = SurveyProfile.find_by(user_id: session[:userinfo]["sub"])
# @survey_responses = SurveyResponse.where(profile_id: session[:userinfo]["sub"])
return if session[:userinfo].nil?

@survey_profile = SurveyProfile.find_by(user_id: session[:userinfo]['sub'])
return if @survey_profile.nil?

@survey_responses = SurveyResponse.where(profile_id: @survey_profile.id)
end
end
5 changes: 5 additions & 0 deletions rails_root/app/views/home/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@

<% if session[:userinfo].present? %>
<h1><%= session[:userinfo]['name'] %> - Welcome to Our Rails App</h1>
<br>
<h2>Your Profile</h2>
<% if @survey_profile.present? %>
<%= render @survey_profile%>
<%end%>
<h2>Your History Responses</h2>
<div class="table-responsive">
<table class="table">
Expand Down
4 changes: 0 additions & 4 deletions rails_root/app/views/survey_profiles/_survey_profile.html.erb
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
<div id="<%= dom_id survey_profile %>">
<p>
<strong>User:</strong>
<%= survey_profile.user_id %>
</p>

<p>
<strong>First name:</strong>
Expand Down
2 changes: 1 addition & 1 deletion rails_root/spec/views/home/index.html.erb_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

RSpec.describe 'home/index.html.erb', type: :view do
it 'displays the welcome message with name' do
session[:userinfo] = { 'name' => 'Peter', 'sub' => 'testestest' }
session[:userinfo] = { 'name' => 'Peter', 'sub' => 1 }
render
expect(rendered).to have_text('Peter - Welcome to Our Rails App')
end
Expand Down
Loading