diff --git a/app/assets/javascripts/schools.js.coffee b/app/assets/javascripts/schools.js.coffee new file mode 100644 index 0000000..24f83d1 --- /dev/null +++ b/app/assets/javascripts/schools.js.coffee @@ -0,0 +1,3 @@ +# Place all the behaviors and hooks related to the matching controller here. +# All this logic will automatically be available in application.js. +# You can use CoffeeScript in this file: http://coffeescript.org/ diff --git a/app/assets/javascripts/weights.js.coffee b/app/assets/javascripts/weights.js.coffee new file mode 100644 index 0000000..24f83d1 --- /dev/null +++ b/app/assets/javascripts/weights.js.coffee @@ -0,0 +1,3 @@ +# Place all the behaviors and hooks related to the matching controller here. +# All this logic will automatically be available in application.js. +# You can use CoffeeScript in this file: http://coffeescript.org/ diff --git a/app/assets/javascripts/wrestlers.js.coffee b/app/assets/javascripts/wrestlers.js.coffee new file mode 100644 index 0000000..24f83d1 --- /dev/null +++ b/app/assets/javascripts/wrestlers.js.coffee @@ -0,0 +1,3 @@ +# Place all the behaviors and hooks related to the matching controller here. +# All this logic will automatically be available in application.js. +# You can use CoffeeScript in this file: http://coffeescript.org/ diff --git a/app/assets/stylesheets/scaffolds.css.scss b/app/assets/stylesheets/scaffolds.css.scss new file mode 100644 index 0000000..6ec6a8f --- /dev/null +++ b/app/assets/stylesheets/scaffolds.css.scss @@ -0,0 +1,69 @@ +body { + background-color: #fff; + color: #333; + font-family: verdana, arial, helvetica, sans-serif; + font-size: 13px; + line-height: 18px; +} + +p, ol, ul, td { + font-family: verdana, arial, helvetica, sans-serif; + font-size: 13px; + line-height: 18px; +} + +pre { + background-color: #eee; + padding: 10px; + font-size: 11px; +} + +a { + color: #000; + &:visited { + color: #666; + } + &:hover { + color: #fff; + background-color: #000; + } +} + +div { + &.field, &.actions { + margin-bottom: 10px; + } +} + +#notice { + color: green; +} + +.field_with_errors { + padding: 2px; + background-color: red; + display: table; +} + +#error_explanation { + width: 450px; + border: 2px solid red; + padding: 7px; + padding-bottom: 0; + margin-bottom: 20px; + background-color: #f0f0f0; + h2 { + text-align: left; + font-weight: bold; + padding: 5px 5px 5px 15px; + font-size: 12px; + margin: -7px; + margin-bottom: 0px; + background-color: #c00; + color: #fff; + } + ul li { + font-size: 12px; + list-style: square; + } +} diff --git a/app/assets/stylesheets/schools.css.scss b/app/assets/stylesheets/schools.css.scss new file mode 100644 index 0000000..813d2d0 --- /dev/null +++ b/app/assets/stylesheets/schools.css.scss @@ -0,0 +1,3 @@ +// Place all the styles related to the Schools controller here. +// They will automatically be included in application.css. +// You can use Sass (SCSS) here: http://sass-lang.com/ diff --git a/app/assets/stylesheets/weights.css.scss b/app/assets/stylesheets/weights.css.scss new file mode 100644 index 0000000..90a4fae --- /dev/null +++ b/app/assets/stylesheets/weights.css.scss @@ -0,0 +1,3 @@ +// Place all the styles related to the Weights controller here. +// They will automatically be included in application.css. +// You can use Sass (SCSS) here: http://sass-lang.com/ diff --git a/app/assets/stylesheets/wrestlers.css.scss b/app/assets/stylesheets/wrestlers.css.scss new file mode 100644 index 0000000..6a79218 --- /dev/null +++ b/app/assets/stylesheets/wrestlers.css.scss @@ -0,0 +1,3 @@ +// Place all the styles related to the Wrestlers controller here. +// They will automatically be included in application.css. +// You can use Sass (SCSS) here: http://sass-lang.com/ diff --git a/app/controllers/schools_controller.rb b/app/controllers/schools_controller.rb new file mode 100644 index 0000000..6e5986b --- /dev/null +++ b/app/controllers/schools_controller.rb @@ -0,0 +1,74 @@ +class SchoolsController < ApplicationController + before_action :set_school, only: [:show, :edit, :update, :destroy] + + # GET /schools + # GET /schools.json + def index + @schools = School.all + end + + # GET /schools/1 + # GET /schools/1.json + def show + end + + # GET /schools/new + def new + @school = School.new + end + + # GET /schools/1/edit + def edit + end + + # POST /schools + # POST /schools.json + def create + @school = School.new(school_params) + + respond_to do |format| + if @school.save + format.html { redirect_to @school, notice: 'School was successfully created.' } + format.json { render action: 'show', status: :created, location: @school } + else + format.html { render action: 'new' } + format.json { render json: @school.errors, status: :unprocessable_entity } + end + end + end + + # PATCH/PUT /schools/1 + # PATCH/PUT /schools/1.json + def update + respond_to do |format| + if @school.update(school_params) + format.html { redirect_to @school, notice: 'School was successfully updated.' } + format.json { head :no_content } + else + format.html { render action: 'edit' } + format.json { render json: @school.errors, status: :unprocessable_entity } + end + end + end + + # DELETE /schools/1 + # DELETE /schools/1.json + def destroy + @school.destroy + respond_to do |format| + format.html { redirect_to schools_url } + format.json { head :no_content } + end + end + + private + # Use callbacks to share common setup or constraints between actions. + def set_school + @school = School.find(params[:id]) + end + + # Never trust parameters from the scary internet, only allow the white list through. + def school_params + params.require(:school).permit(:name, :score) + end +end diff --git a/app/controllers/static_pages_controller.rb b/app/controllers/static_pages_controller.rb index ef48a24..c38239d 100644 --- a/app/controllers/static_pages_controller.rb +++ b/app/controllers/static_pages_controller.rb @@ -2,5 +2,9 @@ class StaticPagesController < ApplicationController def index end + + def school + @school = School.all + end end diff --git a/app/controllers/weights_controller.rb b/app/controllers/weights_controller.rb new file mode 100644 index 0000000..f55be5b --- /dev/null +++ b/app/controllers/weights_controller.rb @@ -0,0 +1,75 @@ +class WeightsController < ApplicationController + before_action :set_weight, only: [:show, :edit, :update, :destroy] + + # GET /weights + # GET /weights.json + def index + @weights = Weight.all + end + + # GET /weights/1 + # GET /weights/1.json + def show + @wrestler = Wrestler.all + end + + # GET /weights/new + def new + @weight = Weight.new + end + + # GET /weights/1/edit + def edit + end + + # POST /weights + # POST /weights.json + def create + @weight = Weight.new(weight_params) + + respond_to do |format| + if @weight.save + format.html { redirect_to @weight, notice: 'Weight was successfully created.' } + format.json { render action: 'show', status: :created, location: @weight } + else + format.html { render action: 'new' } + format.json { render json: @weight.errors, status: :unprocessable_entity } + end + end + end + + # PATCH/PUT /weights/1 + # PATCH/PUT /weights/1.json + def update + respond_to do |format| + if @weight.update(weight_params) + format.html { redirect_to @weight, notice: 'Weight was successfully updated.' } + format.json { head :no_content } + else + format.html { render action: 'edit' } + format.json { render json: @weight.errors, status: :unprocessable_entity } + end + end + end + + # DELETE /weights/1 + # DELETE /weights/1.json + def destroy + @weight.destroy + respond_to do |format| + format.html { redirect_to weights_url } + format.json { head :no_content } + end + end + + private + # Use callbacks to share common setup or constraints between actions. + def set_weight + @weight = Weight.find(params[:id]) + end + + # Never trust parameters from the scary internet, only allow the white list through. + def weight_params + params.require(:weight).permit(:max) + end +end diff --git a/app/controllers/wrestlers_controller.rb b/app/controllers/wrestlers_controller.rb new file mode 100644 index 0000000..fce7f89 --- /dev/null +++ b/app/controllers/wrestlers_controller.rb @@ -0,0 +1,74 @@ +class WrestlersController < ApplicationController + before_action :set_wrestler, only: [:show, :edit, :update, :destroy] + + # GET /wrestlers + # GET /wrestlers.json + def index + @wrestlers = Wrestler.all + end + + # GET /wrestlers/1 + # GET /wrestlers/1.json + def show + end + + # GET /wrestlers/new + def new + @wrestler = Wrestler.new + end + + # GET /wrestlers/1/edit + def edit + end + + # POST /wrestlers + # POST /wrestlers.json + def create + @wrestler = Wrestler.new(wrestler_params) + + respond_to do |format| + if @wrestler.save + format.html { redirect_to @wrestler, notice: 'Wrestler was successfully created.' } + format.json { render action: 'show', status: :created, location: @wrestler } + else + format.html { render action: 'new' } + format.json { render json: @wrestler.errors, status: :unprocessable_entity } + end + end + end + + # PATCH/PUT /wrestlers/1 + # PATCH/PUT /wrestlers/1.json + def update + respond_to do |format| + if @wrestler.update(wrestler_params) + format.html { redirect_to @wrestler, notice: 'Wrestler was successfully updated.' } + format.json { head :no_content } + else + format.html { render action: 'edit' } + format.json { render json: @wrestler.errors, status: :unprocessable_entity } + end + end + end + + # DELETE /wrestlers/1 + # DELETE /wrestlers/1.json + def destroy + @wrestler.destroy + respond_to do |format| + format.html { redirect_to wrestlers_url } + format.json { head :no_content } + end + end + + private + # Use callbacks to share common setup or constraints between actions. + def set_wrestler + @wrestler = Wrestler.find(params[:id]) + end + + # Never trust parameters from the scary internet, only allow the white list through. + def wrestler_params + params.require(:wrestler).permit(:name, :school_id, :weight_id, :seed, :original_seed) + end +end diff --git a/app/helpers/schools_helper.rb b/app/helpers/schools_helper.rb new file mode 100644 index 0000000..e1893f4 --- /dev/null +++ b/app/helpers/schools_helper.rb @@ -0,0 +1,2 @@ +module SchoolsHelper +end diff --git a/app/helpers/weights_helper.rb b/app/helpers/weights_helper.rb new file mode 100644 index 0000000..75b0e7f --- /dev/null +++ b/app/helpers/weights_helper.rb @@ -0,0 +1,2 @@ +module WeightsHelper +end diff --git a/app/helpers/wrestlers_helper.rb b/app/helpers/wrestlers_helper.rb new file mode 100644 index 0000000..8c1737f --- /dev/null +++ b/app/helpers/wrestlers_helper.rb @@ -0,0 +1,2 @@ +module WrestlersHelper +end diff --git a/app/models/school.rb b/app/models/school.rb new file mode 100644 index 0000000..47f747a --- /dev/null +++ b/app/models/school.rb @@ -0,0 +1,3 @@ +class School < ActiveRecord::Base + has_many :wrestlers +end diff --git a/app/models/weight.rb b/app/models/weight.rb new file mode 100644 index 0000000..1178aa5 --- /dev/null +++ b/app/models/weight.rb @@ -0,0 +1,3 @@ +class Weight < ActiveRecord::Base + has_many :wrestlers +end diff --git a/app/models/wrestler.rb b/app/models/wrestler.rb new file mode 100644 index 0000000..eeaf7c6 --- /dev/null +++ b/app/models/wrestler.rb @@ -0,0 +1,4 @@ +class Wrestler < ActiveRecord::Base + belongs_to :school + belongs_to :weight +end diff --git a/app/views/layouts/_header.html.erb b/app/views/layouts/_header.html.erb index 3b09e86..9748f79 100644 --- a/app/views/layouts/_header.html.erb +++ b/app/views/layouts/_header.html.erb @@ -5,7 +5,9 @@ diff --git a/app/views/schools/_form.html.erb b/app/views/schools/_form.html.erb new file mode 100644 index 0000000..7fa388f --- /dev/null +++ b/app/views/schools/_form.html.erb @@ -0,0 +1,25 @@ +<%= form_for(@school) do |f| %> + <% if @school.errors.any? %> +
+

<%= pluralize(@school.errors.count, "error") %> prohibited this school from being saved:

+ + +
+ <% end %> + +
+ <%= f.label :name %>
+ <%= f.text_field :name %> +
+
+ <%= f.label :score %>
+ <%= f.number_field :score %> +
+
+ <%= f.submit %> +
+<% end %> diff --git a/app/views/schools/edit.html.erb b/app/views/schools/edit.html.erb new file mode 100644 index 0000000..15ebfaf --- /dev/null +++ b/app/views/schools/edit.html.erb @@ -0,0 +1,6 @@ +

Editing school

+ +<%= render 'form' %> + +<%= link_to 'Show', @school %> | +<%= link_to 'Back', schools_path %> diff --git a/app/views/schools/index.html.erb b/app/views/schools/index.html.erb new file mode 100644 index 0000000..975f718 --- /dev/null +++ b/app/views/schools/index.html.erb @@ -0,0 +1,29 @@ +

Listing schools

+ + + + + + + + + + + + + + <% @schools.each do |school| %> + + + + + + + + <% end %> + +
NameScore
<%= school.name %><%= school.score %><%= link_to 'Show', school %><%= link_to 'Edit', edit_school_path(school) %><%= link_to 'Destroy', school, method: :delete, data: { confirm: 'Are you sure?' } %>
+ +
+ +<%= link_to 'New School', new_school_path %> diff --git a/app/views/schools/index.json.jbuilder b/app/views/schools/index.json.jbuilder new file mode 100644 index 0000000..753c7c3 --- /dev/null +++ b/app/views/schools/index.json.jbuilder @@ -0,0 +1,4 @@ +json.array!(@schools) do |school| + json.extract! school, :id, :name, :score + json.url school_url(school, format: :json) +end diff --git a/app/views/schools/new.html.erb b/app/views/schools/new.html.erb new file mode 100644 index 0000000..73641d5 --- /dev/null +++ b/app/views/schools/new.html.erb @@ -0,0 +1,5 @@ +

New school

+ +<%= render 'form' %> + +<%= link_to 'Back', schools_path %> diff --git a/app/views/schools/show.html.erb b/app/views/schools/show.html.erb new file mode 100644 index 0000000..f056da2 --- /dev/null +++ b/app/views/schools/show.html.erb @@ -0,0 +1,14 @@ +

<%= notice %>

+ +

+ Name: + <%= @school.name %> +

+ +

+ Score: + <%= @school.score %> +

+ +<%= link_to 'Edit', edit_school_path(@school) %> | +<%= link_to 'Back', schools_path %> diff --git a/app/views/schools/show.json.jbuilder b/app/views/schools/show.json.jbuilder new file mode 100644 index 0000000..a129047 --- /dev/null +++ b/app/views/schools/show.json.jbuilder @@ -0,0 +1 @@ +json.extract! @school, :id, :name, :score, :created_at, :updated_at diff --git a/app/views/static_pages/school.html.erb b/app/views/static_pages/school.html.erb new file mode 100644 index 0000000..45f7937 --- /dev/null +++ b/app/views/static_pages/school.html.erb @@ -0,0 +1,17 @@ +

School Scores

+ + + + + + + + + <% @school.each do |school| %> + + + + + <% end %> + +
NameScore
<%= school.name %><%= school.score %>
\ No newline at end of file diff --git a/app/views/weights/_form.html.erb b/app/views/weights/_form.html.erb new file mode 100644 index 0000000..8d9beaf --- /dev/null +++ b/app/views/weights/_form.html.erb @@ -0,0 +1,21 @@ +<%= form_for(@weight) do |f| %> + <% if @weight.errors.any? %> +
+

<%= pluralize(@weight.errors.count, "error") %> prohibited this weight from being saved:

+ + +
+ <% end %> + +
+ <%= f.label :max %>
+ <%= f.number_field :max %> +
+
+ <%= f.submit %> +
+<% end %> diff --git a/app/views/weights/edit.html.erb b/app/views/weights/edit.html.erb new file mode 100644 index 0000000..01ca526 --- /dev/null +++ b/app/views/weights/edit.html.erb @@ -0,0 +1,6 @@ +

Editing weight

+ +<%= render 'form' %> + +<%= link_to 'Show', @weight %> | +<%= link_to 'Back', weights_path %> diff --git a/app/views/weights/index.html.erb b/app/views/weights/index.html.erb new file mode 100644 index 0000000..6b7e9d9 --- /dev/null +++ b/app/views/weights/index.html.erb @@ -0,0 +1,27 @@ +

Listing weights

+ + + + + + + + + + + + + <% @weights.each do |weight| %> + + + + + + + <% end %> + +
Max
<%= weight.max %><%= link_to 'Show', weight %><%= link_to 'Edit', edit_weight_path(weight) %><%= link_to 'Destroy', weight, method: :delete, data: { confirm: 'Are you sure?' } %>
+ +
+ +<%= link_to 'New Weight', new_weight_path %> diff --git a/app/views/weights/index.json.jbuilder b/app/views/weights/index.json.jbuilder new file mode 100644 index 0000000..608d638 --- /dev/null +++ b/app/views/weights/index.json.jbuilder @@ -0,0 +1,4 @@ +json.array!(@weights) do |weight| + json.extract! weight, :id, :max + json.url weight_url(weight, format: :json) +end diff --git a/app/views/weights/new.html.erb b/app/views/weights/new.html.erb new file mode 100644 index 0000000..b0643f0 --- /dev/null +++ b/app/views/weights/new.html.erb @@ -0,0 +1,5 @@ +

New weight

+ +<%= render 'form' %> + +<%= link_to 'Back', weights_path %> diff --git a/app/views/weights/show.html.erb b/app/views/weights/show.html.erb new file mode 100644 index 0000000..e2dc586 --- /dev/null +++ b/app/views/weights/show.html.erb @@ -0,0 +1,37 @@ +

<%= notice %>

+ +

Weight Class:<%= @weight.max %>

+ + +<%= link_to 'Edit Weight Class', edit_weight_path(@weight) %> | +<%= link_to 'Back to Weight Classes', weights_path %> +
+
+
+ + + + + + + + + + + <% @wrestler.each do |wrestler| %> + <% if wrestler.weight_id == @weight.id %> + + + + + + + <% end %> + <% end %> + +
NameSchoolSeedActions for wrestler
<%= wrestler.name %><%= School.find(wrestler.school_id).name %><%= wrestler.original_seed %><%= link_to 'Show', wrestler , :class=>"btn" %><%= link_to 'Edit', edit_wrestler_path(wrestler) , :class=>"btn" %><%= link_to 'Destroy', wrestler, method: :delete, data: { confirm: 'Are you sure?' } , :class=>"btn btn-danger" %>
+ + + + + diff --git a/app/views/weights/show.json.jbuilder b/app/views/weights/show.json.jbuilder new file mode 100644 index 0000000..52d8944 --- /dev/null +++ b/app/views/weights/show.json.jbuilder @@ -0,0 +1 @@ +json.extract! @weight, :id, :max, :created_at, :updated_at diff --git a/app/views/wrestlers/_form.html.erb b/app/views/wrestlers/_form.html.erb new file mode 100644 index 0000000..c1bb33d --- /dev/null +++ b/app/views/wrestlers/_form.html.erb @@ -0,0 +1,39 @@ +<%= form_for(@wrestler) do |f| %> + <% if @wrestler.errors.any? %> +
+

<%= pluralize(@wrestler.errors.count, "error") %> prohibited this wrestler from being saved:

+ + +
+ <% end %> + +
+ <%= f.label :name %>
+ <%= f.text_field :name %> +
+
+ <%= f.label 'School' %>
+ <%= f.collection_select :school_id, School.all, :id, :name %> +
+
+ <%= f.label 'Weight Class' %>
+ <%= f.collection_select :weight_id, Weight.all, :id, :max %> +
+
+ <%= f.label :seed %>
+ <%= f.number_field :seed %> +
+
+ <%= f.label :original_seed %>
+ <%= f.number_field :original_seed %> +
+
+ <%= f.submit %> +
+<% end %> + + diff --git a/app/views/wrestlers/edit.html.erb b/app/views/wrestlers/edit.html.erb new file mode 100644 index 0000000..0b081d5 --- /dev/null +++ b/app/views/wrestlers/edit.html.erb @@ -0,0 +1,6 @@ +

Editing wrestler

+ +<%= render 'form' %> + +<%= link_to 'Show', @wrestler %> | +<%= link_to 'Back', wrestlers_path %> diff --git a/app/views/wrestlers/index.html.erb b/app/views/wrestlers/index.html.erb new file mode 100644 index 0000000..d768e06 --- /dev/null +++ b/app/views/wrestlers/index.html.erb @@ -0,0 +1,35 @@ +

Listing wrestlers

+ + + + + + + + + + + + + + + + + <% @wrestlers.each do |wrestler| %> + + + + + + + + + + + <% end %> + +
NameSchoolWeightSeedOriginal seed
<%= wrestler.name %><%= School.find(wrestler.school_id).name %><%= Weight.find(wrestler.weight_id).max %><%= wrestler.seed %><%= wrestler.original_seed %><%= link_to 'Show', wrestler %><%= link_to 'Edit', edit_wrestler_path(wrestler) %><%= link_to 'Destroy', wrestler, method: :delete, data: { confirm: 'Are you sure?' } %>
+ +
+ +<%= link_to 'New Wrestler', new_wrestler_path %> diff --git a/app/views/wrestlers/index.json.jbuilder b/app/views/wrestlers/index.json.jbuilder new file mode 100644 index 0000000..601880b --- /dev/null +++ b/app/views/wrestlers/index.json.jbuilder @@ -0,0 +1,4 @@ +json.array!(@wrestlers) do |wrestler| + json.extract! wrestler, :id, :name, :school_id, :weight_id, :seed, :original_seed + json.url wrestler_url(wrestler, format: :json) +end diff --git a/app/views/wrestlers/new.html.erb b/app/views/wrestlers/new.html.erb new file mode 100644 index 0000000..3922807 --- /dev/null +++ b/app/views/wrestlers/new.html.erb @@ -0,0 +1,5 @@ +

New wrestler

+ +<%= render 'form' %> + +<%= link_to 'Back', wrestlers_path %> diff --git a/app/views/wrestlers/show.html.erb b/app/views/wrestlers/show.html.erb new file mode 100644 index 0000000..2dfd3ea --- /dev/null +++ b/app/views/wrestlers/show.html.erb @@ -0,0 +1,29 @@ +

<%= notice %>

+ +

+ Name: + <%= @wrestler.name %> +

+ +

+ School: + <%= School.find(@wrestler.school_id).name %> +

+ +

+ Weight: + <%= Weight.find(@wrestler.weight_id).max %> +

+ +

+ Seed: + <%= @wrestler.seed %> +

+ +

+ Original seed: + <%= @wrestler.original_seed %> +

+ +<%= link_to 'Edit', edit_wrestler_path(@wrestler) %> | +<%= link_to 'Back', wrestlers_path %> diff --git a/app/views/wrestlers/show.json.jbuilder b/app/views/wrestlers/show.json.jbuilder new file mode 100644 index 0000000..d96c5e2 --- /dev/null +++ b/app/views/wrestlers/show.json.jbuilder @@ -0,0 +1 @@ +json.extract! @wrestler, :id, :name, :school_id, :weight_id, :seed, :original_seed, :created_at, :updated_at diff --git a/config/routes.rb b/config/routes.rb index e79fea3..5988d49 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,9 +1,16 @@ Wrestling::Application.routes.draw do + resources :wrestlers + + resources :weights + + resources :schools + # The priority is based upon order of creation: first created -> highest priority. # See how all your routes lay out with "rake routes". # You can have the root of your site routed with "root" root 'static_pages#index' + get 'static_pages/school' # Example of regular route: # get 'products/:id' => 'catalog#view' diff --git a/db/migrate/20131231134936_create_schools.rb b/db/migrate/20131231134936_create_schools.rb new file mode 100644 index 0000000..3849f8d --- /dev/null +++ b/db/migrate/20131231134936_create_schools.rb @@ -0,0 +1,10 @@ +class CreateSchools < ActiveRecord::Migration + def change + create_table :schools do |t| + t.string :name + t.integer :score + + t.timestamps + end + end +end diff --git a/db/migrate/20131231134955_create_weights.rb b/db/migrate/20131231134955_create_weights.rb new file mode 100644 index 0000000..e3e29ef --- /dev/null +++ b/db/migrate/20131231134955_create_weights.rb @@ -0,0 +1,9 @@ +class CreateWeights < ActiveRecord::Migration + def change + create_table :weights do |t| + t.integer :max + + t.timestamps + end + end +end diff --git a/db/migrate/20131231135039_create_wrestlers.rb b/db/migrate/20131231135039_create_wrestlers.rb new file mode 100644 index 0000000..754b75c --- /dev/null +++ b/db/migrate/20131231135039_create_wrestlers.rb @@ -0,0 +1,13 @@ +class CreateWrestlers < ActiveRecord::Migration + def change + create_table :wrestlers do |t| + t.string :name + t.integer :school_id + t.integer :weight_id + t.integer :seed + t.integer :original_seed + + t.timestamps + end + end +end diff --git a/db/schema.rb b/db/schema.rb new file mode 100644 index 0000000..34de1f8 --- /dev/null +++ b/db/schema.rb @@ -0,0 +1,39 @@ +# encoding: UTF-8 +# This file is auto-generated from the current state of the database. Instead +# of editing this file, please use the migrations feature of Active Record to +# incrementally modify your database, and then regenerate this schema definition. +# +# Note that this schema.rb definition is the authoritative source for your +# database schema. If you need to create the application database on another +# system, you should be using db:schema:load, not running all the migrations +# from scratch. The latter is a flawed and unsustainable approach (the more migrations +# you'll amass, the slower it'll run and the greater likelihood for issues). +# +# It's strongly recommended that you check this file into your version control system. + +ActiveRecord::Schema.define(version: 20131231135039) do + + create_table "schools", force: true do |t| + t.string "name" + t.integer "score" + t.datetime "created_at" + t.datetime "updated_at" + end + + create_table "weights", force: true do |t| + t.integer "max" + t.datetime "created_at" + t.datetime "updated_at" + end + + create_table "wrestlers", force: true do |t| + t.string "name" + t.integer "school_id" + t.integer "weight_id" + t.integer "seed" + t.integer "original_seed" + t.datetime "created_at" + t.datetime "updated_at" + end + +end diff --git a/test/controllers/schools_controller_test.rb b/test/controllers/schools_controller_test.rb new file mode 100644 index 0000000..1f52b81 --- /dev/null +++ b/test/controllers/schools_controller_test.rb @@ -0,0 +1,49 @@ +require 'test_helper' + +class SchoolsControllerTest < ActionController::TestCase + setup do + @school = schools(:one) + end + + test "should get index" do + get :index + assert_response :success + assert_not_nil assigns(:schools) + end + + test "should get new" do + get :new + assert_response :success + end + + test "should create school" do + assert_difference('School.count') do + post :create, school: { name: @school.name, score: @school.score } + end + + assert_redirected_to school_path(assigns(:school)) + end + + test "should show school" do + get :show, id: @school + assert_response :success + end + + test "should get edit" do + get :edit, id: @school + assert_response :success + end + + test "should update school" do + patch :update, id: @school, school: { name: @school.name, score: @school.score } + assert_redirected_to school_path(assigns(:school)) + end + + test "should destroy school" do + assert_difference('School.count', -1) do + delete :destroy, id: @school + end + + assert_redirected_to schools_path + end +end diff --git a/test/controllers/weights_controller_test.rb b/test/controllers/weights_controller_test.rb new file mode 100644 index 0000000..4381d23 --- /dev/null +++ b/test/controllers/weights_controller_test.rb @@ -0,0 +1,49 @@ +require 'test_helper' + +class WeightsControllerTest < ActionController::TestCase + setup do + @weight = weights(:one) + end + + test "should get index" do + get :index + assert_response :success + assert_not_nil assigns(:weights) + end + + test "should get new" do + get :new + assert_response :success + end + + test "should create weight" do + assert_difference('Weight.count') do + post :create, weight: { max: @weight.max } + end + + assert_redirected_to weight_path(assigns(:weight)) + end + + test "should show weight" do + get :show, id: @weight + assert_response :success + end + + test "should get edit" do + get :edit, id: @weight + assert_response :success + end + + test "should update weight" do + patch :update, id: @weight, weight: { max: @weight.max } + assert_redirected_to weight_path(assigns(:weight)) + end + + test "should destroy weight" do + assert_difference('Weight.count', -1) do + delete :destroy, id: @weight + end + + assert_redirected_to weights_path + end +end diff --git a/test/controllers/wrestlers_controller_test.rb b/test/controllers/wrestlers_controller_test.rb new file mode 100644 index 0000000..ed111fb --- /dev/null +++ b/test/controllers/wrestlers_controller_test.rb @@ -0,0 +1,49 @@ +require 'test_helper' + +class WrestlersControllerTest < ActionController::TestCase + setup do + @wrestler = wrestlers(:one) + end + + test "should get index" do + get :index + assert_response :success + assert_not_nil assigns(:wrestlers) + end + + test "should get new" do + get :new + assert_response :success + end + + test "should create wrestler" do + assert_difference('Wrestler.count') do + post :create, wrestler: { name: @wrestler.name, original_seed: @wrestler.original_seed, school_id: @wrestler.school_id, seed: @wrestler.seed, weight_id: @wrestler.weight_id } + end + + assert_redirected_to wrestler_path(assigns(:wrestler)) + end + + test "should show wrestler" do + get :show, id: @wrestler + assert_response :success + end + + test "should get edit" do + get :edit, id: @wrestler + assert_response :success + end + + test "should update wrestler" do + patch :update, id: @wrestler, wrestler: { name: @wrestler.name, original_seed: @wrestler.original_seed, school_id: @wrestler.school_id, seed: @wrestler.seed, weight_id: @wrestler.weight_id } + assert_redirected_to wrestler_path(assigns(:wrestler)) + end + + test "should destroy wrestler" do + assert_difference('Wrestler.count', -1) do + delete :destroy, id: @wrestler + end + + assert_redirected_to wrestlers_path + end +end diff --git a/test/fixtures/schools.yml b/test/fixtures/schools.yml new file mode 100644 index 0000000..9fa493d --- /dev/null +++ b/test/fixtures/schools.yml @@ -0,0 +1,9 @@ +# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html + +one: + name: MyString + score: 1 + +two: + name: MyString + score: 1 diff --git a/test/fixtures/weights.yml b/test/fixtures/weights.yml new file mode 100644 index 0000000..070eb84 --- /dev/null +++ b/test/fixtures/weights.yml @@ -0,0 +1,7 @@ +# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html + +one: + max: 1 + +two: + max: 1 diff --git a/test/fixtures/wrestlers.yml b/test/fixtures/wrestlers.yml new file mode 100644 index 0000000..2d4213b --- /dev/null +++ b/test/fixtures/wrestlers.yml @@ -0,0 +1,15 @@ +# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html + +one: + name: MyString + school_id: 1 + weight_id: 1 + seed: 1 + original_seed: 1 + +two: + name: MyString + school_id: 1 + weight_id: 1 + seed: 1 + original_seed: 1 diff --git a/test/helpers/schools_helper_test.rb b/test/helpers/schools_helper_test.rb new file mode 100644 index 0000000..af3ff51 --- /dev/null +++ b/test/helpers/schools_helper_test.rb @@ -0,0 +1,4 @@ +require 'test_helper' + +class SchoolsHelperTest < ActionView::TestCase +end diff --git a/test/helpers/weights_helper_test.rb b/test/helpers/weights_helper_test.rb new file mode 100644 index 0000000..758d544 --- /dev/null +++ b/test/helpers/weights_helper_test.rb @@ -0,0 +1,4 @@ +require 'test_helper' + +class WeightsHelperTest < ActionView::TestCase +end diff --git a/test/helpers/wrestlers_helper_test.rb b/test/helpers/wrestlers_helper_test.rb new file mode 100644 index 0000000..fcafd87 --- /dev/null +++ b/test/helpers/wrestlers_helper_test.rb @@ -0,0 +1,4 @@ +require 'test_helper' + +class WrestlersHelperTest < ActionView::TestCase +end diff --git a/test/models/school_test.rb b/test/models/school_test.rb new file mode 100644 index 0000000..e86105e --- /dev/null +++ b/test/models/school_test.rb @@ -0,0 +1,7 @@ +require 'test_helper' + +class SchoolTest < ActiveSupport::TestCase + # test "the truth" do + # assert true + # end +end diff --git a/test/models/weight_test.rb b/test/models/weight_test.rb new file mode 100644 index 0000000..3345212 --- /dev/null +++ b/test/models/weight_test.rb @@ -0,0 +1,7 @@ +require 'test_helper' + +class WeightTest < ActiveSupport::TestCase + # test "the truth" do + # assert true + # end +end diff --git a/test/models/wrestler_test.rb b/test/models/wrestler_test.rb new file mode 100644 index 0000000..6651aa3 --- /dev/null +++ b/test/models/wrestler_test.rb @@ -0,0 +1,7 @@ +require 'test_helper' + +class WrestlerTest < ActiveSupport::TestCase + # test "the truth" do + # assert true + # end +end