-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of github.com:wicz/liskov
* 'master' of github.com:wicz/liskov: naive passing student page test DRY'd up how PersonDecorator are created and added filter chain in students controller fixed test broken by new task factories
- Loading branch information
Showing
9 changed files
with
60 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,33 @@ | ||
class StudentsController < ApplicationController | ||
|
||
before_filter :find_course, :find_person, :find_membership | ||
|
||
def show | ||
@student = StudentDecorator.new(@membership) | ||
end | ||
|
||
private | ||
|
||
#TODO: This is duped in TasksController. DRY it up! | ||
def find_course | ||
@course = Course.find(params[:course_id]) | ||
rescue ActiveRecord::RecordNotFound | ||
redirect_to(root_url, alert: "Couldn't find course") | ||
end | ||
|
||
def find_person | ||
@person = clubhouse_person(params[:id]) | ||
|
||
unless @person | ||
redirect_to(@course, alert: "Student does not exist.") | ||
end | ||
end | ||
|
||
def find_membership | ||
@membership = @course.membership_for(@person) | ||
|
||
unless @membership | ||
redirect_to(@course, alert: "Student does not belong to course.") | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
class StudentDecorator < ApplicationDecorator | ||
decorates :course_membership | ||
|
||
def tasks | ||
course_membership.course.tasks.map(&:description) | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
%ul | ||
- @student.tasks.each do |t| | ||
%li= t | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters