Commit 61fbe14

mo khan <mo@mokhan.ca>
2014-04-18 16:52:33
start to flush out videos controller.
1 parent 7b05fb5
Changed files (6)
app/assets/javascripts/templates/videos.hbs
@@ -1,6 +1,6 @@
+{{outlet}}
 <ul class="nav nav-pills nav-stacked well">
   {{#each video in controller}}
   <li> {{#link-to 'video' video}}{{video.title}}{{/link-to}} </li>
   {{/each}}
 </ul>
-{{outlet}}
app/controllers/videos_controller.rb
@@ -13,4 +13,8 @@ class VideosController < ApplicationController
       },
     ]
   end
+
+  def create
+    raise "heck"
+  end
 end
config/routes.rb
@@ -1,6 +1,6 @@
 Mocode::Application.routes.draw do
   resources :sessions, only: [:new, :create, :destroy]
-  resources :videos, only: [:index]
+  resources :videos, only: [:index, :create]
   get 'dashboard', to: 'dashboard#index'
   root 'dashboard#index'
   # The priority is based upon order of creation: first created -> highest priority.
spec/controllers/videos_controller_spec.rb
@@ -0,0 +1,17 @@
+require "spec_helper"
+
+describe VideosController do
+  context "#create" do
+    let(:user) { User.create }
+    let(:user_session) { Session.create!(user_id: user.id) }
+
+    before :each do
+      test_sign_in(user_session)
+    end
+
+    it "creates a new video" do
+      post :create, video: { title: 'hello', url: '' }
+      response.should be_success
+    end
+  end
+end
spec/support/integration_helpers.rb
@@ -0,0 +1,5 @@
+module IntegrationHelpers
+  def test_sign_in(user_session)
+    session[user_session.id]
+  end
+end
spec/spec_helper.rb
@@ -13,6 +13,7 @@ Dir[Rails.root.join("spec/support/**/*.rb")].each { |f| require f }
 ActiveRecord::Migration.check_pending! if defined?(ActiveRecord::Migration)
 
 RSpec.configure do |config|
+  config.include IntegrationHelpers
   # ## Mock Framework
   #
   # If you prefer to use mocha, flexmock or RR, uncomment the appropriate line: