From 86acb8824b612336996601197d247828fcb2f7b3 Mon Sep 17 00:00:00 2001 From: Nidhi Sarvaiya Date: Fri, 29 Sep 2023 16:40:22 -0400 Subject: [PATCH] Code and spec for showing learning topic in learning hours table of Volunteer --- app/views/learning_hours/index.html.erb | 6 ++++++ spec/requests/learning_hours_spec.rb | 12 ++++++++++++ 2 files changed, 18 insertions(+) diff --git a/app/views/learning_hours/index.html.erb b/app/views/learning_hours/index.html.erb index efc2404d35..fbbb3f5d48 100644 --- a/app/views/learning_hours/index.html.erb +++ b/app/views/learning_hours/index.html.erb @@ -15,6 +15,9 @@ Title Learning Type + <% if current_user.casa_org.learning_topic_active %> + Learning Topic + <% end %> Date Time Spent @@ -26,6 +29,9 @@ <%= link_to learning_hour.name, volunteer_learning_hour_path(id: learning_hour.id) %> <%= learning_hour.learning_hour_type.name %> + <% if current_user.casa_org.learning_topic_active %> + <%= learning_hour.learning_hour_topic&.name %> + <% end %> <%= learning_hour.occurred_at.strftime("%B %d, %Y") %> <% if (learning_hour.duration_hours > 0) %> diff --git a/spec/requests/learning_hours_spec.rb b/spec/requests/learning_hours_spec.rb index 57d40a5512..e521358758 100644 --- a/spec/requests/learning_hours_spec.rb +++ b/spec/requests/learning_hours_spec.rb @@ -11,6 +11,18 @@ get volunteer_learning_hours_path(volunteer_id: volunteer.id) expect(response).to have_http_status(:success) end + + it "displays the Learning Topic column if learning_topic_active is true" do + volunteer.casa_org.update(learning_topic_active: true) + get volunteer_learning_hours_path(volunteer_id: volunteer.id) + expect(response.body).to include("Learning Topic") + end + + it "does not display the Learning Topic column if learning_topic_active is false" do + volunteer.casa_org.update(learning_topic_active: false) + get volunteer_learning_hours_path(volunteer_id: volunteer.id) + expect(response.body).not_to include("Learning Topic") + end end end end