Skip to content

Commit

Permalink
Merge pull request #5588 from rubyforgood/5513-write-system-test-for-…
Browse files Browse the repository at this point in the history
…supervisors-and-admins-seeing-learning-hours

Modify system tests for LearningHours#index to verify different behaviours for Admins/Supervisors vs Volunteers
  • Loading branch information
compwron authored Apr 15, 2024
2 parents 0bc2b48 + dc7a4de commit 0be8d37
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions spec/system/learning_hours/index_spec.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
require "rails_helper"

RSpec.describe "Learning Hours Index", type: :system do
let(:volunteer) { create(:volunteer) }
let(:supervisor) { create(:supervisor) }
let(:learning_hours) { create_list(:learning_hour, 5, user: volunteer) }
let!(:supervisor) { create(:supervisor, :with_volunteers) }
let!(:volunteer) { supervisor.volunteers.first }
let!(:learning_hours) { create_list(:learning_hour, 2, user: volunteer) }

before do
login_as user, scope: :user
Expand All @@ -28,10 +28,17 @@
visit learning_hours_path
end

it "displays the supervisor/admin learning hours", js: true do
it "displays a list of volunteers and the learning hours they completed", js: true do
expect(page).to have_content("Learning Hours")
expect(page).to have_content("Volunteer")
expect(page).to have_content(volunteer.display_name)
expect(page).to have_content("Time Completed")
expect(page).to have_content("#{volunteer.learning_hours.sum(:duration_hours)} hours")
end

it "when clicking on a volunteer's name it redirects to the `learning_hours_volunteer_path` for the volunteer" do
click_on volunteer.display_name
expect(page).to have_current_path(learning_hours_volunteer_path(volunteer.id))
end

shared_examples_for "functioning sort buttons" do
Expand Down

0 comments on commit 0be8d37

Please sign in to comment.