Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Done #1072

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Done #1072

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
197 changes: 197 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,197 @@
GEM
remote: https://rubygems.org/
specs:
actioncable (5.0.7.2)
actionpack (= 5.0.7.2)
nio4r (>= 1.2, < 3.0)
websocket-driver (~> 0.6.1)
actionmailer (5.0.7.2)
actionpack (= 5.0.7.2)
actionview (= 5.0.7.2)
activejob (= 5.0.7.2)
mail (~> 2.5, >= 2.5.4)
rails-dom-testing (~> 2.0)
actionpack (5.0.7.2)
actionview (= 5.0.7.2)
activesupport (= 5.0.7.2)
rack (~> 2.0)
rack-test (~> 0.6.3)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.0, >= 1.0.2)
actionview (5.0.7.2)
activesupport (= 5.0.7.2)
builder (~> 3.1)
erubis (~> 2.7.0)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.0, >= 1.0.3)
activejob (5.0.7.2)
activesupport (= 5.0.7.2)
globalid (>= 0.3.6)
activemodel (5.0.7.2)
activesupport (= 5.0.7.2)
activerecord (5.0.7.2)
activemodel (= 5.0.7.2)
activesupport (= 5.0.7.2)
arel (~> 7.0)
activesupport (5.0.7.2)
concurrent-ruby (~> 1.0, >= 1.0.2)
i18n (>= 0.7, < 2)
minitest (~> 5.1)
tzinfo (~> 1.1)
annotate (2.7.5)
activerecord (>= 3.2, < 7.0)
rake (>= 10.4, < 13.0)
arel (7.1.4)
bootsnap (1.4.4)
msgpack (~> 1.0)
builder (3.2.3)
coffee-rails (4.1.1)
coffee-script (>= 2.2.0)
railties (>= 4.0.0, < 5.1.x)
coffee-script (2.4.1)
coffee-script-source
execjs
coffee-script-source (1.12.2)
concurrent-ruby (1.1.5)
crass (1.0.4)
diff-lcs (1.3)
erubis (2.7.0)
execjs (2.7.0)
faker (2.1.0)
i18n (>= 0.7)
ffi (1.11.1)
globalid (0.4.2)
activesupport (>= 4.2.0)
i18n (1.6.0)
concurrent-ruby (~> 1.0)
jbuilder (2.9.1)
activesupport (>= 4.2.0)
jquery-rails (4.3.5)
rails-dom-testing (>= 1, < 3)
railties (>= 4.2.0)
thor (>= 0.14, < 2.0)
json (1.8.6)
loofah (2.2.3)
crass (~> 1.0.2)
nokogiri (>= 1.5.9)
mail (2.7.1)
mini_mime (>= 0.1.1)
method_source (0.9.2)
mini_mime (1.0.2)
mini_portile2 (2.4.0)
minitest (5.11.3)
msgpack (1.3.1)
nio4r (2.4.0)
nokogiri (1.10.3)
mini_portile2 (~> 2.4.0)
rack (2.0.7)
rack-test (0.6.3)
rack (>= 1.0)
rails (5.0.7.2)
actioncable (= 5.0.7.2)
actionmailer (= 5.0.7.2)
actionpack (= 5.0.7.2)
actionview (= 5.0.7.2)
activejob (= 5.0.7.2)
activemodel (= 5.0.7.2)
activerecord (= 5.0.7.2)
activesupport (= 5.0.7.2)
bundler (>= 1.3.0)
railties (= 5.0.7.2)
sprockets-rails (>= 2.0.0)
rails-controller-testing (1.0.4)
actionpack (>= 5.0.1.x)
actionview (>= 5.0.1.x)
activesupport (>= 5.0.1.x)
rails-dom-testing (2.0.3)
activesupport (>= 4.2.0)
nokogiri (>= 1.6)
rails-html-sanitizer (1.2.0)
loofah (~> 2.2, >= 2.2.2)
railties (5.0.7.2)
actionpack (= 5.0.7.2)
activesupport (= 5.0.7.2)
method_source
rake (>= 0.8.7)
thor (>= 0.18.1, < 2.0)
rake (12.3.3)
rb-fsevent (0.10.3)
rb-inotify (0.10.0)
ffi (~> 1.0)
rdoc (4.3.0)
rspec-core (3.8.2)
rspec-support (~> 3.8.0)
rspec-expectations (3.8.4)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.8.0)
rspec-mocks (3.8.1)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.8.0)
rspec-rails (4.0.0.beta2)
actionpack (>= 4.2)
activesupport (>= 4.2)
railties (>= 4.2)
rspec-core (~> 3.8)
rspec-expectations (~> 3.8)
rspec-mocks (~> 3.8)
rspec-support (~> 3.8)
rspec-support (3.8.2)
sass (3.7.4)
sass-listen (~> 4.0.0)
sass-listen (4.0.0)
rb-fsevent (~> 0.9, >= 0.9.4)
rb-inotify (~> 0.9, >= 0.9.7)
sass-rails (5.0.7)
railties (>= 4.0.0, < 6)
sass (~> 3.1)
sprockets (>= 2.8, < 4.0)
sprockets-rails (>= 2.0, < 4.0)
tilt (>= 1.1, < 3)
sdoc (0.4.2)
json (~> 1.7, >= 1.7.7)
rdoc (~> 4.0)
spring (2.1.0)
sprockets (3.7.2)
concurrent-ruby (~> 1.0)
rack (> 1, < 3)
sprockets-rails (3.2.1)
actionpack (>= 4.0)
activesupport (>= 4.0)
sprockets (>= 3.0.0)
sqlite3 (1.3.13)
thor (0.20.3)
thread_safe (0.3.6)
tilt (2.0.9)
turbolinks (5.2.0)
turbolinks-source (~> 5.2)
turbolinks-source (5.2.0)
tzinfo (1.2.5)
thread_safe (~> 0.1)
uglifier (4.1.20)
execjs (>= 0.3.0, < 3)
websocket-driver (0.6.5)
websocket-extensions (>= 0.1.0)
websocket-extensions (0.1.4)

PLATFORMS
ruby

DEPENDENCIES
annotate
bootsnap
coffee-rails (~> 4.1.0)
faker
jbuilder (~> 2.0)
jquery-rails
rails
rails-controller-testing
rspec-rails (>= 2.0.0.beta)
sass-rails (~> 5.0)
sdoc (~> 0.4.0)
spring
sqlite3 (~> 1.3.6)
turbolinks
uglifier (>= 1.3.0)

BUNDLED WITH
2.0.1
10 changes: 10 additions & 0 deletions app/models/student.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,14 @@
class Student < ActiveRecord::Base
has_many :classroom_students
has_many :classrooms, through: :classroom_students

def self.search(name)
if name == ''
self.all
else
self.all.select do |s|
s.name.downcase.include?(name)
end
end
end
end
4 changes: 4 additions & 0 deletions app/views/classrooms/_classroom.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<p>
<%= @classroom.course_name %>
<%= @classroom.semester %>
</p>
11 changes: 6 additions & 5 deletions app/views/classrooms/show.html.erb
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
Classroom Info
<p>
<%= @classroom.course_name %>
<%= @classroom.semester %>
</p>

<%= render partial: 'classroom', locals: {classroom: @classroom} %>

We now want to call out the oldest student in the class:
<%= render 'students/student' %>

<%= @classroom.students.all.each do |student| %>
<%= render partial: 'students/student', locals: {student: student} %>
<% end %>
2 changes: 1 addition & 1 deletion app/views/students/_form.html.erb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<%= form_for @student do |f|%>
<%= form_for student do |f|%>
<p>
<%= f.label :name %>
<%= f.text_field :name %>
Expand Down
6 changes: 3 additions & 3 deletions app/views/students/_student.html.erb
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<ul>
<li>
Name: <%= @student.name %>
Name: <%= student.name %>
</li>
<li>
Birthday: <%= @student.birthday.strftime("%m/%d/%Y") %>
Birthday: <%= student.birthday.strftime("%m/%d/%Y") %>
</li>
<li>
Hometown: <%= @student.hometown.capitalize %>
Hometown: <%= student.hometown.capitalize %>
</li>
</ul>
2 changes: 1 addition & 1 deletion app/views/students/edit.html.erb
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<%= render 'form' %>
<%= render partial: 'form', locals: {student: @student} %>
5 changes: 5 additions & 0 deletions app/views/students/index.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<%= Student.all.each do |student| %>

<%= render partial: 'student', locals: {student: student} %>

<% end %>
2 changes: 1 addition & 1 deletion app/views/students/new.html.erb
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<%= render 'form' %>
<%= render partial: 'form', locals: {student: @student} %>
2 changes: 1 addition & 1 deletion app/views/students/show.html.erb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<h1>Student Info</h1>

<%= render 'student' %>
<%= render partial: 'student', locals: {student: @student} %>
2 changes: 2 additions & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
Rails.application.routes.draw do
# For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html

resources :students
end
4 changes: 2 additions & 2 deletions spec/models/student_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

before do
student_names.each do |name|
Student.create(name: name, hometown: Faker::Address.city, birthday: Faker::Date.between(25.years.ago, 18.years.ago))
Student.create(name: name, hometown: Faker::Address.city, birthday: Faker::Date.between(from: 25.years.ago, to: 18.years.ago))
end
end

Expand All @@ -22,4 +22,4 @@
end
end
end
end
end
6 changes: 3 additions & 3 deletions spec/views/classroom_show_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

RSpec.describe 'classroom_show_view' do
let(:classroom) { Classroom.create(course_name: 'Math', semester: "Spring #{Time.now.year}") }
let(:student) { Student.create(name: 'Bobby', hometown: Faker::Address.city, birthday: Faker::Date.between(25.years.ago, 18.years.ago)) }
let(:student) { Student.create(name: 'Bobby', hometown: Faker::Address.city, birthday: Faker::Date.between(from: 25.years.ago, to: 18.years.ago)) }

before do
5.times do
Student.create(name: Faker::Name.name, hometown: Faker::Address.city, birthday: Faker::Date.between(25.years.ago, 18.years.ago))
Student.create(name: Faker::Name.name, hometown: Faker::Address.city, birthday: Faker::Date.between(from: 25.years.ago, to: 18.years.ago))
end
Student.all.each do |student|
ClassroomStudent.create(student: student, classroom: classroom)
Expand All @@ -15,7 +15,7 @@

it 'renders classroom information on the show view' do
view.lookup_context.prefixes = %w[students classrooms]
student = Student.create(name: 'Bobby', hometown: Faker::Address.city, birthday: Faker::Date.between(25.years.ago, 18.years.ago))
student = Student.create(name: 'Bobby', hometown: Faker::Address.city, birthday: Faker::Date.between(from: 25.years.ago, to: 18.years.ago))
assign(:classroom, classroom)
render template: 'classrooms/show.html.erb'
expect(rendered).to match /Math/
Expand Down
2 changes: 1 addition & 1 deletion spec/views/student_index_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

before do
student_names.each do |name|
Student.create(name: name, hometown: Faker::Address.city, birthday: Faker::Date.between(25.years.ago, 18.years.ago))
Student.create(name: name, hometown: Faker::Address.city, birthday: Faker::Date.between(from: 25.years.ago, to: 18.years.ago))
end
end

Expand Down
6 changes: 3 additions & 3 deletions spec/views/student_new_edit_form_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,15 @@
describe 'edit form' do
it "renders edit student form from the edit.html file" do
view.lookup_context.prefixes = %w[students]
student = Student.create(name: 'Bobby', hometown: Faker::Address.city, birthday: Faker::Date.between(25.years.ago, 18.years.ago))
student = Student.create(name: 'Bobby', hometown: Faker::Address.city, birthday: Faker::Date.between(from: 25.years.ago, to: 18.years.ago))
assign(:student, student)
render :template => "students/edit.html.erb"
expect(rendered).to match /Update Student/
end

it "directly renders the form in a students/form partial with the form object passed through as a local variable" do
view.lookup_context.prefixes = %w[students]
student = Student.create(name: 'Bobby', hometown: Faker::Address.city, birthday: Faker::Date.between(25.years.ago, 18.years.ago))
student = Student.create(name: 'Bobby', hometown: Faker::Address.city, birthday: Faker::Date.between(from: 25.years.ago, to: 18.years.ago))
assign(:student, student)
render :template => "students/new.html.erb"

Expand All @@ -50,7 +50,7 @@

it "directly renders the form in a students/form partial with the form object passed through as a local variable" do
view.lookup_context.prefixes = %w[students]
student = Student.create(name: 'Bobby', hometown: Faker::Address.city, birthday: Faker::Date.between(25.years.ago, 18.years.ago))
student = Student.create(name: 'Bobby', hometown: Faker::Address.city, birthday: Faker::Date.between(from: 25.years.ago, to: 18.years.ago))
assign(:student, student)

render :template => "students/edit.html.erb"
Expand Down
2 changes: 1 addition & 1 deletion spec/views/student_show_spec.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
require "rails_helper"

RSpec.describe "show_view" do
let(:student){ Student.create(name: 'Bobby', hometown: Faker::Address.city, birthday: Faker::Date.between(25.years.ago, 18.years.ago)) }
let(:student){ Student.create(name: 'Bobby', hometown: Faker::Address.city, birthday: Faker::Date.between(from: 25.years.ago, to: 18.years.ago)) }

it "renders student information from the classroom show view" do
view.lookup_context.prefixes = %w[students]
Expand Down