diff --git a/app/controllers/call_attempts_controller.rb b/app/controllers/call_attempts_controller.rb new file mode 100644 index 0000000000000000000000000000000000000000..d5c883fa7ff287e67b854624b95be8c586d01cd0 --- /dev/null +++ b/app/controllers/call_attempts_controller.rb @@ -0,0 +1,51 @@ +class CallAttemptsController < ApplicationController + def index + list + render :action => 'list' + end + + # GETs should be safe (see http://www.w3.org/2001/tag/doc/whenToUseGet.html) + verify :method => :post, :only => [ :destroy, :create, :update ], + :redirect_to => { :action => :list } + + def list + @call_attempt_pages, @call_attempts = paginate :call_attempts, :per_page => 10 + end + + def show + @call_attempt = CallAttempt.find(params[:id]) + end + + def new + @call_attempt = CallAttempt.new + end + + def create + @call_attempt = CallAttempt.new(params[:call_attempt]) + if @call_attempt.save + flash[:notice] = 'CallAttempt was successfully created.' + redirect_to :action => 'list' + else + render :action => 'new' + end + end + + def edit + @call_attempt = CallAttempt.find(params[:id]) + end + + def update + @call_attempt = CallAttempt.find(params[:id]) + if @call_attempt.update_attributes(params[:call_attempt]) + flash[:notice] = 'CallAttempt was successfully updated.' + redirect_to :action => 'show', :id => @call_attempt + else + render :action => 'edit' + end + end + + def destroy + CallAttempt.find(params[:id]).destroy + redirect_to :action => 'list' + end +end diff --git a/app/helpers/call_attempts_helper.rb b/app/helpers/call_attempts_helper.rb new file mode 100644 index 0000000000000000000000000000000000000000..00871226104de74733c3fc89d761bcde033f9353 --- /dev/null +++ b/app/helpers/call_attempts_helper.rb @@ -0,0 +1,2 @@ +module CallAttemptsHelper +end diff --git a/app/models/call_attempt.rb b/app/models/call_attempt.rb new file mode 100644 index 0000000000000000000000000000000000000000..bbd95b351c2941b3e5c6a157345c8d5a88790ed7 --- /dev/null +++ b/app/models/call_attempt.rb @@ -0,0 +1,2 @@ +class CallAttempt < ActiveRecord::Base +end diff --git a/app/views/call_attempts/_form.rhtml b/app/views/call_attempts/_form.rhtml new file mode 100644 index 0000000000000000000000000000000000000000..e89c66a5e2ee4451ca0eecad53435bd73ae81bab --- /dev/null +++ b/app/views/call_attempts/_form.rhtml @@ -0,0 +1,13 @@ +<%= error_messages_for 'call_attempt' %> + +<!--[form:call_attempt]--> +<p><label for="call_attempt_cid">Cid</label><br/> +<%= text_field 'call_attempt', 'cid' %></p> + +<p><label for="call_attempt_from">From</label><br/> +<%= text_field 'call_attempt', 'from' %></p> + +<p><label for="call_attempt_when">When</label><br/> +<%= datetime_select 'call_attempt', 'when' %></p> +<!--[eoform:call_attempt]--> + diff --git a/app/views/call_attempts/edit.rhtml b/app/views/call_attempts/edit.rhtml new file mode 100644 index 0000000000000000000000000000000000000000..db61e46680f2afe53579027310e14c4899112442 --- /dev/null +++ b/app/views/call_attempts/edit.rhtml @@ -0,0 +1,9 @@ +<h1>Editing call_attempt</h1> + +<%= start_form_tag :action => 'update', :id => @call_attempt %> + <%= render :partial => 'form' %> + <%= submit_tag 'Edit' %> +<%= end_form_tag %> + +<%= link_to 'Show', :action => 'show', :id => @call_attempt %> | +<%= link_to 'Back', :action => 'list' %> diff --git a/app/views/call_attempts/list.rhtml b/app/views/call_attempts/list.rhtml new file mode 100644 index 0000000000000000000000000000000000000000..7fe5cec66f22367a2ec1f8f42c7d16f3cec3fb87 --- /dev/null +++ b/app/views/call_attempts/list.rhtml @@ -0,0 +1,27 @@ +<h1>Listing call_attempts</h1> + +<table> + <tr> + <% for column in CallAttempt.content_columns %> + <th><%= column.human_name %></th> + <% end %> + </tr> + +<% for call_attempt in @call_attempts %> + <tr> + <% for column in CallAttempt.content_columns %> + <td><%=h call_attempt.send(column.name) %></td> + <% end %> + <td><%= link_to 'Show', :action => 'show', :id => call_attempt %></td> + <td><%= link_to 'Edit', :action => 'edit', :id => call_attempt %></td> + <td><%= link_to 'Destroy', { :action => 'destroy', :id => call_attempt }, :confirm => 'Are you sure?', :post => true %></td> + </tr> +<% end %> +</table> + +<%= link_to 'Previous page', { :page => @call_attempt_pages.current.previous } if @call_attempt_pages.current.previous %> +<%= link_to 'Next page', { :page => @call_attempt_pages.current.next } if @call_attempt_pages.current.next %> + +<br /> + +<%= link_to 'New call_attempt', :action => 'new' %> diff --git a/app/views/call_attempts/new.rhtml b/app/views/call_attempts/new.rhtml new file mode 100644 index 0000000000000000000000000000000000000000..2f38ef2a93b8daa4bbc557ef28d9ba30431944c6 --- /dev/null +++ b/app/views/call_attempts/new.rhtml @@ -0,0 +1,8 @@ +<h1>New call_attempt</h1> + +<%= start_form_tag :action => 'create' %> + <%= render :partial => 'form' %> + <%= submit_tag "Create" %> +<%= end_form_tag %> + +<%= link_to 'Back', :action => 'list' %> diff --git a/app/views/call_attempts/show.rhtml b/app/views/call_attempts/show.rhtml new file mode 100644 index 0000000000000000000000000000000000000000..07fb205dfb4e7b486423902267858d54acd35d6d --- /dev/null +++ b/app/views/call_attempts/show.rhtml @@ -0,0 +1,8 @@ +<% for column in CallAttempt.content_columns %> +<p> + <b><%= column.human_name %>:</b> <%=h @call_attempt.send(column.name) %> +</p> +<% end %> + +<%= link_to 'Edit', :action => 'edit', :id => @call_attempt %> | +<%= link_to 'Back', :action => 'list' %> diff --git a/app/views/layouts/call_attempts.rhtml b/app/views/layouts/call_attempts.rhtml new file mode 100644 index 0000000000000000000000000000000000000000..d8a91f466941de8c34290c0678fcc10ea2eaa43e --- /dev/null +++ b/app/views/layouts/call_attempts.rhtml @@ -0,0 +1,13 @@ +<html> +<head> + <title>CallAttempts: <%= controller.action_name %></title> + <%= stylesheet_link_tag 'scaffold' %> +</head> +<body> + +<p style="color: green"><%= flash[:notice] %></p> + +<%= @content_for_layout %> + +</body> +</html> diff --git a/test/fixtures/call_attempts.yml b/test/fixtures/call_attempts.yml new file mode 100644 index 0000000000000000000000000000000000000000..8794d28ae419929e241d892341c7429b84e5c74e --- /dev/null +++ b/test/fixtures/call_attempts.yml @@ -0,0 +1,5 @@ +# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html +first: + id: 1 +another: + id: 2 diff --git a/test/functional/call_attempts_controller_test.rb b/test/functional/call_attempts_controller_test.rb new file mode 100644 index 0000000000000000000000000000000000000000..45c43a32977c769ef491664f76155860663ca858 --- /dev/null +++ b/test/functional/call_attempts_controller_test.rb @@ -0,0 +1,88 @@ +require File.dirname(__FILE__) + '/../test_helper' +require 'call_attempts_controller' + +# Re-raise errors caught by the controller. +class CallAttemptsController; def rescue_action(e) raise e end; end + +class CallAttemptsControllerTest < Test::Unit::TestCase + fixtures :call_attempts + + def setup + @controller = CallAttemptsController.new + @request = ActionController::TestRequest.new + @response = ActionController::TestResponse.new + 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(:call_attempts) + end + + def test_show + get :show, :id => 1 + + assert_response :success + assert_template 'show' + + assert_not_nil assigns(:call_attempt) + assert assigns(:call_attempt).valid? + end + + def test_new + get :new + + assert_response :success + assert_template 'new' + + assert_not_nil assigns(:call_attempt) + end + + def test_create + num_call_attempts = CallAttempt.count + + post :create, :call_attempt => {} + + assert_response :redirect + assert_redirected_to :action => 'list' + + assert_equal num_call_attempts + 1, CallAttempt.count + end + + def test_edit + get :edit, :id => 1 + + assert_response :success + assert_template 'edit' + + assert_not_nil assigns(:call_attempt) + assert assigns(:call_attempt).valid? + end + + def test_update + post :update, :id => 1 + assert_response :redirect + assert_redirected_to :action => 'show', :id => 1 + end + + def test_destroy + assert_not_nil CallAttempt.find(1) + + post :destroy, :id => 1 + assert_response :redirect + assert_redirected_to :action => 'list' + + assert_raise(ActiveRecord::RecordNotFound) { + CallAttempt.find(1) + } + end +end diff --git a/test/unit/call_attempt_test.rb b/test/unit/call_attempt_test.rb new file mode 100644 index 0000000000000000000000000000000000000000..e8198113b584514cc2e59ae6ab86b9863378470c --- /dev/null +++ b/test/unit/call_attempt_test.rb @@ -0,0 +1,10 @@ +require File.dirname(__FILE__) + '/../test_helper' + +class CallAttemptTest < Test::Unit::TestCase + fixtures :call_attempts + + # Replace this with your real tests. + def test_truth + assert true + end +end