Permalink
Browse files

adding twcontroller

  • Loading branch information...
1 parent 9660bed commit 9ee1f5293e8d45c625fd2711b803ff93ae324fa4 @rpuskas rpuskas committed Feb 12, 2012
@@ -0,0 +1,83 @@
+class ThoughtworkersController < ApplicationController
+ # GET /thoughtworkers
+ # GET /thoughtworkers.json
+ def index
+ @thoughtworkers = Thoughtworker.all
+
+ respond_to do |format|
+ format.html # index.html.erb
+ format.json { render json: @thoughtworkers }
+ end
+ end
+
+ # GET /thoughtworkers/1
+ # GET /thoughtworkers/1.json
+ def show
+ @thoughtworker = Thoughtworker.find(params[:id])
+
+ respond_to do |format|
+ format.html # show.html.erb
+ format.json { render json: @thoughtworker }
+ end
+ end
+
+ # GET /thoughtworkers/new
+ # GET /thoughtworkers/new.json
+ def new
+ @thoughtworker = Thoughtworker.new
+
+ respond_to do |format|
+ format.html # new.html.erb
+ format.json { render json: @thoughtworker }
+ end
+ end
+
+ # GET /thoughtworkers/1/edit
+ def edit
+ @thoughtworker = Thoughtworker.find(params[:id])
+ end
+
+ # POST /thoughtworkers
+ # POST /thoughtworkers.json
+ def create
+ @thoughtworker = Thoughtworker.new(params[:thoughtworker])
+
+ respond_to do |format|
+ if @thoughtworker.save
+ format.html { redirect_to @thoughtworker, notice: 'Thoughtworker was successfully created.' }
+ format.json { render json: @thoughtworker, status: :created, location: @thoughtworker }
+ else
+ format.html { render action: "new" }
+ format.json { render json: @thoughtworker.errors, status: :unprocessable_entity }
+ end
+ end
+ end
+
+ # PUT /thoughtworkers/1
+ # PUT /thoughtworkers/1.json
+ def update
+ @thoughtworker = Thoughtworker.find(params[:id])
+
+ respond_to do |format|
+ if @thoughtworker.update_attributes(params[:thoughtworker])
+ format.html { redirect_to @thoughtworker, notice: 'Thoughtworker was successfully updated.' }
+ format.json { head :no_content }
+ else
+ format.html { render action: "edit" }
+ format.json { render json: @thoughtworker.errors, status: :unprocessable_entity }
+ end
+ end
+ end
+
+ # DELETE /thoughtworkers/1
+ # DELETE /thoughtworkers/1.json
+ def destroy
+ @thoughtworker = Thoughtworker.find(params[:id])
+ @thoughtworker.destroy
+
+ respond_to do |format|
+ format.html { redirect_to thoughtworkers_url }
+ format.json { head :no_content }
+ end
+ end
+end
@@ -0,0 +1,2 @@
+module ThoughtworkersHelper
+end
@@ -0,0 +1,17 @@
+<%= form_for(@thoughtworker) do |f| %>
+ <% if @thoughtworker.errors.any? %>
+ <div id="error_explanation">
+ <h2><%= pluralize(@thoughtworker.errors.count, "error") %> prohibited this thoughtworker from being saved:</h2>
+
+ <ul>
+ <% @thoughtworker.errors.full_messages.each do |msg| %>
+ <li><%= msg %></li>
+ <% end %>
+ </ul>
+ </div>
+ <% end %>
+
+ <div class="actions">
+ <%= f.submit %>
+ </div>
+<% end %>
@@ -0,0 +1,6 @@
+<h1>Editing thoughtworker</h1>
+
+<%= render 'form' %>
+
+<%= link_to 'Show', @thoughtworker %> |
+<%= link_to 'Back', thoughtworkers_path %>
@@ -0,0 +1,21 @@
+<h1>Listing thoughtworkers</h1>
+
+<table>
+ <tr>
+ <th></th>
+ <th></th>
+ <th></th>
+ </tr>
+
+<% @thoughtworkers.each do |thoughtworker| %>
+ <tr>
+ <td><%= link_to 'Show', thoughtworker %></td>
+ <td><%= link_to 'Edit', edit_thoughtworker_path(thoughtworker) %></td>
+ <td><%= link_to 'Destroy', thoughtworker, confirm: 'Are you sure?', method: :delete %></td>
+ </tr>
+<% end %>
+</table>
+
+<br />
+
+<%= link_to 'New Thoughtworker', new_thoughtworker_path %>
@@ -0,0 +1,5 @@
+<h1>New thoughtworker</h1>
+
+<%= render 'form' %>
+
+<%= link_to 'Back', thoughtworkers_path %>
@@ -0,0 +1,5 @@
+<p id="notice"><%= notice %></p>
+
+
+<%= link_to 'Edit', edit_thoughtworker_path(@thoughtworker) %> |
+<%= link_to 'Back', thoughtworkers_path %>
View
@@ -165,3 +165,55 @@ DETAIL: There are 2 other session(s) using the database.

 (0.4ms) COMMIT
 (0.1ms) ALTER TABLE "schema_migrations" ENABLE TRIGGER ALL;ALTER TABLE "experiences" ENABLE TRIGGER ALL;ALTER TABLE "thoughtworkers" ENABLE TRIGGER ALL;ALTER TABLE "thoughtworkers_experiences" ENABLE TRIGGER ALL
+
+
+Started GET "/Thoughworkers" for 127.0.0.1 at 2012-02-12 15:23:35 -0500
+
+ActionController::RoutingError (No route matches [GET] "/Thoughworkers"):
+ actionpack (3.2.1) lib/action_dispatch/middleware/debug_exceptions.rb:21:in `call'
+ actionpack (3.2.1) lib/action_dispatch/middleware/show_exceptions.rb:56:in `call'
+ railties (3.2.1) lib/rails/rack/logger.rb:26:in `call_app'
+ railties (3.2.1) lib/rails/rack/logger.rb:16:in `call'
+ actionpack (3.2.1) lib/action_dispatch/middleware/request_id.rb:22:in `call'
+ rack (1.4.1) lib/rack/methodoverride.rb:21:in `call'
+ rack (1.4.1) lib/rack/runtime.rb:17:in `call'
+ activesupport (3.2.1) lib/active_support/cache/strategy/local_cache.rb:72:in `call'
+ rack (1.4.1) lib/rack/lock.rb:15:in `call'
+ actionpack (3.2.1) lib/action_dispatch/middleware/static.rb:53:in `call'
+ railties (3.2.1) lib/rails/engine.rb:479:in `call'
+ railties (3.2.1) lib/rails/application.rb:220:in `call'
+ rack (1.4.1) lib/rack/content_length.rb:14:in `call'
+ railties (3.2.1) lib/rails/rack/log_tailer.rb:14:in `call'
+ rack (1.4.1) lib/rack/handler/webrick.rb:59:in `service'
+ /Users/ThoughtWorks/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/webrick/httpserver.rb:111:in `service'
+ /Users/ThoughtWorks/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/webrick/httpserver.rb:70:in `run'
+ /Users/ThoughtWorks/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/webrick/server.rb:183:in `block in start_thread'
+
+
+ Rendered /Users/ThoughtWorks/.rvm/gems/ruby-1.9.2-p290/gems/actionpack-3.2.1/lib/action_dispatch/middleware/templates/rescues/routing_error.erb within rescues/layout (9.1ms)
+
+
+Started GET "/Thoughworker" for 127.0.0.1 at 2012-02-12 15:23:40 -0500
+
+ActionController::RoutingError (No route matches [GET] "/Thoughworker"):
+ actionpack (3.2.1) lib/action_dispatch/middleware/debug_exceptions.rb:21:in `call'
+ actionpack (3.2.1) lib/action_dispatch/middleware/show_exceptions.rb:56:in `call'
+ railties (3.2.1) lib/rails/rack/logger.rb:26:in `call_app'
+ railties (3.2.1) lib/rails/rack/logger.rb:16:in `call'
+ actionpack (3.2.1) lib/action_dispatch/middleware/request_id.rb:22:in `call'
+ rack (1.4.1) lib/rack/methodoverride.rb:21:in `call'
+ rack (1.4.1) lib/rack/runtime.rb:17:in `call'
+ activesupport (3.2.1) lib/active_support/cache/strategy/local_cache.rb:72:in `call'
+ rack (1.4.1) lib/rack/lock.rb:15:in `call'
+ actionpack (3.2.1) lib/action_dispatch/middleware/static.rb:53:in `call'
+ railties (3.2.1) lib/rails/engine.rb:479:in `call'
+ railties (3.2.1) lib/rails/application.rb:220:in `call'
+ rack (1.4.1) lib/rack/content_length.rb:14:in `call'
+ railties (3.2.1) lib/rails/rack/log_tailer.rb:14:in `call'
+ rack (1.4.1) lib/rack/handler/webrick.rb:59:in `service'
+ /Users/ThoughtWorks/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/webrick/httpserver.rb:111:in `service'
+ /Users/ThoughtWorks/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/webrick/httpserver.rb:70:in `run'
+ /Users/ThoughtWorks/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/webrick/server.rb:183:in `block in start_thread'
+
+
+ Rendered /Users/ThoughtWorks/.rvm/gems/ruby-1.9.2-p290/gems/actionpack-3.2.1/lib/action_dispatch/middleware/templates/rescues/routing_error.erb within rescues/layout (0.6ms)
@@ -0,0 +1,49 @@
+require 'test_helper'
+
+class ThoughtworkersControllerTest < ActionController::TestCase
+ setup do
+ @thoughtworker = thoughtworkers(:one)
+ end
+
+ test "should get index" do
+ get :index
+ assert_response :success
+ assert_not_nil assigns(:thoughtworkers)
+ end
+
+ test "should get new" do
+ get :new
+ assert_response :success
+ end
+
+ test "should create thoughtworker" do
+ assert_difference('Thoughtworker.count') do
+ post :create, thoughtworker: @thoughtworker.attributes
+ end
+
+ assert_redirected_to thoughtworker_path(assigns(:thoughtworker))
+ end
+
+ test "should show thoughtworker" do
+ get :show, id: @thoughtworker
+ assert_response :success
+ end
+
+ test "should get edit" do
+ get :edit, id: @thoughtworker
+ assert_response :success
+ end
+
+ test "should update thoughtworker" do
+ put :update, id: @thoughtworker, thoughtworker: @thoughtworker.attributes
+ assert_redirected_to thoughtworker_path(assigns(:thoughtworker))
+ end
+
+ test "should destroy thoughtworker" do
+ assert_difference('Thoughtworker.count', -1) do
+ delete :destroy, id: @thoughtworker
+ end
+
+ assert_redirected_to thoughtworkers_path
+ end
+end
@@ -0,0 +1,4 @@
+require 'test_helper'
+
+class ThoughtworkersHelperTest < ActionView::TestCase
+end
View
@@ -0,0 +1 @@
+1239

0 comments on commit 9ee1f52

Please sign in to comment.