Skip to content

Commit

Permalink
Code and spec for showing learning topic in learning hours table of V…
Browse files Browse the repository at this point in the history
…olunteer
  • Loading branch information
sarvaiyanidhi committed Sep 29, 2023
1 parent 2b5e1db commit 86acb88
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
6 changes: 6 additions & 0 deletions app/views/learning_hours/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
<tr>
<th>Title</th>
<th>Learning Type</th>
<% if current_user.casa_org.learning_topic_active %>
<th>Learning Topic</th>
<% end %>
<th>Date</th>
<th>Time Spent</th>
</tr>
Expand All @@ -26,6 +29,9 @@
<%= link_to learning_hour.name, volunteer_learning_hour_path(id: learning_hour.id) %>
</td>
<td> <%= learning_hour.learning_hour_type.name %> </td>
<% if current_user.casa_org.learning_topic_active %>
<td> <%= learning_hour.learning_hour_topic&.name %> </td>
<% end %>
<td> <%= learning_hour.occurred_at.strftime("%B %d, %Y") %> </td>
<td>
<% if (learning_hour.duration_hours > 0) %>
Expand Down
12 changes: 12 additions & 0 deletions spec/requests/learning_hours_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 86acb88

Please sign in to comment.