diff options
-rw-r--r-- | README | 9 | ||||
-rw-r--r-- | app/controllers/application.rb | 17 | ||||
-rw-r--r-- | app/helpers/application_helper.rb | 32 | ||||
-rw-r--r-- | app/helpers/link_to_helper.rb | 46 | ||||
-rw-r--r-- | spec/controllers/user_controller_spec.rb | 1 | ||||
-rw-r--r-- | todo.txt | 9 | ||||
-rw-r--r-- | vendor/plugins/rake_tasks/tasks/spec.rake | 7 |
7 files changed, 79 insertions, 42 deletions
@@ -173,9 +173,14 @@ public script Helper scripts for automation and generation. +spec + Unit and functional specifications along with fixtures. We use this instead of + test. + test - Unit and functional tests along with fixtures. When using the script/generate scripts, template - test files will be generated for you and placed in this directory. + DEPRECATED for this project, see 'spec' instead. Unit and functional tests + along with fixtures. When using the script/generate scripts, template test + files will be generated for you and placed in this directory. vendor External libraries that the application depends on. Also includes the plugins subdirectory. diff --git a/app/controllers/application.rb b/app/controllers/application.rb index d0d0fef7e..824f6f77b 100644 --- a/app/controllers/application.rb +++ b/app/controllers/application.rb @@ -6,7 +6,7 @@ # Copyright (c) 2007 UK Citizens Online Democracy. All rights reserved. # Email: francis@mysociety.org; WWW: http://www.mysociety.org/ # -# $Id: application.rb,v 1.20 2007-10-31 17:25:29 francis Exp $ +# $Id: application.rb,v 1.21 2007-11-01 05:35:43 francis Exp $ class ApplicationController < ActionController::Base @@ -73,17 +73,10 @@ class ApplicationController < ActionController::Base end end - # Simplified links to our objects - # XXX See controllers/user_controller.rb controllers/body_controller.rb for inverse - # XXX consolidate somehow with stuff in helpers/application_helper.rb - helper_method :simplify_url_part - def simplify_url_part(text) - text.downcase! - text.gsub!(/ /, "-") - text.gsub!(/[^a-z0-9_-]/, "") - text - end - + # URL generating functions are needed by all controllers (for redirects) + # and views (for links), so include them into all of both. + include LinkToHelper + end diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index ee0bd877e..5ecf8f57b 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -1,12 +1,16 @@ # app/helpers/application_helper.rb: -# Methods added to this helper will be available to all templates in the application. +# Methods added to this helper will be available to all views (i.e. templates) +# in the application. # # Copyright (c) 2007 UK Citizens Online Democracy. All rights reserved. # Email: francis@mysociety.org; WWW: http://www.mysociety.org/ # -# $Id: application_helper.rb,v 1.11 2007-10-30 18:52:27 francis Exp $ +# $Id: application_helper.rb,v 1.12 2007-11-01 05:35:43 francis Exp $ module ApplicationHelper + # URL generating functions are needed by all controllers (for redirects) + # and views (for links), so include them into all of both. + include LinkToHelper # Copied from error_messages_for in active_record_helper.rb def foi_error_messages_for(*params) @@ -38,30 +42,6 @@ module ApplicationHelper def simple_date(date) return date.strftime("%e %B %Y") end - - - # Links to various models - # XXX consolidate with simplify_url_part in controllers/application.rb so - # ones with calls to simplify_url_part are only in one place - - def request_link(info_request) - link_to h(info_request.title), show_request_url(:id => info_request) - end - - def public_body_link_short(public_body) - link_to h(public_body.short_name), show_public_body_url(:simple_short_name => simplify_url_part(public_body.short_name)) - end - def public_body_link(public_body) - link_to h(public_body.name), show_public_body_url(:simple_short_name => simplify_url_part(public_body.short_name)) - end - - def user_link(user) - link_to h(user.name), show_user_url(:simple_name => simplify_url_part(user.name)) - end - - def info_request_link(info_request) - link_to h(info_request.title), show_request_url(:id => info_request) - end end diff --git a/app/helpers/link_to_helper.rb b/app/helpers/link_to_helper.rb new file mode 100644 index 000000000..b621916b7 --- /dev/null +++ b/app/helpers/link_to_helper.rb @@ -0,0 +1,46 @@ +# app/helpers/application_helper.rb: +# This module is included into all controllers via controllers/application.rb +# - +# +# Copyright (c) 2007 UK Citizens Online Democracy. All rights reserved. +# Email: francis@mysociety.org; WWW: http://www.mysociety.org/ +# +# $Id: link_to_helper.rb,v 1.1 2007-11-01 05:35:43 francis Exp $ + +module LinkToHelper + + # Links to various models + # XXX consolidate with simplify_url_part in controllers/application.rb so + # ones with calls to simplify_url_part are only in one place + + def request_link(info_request) + link_to h(info_request.title), show_request_url(:id => info_request) + end + + def public_body_link_short(public_body) + link_to h(public_body.short_name), show_public_body_url(:simple_short_name => simplify_url_part(public_body.short_name)) + end + def public_body_link(public_body) + link_to h(public_body.name), show_public_body_url(:simple_short_name => simplify_url_part(public_body.short_name)) + end + + def user_link(user) + link_to h(user.name), show_user_url(:simple_name => simplify_url_part(user.name)) + end + + def info_request_link(info_request) + link_to h(info_request.title), show_request_url(:id => info_request) + end + + # Simplified links to our objects + # XXX See controllers/user_controller.rb controllers/body_controller.rb for inverse + # XXX consolidate somehow with stuff in helpers/application_helper.rb + def simplify_url_part(text) + text.downcase! + text.gsub!(/ /, "-") + text.gsub!(/[^a-z0-9_-]/, "") + text + end + +end + diff --git a/spec/controllers/user_controller_spec.rb b/spec/controllers/user_controller_spec.rb index 8354e774c..239b7cf56 100644 --- a/spec/controllers/user_controller_spec.rb +++ b/spec/controllers/user_controller_spec.rb @@ -25,3 +25,4 @@ describe UserController, "when showing a user" do # XXX test for 404s when don't give valid name end + @@ -1,3 +1,12 @@ +Offline +======= + +Work out how to do controller/view integrated specs and add some +Change to will_paginate + +Next +==== + Send confirmation email Send email to requestor telling them new information has come in diff --git a/vendor/plugins/rake_tasks/tasks/spec.rake b/vendor/plugins/rake_tasks/tasks/spec.rake index 9f07b0100..a4d608d1b 100644 --- a/vendor/plugins/rake_tasks/tasks/spec.rake +++ b/vendor/plugins/rake_tasks/tasks/spec.rake @@ -25,7 +25,9 @@ namespace :spec do files = {} `find #{PROJ_DIR} -name '*.rb'`.split(/\n/).each do |file| spec_file = file.sub('/app/', '/spec/').sub('.rb', '_spec.rb') - type = (File.dirname(file).split("/").last == "models" ? "model" : "controller") + dir_type = File.dirname(file).split("/").last + next if dir_type == "helpers" + type = (dir_type == "models" ? "model" : "controller") File.exists?(spec_file) ? next : files[spec_file] = type end files @@ -43,7 +45,8 @@ namespace :spec do desc "Check files in the app directory for corresponding test files in the spec directory." task :check do - files = find_untested_ruby_files.merge(find_untested_view_files) + # XXX Don't check views, as we use controllers for view tests. Francis. + files = find_untested_ruby_files #.merge(find_untested_view_files) unless files.empty? puts "Missing test files:" files.each {|file, type| puts " #{file}"} |