diff options
author | Louise Crow <louise.crow@gmail.com> | 2014-06-16 13:46:22 +0100 |
---|---|---|
committer | Louise Crow <louise.crow@gmail.com> | 2014-06-16 13:46:22 +0100 |
commit | 04145fbe231cdbbc88b9172dad1ae3d1ddfb65cc (patch) | |
tree | 0516d6a792f4f0174e673579e2bf01bb4f8242bb | |
parent | 6c89d63b6eebe33401efbf376e3884c61fb92d26 (diff) | |
parent | 7bf6cbe307d3fd99680c084025240ed504e37297 (diff) |
Merge branch 'rails-3-develop' of ssh://git.mysociety.org/data/git/public/alaveteli into rails-3-develop
57 files changed, 362 insertions, 233 deletions
diff --git a/app/controllers/admin_request_controller.rb b/app/controllers/admin_request_controller.rb index fc291d998..5c45a6e6e 100644 --- a/app/controllers/admin_request_controller.rb +++ b/app/controllers/admin_request_controller.rb @@ -199,7 +199,7 @@ class AdminRequestController < AdminController end # Bejeeps, look, sometimes a URL is something that belongs in a controller, jesus. - # XXX hammer this square peg into the round MVC hole + # TODO: hammer this square peg into the round MVC hole post_redirect = PostRedirect.new( :uri => upload_response_url(:url_title => info_request.url_title), :user_id => user.id) @@ -253,7 +253,7 @@ class AdminRequestController < AdminController end info_request_event.described_state = 'waiting_clarification' info_request_event.calculated_state = 'waiting_clarification' - # XXX deliberately don't update described_at so doesn't reenter search? + # TODO: deliberately don't update described_at so doesn't reenter search? info_request_event.save! flash[:notice] = "Old response marked as having been a clarification" diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 78a82316a..0c5f5bd02 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -278,10 +278,10 @@ class ApplicationController < ActionController::Base session[:post_redirect_token] = post_redirect.token - # XXX what is the built in Ruby URI munging function that can do this + # TODO: what is the built in Ruby URI munging function that can do this # choice of & vs. ? more elegantly than this dumb if statement? if uri.include?("?") - # XXX This looks odd. What would a fragment identifier be doing server-side? + # TODO: This looks odd. What would a fragment identifier be doing server-side? # But it also looks harmless, so I’ll leave it just in case. if uri.include?("#") uri.sub!("#", "&post_redirect=1#") diff --git a/app/controllers/comment_controller.rb b/app/controllers/comment_controller.rb index 5e39c3a2c..2c0037577 100644 --- a/app/controllers/comment_controller.rb +++ b/app/controllers/comment_controller.rb @@ -21,7 +21,7 @@ class CommentController < ApplicationController end if params[:comment] - # XXX this check should theoretically be a validation rule in the model + # TODO: this check should theoretically be a validation rule in the model @existing_comment = Comment.find_existing(@info_request.id, params[:comment][:body]) else # Default to subscribing to request when first viewing form diff --git a/app/controllers/general_controller.rb b/app/controllers/general_controller.rb index e2a2190b0..28055ddbf 100644 --- a/app/controllers/general_controller.rb +++ b/app/controllers/general_controller.rb @@ -59,7 +59,7 @@ class GeneralController < ApplicationController # Actual search def search - # XXX Why is this so complicated with arrays and stuff? Look at the route + # TODO: Why is this so complicated with arrays and stuff? Look at the route # in config/routes.rb for comments. combined = params[:combined].split("/") @sortby = nil @@ -70,7 +70,7 @@ class GeneralController < ApplicationController else @advanced = false end - # XXX currently /described isn't linked to anywhere, just used in RSS and for /list/successful + # TODO: currently /described isn't linked to anywhere, just used in RSS and for /list/successful # This is because it's confusingly different from /newest - but still useful for power users. if combined.size > 0 && (['newest', 'described', 'relevant'].include?(combined[-1])) @sort_postfix = combined.pop @@ -124,7 +124,7 @@ class GeneralController < ApplicationController end end - # Query each type separately for separate display (XXX we are calling + # Query each type separately for separate display (TODO: we are calling # perform_search multiple times and it clobbers per_page for each one, # so set as separate var) requests_per_page = params[:requests_per_page] ? params[:requests_per_page].to_i : 25 diff --git a/app/controllers/public_body_controller.rb b/app/controllers/public_body_controller.rb index 96e69d333..f909a5989 100644 --- a/app/controllers/public_body_controller.rb +++ b/app/controllers/public_body_controller.rb @@ -10,7 +10,7 @@ require 'confidence_intervals' require 'tempfile' class PublicBodyController < ApplicationController - # XXX tidy this up with better error messages, and a more standard infrastructure for the redirect to canonical URL + # TODO: tidy this up with better error messages, and a more standard infrastructure for the redirect to canonical URL def show long_cache if MySociety::Format.simplify_url_part(params[:url_name], 'body') != params[:url_name] @@ -43,7 +43,7 @@ class PublicBodyController < ApplicationController query = InfoRequestEvent.make_query_from_params(params.merge(:latest_status => @view)) query += " requested_from:#{@public_body.url_name}" # Use search query for this so can collapse and paginate easily - # XXX really should just use SQL query here rather than Xapian. + # TODO: really should just use SQL query here rather than Xapian. sortby = "described" begin @xapian_requests = perform_search([InfoRequestEvent], query, sortby, 'request_collapse') @@ -86,7 +86,7 @@ class PublicBodyController < ApplicationController def list long_cache - # XXX move some of these tag SQL queries into has_tag_string.rb + # TODO: move some of these tag SQL queries into has_tag_string.rb like_query = params[:public_body_query] like_query = "" if like_query.nil? diff --git a/app/controllers/request_controller.rb b/app/controllers/request_controller.rb index 55a03e7b4..6281959fb 100644 --- a/app/controllers/request_controller.rb +++ b/app/controllers/request_controller.rb @@ -310,7 +310,7 @@ class RequestController < ApplicationController end # See if the exact same request has already been submitted - # XXX this check should theoretically be a validation rule in the + # TODO: this check should theoretically be a validation rule in the # model, except we really want to pass @existing_request to the view so # it can link to it. @existing_request = InfoRequest.find_existing(params[:info_request][:title], params[:info_request][:public_body_id], params[:outgoing_message][:body]) @@ -365,7 +365,7 @@ class RequestController < ApplicationController end # This automatically saves dependent objects, such as @outgoing_message, in the same transaction @info_request.save! - # XXX send_message needs the database id, so we send after saving, which isn't ideal if the request broke here. + # TODO: send_message needs the database id, so we send after saving, which isn't ideal if the request broke here. @outgoing_message.send_message flash[:notice] = _("<p>Your {{law_used_full}} request has been <strong>sent on its way</strong>!</p> <p><strong>We will email you</strong> when there is a response, or after {{late_number_of_days}} working days if the authority still hasn't @@ -543,7 +543,7 @@ class RequestController < ApplicationController elsif @info_request_event.is_outgoing_message? redirect_to outgoing_message_url(@info_request_event.outgoing_message), :status => :moved_permanently else - # XXX maybe there are better URLs for some events than this + # TODO: maybe there are better URLs for some events than this redirect_to request_url(@info_request_event.info_request), :status => :moved_permanently end end @@ -1012,7 +1012,7 @@ class RequestController < ApplicationController params[:info_request][:public_body] = PublicBody.find(params[:url_name]) else public_body = PublicBody.find_by_url_name_with_historic(params[:url_name]) - raise ActiveRecord::RecordNotFound.new("None found") if public_body.nil? # XXX proper 404 + raise ActiveRecord::RecordNotFound.new("None found") if public_body.nil? # TODO: proper 404 params[:info_request][:public_body] = public_body end elsif params[:public_body_id] diff --git a/app/controllers/services_controller.rb b/app/controllers/services_controller.rb index 97c47c448..dc4f783a6 100644 --- a/app/controllers/services_controller.rb +++ b/app/controllers/services_controller.rb @@ -31,7 +31,7 @@ class ServicesController < ApplicationController FastGettext.locale = old_fgt_locale end end - render :text => text, :content_type => "text/plain" # XXX workaround the HTML validation in test suite + render :text => text, :content_type => "text/plain" # TODO: workaround the HTML validation in test suite end def hidden_user_explanation diff --git a/app/controllers/track_controller.rb b/app/controllers/track_controller.rb index dccc52efc..c15fb573d 100644 --- a/app/controllers/track_controller.rb +++ b/app/controllers/track_controller.rb @@ -82,7 +82,7 @@ class TrackController < ApplicationController def track_search_query @query = params[:query_array] - # XXX more hackery to make alternate formats still work with query_array + # TODO: more hackery to make alternate formats still work with query_array if /^(.*)\.json$/.match(@query) @query = $1 params[:format] = "json" diff --git a/app/controllers/user_controller.rb b/app/controllers/user_controller.rb index 12207362b..fcc500e06 100644 --- a/app/controllers/user_controller.rb +++ b/app/controllers/user_controller.rb @@ -46,7 +46,7 @@ class UserController < ApplicationController @is_you = !@user.nil? && @user.id == @display_user.id # Use search query for this so can collapse and paginate easily - # XXX really should just use SQL query here rather than Xapian. + # TODO: really should just use SQL query here rather than Xapian. if @show_requests begin requests_query = 'requested_by:' + @display_user.url_name @@ -102,11 +102,11 @@ class UserController < ApplicationController @is_you = !@user.nil? && @user.id == @display_user.id feed_results = Set.new # Use search query for this so can collapse and paginate easily - # XXX really should just use SQL query here rather than Xapian. + # TODO: really should just use SQL query here rather than Xapian. begin requests_query = 'requested_by:' + @display_user.url_name comments_query = 'commented_by:' + @display_user.url_name - # XXX combine these as OR query + # TODO: combine these as OR query @xapian_requests = perform_search([InfoRequestEvent], requests_query, 'newest', 'request_collapse') @xapian_comments = perform_search([InfoRequestEvent], comments_query, 'newest', nil) rescue @@ -121,7 +121,7 @@ class UserController < ApplicationController if @is_you @track_things = TrackThing.find(:all, :conditions => ["tracking_user_id = ? and track_medium = ?", @display_user.id, 'email_daily'], :order => 'created_at desc') for track_thing in @track_things - # XXX factor out of track_mailer.rb + # TODO: factor out of track_mailer.rb xapian_object = ActsAsXapian::Search.new([InfoRequestEvent], track_thing.track_query, :sort_by_prefix => 'described_at', :sort_by_ascending => true, @@ -262,7 +262,7 @@ class UserController < ApplicationController end end - # Change password (XXX and perhaps later email) - requires email authentication + # Change password (TODO: and perhaps later email) - requires email authentication def signchangepassword if @user and ((not session[:user_circumstance]) or (session[:user_circumstance] != "change_password")) # Not logged in via email, so send confirmation diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 33525cb3d..45b042354 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -13,6 +13,9 @@ module ApplicationHelper # all of all. include LinkToHelper + # Some extra date and time formatters + include DateTimeHelper + # Site-wide access to configuration settings include ConfigHelper diff --git a/app/helpers/date_time_helper.rb b/app/helpers/date_time_helper.rb new file mode 100644 index 000000000..5f129e590 --- /dev/null +++ b/app/helpers/date_time_helper.rb @@ -0,0 +1,69 @@ +module DateTimeHelper + # Public: Usually-correct format for a DateTime-ish object + # To define a new new format define the `simple_date_{FORMAT}` method + # + # date - a DateTime, Date or Time + # opts - a Hash of options (default: { format: :html}) + # :format - :html returns a HTML <time> tag + # :text returns a plain String + # + # Examples + # + # simple_date(Time.now) + # # => "<time>..." + # + # simple_date(Time.now, :format => :text) + # # => "March 10, 2014" + # + # Returns a String + # Raises ArgumentError if the format is unrecognized + def simple_date(date, opts = {}) + opts = { :format => :html }.merge(opts) + date_formatter = "simple_date_#{ opts[:format] }" + + if respond_to?(date_formatter) + send(date_formatter, date) + else + raise ArgumentError, "Unrecognized format :#{ opts[:format] }" + end + end + + # Usually-correct HTML formatting of a DateTime-ish object + # Use LinkToHelper#simple_date with desired formatting options + # + # date - a DateTime, Date or Time + # + # Returns a String + def simple_date_html(date) + date = date.in_time_zone unless date.is_a?(Date) + time_tag date, simple_date_text(date), :title => date.to_s + end + + # Usually-correct plain text formatting of a DateTime-ish object + # Use LinkToHelper#simple_date with desired formatting options + # + # date - a DateTime, Date or Time + # + # Returns a String + def simple_date_text(date) + date = date.in_time_zone.to_date unless date.is_a? Date + + date_format = _('simple_date_format') + date_format = :long if date_format == 'simple_date_format' + I18n.l(date, :format => date_format) + end + + # Strips the date from a DateTime + # + # date - a DateTime, Date or Time + # + # Examples + # + # simple_time(Time.now) + # # => "10:46:54" + # + # Returns a String + def simple_time(date) + date.strftime("%H:%M:%S").strip + end +end diff --git a/app/helpers/link_to_helper.rb b/app/helpers/link_to_helper.rb index dd6ffa805..3709469cf 100755 --- a/app/helpers/link_to_helper.rb +++ b/app/helpers/link_to_helper.rb @@ -28,19 +28,19 @@ module LinkToHelper # Incoming / outgoing messages def incoming_message_url(incoming_message, options = {}) - return request_url(incoming_message.info_request, options.merge(:anchor => "incoming-#{incoming_message.id}")) + message_url(incoming_message, options) end def incoming_message_path(incoming_message) - incoming_message_url(incoming_message, :only_path => true) + message_path(incoming_message) end def outgoing_message_url(outgoing_message, options = {}) - request_url(outgoing_message.info_request, options.merge(:anchor => "outgoing-#{outgoing_message.id}")) + message_url(outgoing_message, options) end def outgoing_message_path(outgoing_message) - outgoing_message_url(outgoing_message, :only_path => true) + message_path(outgoing_message) end def comment_url(comment, options = {}) @@ -279,73 +279,30 @@ module LinkToHelper end end - # Public: Usually-correct format for a DateTime-ish object - # To define a new new format define the `simple_date_{FORMAT}` method - # - # date - a DateTime, Date or Time - # opts - a Hash of options (default: { format: :html}) - # :format - :html returns a HTML <time> tag - # :text returns a plain String - # - # Examples - # - # simple_date(Time.now) - # # => "<time>..." - # - # simple_date(Time.now, :format => :text) - # # => "March 10, 2014" - # - # Returns a String - # Raises ArgumentError if the format is unrecognized - def simple_date(date, opts = {}) - opts = { :format => :html }.merge(opts) - date_formatter = "simple_date_#{ opts[:format] }" - - if respond_to?(date_formatter) - send(date_formatter, date) - else - raise ArgumentError, "Unrecognised format :#{ opts[:format] }" - end - end + #I18n locale switcher - # Usually-correct HTML formatting of a DateTime-ish object - # Use LinkToHelper#simple_date with desired formatting options - # - # date - a DateTime, Date or Time - # - # Returns a String - def simple_date_html(date) - date = date.in_time_zone unless date.is_a? Date - time_tag date, simple_date_text(date), :title => date.to_s + def locale_switcher(locale, params) + params['locale'] = locale + return url_for(params) end - # Usually-correct plain text formatting of a DateTime-ish object - # Use LinkToHelper#simple_date with desired formatting options - # - # date - a DateTime, Date or Time - # - # Returns a String - def simple_date_text(date) - date = date.in_time_zone.to_date unless date.is_a? Date + private - date_format = _("simple_date_format") - date_format = :long if date_format == "simple_date_format" - I18n.l(date, :format => date_format) - end + # Private: Generate a request_url linking to the new correspondence + def message_url(message, options = {}) + message_type = message.class.to_s.gsub('Message', '').downcase - def simple_time(date) - return date.strftime("%H:%M:%S").strip - end + default_options = { :anchor => "#{ message_type }-#{ message.id }" } - def year_from_date(date) - return date.strftime("%Y").strip - end + if options.delete(:cachebust) + default_options.merge!(:nocache => "#{ message_type }-#{ message.id }") + end - #I18n locale switcher + request_url(message.info_request, options.merge(default_options)) + end - def locale_switcher(locale, params) - params['locale'] = locale - return url_for(params) + def message_path(message) + message_url(message, :only_path => true) end end diff --git a/app/mailers/outgoing_mailer.rb b/app/mailers/outgoing_mailer.rb index 083c05a7c..797bf9fdd 100644 --- a/app/mailers/outgoing_mailer.rb +++ b/app/mailers/outgoing_mailer.rb @@ -8,7 +8,7 @@ # separated) paragraphs, as is the convention for all the other mailers. This # turned out to fit better with user exepectations when formatting messages. # -# XXX The other mail templates are written to use blank line separated +# TODO: The other mail templates are written to use blank line separated # paragraphs. They could be rewritten, and the wrapping method made uniform # throughout the application. @@ -35,10 +35,10 @@ class OutgoingMailer < ApplicationMailer :subject => OutgoingMailer.subject_for_followup(info_request, outgoing_message)) end - # XXX the condition checking valid_to_reply_to? also appears in views/request/_followup.html.erb, + # TODO: the condition checking valid_to_reply_to? also appears in views/request/_followup.html.erb, # it shouldn't really, should call something here. - # XXX also OutgoingMessage.get_salutation - # XXX these look like they should be members of IncomingMessage, but logically they + # TODO: also OutgoingMessage.get_salutation + # TODO: these look like they should be members of IncomingMessage, but logically they # need to work even when IncomingMessage is nil def OutgoingMailer.name_and_email_for_followup(info_request, incoming_message_followup) if incoming_message_followup.nil? || !incoming_message_followup.valid_to_reply_to? diff --git a/app/mailers/request_mailer.rb b/app/mailers/request_mailer.rb index 1fd5b9ba7..768257ba8 100644 --- a/app/mailers/request_mailer.rb +++ b/app/mailers/request_mailer.rb @@ -71,7 +71,7 @@ class RequestMailer < ApplicationMailer def new_response(info_request, incoming_message) # Don't use login link here, just send actual URL. This is # because people tend to forward these emails amongst themselves. - @url = incoming_message_url(incoming_message) + @url = incoming_message_url(incoming_message, :cachebust => true) @incoming_message, @info_request = incoming_message, info_request headers('Return-Path' => blackhole_email, @@ -234,7 +234,7 @@ class RequestMailer < ApplicationMailer def requests_matching_email(email) # We deliberately don't use Envelope-to here, so ones that are BCC # drop into the holding pen for checking. - reply_info_requests = [] # XXX should be set? + reply_info_requests = [] # TODO: should be set? for address in (email.to || []) + (email.cc || []) reply_info_request = InfoRequest.find_by_incoming_email(address) reply_info_requests.push(reply_info_request) if reply_info_request @@ -362,7 +362,7 @@ class RequestMailer < ApplicationMailer store_sent.user = info_request.user store_sent.alert_type = type_code store_sent.info_request_event_id = alert_event_id - # XXX uses same template for reminder 1 and reminder 2 right now. + # TODO: uses same template for reminder 1 and reminder 2 right now. RequestMailer.new_response_reminder_alert(info_request, last_response_message).deliver store_sent.save! end @@ -405,7 +405,7 @@ class RequestMailer < ApplicationMailer # cron jobs broke for more than a month events would be lost, but no # matter. I suspect the performance gain will be needed (with an index on updated_at) - # XXX the :order part info_request_events.created_at is a work around + # TODO: the :order part info_request_events.created_at is a work around # for a very old Rails bug which means eager loading does not respect # association orders. # http://dev.rubyonrails.org/ticket/3438 diff --git a/app/models/comment.rb b/app/models/comment.rb index b4c099123..a62c086d5 100644 --- a/app/models/comment.rb +++ b/app/models/comment.rb @@ -63,7 +63,7 @@ class Comment < ActiveRecord::Base # When posting a new comment, use this to check user hasn't double submitted. def Comment.find_existing(info_request_id, body) - # XXX can add other databases here which have regexp_replace + # TODO: can add other databases here which have regexp_replace if ActiveRecord::Base.connection.adapter_name == "PostgreSQL" # Exclude spaces from the body comparison using regexp_replace return Comment.find(:first, :conditions => [ "info_request_id = ? and regexp_replace(body, '[[:space:]]', '', 'g') = regexp_replace(?, '[[:space:]]', '', 'g')", info_request_id, body ]) diff --git a/app/models/foi_attachment.rb b/app/models/foi_attachment.rb index 6f198249a..a8d105f52 100644 --- a/app/models/foi_attachment.rb +++ b/app/models/foi_attachment.rb @@ -178,7 +178,7 @@ class FoiAttachment < ActiveRecord::Base return filename end - # XXX changing this will break existing URLs, so have a care - maybe + # TODO: changing this will break existing URLs, so have a care - maybe # make another old_display_filename see above def display_filename filename = self.filename diff --git a/app/models/incoming_message.rb b/app/models/incoming_message.rb index 124db8d4a..135a6bdaf 100644 --- a/app/models/incoming_message.rb +++ b/app/models/incoming_message.rb @@ -150,7 +150,7 @@ class IncomingMessage < ActiveRecord::Base end # The cached fields mentioned in the previous comment - # XXX there must be a nicer way to do this without all that + # TODO: there must be a nicer way to do this without all that # repetition. I tried overriding method_missing but got some # unpredictable results. def valid_to_reply_to @@ -194,7 +194,7 @@ class IncomingMessage < ActiveRecord::Base end # And look up by URL part number and display filename to get an attachment - # XXX relies on extract_attachments calling MailHandler.ensure_parts_counted + # TODO: relies on extract_attachments calling MailHandler.ensure_parts_counted # The filename here is passed from the URL parameter, so it's the # display_filename rather than the real filename. def self.get_attachment_by_url_part_number_and_filename(attachments, found_url_part_number, display_filename) @@ -220,7 +220,7 @@ class IncomingMessage < ActiveRecord::Base # Converts email addresses we know about into textual descriptions of them def mask_special_emails!(text) - # XXX can later display some of these special emails as actual emails, + # TODO: can later display some of these special emails as actual emails, # if they are public anyway. For now just be precautionary and only # put in descriptions of them in square brackets. if self.info_request.public_body.is_followupable? @@ -368,8 +368,8 @@ class IncomingMessage < ActiveRecord::Base # Remove quoted sections from emails (eventually the aim would be for this - # to do as good a job as GMail does) XXX bet it needs a proper parser - # XXX and this FOLDED_QUOTED_SECTION stuff is a mess + # to do as good a job as GMail does) TODO: bet it needs a proper parser + # TODO: and this FOLDED_QUOTED_SECTION stuff is a mess def self.remove_quoted_sections(text, replacement = "FOLDED_QUOTED_SECTION") text = text.dup replacement = "\n" + replacement + "\n" @@ -399,7 +399,7 @@ class IncomingMessage < ActiveRecord::Base ( \s*#{score}\n(?:(?!#{score}\n).)*? # top line (disclaimer:\n|confidential|received\sthis\semail\sin\serror|virus|intended\s+recipient|monitored\s+centrally|intended\s+(for\s+|only\s+for\s+use\s+by\s+)the\s+addressee|routinely\s+monitored|MessageLabs|unauthorised\s+use) - .*?(?:#{score}|\z) # bottom line OR end of whole string (for ones with no terminator XXX risky) + .*?(?:#{score}|\z) # bottom line OR end of whole string (for ones with no terminator TODO: risky) ) /imx, replacement) end @@ -480,7 +480,7 @@ class IncomingMessage < ActiveRecord::Base # Returns body text from main text part of email, converted to UTF-8, with uudecode removed, # emails and privacy sensitive things remove, censored, and folded to remove excess quoted text # (marked with FOLDED_QUOTED_SECTION) - # XXX returns a .dup of the text, so calling functions can in place modify it + # TODO: returns a .dup of the text, so calling functions can in place modify it def get_main_body_text_folded if self.cached_main_body_text_folded.nil? self._cache_main_body_text @@ -511,7 +511,7 @@ class IncomingMessage < ActiveRecord::Base source_charset = part.charset if part.content_type == 'text/html' # e.g. http://www.whatdotheyknow.com/request/35/response/177 - # XXX This is a bit of a hack as it is calling a + # TODO: This is a bit of a hack as it is calling a # convert to text routine. Could instead call a # sanitize HTML one. @@ -627,7 +627,7 @@ class IncomingMessage < ActiveRecord::Base return nil end # otherwise return it assuming it is text (sometimes you get things - # like binary/octet-stream, or the like, which are really text - XXX if + # like binary/octet-stream, or the like, which are really text - TODO: if # you find an example, put URL here - perhaps we should be always returning # nil in this case) return p @@ -722,7 +722,7 @@ class IncomingMessage < ActiveRecord::Base text = get_main_body_text_unfolded folded_quoted_text = get_main_body_text_folded - # Remove quoted sections, adding HTML. XXX The FOLDED_QUOTED_SECTION is + # Remove quoted sections, adding HTML. TODO: The FOLDED_QUOTED_SECTION is # a nasty hack so we can escape other HTML before adding the unfold # links, without escaping them. Rather than using some proper parser # making a tree structure (I don't know of one that is to hand, that diff --git a/app/models/info_request.rb b/app/models/info_request.rb index 47ad435cb..a2112a210 100644 --- a/app/models/info_request.rb +++ b/app/models/info_request.rb @@ -387,16 +387,16 @@ public # When constructing a new request, use this to check user hasn't double submitted. - # XXX could have a date range here, so say only check last month's worth of new requests. If somebody is making + # TODO: could have a date range here, so say only check last month's worth of new requests. If somebody is making # repeated requests, say once a quarter for time information, then might need to do that. - # XXX this *should* also check outgoing message joined to is an initial + # TODO: this *should* also check outgoing message joined to is an initial # request (rather than follow up) def InfoRequest.find_existing(title, public_body_id, body) return InfoRequest.find(:first, :conditions => [ "title = ? and public_body_id = ? and outgoing_messages.body = ?", title, public_body_id, body ], :include => [ :outgoing_messages ] ) end def find_existing_outgoing_message(body) - # XXX can add other databases here which have regexp_replace + # TODO: can add other databases here which have regexp_replace if ActiveRecord::Base.connection.adapter_name == "PostgreSQL" # Exclude spaces from the body comparison using regexp_replace return self.outgoing_messages.find(:first, :conditions => [ "regexp_replace(outgoing_messages.body, '[[:space:]]', '', 'g') = regexp_replace(?, '[[:space:]]', '', 'g')", body ]) @@ -658,7 +658,7 @@ public event.last_described_at = Time.now() event.save! end - if event.last_described_at.nil? # XXX actually maybe this isn't needed + if event.last_described_at.nil? # TODO: actually maybe this isn't needed event.last_described_at = Time.now() event.save! end @@ -713,7 +713,7 @@ public elsif event.event_type == 'resent' last_sent = event elsif expecting_clarification and event.event_type == 'followup_sent' - # XXX this needs to cope with followup_resent, which it doesn't. + # TODO: this needs to cope with followup_resent, which it doesn't. # Not really easy to do, and only affects cases where followups # were resent after a clarification. last_sent = event diff --git a/app/models/info_request_event.rb b/app/models/info_request_event.rb index 5eed5ba83..9dde3ba80 100644 --- a/app/models/info_request_event.rb +++ b/app/models/info_request_event.rb @@ -75,7 +75,7 @@ class InfoRequestEvent < ActiveRecord::Base :values => [ [ :created_at, 0, "range_search", :date ], # for QueryParser range searches e.g. 01/01/2008..14/01/2008 [ :created_at_numeric, 1, "created_at", :number ], # for sorting - [ :described_at_numeric, 2, "described_at", :number ], # XXX using :number for lack of :datetime support in Xapian values + [ :described_at_numeric, 2, "described_at", :number ], # TODO: using :number for lack of :datetime support in Xapian values [ :request, 3, "request_collapse", :string ], [ :request_title_collapse, 4, "request_title_collapse", :string ], ], @@ -174,7 +174,7 @@ class InfoRequestEvent < ActiveRecord::Base end def get_clipped_response_efficiently - # XXX this ugly code is an attempt to not always load all the + # TODO: this ugly code is an attempt to not always load all the # columns for an incoming message, which can be *very* large # (due to all the cached text). We care particularly in this # case because it's called for every search result on a page @@ -266,7 +266,7 @@ class InfoRequestEvent < ActiveRecord::Base # We store YAML version of parameters in the database def params=(params) - # XXX should really set these explicitly, and stop storing them in + # TODO: should really set these explicitly, and stop storing them in # here, but keep it for compatibility with old way for now if not params[:incoming_message_id].nil? self.incoming_message_id = params[:incoming_message_id] @@ -392,7 +392,7 @@ class InfoRequestEvent < ActiveRecord::Base :outgoing_message_id => self.outgoing_message_id, :comment_id => self.comment_id, - # XXX would be nice to add links here, but alas the + # TODO: would be nice to add links here, but alas the # code to make them is in views only. See views/request/details.html.erb # perhaps can call with @template somehow } diff --git a/app/models/mail_server_log.rb b/app/models/mail_server_log.rb index 0e5b60ff1..07d2fdac0 100644 --- a/app/models/mail_server_log.rb +++ b/app/models/mail_server_log.rb @@ -166,7 +166,7 @@ class MailServerLog < ActiveRecord::Base # lines. Writes any errors to STDERR. This check is really mainly to # check the envelope from is the request address, as Ruby is quite # flaky with regard to that, and it is important for anti-spam reasons. - # XXX does this really check that, as the log just wouldn't pick + # TODO: does this really check that, as the log just wouldn't pick # up at all if the requests weren't sent that way as there would be # no request- email in it? # diff --git a/app/models/outgoing_message.rb b/app/models/outgoing_message.rb index a435511d3..160f69d0b 100644 --- a/app/models/outgoing_message.rb +++ b/app/models/outgoing_message.rb @@ -125,7 +125,7 @@ class OutgoingMessage < ActiveRecord::Base get_salutation + "\n\n" + get_default_letter + "\n\n" + get_signoff + "\n\n" end def set_signature_name(name) - # XXX We use raw_body here to get unstripped one + # TODO: We use raw_body here to get unstripped one if self.raw_body == self.get_default_message self.body = self.raw_body + name end diff --git a/app/models/post_redirect.rb b/app/models/post_redirect.rb index 5da3d2742..6f288b471 100644 --- a/app/models/post_redirect.rb +++ b/app/models/post_redirect.rb @@ -65,7 +65,7 @@ class PostRedirect < ActiveRecord::Base # Used by (rspec) test code only def self.get_last_post_redirect - # XXX yeuch - no other easy way of getting the token so we can check + # TODO: yeuch - no other easy way of getting the token so we can check # the redirect URL, as it is by definition opaque to the controller # apart from in the place that it redirects to. post_redirects = PostRedirect.find_by_sql("select * from post_redirects order by id desc limit 1") diff --git a/app/models/profile_photo.rb b/app/models/profile_photo.rb index 6c3b2cfa0..3c0be222c 100644 --- a/app/models/profile_photo.rb +++ b/app/models/profile_photo.rb @@ -115,7 +115,7 @@ class ProfilePhoto < ActiveRecord::Base return end - self.image = image_list[0] # XXX perhaps take largest image or somesuch if there were multiple in the file? + self.image = image_list[0] # TODO: perhaps take largest image or somesuch if there were multiple in the file? self.convert_image end end diff --git a/app/models/public_body.rb b/app/models/public_body.rb index 03ec270ee..fd7780981 100644 --- a/app/models/public_body.rb +++ b/app/models/public_body.rb @@ -93,7 +93,7 @@ class PublicBody < ActiveRecord::Base self.translations.find_by_locale(locale) end - # XXX - Don't like repeating this! + # TODO: - Don't like repeating this! def calculate_cached_fields(t) PublicBody.set_first_letter(t) short_long_name = t.name @@ -329,7 +329,7 @@ class PublicBody < ActiveRecord::Base first = false end if html - # XXX this should call proper route helpers, but is in model sigh + # TODO: this should call proper route helpers, but is in model sigh desc = '<a href="/body/list/' + tag.name + '">' + desc + '</a>' end types.push(desc) diff --git a/app/models/track_thing.rb b/app/models/track_thing.rb index 13b6f78dd..10ba28f4a 100644 --- a/app/models/track_thing.rb +++ b/app/models/track_thing.rb @@ -149,7 +149,7 @@ class TrackThing < ActiveRecord::Base end end track_thing.track_query = query - # XXX should extract requested_by:, request:, requested_from: + # TODO: should extract requested_by:, request:, requested_from: # and stick their values into the respective relations. # Should also update "params" to make the list_description # nicer and more generic. It will need to do some clever @@ -271,7 +271,7 @@ class TrackThing < ActiveRecord::Base :web => _("To follow requests and responses matching your search"), :email => _("Then you will be notified whenever a new request or response matches your search."), :email_subject => _("Confirm you want to follow new requests or responses matching your search"), - # RSS sorting - XXX hmmm, we don't really know which to use + # RSS sorting - TODO: hmmm, we don't really know which to use # here for sorting. Might be a query term (e.g. 'cctv'), in # which case newest is good, or might be something like # all refused requests in which case want to sort by diff --git a/app/models/user.rb b/app/models/user.rb index d75622b37..4b83d8572 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -99,7 +99,7 @@ class User < ActiveRecord::Base end # Don't display any leading/trailing spaces - # XXX we have strip_attributes! now, so perhaps this can be removed (might + # TODO: we have strip_attributes! now, so perhaps this can be removed (might # be still needed for existing cases) def name name = read_attribute(:name) @@ -222,7 +222,7 @@ class User < ActiveRecord::Base # Can the user make new requests, without having to describe state of (most) existing ones? def can_leave_requests_undescribed? - # XXX should be flag in database really + # TODO: should be flag in database really if self.url_name == "heather_brooke" || self.url_name == "heather_brooke_2" return true end @@ -425,7 +425,7 @@ class User < ActiveRecord::Base ## Class methods def User.encrypted_password(password, salt) - string_to_hash = password + salt # XXX need to add a secret here too? + string_to_hash = password + salt # TODO: need to add a secret here too? Digest::SHA1.hexdigest(string_to_hash) end diff --git a/app/views/track_mailer/event_digest.text.erb b/app/views/track_mailer/event_digest.text.erb index b83c184f0..a154f430f 100644 --- a/app/views/track_mailer/event_digest.text.erb +++ b/app/views/track_mailer/event_digest.text.erb @@ -17,14 +17,14 @@ # e.g. Julian Burgess sent a request to Royal Mail Group (15 May 2008) if event.event_type == 'response' - url = incoming_message_url(event.incoming_message) + url = incoming_message_url(event.incoming_message, :cachebust => true) main_text += _("{{public_body}} sent a response to {{user_name}}", :public_body => event.info_request.public_body.name, :user_name => event.info_request.user_name) elsif event.event_type == 'followup_sent' - url = outgoing_message_url(event.outgoing_message) + url = outgoing_message_url(event.outgoing_message, :cachebust => true) main_text += _("{{user_name}} sent a follow up message to {{public_body}}", :user_name => event.info_request.user_name, :public_body => event.info_request.public_body.name) elsif event.event_type == 'sent' # this is unlikely to happen in real life, but happens in the test code - url = outgoing_message_url(event.outgoing_message) + url = outgoing_message_url(event.outgoing_message, :cachebust => true) main_text += _("{{user_name}} sent a request to {{public_body}}", :user_name => event.info_request.user_name, :public_body => event.info_request.public_body.name) elsif event.event_type == 'comment' url = comment_url(event.comment) diff --git a/app/views/user/_user_listing_single.html.erb b/app/views/user/_user_listing_single.html.erb index ed1b95718..3cb0d283f 100644 --- a/app/views/user/_user_listing_single.html.erb +++ b/app/views/user/_user_listing_single.html.erb @@ -18,7 +18,7 @@ end %> <span class="bottomline"> <%= pluralize(display_user.info_requests.size, "request") %> <%= _('made.')%> <%= pluralize(display_user.visible_comments.size, "annotation") %> <%= _('made.')%> - <%= _('Joined in')%> <%= year_from_date(display_user.created_at) %>. + <%= _('Joined in')%> <%= display_user.created_at.year %>. </span> </div> diff --git a/app/views/user/show.html.erb b/app/views/user/show.html.erb index ce328b46f..7ae577565 100644 --- a/app/views/user/show.html.erb +++ b/app/views/user/show.html.erb @@ -64,7 +64,7 @@ <h1> <%= h(@display_user.name) + (@is_you ? _(" (you)") : "") %></h1> <p class="subtitle"> - <%= _('Joined {{site_name}} in', :site_name=>site_name) %> <%= year_from_date(@display_user.created_at) %> + <%= _('Joined {{site_name}} in', :site_name=>site_name) %> <%= @display_user.created_at.year %> <% if !@user.nil? && @user.admin_page_links? %> (<%= link_to "admin", admin_user_show_path(@display_user) %>) <% end %> diff --git a/config/httpd.conf-example b/config/httpd.conf-example index dc2e4966e..8d549d363 100644 --- a/config/httpd.conf-example +++ b/config/httpd.conf-example @@ -16,7 +16,7 @@ RewriteEngine On #RewriteLog /var/log/apache2/rewrite.log #RewriteLogLevel 9 -# XXX do we need this now we use Passenger? +# TODO: do we need this now we use Passenger? # Pass through the HTTP basic authentication to mongrel. See also # admin_http_auth_user in app/controllers/application.rb # Note: Apache 2 only. Doesn't work in Apache 1.3, you'll need to live without diff --git a/config/routes.rb b/config/routes.rb index d9d21f0bd..7cc85c974 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -16,7 +16,7 @@ Alaveteli::Application.routes.draw do match '/blog' => 'general#blog', :as => :blog match '/search' => 'general#search_redirect', :as => :search_redirect match '/search/all' => 'general#search_redirect', :as => :search_redirect - # XXX combined is the search query, and then if sorted a "/newest" at the end. + # `combined` is the search query, and then if sorted a "/newest" at the end. # Couldn't find a way to do this in routes which also picked up multiple other slashes # and dots and other characters that can appear in search query. So we sort it all # out in the controller. @@ -130,7 +130,7 @@ Alaveteli::Application.routes.draw do match '/:feed/list/:view' => 'track#track_list', :as => :track_list, :view => nil, :feed => /(track|feed)/ match '/:feed/body/:url_name' => 'track#track_public_body', :as => :track_public_body, :feed => /(track|feed)/ match '/:feed/user/:url_name' => 'track#track_user', :as => :track_user, :feed => /(track|feed)/ - # XXX :format doesn't work. See hacky code in the controller that makes up for this. + # TODO: :format doesn't work. See hacky code in the controller that makes up for this. match '/:feed/search/:query_array' => 'track#track_search_query', :as => :track_search, :feed => /(track|feed)/, diff --git a/config/varnish-alaveteli.vcl b/config/varnish-alaveteli.vcl index 5dd0ac83c..d3726682c 100644 --- a/config/varnish-alaveteli.vcl +++ b/config/varnish-alaveteli.vcl @@ -92,7 +92,7 @@ sub vcl_recv { # ban lists, see # http://kristianlyng.wordpress.com/2010/07/28/smart-bans-with-varnish/ - # XXX in Varnish 2.x, the following would be + # TODO: in Varnish 2.x, the following would be # purge("obj.http.x-url ~ " req.url); ban("obj.http.x-url ~ " + req.url); error 200 "Banned"; diff --git a/db/migrate/028_give_incoming_messages_events.rb b/db/migrate/028_give_incoming_messages_events.rb index 831068562..46acd831e 100644 --- a/db/migrate/028_give_incoming_messages_events.rb +++ b/db/migrate/028_give_incoming_messages_events.rb @@ -1,4 +1,4 @@ -# XXX If this one fails with errors about described_state on save, then you need +# TODO: If this one fails with errors about described_state on save, then you need # to temporarily modify the model for InfoRequestEvents to remove this part: # validates_inclusion_of :described_state, :in => [ # Or do some nice hack in here to make it happen permanently :) diff --git a/db/migrate/036_add_public_body_tags.rb b/db/migrate/036_add_public_body_tags.rb index 99a507f13..f7fefdf48 100644 --- a/db/migrate/036_add_public_body_tags.rb +++ b/db/migrate/036_add_public_body_tags.rb @@ -11,7 +11,7 @@ class AddPublicBodyTags < ActiveRecord::Migration end # MySQL cannot index text blobs like this - # XXX perhaps should change :name to be a :string + # TODO: perhaps should change :name to be a :string if ActiveRecord::Base.connection.adapter_name != "MySQL" add_index :public_body_tags, [:public_body_id, :name], :unique => true end diff --git a/db/migrate/061_include_responses_in_tracks.rb b/db/migrate/061_include_responses_in_tracks.rb index f357e57c2..c7a3b26cf 100644 --- a/db/migrate/061_include_responses_in_tracks.rb +++ b/db/migrate/061_include_responses_in_tracks.rb @@ -4,6 +4,6 @@ class IncludeResponsesInTracks < ActiveRecord::Migration end def self.down - # XXX forget it + # TODO: forget it end end diff --git a/db/migrate/065_add_comments_to_user_track.rb b/db/migrate/065_add_comments_to_user_track.rb index 9c4ff2936..50d1f9d5d 100644 --- a/db/migrate/065_add_comments_to_user_track.rb +++ b/db/migrate/065_add_comments_to_user_track.rb @@ -9,6 +9,6 @@ class AddCommentsToUserTrack < ActiveRecord::Migration end def self.down - # XXX forget it + # TODO: forget it end end diff --git a/db/migrate/088_public_body_machine_tags.rb b/db/migrate/088_public_body_machine_tags.rb index 0089607c6..6a0815568 100644 --- a/db/migrate/088_public_body_machine_tags.rb +++ b/db/migrate/088_public_body_machine_tags.rb @@ -3,7 +3,7 @@ class PublicBodyMachineTags < ActiveRecord::Migration add_column :public_body_tags, :value, :text # MySQL cannot index text blobs like this - # XXX perhaps should change :name/:value to be a :string + # TODO: perhaps should change :name/:value to be a :string if ActiveRecord::Base.connection.adapter_name != "MySQL" add_index :public_body_tags, :name end diff --git a/db/migrate/090_remove_tag_uniqueness.rb b/db/migrate/090_remove_tag_uniqueness.rb index 1c06de439..d1affade3 100644 --- a/db/migrate/090_remove_tag_uniqueness.rb +++ b/db/migrate/090_remove_tag_uniqueness.rb @@ -1,7 +1,7 @@ class RemoveTagUniqueness < ActiveRecord::Migration def self.up # MySQL cannot index text blobs like this - # XXX perhaps should change :name/:value to be a :string + # TODO: perhaps should change :name/:value to be a :string if ActiveRecord::Base.connection.adapter_name != "MySQL" remove_index :public_body_tags, [:public_body_id, :name] # allow the key to repeat, but not the value also diff --git a/lib/acts_as_xapian/acts_as_xapian.rb b/lib/acts_as_xapian/acts_as_xapian.rb index b30bb4d10..168d2eec3 100644 --- a/lib/acts_as_xapian/acts_as_xapian.rb +++ b/lib/acts_as_xapian/acts_as_xapian.rb @@ -24,7 +24,7 @@ end module ActsAsXapian ###################################################################### # Module level variables - # XXX must be some kind of cattr_accessor that can do this better + # TODO: must be some kind of cattr_accessor that can do this better def ActsAsXapian.bindings_available $acts_as_xapian_bindings_available end @@ -109,12 +109,12 @@ module ActsAsXapian @@db_path = File.join(db_parent_path, environment) # make some things that don't depend on the db - # XXX this gets made once for each acts_as_xapian. Oh well. + # TODO: this gets made once for each acts_as_xapian. Oh well. @@stemmer = Xapian::Stem.new('english') end # Opens / reopens the db for reading - # XXX we perhaps don't need to rebuild database and enquire and queryparser - + # TODO: we perhaps don't need to rebuild database and enquire and queryparser - # but db.reopen wasn't enough by itself, so just do everything it's easier. def ActsAsXapian.readable_init raise NoXapianRubyBindingsError.new("Xapian Ruby bindings not installed") unless ActsAsXapian.bindings_available @@ -188,7 +188,7 @@ module ActsAsXapian raise "Z is reserved for stemming terms" if term[1] == "Z" raise "Already have code '" + term[1] + "' in another model but with different prefix '" + @@terms_by_capital[term[1]] + "'" if @@terms_by_capital.include?(term[1]) && @@terms_by_capital[term[1]] != term[2] @@terms_by_capital[term[1]] = term[2] - # XXX use boolean here so doesn't stem our URL names in WhatDoTheyKnow + # TODO: use boolean here so doesn't stem our URL names in WhatDoTheyKnow # If making acts_as_xapian generic, would really need to make the :terms have # another option that lets people choose non-boolean for terms that need it # (i.e. searching explicitly within a free text field) @@ -231,7 +231,7 @@ module ActsAsXapian raise "acts_as_xapian hasn't been called in any models" if @@init_values.empty? # if DB is not nil, then we're already initialised, so don't do it - # again XXX reopen it each time, xapian_spec.rb needs this so database + # again TODO: reopen it each time, xapian_spec.rb needs this so database # gets written twice correctly. # return unless @@writable_db.nil? @@ -510,7 +510,7 @@ module ActsAsXapian # Find the documents by their unique term input_models_query = Xapian::Query.new(Xapian::Query::OP_OR, query_models.map{|m| "I" + m.xapian_document_term}) ActsAsXapian.enquire.query = input_models_query - matches = ActsAsXapian.enquire.mset(0, 100, 100) # XXX so this whole method will only work with 100 docs + matches = ActsAsXapian.enquire.mset(0, 100, 100) # TODO: so this whole method will only work with 100 docs # Get set of relevant terms for those documents selection = Xapian::RSet.new() @@ -601,7 +601,7 @@ module ActsAsXapian begin if job.action == 'update' - # XXX Index functions may reference other models, so we could eager load here too? + # TODO: Index functions may reference other models, so we could eager load here too? model = job.model.constantize.find(job.model_id) # :include => cls.constantize.xapian_options[:include] model.xapian_index elsif job.action == 'destroy' @@ -717,7 +717,7 @@ module ActsAsXapian ActiveRecord::Base.connection.disconnect! - pid = Process.fork # XXX this will only work on Unix, tough + pid = Process.fork # TODO: this will only work on Unix, tough if pid Process.waitpid(pid) if not $?.success? @@ -898,7 +898,7 @@ module ActsAsXapian ActsAsXapian.term_generator.document = doc for text in texts_to_index ActsAsXapian.term_generator.increase_termpos # stop phrases spanning different text fields - # XXX the "1" here is a weight that could be varied for a boost function + # TODO: the "1" here is a weight that could be varied for a boost function ActsAsXapian.term_generator.index_text(xapian_value(text, nil, true), 1) end end diff --git a/lib/alaveteli_file_types.rb b/lib/alaveteli_file_types.rb index e89bc0c78..617048c05 100644 --- a/lib/alaveteli_file_types.rb +++ b/lib/alaveteli_file_types.rb @@ -16,15 +16,15 @@ class AlaveteliFileTypes "tnef" => 'application/ms-tnef', "tif" => 'image/tiff', "gif" => 'image/gif', - "jpg" => 'image/jpeg', # XXX add jpeg + "jpg" => 'image/jpeg', # TODO: add jpeg "png" => 'image/png', "bmp" => 'image/bmp', - "html" => 'text/html', # XXX add htm + "html" => 'text/html', # TODO: add htm "vcf" => 'text/x-vcard', "zip" => 'application/zip', "delivery-status" => 'message/delivery-status' } - # XXX doesn't have way of choosing default for inverse map - might want to add + # TODO: doesn't have way of choosing default for inverse map - might want to add # one when you need it FileExtensionToMimeTypeRev = FileExtensionToMimeType.invert @@ -46,7 +46,7 @@ class AlaveteliFileTypes m = Mahoro.new(Mahoro::MIME) mahoro_type = m.buffer(content) mahoro_type.strip! - # XXX we shouldn't have to check empty? here, but Mahoro sometimes returns a blank line :( + # TODO: we shouldn't have to check empty? here, but Mahoro sometimes returns a blank line :( # e.g. for InfoRequestEvent 17930 if mahoro_type.nil? || mahoro_type.empty? return nil diff --git a/lib/has_tag_string/has_tag_string.rb b/lib/has_tag_string/has_tag_string.rb index 4022faaac..c28720f04 100644 --- a/lib/has_tag_string/has_tag_string.rb +++ b/lib/has_tag_string/has_tag_string.rb @@ -10,7 +10,7 @@ module HasTagString # Represents one tag of one model. # The migration to make this is currently only in WDTK code. class HasTagStringTag < ActiveRecord::Base - # XXX strip_attributes! + # TODO: strip_attributes! validates_presence_of :name @@ -46,7 +46,7 @@ module HasTagString # Methods which are added to the model instances being tagged module InstanceMethods # Given an input string of tags, sets all tags to that string. - # XXX This immediately saves the new tags. + # TODO: This immediately saves the new tags. def tag_string=(tag_string) if tag_string.nil? tag_string = "" diff --git a/lib/mail_handler/backends/mail_backend.rb b/lib/mail_handler/backends/mail_backend.rb index e019eba97..190e79e97 100644 --- a/lib/mail_handler/backends/mail_backend.rb +++ b/lib/mail_handler/backends/mail_backend.rb @@ -323,7 +323,7 @@ module MailHandler end end end - # XXX call _convert_part_body_to_text here, but need to get charset somehow + # TODO: call _convert_part_body_to_text here, but need to get charset somehow # e.g. http://www.whatdotheyknow.com/request/1593/response/3088/attach/4/Freedom%20of%20Information%20request%20-%20car%20oval%20sticker:%20Article%2020,%20Convention%20on%20Road%20Traffic%201949.txt body = headers + "\n" + body end diff --git a/lib/mail_handler/mail_handler.rb b/lib/mail_handler/mail_handler.rb index 53033d440..47015f207 100644 --- a/lib/mail_handler/mail_handler.rb +++ b/lib/mail_handler/mail_handler.rb @@ -70,7 +70,7 @@ module MailHandler # note re. charset: TMail always tries to convert email bodies # to UTF8 by default, so normally it should already be that. text = '' - # XXX - tell all these command line tools to return utf-8 + # TODO: - tell all these command line tools to return utf-8 if content_type == 'text/plain' text += body + "\n\n" else @@ -151,7 +151,7 @@ module MailHandler body = entry.get_input_stream.read rescue # move to next attachment silently if there were problems - # XXX really should reduce this to specific exceptions? + # TODO: really should reduce this to specific exceptions? # e.g. password protected next end diff --git a/lib/strip_attributes/strip_attributes.rb b/lib/strip_attributes/strip_attributes.rb index 130d10185..12350277d 100644 --- a/lib/strip_attributes/strip_attributes.rb +++ b/lib/strip_attributes/strip_attributes.rb @@ -1,6 +1,6 @@ module StripAttributes # Strips whitespace from model fields and leaves nil values as nil. - # XXX this differs from official StripAttributes, as it doesn't make blank cells null. + # TODO: this differs from official StripAttributes, as it doesn't make blank cells null. def strip_attributes!(options = nil) before_validation do |record| attribute_names = StripAttributes.narrow(record.attribute_names, options) diff --git a/script/request-creation-graph b/script/request-creation-graph index ef1d2cf73..7d347a7d2 100755 --- a/script/request-creation-graph +++ b/script/request-creation-graph @@ -17,7 +17,7 @@ cd `dirname $0` cd ../ source commonlib/shlib/deployfns -# XXX this is nasty :) +# TODO: this is nasty :) OPTION_FOI_DB_HOST=`grep "host:" config/database.yml | head --lines=1 | cut -d ":" -f 2` OPTION_FOI_DB_PORT=`grep "port:" config/database.yml | head --lines=1 | cut -d ":" -f 2` OPTION_FOI_DB_NAME=`grep "database:" config/database.yml | head --lines=1 | cut -d ":" -f 2` diff --git a/script/user-use-graph b/script/user-use-graph index f508c9cb6..00eeb36f8 100755 --- a/script/user-use-graph +++ b/script/user-use-graph @@ -16,7 +16,7 @@ cd `dirname $0` cd ../ source commonlib/shlib/deployfns -# XXX this is nasty :) +# TODO: this is nasty :) OPTION_FOI_DB_HOST=`grep "host:" config/database.yml | head --lines=1 | cut -d ":" -f 2` OPTION_FOI_DB_PORT=`grep "port:" config/database.yml | head --lines=1 | cut -d ":" -f 2` OPTION_FOI_DB_NAME=`grep "database:" config/database.yml | head --lines=1 | cut -d ":" -f 2` diff --git a/spec/controllers/comment_controller_spec.rb b/spec/controllers/comment_controller_spec.rb index 5e250f689..480c85ad7 100644 --- a/spec/controllers/comment_controller_spec.rb +++ b/spec/controllers/comment_controller_spec.rb @@ -26,7 +26,7 @@ describe CommentController, "when commenting on a request" do post :new, params post_redirect = PostRedirect.get_last_post_redirect response.should redirect_to(:controller => 'user', :action => 'signin', :token => post_redirect.token) - # post_redirect.post_params.should == params # XXX get this working. there's a : vs '' problem amongst others + # post_redirect.post_params.should == params # TODO: get this working. there's a : vs '' problem amongst others end it "should create the comment, and redirect to request page when input is good and somebody is logged in" do diff --git a/spec/controllers/request_controller_spec.rb b/spec/controllers/request_controller_spec.rb index 070511fb0..48f37a45c 100644 --- a/spec/controllers/request_controller_spec.rb +++ b/spec/controllers/request_controller_spec.rb @@ -77,7 +77,7 @@ describe RequestController, "when changing things that appear on the request pag PurgeRequest.all().count.should == 0 end it "should purge the downstream cache when censor rules have changed" do - # XXX really, CensorRules should execute expiry logic as part + # TODO: really, CensorRules should execute expiry logic as part # of the after_save of the model. Currently this is part of # the AdminCensorRuleController logic, so must be tested from # there. Leaving this stub test in place as a reminder @@ -643,7 +643,7 @@ describe RequestController, "when showing one request" do ir = info_requests(:fancy_dog_request) receive_incoming_mail('incoming-request-two-same-name.email', ir.incoming_email) - # XXX this is horrid, but don't know a better way. If we + # TODO: this is horrid, but don't know a better way. If we # don't do this, the info_request_event to which the # info_request is attached still uses the unmodified # version from the fixture. @@ -900,7 +900,7 @@ describe RequestController, "when handling prominence" do end -# XXX do this for invalid ids +# TODO: do this for invalid ids # it "should render 404 file" do # response.should render_template("#{Rails.root}/public/404.html") # response.headers["Status"].should == "404 Not Found" @@ -1004,7 +1004,7 @@ describe RequestController, "when creating a new request" do post :new, params post_redirect = PostRedirect.get_last_post_redirect response.should redirect_to(:controller => 'user', :action => 'signin', :token => post_redirect.token) - # post_redirect.post_params.should == params # XXX get this working. there's a : vs '' problem amongst others + # post_redirect.post_params.should == params # TODO: get this working. there's a : vs '' problem amongst others end it 'redirects to the frontpage if the action is sent the invalid @@ -1804,7 +1804,7 @@ describe RequestController, "when sending a followup message" do session[:user_id] = users(:bob_smith_user).id post :show_response, :outgoing_message => { :body => "", :what_doing => 'normal_sort'}, :id => info_requests(:fancy_dog_request).id, :incoming_message_id => incoming_messages(:useless_incoming_message), :submitted_followup => 1 - # XXX how do I check the error message here? + # TODO: how do I check the error message here? response.should render_template('show_response') end @@ -1854,13 +1854,13 @@ describe RequestController, "when sending a followup message" do # second time should give an error post :show_response, :outgoing_message => { :body => "Stop repeating yourself!", :what_doing => 'normal_sort' }, :id => info_requests(:fancy_dog_request).id, :incoming_message_id => incoming_messages(:useless_incoming_message), :submitted_followup => 1 - # XXX how do I check the error message here? + # TODO: how do I check the error message here? response.should render_template('show_response') end end -# XXX Stuff after here should probably be in request_mailer_spec.rb - but then +# TODO: Stuff after here should probably be in request_mailer_spec.rb - but then # it can't check the URLs in the emails I don't think, ugh. describe RequestController, "sending overdue request alerts" do @@ -1889,7 +1889,7 @@ describe RequestController, "sending overdue request alerts" do mail_token = $2 session[:user_id].should be_nil - controller.test_code_redirect_by_email_token(mail_token, self) # XXX hack to avoid having to call User controller for email link + controller.test_code_redirect_by_email_token(mail_token, self) # TODO: hack to avoid having to call User controller for email link session[:user_id].should == info_requests(:naughty_chicken_request).user.id response.should render_template('show_response') @@ -1946,7 +1946,7 @@ describe RequestController, "sending overdue request alerts" do mail_token = $2 session[:user_id].should be_nil - controller.test_code_redirect_by_email_token(mail_token, self) # XXX hack to avoid having to call User controller for email link + controller.test_code_redirect_by_email_token(mail_token, self) # TODO: hack to avoid having to call User controller for email link session[:user_id].should == info_requests(:naughty_chicken_request).user.id response.should render_template('show_response') @@ -2028,12 +2028,12 @@ describe RequestController, "sending unclassified new response reminder alerts" mail_token = $2 session[:user_id].should be_nil - controller.test_code_redirect_by_email_token(mail_token, self) # XXX hack to avoid having to call User controller for email link + controller.test_code_redirect_by_email_token(mail_token, self) # TODO: hack to avoid having to call User controller for email link session[:user_id].should == info_requests(:fancy_dog_request).user.id response.should render_template('show') assigns[:info_request].should == info_requests(:fancy_dog_request) - # XXX should check anchor tag here :) that it goes to last new response + # TODO: should check anchor tag here :) that it goes to last new response end end @@ -2064,7 +2064,7 @@ describe RequestController, "clarification required alerts" do mail_token = $2 session[:user_id].should be_nil - controller.test_code_redirect_by_email_token(mail_token, self) # XXX hack to avoid having to call User controller for email link + controller.test_code_redirect_by_email_token(mail_token, self) # TODO: hack to avoid having to call User controller for email link session[:user_id].should == info_requests(:fancy_dog_request).user.id response.should render_template('show_response') diff --git a/spec/controllers/track_controller_spec.rb b/spec/controllers/track_controller_spec.rb index d2b45b6bf..29f5c7fe1 100644 --- a/spec/controllers/track_controller_spec.rb +++ b/spec/controllers/track_controller_spec.rb @@ -122,11 +122,11 @@ describe TrackController, "when sending alerts for a track" do mail.body.should =~ /This a the daftest comment the world has ever seen/ # comment text included # Check subscription managing link -# XXX We can't do this, as it is redirecting to another controller. I'm +# TODO: We can't do this, as it is redirecting to another controller. I'm # apparently meant to be writing controller unit tests here, not functional # tests. Bah, I so don't care, bit of an obsessive constraint. # session[:user_id].should be_nil -# controller.test_code_redirect_by_email_token(mail_token, self) # XXX hack to avoid having to call User controller for email link +# controller.test_code_redirect_by_email_token(mail_token, self) # TODO: hack to avoid having to call User controller for email link # session[:user_id].should == users(:silly_name_user).id # # response.should render_template('users/show') @@ -173,7 +173,7 @@ describe TrackController, "when viewing RSS feed for a track" do get :track_request, :feed => 'feed', :url_title => track_thing.info_request.url_title response.should render_template('track/atom_feed') response.content_type.should == 'application/atom+xml' - # XXX should check it is an atom.builder type being rendered, not sure how to + # TODO: should check it is an atom.builder type being rendered, not sure how to assigns[:xapian_object].matches_estimated.should == 3 assigns[:xapian_object].results.size.should == 3 diff --git a/spec/controllers/user_controller_spec.rb b/spec/controllers/user_controller_spec.rb index cf361d898..6ecdf1ad4 100644 --- a/spec/controllers/user_controller_spec.rb +++ b/spec/controllers/user_controller_spec.rb @@ -1,7 +1,7 @@ # coding: utf-8 require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') -# XXX Use route_for or params_from to check /c/ links better +# TODO: Use route_for or params_from to check /c/ links better # http://rspec.rubyforge.org/rspec-rails/1.1.12/classes/Spec/Rails/Example/ControllerExampleGroup.html describe UserController, "when redirecting a show request to a canonical url" do @@ -327,7 +327,7 @@ describe UserController, "when signing up" do deliveries[0].body.should match(/when\s+you\s+already\s+have\s+an/) end - # XXX need to do bob@localhost signup and check that sends different email + # TODO: need to do bob@localhost signup and check that sends different email end describe UserController, "when signing out" do @@ -380,7 +380,7 @@ describe UserController, "when sending another user a message" do mail = deliveries[0] mail.body.should include("Bob Smith has used #{AlaveteliConfiguration::site_name} to send you the message below") mail.body.should include("Just a test!") - #mail.to_addrs.first.to_s.should == users(:silly_name_user).name_and_email # XXX fix some nastiness with quoting name_and_email + #mail.to_addrs.first.to_s.should == users(:silly_name_user).name_and_email # TODO: fix some nastiness with quoting name_and_email mail.from_addrs.first.to_s.should == users(:bob_smith_user).email end @@ -651,7 +651,7 @@ describe UserController, "when using profile photos" do @user.profile_photo.should_not be_nil end - # XXX todo check the two stage javascript cropping (above only tests one stage non-javascript one) + # TODO: todo check the two stage javascript cropping (above only tests one stage non-javascript one) end describe UserController, "when showing JSON version for API" do diff --git a/spec/helpers/date_time_helper_spec.rb b/spec/helpers/date_time_helper_spec.rb new file mode 100644 index 000000000..c4fdee1d1 --- /dev/null +++ b/spec/helpers/date_time_helper_spec.rb @@ -0,0 +1,71 @@ +require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') + +describe DateTimeHelper do + + include DateTimeHelper + + describe :simple_date do + + it 'formats a date in html by default' do + time = Time.utc(2012, 11, 07, 21, 30, 26) + self.should_receive(:simple_date_html).with(time) + simple_date(time) + end + + it 'formats a date in the specified format' do + time = Time.utc(2012, 11, 07, 21, 30, 26) + self.should_receive(:simple_date_text).with(time) + simple_date(time, :format => :text) + end + + it 'raises an argument error if given an unrecognized format' do + time = Time.utc(2012, 11, 07, 21, 30, 26) + expect { simple_date(time, :format => :unknown) }.to raise_error(ArgumentError) + end + + end + + describe :simple_date_html do + + it 'formats a date in a time tag' do + Time.use_zone('London') do + time = Time.utc(2012, 11, 07, 21, 30, 26) + expected = %Q(<time datetime="2012-11-07T21:30:26+00:00" title="2012-11-07 21:30:26 +0000">November 07, 2012</time>) + simple_date_html(time).should == expected + end + end + + end + + describe :simple_date_text do + + it 'should respect time zones' do + Time.use_zone('Australia/Sydney') do + simple_date_text(Time.utc(2012, 11, 07, 21, 30, 26)).should == 'November 08, 2012' + end + end + + it 'should handle Date objects' do + simple_date_text(Date.new(2012, 11, 21)).should == 'November 21, 2012' + end + + end + + describe :simple_time do + + it 'returns 00:00:00 for a date' do + simple_time(Date.new(2012, 11, 21)).should == '00:00:00' + end + + it 'returns the time component of a datetime' do + date = DateTime.new(2012, 11, 21, 10, 34, 56) + simple_time(date).should == '10:34:56' + end + + it 'returns the time component of a time' do + time = Time.utc(2000, 'jan', 1, 20, 15, 1) + simple_time(time).should == '20:15:01' + end + + end +end diff --git a/spec/helpers/link_to_helper_spec.rb b/spec/helpers/link_to_helper_spec.rb index 4a01ec683..261e1ef3e 100644 --- a/spec/helpers/link_to_helper_spec.rb +++ b/spec/helpers/link_to_helper_spec.rb @@ -20,6 +20,82 @@ describe LinkToHelper do end + describe 'when linking to new incoming messages' do + + before do + @info_request = mock_model(InfoRequest, :id => 123, :url_title => 'test_title') + @incoming_message = mock_model(IncomingMessage, :id => 32, :info_request => @info_request) + end + + context 'for external links' do + + it 'generates the url to the info request of the message' do + incoming_message_url(@incoming_message).should include('http://test.host/request/test_title') + end + + it 'includes an anchor to the new message' do + incoming_message_url(@incoming_message).should include('#incoming-32') + end + + it 'does not cache by default' do + incoming_message_url(@incoming_message).should_not include('nocache=incoming-32') + end + + it 'includes a cache busting parameter if set' do + incoming_message_url(@incoming_message, :cachebust => true).should include('nocache=incoming-32') + end + + end + + context 'for internal links' do + + it 'generates the incoming_message_url with the path only' do + expected = '/request/test_title#incoming-32' + incoming_message_path(@incoming_message).should == expected + end + + end + + end + + describe 'when linking to new outgoing messages' do + + before do + @info_request = mock_model(InfoRequest, :id => 123, :url_title => 'test_title') + @outgoing_message = mock_model(OutgoingMessage, :id => 32, :info_request => @info_request) + end + + context 'for external links' do + + it 'generates the url to the info request of the message' do + outgoing_message_url(@outgoing_message).should include('http://test.host/request/test_title') + end + + it 'includes an anchor to the new message' do + outgoing_message_url(@outgoing_message).should include('#outgoing-32') + end + + it 'does not cache by default' do + outgoing_message_url(@outgoing_message).should_not include('nocache=outgoing-32') + end + + it 'includes a cache busting parameter if set' do + outgoing_message_url(@outgoing_message, :cachebust => true).should include('nocache=outgoing-32') + end + + end + + context 'for internal links' do + + it 'generates the outgoing_message_url with the path only' do + expected = '/request/test_title#outgoing-32' + outgoing_message_path(@outgoing_message).should == expected + end + + end + + end + describe 'when displaying a user link for a request' do context "for external requests" do @@ -69,51 +145,4 @@ describe LinkToHelper do end - describe 'simple_date' do - - it 'formats a date in html by default' do - time = Time.utc(2012, 11, 07, 21, 30, 26) - self.should_receive(:simple_date_html).with(time) - simple_date(time) - end - - it 'formats a date in the specified format' do - time = Time.utc(2012, 11, 07, 21, 30, 26) - self.should_receive(:simple_date_text).with(time) - simple_date(time, :format => :text) - end - - it 'raises an argument error if given an unrecognized format' do - time = Time.utc(2012, 11, 07, 21, 30, 26) - expect { simple_date(time, :format => :unknown) }.to raise_error(ArgumentError) - end - - end - - describe 'simple_date_html' do - - it 'formats a date in a time tag' do - Time.use_zone('London') do - time = Time.utc(2012, 11, 07, 21, 30, 26) - expected = "<time datetime=\"2012-11-07T21:30:26+00:00\" title=\"2012-11-07 21:30:26 +0000\">November 07, 2012</time>" - simple_date_html(time).should == expected - end - end - - end - - describe 'simple_date_text' do - - it 'should respect time zones' do - Time.use_zone('Australia/Sydney') do - simple_date_text(Time.utc(2012, 11, 07, 21, 30, 26)).should == 'November 08, 2012' - end - end - - it 'should handle Date objects' do - simple_date_text(Date.new(2012, 11, 21)).should == 'November 21, 2012' - end - - end - end diff --git a/spec/models/customstates.rb b/spec/models/customstates.rb index bffbe86fb..942e1fcde 100644 --- a/spec/models/customstates.rb +++ b/spec/models/customstates.rb @@ -24,7 +24,7 @@ module InfoRequestCustomStates end def date_deadline_extended - # XXX shouldn't this be 15 days after the date the status was + # TODO: shouldn't this be 15 days after the date the status was # changed to "deadline extended"? Or perhaps 15 days ater the # initial request due date? return Holiday.due_date_from_working_days(self.date_response_required_by, 15) diff --git a/spec/models/public_body_spec.rb b/spec/models/public_body_spec.rb index 38e31783d..0e1db6986 100644 --- a/spec/models/public_body_spec.rb +++ b/spec/models/public_body_spec.rb @@ -493,7 +493,7 @@ describe PublicBody, " when loading CSV files" do PublicBody.count.should == original_count + 3 - # XXX Not sure why trying to do a I18n.with_locale fails here. Seems related to + # TODO: Not sure why trying to do a I18n.with_locale fails here. Seems related to # the way categories are loaded every time from the PublicBody class. For now we just # test some translation was done. body = PublicBody.find_by_name('North West Fake Authority') diff --git a/spec/models/raw_email_spec.rb b/spec/models/raw_email_spec.rb index f86b35e99..aa82b0bc3 100644 --- a/spec/models/raw_email_spec.rb +++ b/spec/models/raw_email_spec.rb @@ -23,7 +23,7 @@ describe User, "manipulating a raw email" do @raw_email.data.should == "Hello, world!" end - # XXX this test fails, hopefully will be fixed in later Rails. + # TODO: this test fails, hopefully will be fixed in later Rails. # Doesn't matter too much for us for storing raw_emails, it would seem, # but keep an eye out. diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index c54043092..7dcd3ab8a 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -284,7 +284,7 @@ describe User, " when making name and email address" do end end -# XXX not finished +# TODO: not finished describe User, "when setting a profile photo" do before do @user = User.new diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index e391c97d3..0e3fe35c7 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -123,7 +123,7 @@ Spork.prefork do end end - # XXX No idea what namespace/class/module to put this in + # TODO: No idea what namespace/class/module to put this in # Create a clean xapian index based on the fixture files and the raw_email data. def create_fixtures_xapian_index load_raw_emails_data |