From cab5cc436e348a0e0dd81f31cb442cccb96cf737 Mon Sep 17 00:00:00 2001 From: Andrew Tomaka Date: Sun, 4 Aug 2013 20:58:01 -0400 Subject: [PATCH] Setup basic workout index action --- app/assets/javascripts/workouts.js.coffee | 3 ++ app/assets/stylesheets/workouts.css.scss | 3 ++ app/controllers/workouts_controller.rb | 5 ++ app/helpers/workouts_helper.rb | 2 + app/models/workout.rb | 2 + app/views/workouts/index.html.erb | 5 ++ config/routes.rb | 56 +------------------- db/migrate/20130805003121_create_workouts.rb | 9 ++++ db/schema.rb | 22 ++++++++ spec/controllers/workouts_controller_spec.rb | 5 ++ spec/factories/workouts.rb | 7 +++ spec/features/workouts_spec.rb | 19 +++++++ 12 files changed, 84 insertions(+), 54 deletions(-) create mode 100644 app/assets/javascripts/workouts.js.coffee create mode 100644 app/assets/stylesheets/workouts.css.scss create mode 100644 app/controllers/workouts_controller.rb create mode 100644 app/helpers/workouts_helper.rb create mode 100644 app/models/workout.rb create mode 100644 app/views/workouts/index.html.erb create mode 100644 db/migrate/20130805003121_create_workouts.rb create mode 100644 db/schema.rb create mode 100644 spec/controllers/workouts_controller_spec.rb create mode 100644 spec/factories/workouts.rb create mode 100644 spec/features/workouts_spec.rb diff --git a/app/assets/javascripts/workouts.js.coffee b/app/assets/javascripts/workouts.js.coffee new file mode 100644 index 0000000..24f83d1 --- /dev/null +++ b/app/assets/javascripts/workouts.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/workouts.css.scss b/app/assets/stylesheets/workouts.css.scss new file mode 100644 index 0000000..b698d8f --- /dev/null +++ b/app/assets/stylesheets/workouts.css.scss @@ -0,0 +1,3 @@ +// Place all the styles related to the workouts 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/workouts_controller.rb b/app/controllers/workouts_controller.rb new file mode 100644 index 0000000..b02362a --- /dev/null +++ b/app/controllers/workouts_controller.rb @@ -0,0 +1,5 @@ +class WorkoutsController < ApplicationController + def index + @workouts = Workout.all + end +end diff --git a/app/helpers/workouts_helper.rb b/app/helpers/workouts_helper.rb new file mode 100644 index 0000000..aca56b0 --- /dev/null +++ b/app/helpers/workouts_helper.rb @@ -0,0 +1,2 @@ +module WorkoutsHelper +end diff --git a/app/models/workout.rb b/app/models/workout.rb new file mode 100644 index 0000000..6a57f89 --- /dev/null +++ b/app/models/workout.rb @@ -0,0 +1,2 @@ +class Workout < ActiveRecord::Base +end diff --git a/app/views/workouts/index.html.erb b/app/views/workouts/index.html.erb new file mode 100644 index 0000000..e7d8549 --- /dev/null +++ b/app/views/workouts/index.html.erb @@ -0,0 +1,5 @@ + diff --git a/config/routes.rb b/config/routes.rb index 7cb5ee6..39d8358 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,56 +1,4 @@ Allpro::Application.routes.draw do - # 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 'welcome#index' - - # Example of regular route: - # get 'products/:id' => 'catalog#view' - - # Example of named route that can be invoked with purchase_url(id: product.id) - # get 'products/:id/purchase' => 'catalog#purchase', as: :purchase - - # Example resource route (maps HTTP verbs to controller actions automatically): - # resources :products - - # Example resource route with options: - # resources :products do - # member do - # get 'short' - # post 'toggle' - # end - # - # collection do - # get 'sold' - # end - # end - - # Example resource route with sub-resources: - # resources :products do - # resources :comments, :sales - # resource :seller - # end - - # Example resource route with more complex sub-resources: - # resources :products do - # resources :comments - # resources :sales do - # get 'recent', on: :collection - # end - # end - - # Example resource route with concerns: - # concern :toggleable do - # post 'toggle' - # end - # resources :posts, concerns: :toggleable - # resources :photos, concerns: :toggleable - - # Example resource route within a namespace: - # namespace :admin do - # # Directs /admin/products/* to Admin::ProductsController - # # (app/controllers/admin/products_controller.rb) - # resources :products - # end + root :to => 'workouts#index' + resources :workouts end diff --git a/db/migrate/20130805003121_create_workouts.rb b/db/migrate/20130805003121_create_workouts.rb new file mode 100644 index 0000000..cfd96e8 --- /dev/null +++ b/db/migrate/20130805003121_create_workouts.rb @@ -0,0 +1,9 @@ +class CreateWorkouts < ActiveRecord::Migration + def change + create_table :workouts do |t| + t.datetime :date + + t.timestamps + end + end +end diff --git a/db/schema.rb b/db/schema.rb new file mode 100644 index 0000000..1454a16 --- /dev/null +++ b/db/schema.rb @@ -0,0 +1,22 @@ +# 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: 20130805003121) do + + create_table "workouts", force: true do |t| + t.datetime "date" + t.datetime "created_at" + t.datetime "updated_at" + end + +end diff --git a/spec/controllers/workouts_controller_spec.rb b/spec/controllers/workouts_controller_spec.rb new file mode 100644 index 0000000..ac08e6e --- /dev/null +++ b/spec/controllers/workouts_controller_spec.rb @@ -0,0 +1,5 @@ +require 'spec_helper' + +describe WorkoutsController do + +end diff --git a/spec/factories/workouts.rb b/spec/factories/workouts.rb new file mode 100644 index 0000000..25c7c34 --- /dev/null +++ b/spec/factories/workouts.rb @@ -0,0 +1,7 @@ +# Read about factories at https://github.com/thoughtbot/factory_girl + +FactoryGirl.define do + factory :workout do + date "2013-08-04 20:31:21" + end +end diff --git a/spec/features/workouts_spec.rb b/spec/features/workouts_spec.rb new file mode 100644 index 0000000..9d7ac30 --- /dev/null +++ b/spec/features/workouts_spec.rb @@ -0,0 +1,19 @@ +require 'spec_helper' + +describe "Workouts" do + before :all do + @workout = FactoryGirl.create(:workout) + end + + describe "GET /workouts" do + it "should return 200" do + visit workouts_path + page.status_code.should be 200 + end + + it "should return workouts" do + visit workouts_path + page.should have_content @workout.date + end + end +end