refactoring buttons to their own controller

This commit is contained in:
mike.gaffney 2009-06-01 12:25:36 -05:00
parent 5430930bac
commit 2219ab62d3
6 changed files with 30 additions and 5 deletions

View File

@ -0,0 +1,7 @@
class ButtonsController < ApplicationController
def show
end
def create
render :text => "success"
end
end

View File

@ -9,9 +9,6 @@ class WebratController < ApplicationController
def form
end
def buttons
end
def submit
render :text => "OK <a href='/' id='link_id'>Test Link Text</a>"
end

View File

@ -0,0 +1,2 @@
module ButtonsHelper
end

View File

@ -0,0 +1,11 @@
<h1 id='form_title' class='form title'>Webrat Buttons Form</h1>
<% form_tag "/buttons" do %>
<input type="button" id="input_button_id" value="input_button_value" />
<input type="submit" id="input_submit_id" value="input_submit_value" />
<input type="image" id="input_image_id" value="input_image_value" alt="input_image_alt" src="" />
<button type="button" id="button_button_id" value="button_button_value">button_button_text</button>
<button type="submit" id="button_submit_id" value="button_submit_value">button_submit_text</button>
<button type="image" id="button_image_id" value="button_image_value">button_image_text</button>
<% end %>

View File

@ -1,4 +1,6 @@
ActionController::Routing::Routes.draw do |map|
map.resource 'links', :only => [:show]
map.resource 'buttons', :only => [:show, :create]
map.with_options :controller => "webrat" do |webrat|
webrat.submit "/submit", :action => "submit"
webrat.internal_redirect "/internal_redirect", :action => "internal_redirect"
@ -9,8 +11,6 @@ ActionController::Routing::Routes.draw do |map|
webrat.redirect_to_show_params "/redirect_to_show_params", :action => "redirect_to_show_params"
webrat.show_params "/show_params", :action => "show_params"
webrat.buttons "/buttons", :action => "buttons"
webrat.root :action => "form"
end
map.resource 'links'
end

View File

@ -0,0 +1,8 @@
require 'test_helper'
class ButtonsControllerTest < ActionController::TestCase
# Replace this with your real tests.
test "the truth" do
assert true
end
end