diff --git a/app/views/courses/show.html.erb b/app/views/courses/show.html.erb index 688f991e3..8968228f1 100644 --- a/app/views/courses/show.html.erb +++ b/app/views/courses/show.html.erb @@ -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 %>

No splits are associated with this course.

<% end %> diff --git a/spec/system/visit_course_events_spec.rb b/spec/system/visit_course_events_spec.rb new file mode 100644 index 000000000..8a984a272 --- /dev/null +++ b/spec/system/visit_course_events_spec.rb @@ -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 diff --git a/spec/system/visit_course_splits_spec.rb b/spec/system/visit_course_splits_spec.rb new file mode 100644 index 000000000..e697edf99 --- /dev/null +++ b/spec/system/visit_course_splits_spec.rb @@ -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