diff --git a/app/controllers/application.rb b/app/controllers/application.rb index ce9283a..854ac72 100644 --- a/app/controllers/application.rb +++ b/app/controllers/application.rb @@ -92,15 +92,9 @@ class ApplicationController < ActionController::Base ] cond_var = { :model_title => tfu, - :help_owner_type => 'Help' } - # specific overrides for help, this has an owner type but it is just a Page - if obj_type == 'help' - cond_ary << 'owner_type = :help_owner_type' - obj_type = 'pages' - elsif obj_type == 'pages' - cond_ary << 'owner_type IS NULL' - end + cond_ary << 'owner_type IS NULL' if obj_type == 'pages' + # the eventual name of the instance variable, like +@page+ obj_name = obj_type.singularize diff --git a/app/controllers/help_controller.rb b/app/controllers/help_controller.rb deleted file mode 100644 index c456904..0000000 --- a/app/controllers/help_controller.rb +++ /dev/null @@ -1,98 +0,0 @@ -class HelpController < ApplicationController - append_before_filter :fetch_model, - :only => [ :show, :edit, :update, :destroy ] - - # GET /help - # GET /help.xml - def index - @page = Page.find_by_title_and_owner_type 'HomePage', 'Help' - @content_title = 'BarleySodas Help' - @secondary_title = '' - @tags = Page.tags(:limit => 25, :order => 'name DESC', - :owner_type => 'Help') - end - - # GET /help/1 - # GET /help/1.xml - def show - @secondary_title = '' - respond_to do |format| - format.html # show.rhtml - format.xml { render :xml => @page.to_xml } - end - end - - # GET /help/new - def new - @page = Page.new - @page.title = params[:new_title] if params[:new_title] - @secondary_title = 'Creating help page' - end - - # GET /help/1;edit - def edit - @secondary_title = 'Updating help page' - end - - # POST /help - # POST /help.xml - def create - @page = Page.new(params[:page]) - @page.owner_type = 'Help' - respond_to do |format| - if @page.save - flash[:notice] = 'Help was successfully created.' - format.html { - if @page.title == 'HomePage' - redirect_to :controller => 'help', :action => 'index' - else - redirect_to help_url({ :id => @page.title_for_url }) - end - } - format.xml { head :created, - :location => help_url({ :id => @page.title_for_url }) } - else - format.html { - @secondary_title = 'Creating help page' - render :action => "new" - } - format.xml { render :xml => @page.errors.to_xml } - end - end - end - - # PUT /help/1 - # PUT /help/1.xml - def update - @page.attributes = params[:page] - respond_to do |format| - if @page.save - flash[:notice] = 'Help was successfully updated.' - format.html { - if @page.title == 'HomePage' - redirect_to :controller => 'help', :action => 'index' - else - redirect_to help_url({ :id => @page.title_for_url }) - end - } - format.xml { head :ok } - else - format.html { - @secondary_title = 'Updating help page' - render :action => "edit" - } - format.xml { render :xml => @page.errors.to_xml, :status => 400 } - end - end - end - - # DELETE /help/1 - # DELETE /help/1.xml - def destroy - @page.destroy - respond_to do |format| - format.html { redirect_to :controller => 'help', :action => 'index' } - format.xml { head :ok } - end - end -end diff --git a/app/helpers/help_helper.rb b/app/helpers/help_helper.rb deleted file mode 100644 index ba75291..0000000 --- a/app/helpers/help_helper.rb +++ /dev/null @@ -1,11 +0,0 @@ -module HelpHelper - def show_help_link(page, better_title = 'Show') - link_to better_title, help_path({ :id => page.title_for_url }), - { :title => page.title } - end - - def edit_help_link(page) - link_to 'Edit Help Page', edit_help_path({ :id => page.title_for_url }), - { :title => "Edit Help Page #{page.title}" } - end -end diff --git a/app/views/help/edit.rhtml b/app/views/help/edit.rhtml deleted file mode 100644 index c02a020..0000000 --- a/app/views/help/edit.rhtml +++ /dev/null @@ -1,12 +0,0 @@ -<%= error_messages_for :page %> - -<% form_for(:help, :url => help_path({ :id => @page.title_for_url }), :html => { :method => :put }) do |f| %> - <%= render :partial => 'pages/page_form' %> -

- <%= submit_tag "Update" %> -

-<% end %> - -<% content_for :sidebar do -%> - <%= show_help_link(@page) unless @page.title == 'HomePage' -%>
-<% end -%> \ No newline at end of file diff --git a/app/views/help/index.rhtml b/app/views/help/index.rhtml deleted file mode 100644 index dba66f8..0000000 --- a/app/views/help/index.rhtml +++ /dev/null @@ -1,6 +0,0 @@ -<%= render :partial => 'pages/page' -%> - -<% content_for :sidebar do -%> - <%= edit_help_link(@page) -%>
- <%= render :partial => 'shared/tag_cloud' %> -<% end -%> \ No newline at end of file diff --git a/app/views/help/new.rhtml b/app/views/help/new.rhtml deleted file mode 100644 index 2dcba1d..0000000 --- a/app/views/help/new.rhtml +++ /dev/null @@ -1,11 +0,0 @@ -<%= error_messages_for :page %> - -<% form_for(:help, :url => { :controller => 'help', :action => 'index' }, :html => { :method => :post }) do |f| %> -

- <%= text_field 'page', 'title' %> -

- <%= render :partial => 'pages/page_form' %> -

- <%= submit_tag "Create" %> -

-<% end %> \ No newline at end of file diff --git a/app/views/help/show.rhtml b/app/views/help/show.rhtml deleted file mode 100644 index 7064640..0000000 --- a/app/views/help/show.rhtml +++ /dev/null @@ -1,6 +0,0 @@ -<%= render :partial => 'pages/page' %> - -<% content_for :sidebar do -%> - <%= edit_help_link(@page) -%>
- <%= link_to 'Destroy', help_path(@page.title_for_url), :confirm => 'Are you sure?', :method => :delete unless @page.title == 'HomePage' -%>
-<% end -%> \ No newline at end of file diff --git a/app/views/layouts/application.rhtml b/app/views/layouts/application.rhtml index 4485f6f..13a69a8 100644 --- a/app/views/layouts/application.rhtml +++ b/app/views/layouts/application.rhtml @@ -38,7 +38,6 @@ <%= link_to_unless_current 'Browse Breweries', breweries_path -%>
<%= link_to_unless_current 'BarleySodas People', peoples_path -%>
<% if has_permission_for_action?(:index, :roles) -%><%= link_to_unless_current 'Roles', roles_path -%>
<% end -%> - <%= link_to_unless_current 'Help With BarleySodas', :controller => 'help', :action => 'index' -%>
<% unless logged_in? -%><%= link_to_unless_current 'Login', new_session_path -%><% else -%><%= link_to "Logout #{session[:people_title]}", session_path(:id => session[:people_title]), :method => :delete -%><% end %>
<%= yield :sidebar %> diff --git a/config/routes.rb b/config/routes.rb index dc96d9d..bed18cc 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,6 +1,6 @@ ActionController::Routing::Routes.draw do |map| map.resources :beers, :breweries, :pages, :discussions, :peoples, :roles, - :sessions, :help, :styles + :sessions, :styles map.connect ':controller/:action/:id.:format' map.connect ':controller/:action/:id' diff --git a/test/functional/help_controller_test.rb b/test/functional/help_controller_test.rb deleted file mode 100644 index 42ef9f8..0000000 --- a/test/functional/help_controller_test.rb +++ /dev/null @@ -1,57 +0,0 @@ -require File.dirname(__FILE__) + '/../test_helper' -require 'help_controller' - -# Re-raise errors caught by the controller. -class HelpController; def rescue_action(e) raise e end; end - -class HelpControllerTest < Test::Unit::TestCase - fixtures :help - - def setup - @controller = HelpController.new - @request = ActionController::TestRequest.new - @response = ActionController::TestResponse.new - end - - def test_should_get_index - get :index - assert_response :success - assert assigns(:helps) - end - - def test_should_get_new - get :new - assert_response :success - end - - def test_should_create_help - old_count = Help.count - post :create, :help => { } - assert_equal old_count+1, Help.count - - assert_redirected_to help_path(assigns(:help)) - end - - def test_should_show_help - get :show, :id => 1 - assert_response :success - end - - def test_should_get_edit - get :edit, :id => 1 - assert_response :success - end - - def test_should_update_help - put :update, :id => 1, :help => { } - assert_redirected_to help_path(assigns(:help)) - end - - def test_should_destroy_help - old_count = Help.count - delete :destroy, :id => 1 - assert_equal old_count-1, Help.count - - assert_redirected_to helps_path - end -end