From: Ira W. Snyder <%= flash[:notice] %>
-<%= text_field 'video', 'video_genre' %>
<%= text_field 'video', 'director' %>
Video ID | -Checked Out | - <% for column in Video.content_columns %> -<%= column.human_name %> | - <% end %> +Video ID | +Checked Out | +Title | +New Release | +Genre | +Director | +Media | ||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
<%=h video.id %> | -<%=h video.checkedout? %> | - <% for column in Video.content_columns %> -<%=h video.send(column.name) %> | - <% end %> +<%=h video.id %> | +<%=h video.checkedout? %> | +<%=h video.title %> | +<%=h video.newrelease %> | +<%=h Videogenre.find(video.video_genre).name %> | +<%=h video.director %> | +<%=h video.media %> | <%= link_to 'Show', :action => 'show', :id => video %> | <%= link_to 'Edit', :action => 'edit', :id => video %> | <%= link_to 'Destroy', { :action => 'destroy', :id => video }, :confirm => 'Are you sure?', :method => :post %> | diff --git a/app/views/videogenre/_form.rhtml b/app/views/videogenre/_form.rhtml new file mode 100644 index 0000000..4082225 --- /dev/null +++ b/app/views/videogenre/_form.rhtml @@ -0,0 +1,7 @@ +<%= error_messages_for 'videogenre' %> + + +
<%= column.human_name %> | + <% end %> +|||
---|---|---|---|
<%=h videogenre.send(column.name) %> | + <% end %> +<%= link_to 'Show', :action => 'show', :id => videogenre %> | +<%= link_to 'Edit', :action => 'edit', :id => videogenre %> | +<%= link_to 'Destroy', { :action => 'destroy', :id => videogenre }, :confirm => 'Are you sure?', :method => :post %> | +
+ <%= column.human_name %>: <%=h @videogenre.send(column.name) %> +
+<% end %> + +<%= link_to 'Edit', :action => 'edit', :id => @videogenre %> | +<%= link_to 'Back', :action => 'list' %> diff --git a/db/development.sqlite3 b/db/development.sqlite3 index 166de39..f020ede 100644 Binary files a/db/development.sqlite3 and b/db/development.sqlite3 differ diff --git a/db/migrate/011_create_videogenres.rb b/db/migrate/011_create_videogenres.rb new file mode 100644 index 0000000..a94d38e --- /dev/null +++ b/db/migrate/011_create_videogenres.rb @@ -0,0 +1,11 @@ +class CreateVideogenres < ActiveRecord::Migration + def self.up + create_table :videogenres do |t| + t.column :name, :string, :null => false + end + end + + def self.down + drop_table :videogenres + end +end diff --git a/db/schema.rb b/db/schema.rb index 5c26969..f099861 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -2,7 +2,7 @@ # migrations feature of ActiveRecord to incrementally modify your database, and # then regenerate this schema definition. -ActiveRecord::Schema.define(:version => 10) do +ActiveRecord::Schema.define(:version => 11) do create_table "coitems", :force => true do |t| t.column "customer_id", :integer @@ -30,4 +30,8 @@ ActiveRecord::Schema.define(:version => 10) do t.column "platform", :integer end + create_table "videogenres", :force => true do |t| + t.column "name", :string, :null => false + end + end diff --git a/test/fixtures/videogenres.yml b/test/fixtures/videogenres.yml new file mode 100644 index 0000000..b49c4eb --- /dev/null +++ b/test/fixtures/videogenres.yml @@ -0,0 +1,5 @@ +# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html +one: + id: 1 +two: + id: 2 diff --git a/test/functional/videogenre_controller_test.rb b/test/functional/videogenre_controller_test.rb new file mode 100644 index 0000000..2186b18 --- /dev/null +++ b/test/functional/videogenre_controller_test.rb @@ -0,0 +1,92 @@ +require File.dirname(__FILE__) + '/../test_helper' +require 'videogenre_controller' + +# Re-raise errors caught by the controller. +class VideogenreController; def rescue_action(e) raise e end; end + +class VideogenreControllerTest < Test::Unit::TestCase + fixtures :videogenres + + def setup + @controller = VideogenreController.new + @request = ActionController::TestRequest.new + @response = ActionController::TestResponse.new + + @first_id = videogenres(:first).id + end + + def test_index + get :index + assert_response :success + assert_template 'list' + end + + def test_list + get :list + + assert_response :success + assert_template 'list' + + assert_not_nil assigns(:videogenres) + end + + def test_show + get :show, :id => @first_id + + assert_response :success + assert_template 'show' + + assert_not_nil assigns(:videogenre) + assert assigns(:videogenre).valid? + end + + def test_new + get :new + + assert_response :success + assert_template 'new' + + assert_not_nil assigns(:videogenre) + end + + def test_create + num_videogenres = Videogenre.count + + post :create, :videogenre => {} + + assert_response :redirect + assert_redirected_to :action => 'list' + + assert_equal num_videogenres + 1, Videogenre.count + end + + def test_edit + get :edit, :id => @first_id + + assert_response :success + assert_template 'edit' + + assert_not_nil assigns(:videogenre) + assert assigns(:videogenre).valid? + end + + def test_update + post :update, :id => @first_id + assert_response :redirect + assert_redirected_to :action => 'show', :id => @first_id + end + + def test_destroy + assert_nothing_raised { + Videogenre.find(@first_id) + } + + post :destroy, :id => @first_id + assert_response :redirect + assert_redirected_to :action => 'list' + + assert_raise(ActiveRecord::RecordNotFound) { + Videogenre.find(@first_id) + } + end +end diff --git a/test/unit/videogenre_test.rb b/test/unit/videogenre_test.rb new file mode 100644 index 0000000..5290195 --- /dev/null +++ b/test/unit/videogenre_test.rb @@ -0,0 +1,10 @@ +require File.dirname(__FILE__) + '/../test_helper' + +class VideogenreTest < Test::Unit::TestCase + fixtures :videogenres + + # Replace this with your real tests. + def test_truth + assert true + end +end