Skip to content

Commit

Permalink
don't add clickable links for unpublished courses on index
Browse files Browse the repository at this point in the history
test plan:
* invite a student to a course and accept the invitation
* unpublish the course
* the course should still be listed in the course index
 but shouldn't have a clickable link
* it should be clickable for a teacher enrollment

closes #CNVS-37075 #CNVS-37076

Change-Id: Idddff0ad75cad5c3de34ba59c044ccd328f70d67
Reviewed-on: https://gerrit.instructure.com/112764
Tested-by: Jenkins
Reviewed-by: Jeremy Stanley <[email protected]>
QA-Review: David Mirabile <[email protected]>
Product-Review: Chris Ward <[email protected]>
  • Loading branch information
maneframe committed May 24, 2017
1 parent 226aafd commit bfeacbc
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/views/shared/_current_enrollment.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
</div>
</div>
<% else %>
<% show_link = [:active, :invited, :accepted, :completed].include?(current_enrollment.state_based_on_date) %>
<% show_link = [:active, :invited, :accepted, :completed].include?(current_enrollment.state_based_on_date) && (!current_enrollment.course.unpublished? || current_enrollment.admin?) %>
<% if @show_star_column %>
<td class="course-list-star-column">
<% favorite_course = @favorite_course_ids.include?(current_enrollment.course_id) %>
Expand Down
17 changes: 17 additions & 0 deletions spec/integration/course_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,23 @@
expect(course_rows[2].to_s).to include 'Course 1'
end

it "should not show links to unpublished courses in course index" do
course_with_student(:course_name => "Course 1")
c1 = @course
@student.enrollments.first.update_attribute(:workflow_state, "active") # force active, like with sis
course_with_student(:user => @student, :active_all => true, :course_name => "Course 2")
c2 = @course
user_session(@student)
get "/courses"
doc = Nokogiri::HTML(response.body)
course_rows = doc.css('#my_courses_table tr')
expect(course_rows.size).to eq 3
expect(course_rows[1].to_s).to include 'Course 1'
expect(course_rows[1].to_s).to_not include("href=\"/courses/#{c1.id}\"") # unpublished
expect(course_rows[2].to_s).to include 'Course 2'
expect(course_rows[2].to_s).to include("href=\"/courses/#{c2.id}\"") # published
end

it "should not show students' nicknames to admins on the student's account profile page" do
course_with_student(:active_all => true)
@student.course_nicknames[@course.id] = 'STUDENT_NICKNAME'; @student.save!
Expand Down

0 comments on commit bfeacbc

Please sign in to comment.