Skip to content

Commit

Permalink
Fix unknown local referred_by and add specs for course views (#1363)
Browse files Browse the repository at this point in the history
  • Loading branch information
moveson authored Dec 23, 2024
1 parent f99fdb1 commit 0a787c8
Show file tree
Hide file tree
Showing 3 changed files with 123 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/views/courses/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@

<% if @presenter.display_style == "splits" %>
<% if @presenter.ordered_splits.present? %>
<%= render "splits/splits", splits: @presenter.ordered_splits, referred_by: organization_course_path(@presenter.organization, @presenter.course) %>
<%= render "splits/splits", splits: @presenter.ordered_splits %>
<% else %>
<h4>No splits are associated with this course.</h4>
<% end %>
Expand Down
61 changes: 61 additions & 0 deletions spec/system/visit_course_events_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# frozen_string_literal: true

require "rails_helper"

RSpec.describe "Visit a course events page" do
let(:organization) { organizations(:hardrock) }
let(:course) { courses(:hardrock_cw) }
let(:events) { course.events }

let(:user) { users(:third_user) }
let(:owner) { users(:fourth_user) }
let(:steward) { users(:fifth_user) }
let(:admin) { users(:admin_user) }

before do
organization.update(created_by: owner.id)
organization.stewards << steward
end

scenario "Visitor visits the page" do
visit_page
verify_content_present
end

scenario "User visits the page" do
login_as user, scope: :user

visit_page
verify_content_present
end

scenario "Steward visits the page" do
login_as steward, scope: :user

visit_page
verify_content_present
end

scenario "Owner visits the page" do
login_as owner, scope: :user

visit_page
verify_content_present
end

scenario "Admin visits the page" do
login_as admin, scope: :user

visit_page
verify_content_present
end

def visit_page
visit organization_course_path(organization, course)
end

def verify_content_present
expect(page).to have_content(organization.name)
course.events.each { |event| expect(page).to have_text(event.name) }
end
end
61 changes: 61 additions & 0 deletions spec/system/visit_course_splits_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# frozen_string_literal: true

require "rails_helper"

RSpec.describe "Visit a course splits page" do
let(:organization) { organizations(:hardrock) }
let(:course) { courses(:hardrock_cw) }
let(:splits) { course.splits }

let(:user) { users(:third_user) }
let(:owner) { users(:fourth_user) }
let(:steward) { users(:fifth_user) }
let(:admin) { users(:admin_user) }

before do
organization.update(created_by: owner.id)
organization.stewards << steward
end

scenario "Visitor visits the page" do
visit_page
verify_content_present
end

scenario "User visits the page" do
login_as user, scope: :user

visit_page
verify_content_present
end

scenario "Steward visits the page" do
login_as steward, scope: :user

visit_page
verify_content_present
end

scenario "Owner visits the page" do
login_as owner, scope: :user

visit_page
verify_content_present
end

scenario "Admin visits the page" do
login_as admin, scope: :user

visit_page
verify_content_present
end

def visit_page
visit organization_course_path(organization, course, display_style: :splits)
end

def verify_content_present
expect(page).to have_content(organization.name)
course.splits.each { |split| expect(page).to have_text(split.base_name) }
end
end

0 comments on commit 0a787c8

Please sign in to comment.