diff options
60 files changed, 652 insertions, 129 deletions
diff --git a/.travis.yml b/.travis.yml index 70f1e3ecf..497a03159 100644 --- a/.travis.yml +++ b/.travis.yml @@ -12,6 +12,7 @@ before_install: - git submodule update --init --recursive - psql -c "create database foi_test template template0 encoding 'SQL_ASCII';" -U postgres - cp config/database.yml-test config/database.yml + - cp config/memcached.yml-test config/memcached.yml - sudo apt-get update - export DEBIAN_FRONTEND=noninteractive - sudo apt-get -y install exim4-daemon-light diff --git a/app/controllers/general_controller.rb b/app/controllers/general_controller.rb index 9e47af22a..03b988505 100644 --- a/app/controllers/general_controller.rb +++ b/app/controllers/general_controller.rb @@ -32,8 +32,7 @@ class GeneralController < ApplicationController if body_short_names.empty? # This is too slow @popular_bodies = PublicBody.find(:all, - :select => "public_bodies.*, (select count(*) from info_requests where info_requests.public_body_id = public_bodies.id) as c", - :order => "c desc", + :order => "info_requests_count desc", :limit => 32, :conditions => conditions, :joins => :translations @@ -56,10 +55,13 @@ class GeneralController < ApplicationController # If there are not yet enough successful requests, fill out the list with # other requests if @request_events.count < max_count + @request_events_all_successful = false query = 'variety:sent' xapian_object = perform_search([InfoRequestEvent], query, sortby, 'request_title_collapse', max_count-@request_events.count) more_events = xapian_object.results.map { |r| r[:model] } @request_events += more_events + else + @request_events_all_successful = true end rescue @request_events = [] diff --git a/app/models/application_mailer.rb b/app/models/application_mailer.rb index 3a11733a8..add05ffdb 100644 --- a/app/models/application_mailer.rb +++ b/app/models/application_mailer.rb @@ -5,7 +5,7 @@ # Email: francis@mysociety.org; WWW: http://www.mysociety.org/ # # $Id: application_mailer.rb,v 1.8 2009-02-09 10:37:12 francis Exp $ - +require 'action_mailer/version' class ApplicationMailer < ActionMailer::Base # Include all the functions views get, as emails call similar things. helper :application @@ -26,5 +26,126 @@ class ApplicationMailer < ActionMailer::Base # Site-wide access to configuration settings include ConfigHelper + + # Instantiate a new mailer object. If +method_name+ is not +nil+, the mailer + # will be initialized according to the named method. If not, the mailer will + # remain uninitialized (useful when you only need to invoke the "receive" + # method, for instance). + def initialize(method_name=nil, *parameters) #:nodoc: + create!(method_name, *parameters) if method_name + end + + # For each multipart template (e.g. "the_template_file.text.html.erb") available, + # add the one from the view path with the highest priority as a part to the mail + def render_multipart_templates + added_content_types = {} + self.view_paths.each do |view_path| + Dir.glob("#{view_path}/#{mailer_name}/#{@template}.*").each do |path| + template = view_path["#{mailer_name}/#{File.basename(path)}"] + + # Skip unless template has a multipart format + next unless template && template.multipart? + next if added_content_types[template.content_type] == true + @parts << Part.new( + :content_type => template.content_type, + :disposition => "inline", + :charset => charset, + :body => render_message(template, @body) + ) + added_content_types[template.content_type] = true + end + end + end + + # Look for the current template in each element of view_paths in order, + # return the first + def find_template + self.view_paths.each do |view_path| + if template = view_path["#{mailer_name}/#{@template}"] + return template + end + end + return nil + end + + if ActionMailer::VERSION::MAJOR == 2 + + # This method is a customised version of ActionMailer::Base.create! + # modified to allow templates to be selected correctly for multipart + # mails when themes have added to the view_paths. The problem from our + # point of view with ActionMailer::Base is that it sets template_root to + # the first element of the view_paths array and then uses only that (directly + # and via template_path, which is created from it) in the create! method when + # looking for templates. Our modified version looks for templates in the view_paths + # in order. + # Changed lines marked with *** + + # Initialize the mailer via the given +method_name+. The body will be + # rendered and a new TMail::Mail object created. + def create!(method_name, *parameters) #:nodoc: + initialize_defaults(method_name) + __send__(method_name, *parameters) + + # If an explicit, textual body has not been set, we check assumptions. + unless String === @body + # First, we look to see if there are any likely templates that match, + # which include the content-type in their file name (i.e., + # "the_template_file.text.html.erb", etc.). Only do this if parts + # have not already been specified manually. + if @parts.empty? + # *** render_multipart_templates replaces the following code + # Dir.glob("#{template_path}/#{@template}.*").each do |path| + # template = template_root["#{mailer_name}/#{File.basename(path)}"] + # + # # Skip unless template has a multipart format + # next unless template && template.multipart? + # + # @parts << Part.new( + # :content_type => template.content_type, + # :disposition => "inline", + # :charset => charset, + # :body => render_message(template, @body) + # ) + # end + render_multipart_templates + + unless @parts.empty? + @content_type = "multipart/alternative" if @content_type !~ /^multipart/ + @parts = sort_parts(@parts, @implicit_parts_order) + end + end + + # Then, if there were such templates, we check to see if we ought to + # also render a "normal" template (without the content type). If a + # normal template exists (or if there were no implicit parts) we render + # it. + template_exists = @parts.empty? + + # *** find_template replaces template_root call + # template_exists ||= template_root["#{mailer_name}/#{@template}"] + template_exists ||= find_template + + @body = render_message(@template, @body) if template_exists + + # Finally, if there are other message parts and a textual body exists, + # we shift it onto the front of the parts and set the body to nil (so + # that create_mail doesn't try to render it in addition to the parts). + if !@parts.empty? && String === @body + @parts.unshift ActionMailer::Part.new(:charset => charset, :body => @body) + @body = nil + end + end + + # If this is a multipart e-mail add the mime_version if it is not + # already set. + @mime_version ||= "1.0" if !@parts.empty? + + # build the mail object itself + @mail = create_mail + end + else + raise "ApplicationMailer.create! is obsolete - find another way to ensure that themes can override mail templates for multipart mails" + end + end diff --git a/app/models/public_body.rb b/app/models/public_body.rb index e9a90bce3..d212c371f 100644 --- a/app/models/public_body.rb +++ b/app/models/public_body.rb @@ -509,6 +509,20 @@ class PublicBody < ActiveRecord::Base return self.request_email_domain end + # Returns nil if configuration variable not set + def override_request_email + e = MySociety::Config.get("OVERRIDE_ALL_PUBLIC_BODY_REQUEST_EMAILS", "") + e if e != "" + end + + def request_email + if override_request_email + override_request_email + else + read_attribute(:request_email) + end + end + # Domain name of the request email def request_email_domain return PublicBody.extract_domain_from_email(self.request_email) diff --git a/app/models/request_mailer.rb b/app/models/request_mailer.rb index 4316a9be9..3fc6b0471 100644 --- a/app/models/request_mailer.rb +++ b/app/models/request_mailer.rb @@ -50,7 +50,7 @@ class RequestMailer < ApplicationMailer headers 'Return-Path' => blackhole_email, 'Reply-To' => @from, # we don't care about bounces, likely from spammers 'Auto-Submitted' => 'auto-replied' # http://tools.ietf.org/html/rfc3834 @recipients = email.from_addrs[0].to_s - @subject = "Your response to an FOI request was not delivered" + @subject = _("Your response to an FOI request was not delivered") attachment :content_type => 'message/rfc822', :body => raw_email_data, :filename => "original.eml", :transfer_encoding => '7bit', :content_disposition => 'inline' @body = { @@ -154,7 +154,7 @@ class RequestMailer < ApplicationMailer 'Auto-Submitted' => 'auto-generated', # http://tools.ietf.org/html/rfc3834 'X-Auto-Response-Suppress' => 'OOF' @recipients = info_request.user.name_and_email - @subject = "Someone has updated the status of your request" + @subject = _("Someone has updated the status of your request") url = main_url(request_url(info_request)) @body = {:info_request => info_request, :url => url} end diff --git a/app/models/track_thing.rb b/app/models/track_thing.rb index 9a553b382..63f356168 100644 --- a/app/models/track_thing.rb +++ b/app/models/track_thing.rb @@ -51,15 +51,15 @@ class TrackThing < ActiveRecord::Base def TrackThing.track_type_description(track_type) if track_type == 'request_updates' - "Individual requests" + _("Individual requests") elsif track_type == 'all_new_requests' || track_type == "all_successful_requests" - "Many requests" + _("Many requests") elsif track_type == 'public_body_updates' - "Public authorities" + _("Public authorities") elsif track_type == 'user_updates' - "People" + _("People") elsif track_type == 'search_query' - "Search queries" + _("Search queries") else raise "internal error " + track_type end @@ -195,7 +195,7 @@ class TrackThing < ActiveRecord::Base if self.track_type == 'request_updates' @params = { # Website - :list_description => _("'{{link_to_request}}', a request", :link_to_request => "<a href=\"/request/" + CGI.escapeHTML(self.info_request.url_title) + "\">" + CGI.escapeHTML(self.info_request.title) + "</a>"), # XXX yeuch, sometimes I just want to call view helpers from the model, sorry! can't work out how + :list_description => _("'{{link_to_request}}', a request", :link_to_request => "<a href=\"/request/" + CGI.escapeHTML(self.info_request.url_title) + "\">" + CGI.escapeHTML(self.info_request.title) + "</a>"), # XXX yeuch, sometimes I just want to call view helpers from the model, sorry! can't work out how :verb_on_page => _("Follow this request"), :verb_on_page_already => _("You are already following this request"), # Email @@ -246,7 +246,7 @@ class TrackThing < ActiveRecord::Base elsif self.track_type == 'public_body_updates' @params = { # Website - :list_description => _("'{{link_to_authority}}', a public authority", :link_to_authority => "<a href=\"/body/" + CGI.escapeHTML(self.public_body.url_name) + "\">" + CGI.escapeHTML(self.public_body.name) + "</a>"), # XXX yeuch, sometimes I just want to call view helpers from the model, sorry! can't work out how + :list_description => _("'{{link_to_authority}}', a public authority", :link_to_authority => "<a href=\"/body/" + CGI.escapeHTML(self.public_body.url_name) + "\">" + CGI.escapeHTML(self.public_body.name) + "</a>"), # XXX yeuch, sometimes I just want to call view helpers from the model, sorry! can't work out how :verb_on_page => _("Follow requests to {{public_body_name}}",:public_body_name=>CGI.escapeHTML(self.public_body.name)), :verb_on_page_already => _("You are already following requests to {{public_body_name}}", :public_body_name=>CGI.escapeHTML(self.public_body.name)), # Email @@ -262,7 +262,7 @@ class TrackThing < ActiveRecord::Base elsif self.track_type == 'user_updates' @params = { # Website - :list_description => _("'{{link_to_user}}', a person", :link_to_user => "<a href=\"/user/" + CGI.escapeHTML(self.tracked_user.url_name) + "\">" + CGI.escapeHTML(self.tracked_user.name) + "</a>"), # XXX yeuch, sometimes I just want to call view helpers from the model, sorry! can't work out how + :list_description => _("'{{link_to_user}}', a person", :link_to_user => "<a href=\"/user/" + CGI.escapeHTML(self.tracked_user.url_name) + "\">" + CGI.escapeHTML(self.tracked_user.name) + "</a>"), # XXX yeuch, sometimes I just want to call view helpers from the model, sorry! can't work out how :verb_on_page => _("Follow this person"), :verb_on_page_already => _("You are already following this person"), # Email @@ -278,7 +278,7 @@ class TrackThing < ActiveRecord::Base elsif self.track_type == 'search_query' @params = { # Website - :list_description => "<a href=\"/search/" + CGI.escapeHTML(self.track_query) + "/newest/advanced\">" + self.track_query_description + "</a>", # XXX yeuch, sometimes I just want to call view helpers from the model, sorry! can't work out how + :list_description => "<a href=\"/search/" + CGI.escapeHTML(self.track_query) + "/newest/advanced\">" + self.track_query_description + "</a>", # XXX yeuch, sometimes I just want to call view helpers from the model, sorry! can't work out how :verb_on_page => _("Follow things matching this search"), :verb_on_page_already => _("You are already following things matching this search"), # Email diff --git a/app/views/contact_mailer/user_message.rhtml b/app/views/contact_mailer/user_message.rhtml index fe1f47518..b1d6e81ae 100644 --- a/app/views/contact_mailer/user_message.rhtml +++ b/app/views/contact_mailer/user_message.rhtml @@ -1,7 +1,8 @@ --------------------------------------------------------------------- <%= _('{{user_name}} has used {{site_name}} to send you the message below.', :user_name=>@from_user.name, :site_name=>site_name) %> -<%= _('Your details have not been given to anyone, unless you choose to reply to this -message, which will then go directly to the person who wrote the message.')%> +<%= _('Your details, including your email address, have not been given to anyone.') %> +<%= _('If you reply to this message it will go directly to {{user_name}}, who will +learn your email address. Only reply if that is okay.', :user_name => @from_user.name) %> --------------------------------------------------------------------- <%= @message.strip %> diff --git a/app/views/general/_advanced_search_tips.rhtml b/app/views/general/_advanced_search_tips.rhtml index 520cce89b..914abc1af 100644 --- a/app/views/general/_advanced_search_tips.rhtml +++ b/app/views/general/_advanced_search_tips.rhtml @@ -13,7 +13,7 @@ <li><%= _('<strong><code>request:</code></strong> to restrict to a specific request, typing the title as in the URL.')%> <li><%= _('<strong><code>filetype:pdf</code></strong> to find all responses with PDF attachments. Or try these: <code>{{list_of_file_extensions}}</code>', :list_of_file_extensions => IncomingMessage.get_all_file_extensions)%></li> <li><%= _('Type <strong><code>01/01/2008..14/01/2008</code></strong> to only show things that happened in the first two weeks of January.')%></li> - <li><%= _('<strong><code>tag:charity</code></strong> to find all public bodies or requests with a given tag. You can include multiple tags, + <li><%= _('<strong><code>tag:charity</code></strong> to find all public authorities or requests with a given tag. You can include multiple tags, and tag values, e.g. <code>tag:openlylocal AND tag:financial_transaction:335633</code>. Note that by default any of the tags can be present, you have to put <code>AND</code> explicitly if you only want results them all present.')%></li> <li><%= _('Read about <a href="{{advanced_search_url}}">advanced search operators</a>, such as proximity and wildcards.', :advanced_search_url => "http://www.xapian.org/docs/queryparser.html") %></li> diff --git a/app/views/general/_frontpage_search_examples.es.rhtml b/app/views/general/_frontpage_search_examples.es.rhtml deleted file mode 100644 index 63c7c3c1e..000000000 --- a/app/views/general/_frontpage_search_examples.es.rhtml +++ /dev/null @@ -1 +0,0 @@ -por ejemplo <a href="/es/search/El%20Geraldine%20Quango">El Geraldine Quango</a>, <a href="/search/fancy%20dog">Fancy Dog</a>. diff --git a/app/views/general/_frontpage_search_examples.rhtml b/app/views/general/_frontpage_search_examples.rhtml deleted file mode 100644 index 359a132e2..000000000 --- a/app/views/general/_frontpage_search_examples.rhtml +++ /dev/null @@ -1 +0,0 @@ -for example <a href="/search/Geraldine%20Quango">Geraldine Quango</a> or <a href="/search/fancy%20dog">Fancy Dog</a>. diff --git a/app/views/general/frontpage.rhtml b/app/views/general/frontpage.rhtml index 38133e7ab..e2d74a5e2 100644 --- a/app/views/general/frontpage.rhtml +++ b/app/views/general/frontpage.rhtml @@ -40,7 +40,7 @@ <ul> <% for popular_body in @popular_bodies %> <li><%=public_body_link(popular_body)%> - <%= n_('%d request', '%d requests', popular_body.info_requests.count) % popular_body.info_requests.count %> + <%= n_('%d request', '%d requests', popular_body.info_requests_count) % popular_body.info_requests_count %> </li> <% end%> </ul> @@ -51,20 +51,32 @@ <% end %> <div id="examples_1"> - <h3><%= _("What information has been released?") %></h3> - <%= _("{{site_name}} users have made {{number_of_requests}} requests, including:", + <h3> + <% if @request_events_all_successful %> + <%= _("What information has been released?") %> + <% else %> + <%= _("What information has been requested?") %> + <% end %> + </h3> + <%= _("{{site_name}} users have made {{number_of_requests}} requests, including:", :site_name => site_name, :number_of_requests => InfoRequest.count) %> <ul> <% for event in @request_events %> <li> <%= public_body_link(event.info_request.public_body) %> <%= _('answered a request about') %> - <%=link_to h(event.info_request.title), request_url(event.info_request)%> - <%= _('{{length_of_time}} ago', :length_of_time => time_ago_in_words(event.described_at)) %> + <%=link_to h(event.info_request.title), request_url(event.info_request)%> + <%= _('{{length_of_time}} ago', :length_of_time => time_ago_in_words(event.described_at)) %> <p class="excerpt" onclick="document.location.href='<%=request_url(event.info_request)%>'"><%= excerpt(event.search_text_main(true), "", 200) %></p> </li> <% end %> </ul> - <p><strong><%=link_to _('More successful requests...'), request_list_successful_url %></strong></p> + <p><strong> + <% if @request_events_all_successful %> + <%=link_to _('More successful requests...'), request_list_successful_url %> + <% else %> + <%=link_to _('More requests...'), request_list_all_url %> + <% end %> + </strong></p> </div> </div> diff --git a/app/views/help/contact.rhtml b/app/views/help/contact.rhtml index dd49f7951..37df68f49 100644 --- a/app/views/help/contact.rhtml +++ b/app/views/help/contact.rhtml @@ -10,27 +10,18 @@ <h2>Contact an authority to get official information</h2> <ul> <li><a href="/new">Go here</a> to make a request, in public, for information - from UK public authorities.</li> + from public authorities.</li> <li> Asking for private information about yourself? - Please read our help page about - <a href="/help/requesting#data_protection">data protection</a>. + Please read our + <a href="/help/requesting#data_protection">help page</a>. </li> </ul> - <h2>Take up an issue with Government</h2> - - <ul> - <li><a href="http://www.writetothem.com">Write to your MP, - local councillor or other representative</a>. - <li><a href="http://www.number10.gov.uk/">Number 10</a> is a good place to start if you would like to take an issue up with central government. </li> - </ul> - - <% end %> - <h2>Contact the WhatDoTheyKnow team</h2> + <h2>Contact the <%= site_name %> team</h2> <% if !flash[:notice] %> <ul> <li> @@ -91,8 +82,7 @@ <p class="form_note"> We can only help you with <strong>technical problems</strong>, or questions - about Freedom of Information. See the top of this page if you would like to - contact the Government. + about Freedom of Information. </P> diff --git a/app/views/public_body/list.rhtml b/app/views/public_body/list.rhtml index 8cb207bd4..a66a7f8fd 100644 --- a/app/views/public_body/list.rhtml +++ b/app/views/public_body/list.rhtml @@ -26,14 +26,14 @@ </ul> <% end %> <p> - <%= _('<a href="%s">Are we missing a public authority?</a>.') % [help_requesting_path + '#missing_body'] %> + <%= _('<a href="%s">Are we missing a public authority?</a>') % [help_requesting_path + '#missing_body'] %> </p> <p> <%= link_to _('List of all authorities (CSV)'), all_public_bodies_csv_url() %> </p> </div> -<% @title = _("Public authorities - {{description}}", :description => @description) %> +<% @title = @description.empty? ? _("Public authorities") : _("Public authorities - {{description}}", :description => @description) %> <div id="left_column_flip"> <h1><%= _('Public authorities') %></h1> @@ -44,7 +44,7 @@ </div> <% end %> -<h2 class="publicbody_results"><%= _('Found {{count}} public bodies {{description}}', :count=>@public_bodies.total_entries, :description=>@description) %></h2> +<h2 class="publicbody_results"><%= _('Found {{count}} public authorities {{description}}', :count=>@public_bodies.total_entries, :description=>@description) %></h2> <%= render :partial => 'body_listing', :locals => { :public_bodies => @public_bodies } %> <%= will_paginate(@public_bodies) %><br/> diff --git a/app/views/public_body/show.rhtml b/app/views/public_body/show.rhtml index 63bd5f7fc..b56556d5d 100644 --- a/app/views/public_body/show.rhtml +++ b/app/views/public_body/show.rhtml @@ -64,6 +64,12 @@ <% else %> <%= _('For an unknown reason, it is not possible to make a request to this authority.')%> <% end %> + + <% if @public_body.override_request_email %> + <p> + <%= _("<strong>Note:</strong> Because we're testing, requests are being sent to {{email}} rather than to the actual authority.", :email => @public_body.override_request_email) %> + </p> + <% end %> </div> </div> diff --git a/app/views/request/_summary_suggestion.rhtml b/app/views/request/_summary_suggestion.rhtml new file mode 100644 index 000000000..a5da09cda --- /dev/null +++ b/app/views/request/_summary_suggestion.rhtml @@ -0,0 +1,5 @@ +<% if @info_request.law_used == 'eir' %> + <%= _("'Pollution levels over time for the River Tyne'") %> +<% else %> + <%= _("'Crime statistics by ward level for Wales'") %> +<% end %> diff --git a/app/views/request/new.rhtml b/app/views/request/new.rhtml index 23212fc0b..2ef193c42 100644 --- a/app/views/request/new.rhtml +++ b/app/views/request/new.rhtml @@ -86,12 +86,7 @@ </p> <div class="form_item_note"> (<%= _("a one line summary of the information you are requesting, \n\t\t\te.g.") %> - <% if @info_request.law_used == 'eir' %> - <%= _("'Pollution levels over time for the River Tyne'") %> - <% else %> - <%= _("'Crime statistics by ward level for Wales'") %> - <% end %> - ) + <%= render :partial => "summary_suggestion" %>) </div> </div> diff --git a/app/views/request/upload_response.rhtml b/app/views/request/upload_response.rhtml index 697ff99aa..bc129426d 100644 --- a/app/views/request/upload_response.rhtml +++ b/app/views/request/upload_response.rhtml @@ -43,7 +43,7 @@ <p> <%= hidden_field_tag 'submitted_upload_response', 1 %> - <%= submit_tag "Upload FOI response" %> + <%= submit_tag _("Upload FOI response") %> <%= _(' (<strong>patience</strong>, especially for large files, it may take a while!)')%> </p> <% end %> diff --git a/config/general.yml-example b/config/general.yml-example index 4bae28d96..97af5f61d 100644 --- a/config/general.yml-example +++ b/config/general.yml-example @@ -35,6 +35,7 @@ SPECIAL_REPLY_VERY_LATE_AFTER_DAYS: 60 WORKING_OR_CALENDAR_DAYS: working # example public bodies for the home page, semicolon delimited - short_names +# Comment out if you want this to be auto-generated. WARNING: this is slow & don't use production! FRONTPAGE_PUBLICBODY_EXAMPLES: 'tgq' # URLs of themes to download and use (when running rails-post-deploy @@ -161,5 +162,12 @@ VARNISH_HOST: localhost # Adding a value here will enable Google Analytics on all non-admin pages. GA_CODE: '' +# If you want to override *all* the public body request emails with your own +# email so that request emails that would normally go to the public body +# go to you, then uncomment below and fill in your email. +# Useful for a staging server to play with the whole process of sending requests +# without inadvertently sending an email to a real authority +#OVERRIDE_ALL_PUBLIC_BODY_REQUEST_EMAILS: test-email@foo.com + # Search path for external commandline utilities (such as pdftohtml, pdftk, unrtf) UTILITY_SEARCH_PATH: ["/usr/bin", "/usr/local/bin"] diff --git a/config/memcached.yml-test b/config/memcached.yml-test new file mode 100644 index 000000000..18d959876 --- /dev/null +++ b/config/memcached.yml-test @@ -0,0 +1,2 @@ +test: + disabled: true
\ No newline at end of file diff --git a/db/migrate/074_create_holidays.rb b/db/migrate/074_create_holidays.rb index 46b1ab684..f2197e89e 100644 --- a/db/migrate/074_create_holidays.rb +++ b/db/migrate/074_create_holidays.rb @@ -59,7 +59,7 @@ class CreateHolidays < ActiveRecord::Migration '2010-12-28' => "Boxing Day" } - holidays.sort.each { |date, desc| + holidays.sort.each { |date, desc| Holiday.create :day => date, :description => desc } diff --git a/lib/tasks/config_files.rake b/lib/tasks/config_files.rake index 1dcdde79a..d3843f3a4 100644 --- a/lib/tasks/config_files.rake +++ b/lib/tasks/config_files.rake @@ -1,27 +1,7 @@ +require File.join(File.dirname(__FILE__), 'usage') namespace :config_files do - def usage_message message - puts '' - puts message - puts '' - exit 0 - end - - def check_for_env_vars(env_vars, example) - missing = [] - env_vars.each do |env_var| - unless ENV[env_var] - missing << env_var - end - end - if !missing.empty? - usage = "Usage: This task requires #{env_vars.to_sentence} - missing #{missing.to_sentence}" - if example - usage += "\nExample: #{example}" - end - usage_message usage - end - end + include Usage def convert_ugly(file, replacements) converted_lines = [] diff --git a/lib/tasks/translation.rake b/lib/tasks/translation.rake new file mode 100644 index 000000000..0eb39f5e7 --- /dev/null +++ b/lib/tasks/translation.rake @@ -0,0 +1,192 @@ +require File.join(File.dirname(__FILE__), 'usage') +namespace :translation do + + include Usage + + def write_email(email, email_description, output_file) + mail_object = TMail::Mail.parse(email.to_s) + output_file.write("\n") + output_file.write("Description of email: #{email_description}\n") + output_file.write("Subject line: #{mail_object.subject}\n") + output_file.write("\n") + if mail_object.parts.empty? + output_file.write(mail_object.to_s) + else + mail_object.parts.each do |part| + output_file.write("Message part **\n") + output_file.write(part.body.to_s) + end + end + output_file.write("\n") + output_file.write("********\n") + end + + desc "Create previews of translated emails" + task :preview_emails => :environment do + check_for_env_vars(['INFO_REQUEST_ID', + 'FOLLOW_UP_ID', + 'INCOMING_MESSAGE_ID', + 'COMMENT_ID', + 'TRACK_THING_ID', + 'DIR'], nil) + info_request = InfoRequest.find(ENV['INFO_REQUEST_ID']) + if info_request.outgoing_messages.empty? + raise "Info request #{info_request.id} does not have any outgoing messages" + end + initial_request = info_request.outgoing_messages.first + follow_up = OutgoingMessage.find(ENV['FOLLOW_UP_ID']) + incoming_message = IncomingMessage.find(ENV['INCOMING_MESSAGE_ID']) + comment = Comment.find(ENV['COMMENT_ID']) + track_thing = TrackThing.find(ENV['TRACK_THING_ID']) + + output_file = File.open(File.join(ENV['DIR'], 'message_preview.txt'), 'w') + + # outgoing mailer + request_email = OutgoingMailer.create_initial_request(info_request, initial_request) + write_email(request_email, 'Initial Request', output_file) + + followup_email = OutgoingMailer.create_followup(info_request, follow_up, nil) + write_email(followup_email, 'Follow up', output_file) + + # contact mailer + contact_email = ContactMailer.create_message(info_request.user_name, + info_request.user.email, + 'A test message', + 'Hello!', + info_request.user, + info_request, + info_request.public_body) + + write_email(contact_email, 'Contact email (to admin)', output_file) + + user_contact_email = ContactMailer.create_user_message(info_request.user, + info_request.user, + 'http://www.example.com/user', + 'A test message', + 'Hello!') + write_email(user_contact_email, 'Contact email (user to user)', output_file) + + admin_contact_email = ContactMailer.create_from_admin_message(info_request.user, + 'A test message', + 'Hello!') + write_email(admin_contact_email, 'Contact email (admin to user)', output_file) + + # request mailer + fake_response_email = RequestMailer.create_fake_response(info_request, + info_request.user, + "test body", + "attachment.txt", + "test attachment text") + write_email(fake_response_email, + 'Email created when someone uploads a response directly', + output_file) + + content = File.read(File.join(Rails.root, + 'spec', + 'fixtures', + 'files', + 'incoming-request-plain.email')) + response_mail = TMail::Mail.parse(content) + + response_mail.from = "authority@example.com" + stopped_responses_email = RequestMailer.create_stopped_responses(info_request, + response_mail, + content) + write_email(stopped_responses_email, + 'Bounce if someone sends email to a request that has had responses stopped', + output_file) + + requires_admin_email = RequestMailer.create_requires_admin(info_request) + write_email(requires_admin_email, 'Drawing admin attention to a response', output_file) + + + new_response_email = RequestMailer.create_new_response(info_request, incoming_message) + write_email(new_response_email, + 'Telling the requester that a new response has arrived', + output_file) + + overdue_alert_email = RequestMailer.create_overdue_alert(info_request, info_request.user) + write_email(overdue_alert_email, + 'Telling the requester that the public body is late in replying', + output_file) + + very_overdue_alert_email = RequestMailer.create_very_overdue_alert(info_request, info_request.user) + write_email(very_overdue_alert_email, + 'Telling the requester that the public body is very late in replying', + output_file) + + response_reminder_alert_email = RequestMailer.create_new_response_reminder_alert(info_request, + incoming_message) + write_email(response_reminder_alert_email, + 'Telling the requester that they need to say if the new response contains info or not', + output_file) + + old_unclassified_email = RequestMailer.create_old_unclassified_updated(info_request) + write_email(old_unclassified_email, + 'Telling the requester that someone updated their old unclassified request', + output_file) + + not_clarified_alert_email = RequestMailer.create_not_clarified_alert(info_request, incoming_message) + write_email(not_clarified_alert_email, + 'Telling the requester that they need to clarify their request', + output_file) + + comment_on_alert_email = RequestMailer.create_comment_on_alert(info_request, comment) + write_email(comment_on_alert_email, + 'Telling requester that somebody added an annotation to their request', + output_file) + + comment_on_alert_plural_email = RequestMailer.create_comment_on_alert_plural(info_request, 2, comment) + write_email(comment_on_alert_plural_email, + 'Telling requester that somebody added multiple annotations to their request', + output_file) + + # track mailer + xapian_object = InfoRequest.full_search([InfoRequestEvent], + track_thing.track_query, + 'described_at', + true, + nil, + 100, + 1) + event_digest_email = TrackMailer.create_event_digest(info_request.user, + [[track_thing, + xapian_object.results, + xapian_object]]) + write_email(event_digest_email, 'Alerts on things the user is tracking', output_file) + + # user mailer + site_name = MySociety::Config.get('SITE_NAME', 'Alaveteli') + reasons = { + :web => "", + :email => _("Then you can sign in to {{site_name}}", :site_name => site_name), + :email_subject => _("Confirm your account on {{site_name}}", :site_name => site_name) + } + confirm_login_email = UserMailer.create_confirm_login(info_request.user, + reasons, + 'http://www.example.com') + write_email(confirm_login_email, 'Confirm a user login', output_file) + + already_registered_email = UserMailer.create_already_registered(info_request.user, + reasons, + 'http://www.example.com') + write_email(already_registered_email, 'Tell a user they are already registered', output_file) + + new_email = 'new_email@example.com' + changeemail_confirm_email = UserMailer.create_changeemail_confirm(info_request.user, + new_email, + 'http://www.example.com') + write_email(changeemail_confirm_email, + 'Confirm that the user wants to change their email', + output_file) + + changeemail_already_used = UserMailer.create_changeemail_already_used('old_email@example.com', + new_email) + write_email(changeemail_already_used, + 'Tell a user that the email they want to change to is already used', + output_file) + + output_file.close + end + +end
\ No newline at end of file diff --git a/lib/tasks/usage.rb b/lib/tasks/usage.rb new file mode 100644 index 000000000..d6aac454d --- /dev/null +++ b/lib/tasks/usage.rb @@ -0,0 +1,26 @@ +module Usage + + def usage_message message + puts '' + puts message + puts '' + exit 0 + end + + def check_for_env_vars(env_vars, example) + missing = [] + env_vars.each do |env_var| + unless ENV[env_var] + missing << env_var + end + end + if !missing.empty? + usage = "Usage: This task requires #{env_vars.to_sentence} - missing #{missing.to_sentence}" + if example + usage += "\nExample: #{example}" + end + usage_message usage + end + end + +end
\ No newline at end of file diff --git a/locale/aln/app.po b/locale/aln/app.po index 0b07e2754..d1cbe7518 100644 --- a/locale/aln/app.po +++ b/locale/aln/app.po @@ -359,7 +359,7 @@ msgid "" msgstr "" msgid "" -"<strong><code>tag:charity</code></strong> to find all public bodies or requests with a given tag. You can include multiple tags, \n" +"<strong><code>tag:charity</code></strong> to find all public authorities or requests with a given tag. You can include multiple tags, \n" " and tag values, e.g. <code>tag:openlylocal AND tag:financial_transaction:335633</code>. Note that by default any of the tags\n" " can be present, you have to put <code>AND</code> explicitly if you only want results them all present." msgstr "" @@ -1051,7 +1051,7 @@ msgstr "" msgid "Forgotten your password?" msgstr "" -msgid "Found {{count}} public bodies {{description}}" +msgid "Found {{count}} public authorities {{description}}" msgstr "" msgid "Freedom of Information" diff --git a/locale/app.pot b/locale/app.pot index d927a0cb7..069326864 100644 --- a/locale/app.pot +++ b/locale/app.pot @@ -292,7 +292,7 @@ msgid "<strong><code>status:</code></strong> to select based on the status or hi msgstr "" msgid "" -"<strong><code>tag:charity</code></strong> to find all public bodies or requests with a given tag. You can include multiple tags, \n" +"<strong><code>tag:charity</code></strong> to find all public authorities or requests with a given tag. You can include multiple tags, \n" " and tag values, e.g. <code>tag:openlylocal AND tag:financial_transaction:335633</code>. Note that by default any of the tags\n" " can be present, you have to put <code>AND</code> explicitly if you only want results them all present." msgstr "" @@ -919,7 +919,7 @@ msgstr "" msgid "Forgotten your password?" msgstr "" -msgid "Found {{count}} public bodies {{description}}" +msgid "Found {{count}} public authorities {{description}}" msgstr "" msgid "Freedom of Information" diff --git a/locale/bs/app.po b/locale/bs/app.po index 50f53128b..ea144e873 100644 --- a/locale/bs/app.po +++ b/locale/bs/app.po @@ -365,7 +365,7 @@ msgid "" msgstr "<strong><code>status:</code></strong> da biste birali zasnovano na statusu ili historiji statusa zahtjeva, pogledajte <a href=\"{{statuses_url}}\">tabelu statusa</a> below." msgid "" -"<strong><code>tag:charity</code></strong> to find all public bodies or requests with a given tag. You can include multiple tags, \n" +"<strong><code>tag:charity</code></strong> to find all public authorities or requests with a given tag. You can include multiple tags, \n" " and tag values, e.g. <code>tag:openlylocal AND tag:financial_transaction:335633</code>. Note that by default any of the tags\n" " can be present, you have to put <code>AND</code> explicitly if you only want results them all present." msgstr "" @@ -1057,7 +1057,7 @@ msgstr "Iz nepoznatog razloga, nije moguće podnijeti zahtjev ovoj ustanovi." msgid "Forgotten your password?" msgstr "Zaboravili ste Vaš password?" -msgid "Found {{count}} public bodies {{description}}" +msgid "Found {{count}} public authorities {{description}}" msgstr "Pronađeno {{count}} javnih tijela {{description}}" msgid "Freedom of Information" diff --git a/locale/ca/app.po b/locale/ca/app.po index 570e8ae50..9bf03034f 100644 --- a/locale/ca/app.po +++ b/locale/ca/app.po @@ -361,7 +361,7 @@ msgid "" msgstr "<strong><code>status:</code></strong> para filtrar en función del estado actual o histórico de la solicitud, consulte la <a href=\"{{statuses_url}}\">tabla de estados</a> a continuación." msgid "" -"<strong><code>tag:charity</code></strong> to find all public bodies or requests with a given tag. You can include multiple tags, \n" +"<strong><code>tag:charity</code></strong> to find all public authorities or requests with a given tag. You can include multiple tags, \n" " and tag values, e.g. <code>tag:openlylocal AND tag:financial_transaction:335633</code>. Note that by default any of the tags\n" " can be present, you have to put <code>AND</code> explicitly if you only want results them all present." msgstr "<strong><code>tag:salud</code></strong> para buscar todos los organismos públicos o solicitudes con la etiqueta dada. Puedes incluir múltiples etiquetas, \n y valores, e.g. <code>tag:salud AND tag:financial_transaction:335633</code>. Por defecto, basta con que cualquiera de las etiquetas\n esté presente, añade <code>AND</code> explícitamente si sólo quiere resultados con todas ellas presentes." @@ -1053,7 +1053,7 @@ msgstr "No es posible hacer una solicitud a este organismo, por motivos desconoc msgid "Forgotten your password?" msgstr "¿Has olvidado tu contraseña?" -msgid "Found {{count}} public bodies {{description}}" +msgid "Found {{count}} public authorities {{description}}" msgstr "Encontrados {{count}} organismos públicos {{description}}" msgid "Freedom of Information" diff --git a/locale/cs/app.po b/locale/cs/app.po index e9f50dc19..b62502839 100644 --- a/locale/cs/app.po +++ b/locale/cs/app.po @@ -12,7 +12,7 @@ msgstr "" "Project-Id-Version: alaveteli\n" "Report-Msgid-Bugs-To: http://github.com/sebbacon/alaveteli/issues\n" "POT-Creation-Date: 2012-09-19 09:37+0100\n" -"PO-Revision-Date: 2012-09-24 15:30+0000\n" +"PO-Revision-Date: 2012-09-24 16:05+0000\n" "Last-Translator: louisecrow <louise@mysociety.org>\n" "Language-Team: LANGUAGE <LL@li.org>\n" "MIME-Version: 1.0\n" @@ -366,7 +366,7 @@ msgid "" msgstr "<strong><code>stav:</code></strong> pro výběr dotazů podle současného či minulého stavu, navštivte <a href=\"{{statuses_url}}\">Tabulku stavů</a> below." msgid "" -"<strong><code>tag:charity</code></strong> to find all public bodies or requests with a given tag. You can include multiple tags, \n" +"<strong><code>tag:charity</code></strong> to find all public authorities or requests with a given tag. You can include multiple tags, \n" " and tag values, e.g. <code>tag:openlylocal AND tag:financial_transaction:335633</code>. Note that by default any of the tags\n" " can be present, you have to put <code>AND</code> explicitly if you only want results them all present." msgstr "<strong><code>štítek:charita</code></strong> najde všechny instituce nebo dotazy s daným štítkem. Můžete přidat více štítků \n a významů, např. <code>štítek:místní AND štítek:financial_transaction:335633</code>. Všimněte si že štítků může být více, ale musí obsahovat slůvko<code>AND</code> aby se vám zobrazily odpovídající výsledky." @@ -1058,7 +1058,7 @@ msgstr "Z neznámého důvodu není možné vznést dotaz na tuto instituci. " msgid "Forgotten your password?" msgstr "Zapomněli jste heslo?" -msgid "Found {{count}} public bodies {{description}}" +msgid "Found {{count}} public authorities {{description}}" msgstr "Celkem {{count}} institucí {{description}}" msgid "Freedom of Information" @@ -3639,7 +3639,7 @@ msgid "sign in" msgstr "přihlásit se" msgid "simple_date_format" -msgstr "simple_date_format" +msgstr "%e/%-m/%Y" msgid "successful" msgstr "úspěšné" diff --git a/locale/cy/app.po b/locale/cy/app.po index f129d3685..c66de8d39 100644 --- a/locale/cy/app.po +++ b/locale/cy/app.po @@ -367,7 +367,7 @@ msgid "" msgstr "" msgid "" -"<strong><code>tag:charity</code></strong> to find all public bodies or requests with a given tag. You can include multiple tags, \n" +"<strong><code>tag:charity</code></strong> to find all public authorities or requests with a given tag. You can include multiple tags, \n" " and tag values, e.g. <code>tag:openlylocal AND tag:financial_transaction:335633</code>. Note that by default any of the tags\n" " can be present, you have to put <code>AND</code> explicitly if you only want results them all present." msgstr "" @@ -1059,7 +1059,7 @@ msgstr "" msgid "Forgotten your password?" msgstr "" -msgid "Found {{count}} public bodies {{description}}" +msgid "Found {{count}} public authorities {{description}}" msgstr "" msgid "Freedom of Information" diff --git a/locale/de/app.po b/locale/de/app.po index a890a48a1..4f6a15354 100644 --- a/locale/de/app.po +++ b/locale/de/app.po @@ -362,7 +362,7 @@ msgid "" msgstr "<strong><code>Status:</code></strong> um eine Auswahl nach Status oder historischem Status der Anfrage zu treffen, gehen Sie zur unten angezeigten<a href=\"{{statuses_url}}\">Statusübersicht</a> ." msgid "" -"<strong><code>tag:charity</code></strong> to find all public bodies or requests with a given tag. You can include multiple tags, \n" +"<strong><code>tag:charity</code></strong> to find all public authorities or requests with a given tag. You can include multiple tags, \n" " and tag values, e.g. <code>tag:openlylocal AND tag:financial_transaction:335633</code>. Note that by default any of the tags\n" " can be present, you have to put <code>AND</code> explicitly if you only want results them all present." msgstr "<strong><code>markieren Sie:Karitas</code></strong>, um alle Behörden oder Anfragen mit dieser Markierung zu finden. Sie können mehrere Markierungen, \n and tag values, e.g. <code>tag:openlylocal AND tag:financial_transaction:335633</code>. Note that by default any of the tags\n can be present, you have to put <code>AND</code> explicitly if you only want results them all present." @@ -1054,7 +1054,7 @@ msgstr "Aus unbekannten Gründen ist es nicht möglich eine Anfrage a diese Beh msgid "Forgotten your password?" msgstr "Passwort vergessen?" -msgid "Found {{count}} public bodies {{description}}" +msgid "Found {{count}} public authorities {{description}}" msgstr " {{count}} Behörden {{description}} gefunden" msgid "Freedom of Information" diff --git a/locale/en/app.po b/locale/en/app.po index 2129ccb8c..a972553a6 100644 --- a/locale/en/app.po +++ b/locale/en/app.po @@ -291,7 +291,7 @@ msgid "<strong><code>status:</code></strong> to select based on the status or hi msgstr "" msgid "" -"<strong><code>tag:charity</code></strong> to find all public bodies or requests with a given tag. You can include multiple tags, \n" +"<strong><code>tag:charity</code></strong> to find all public authorities or requests with a given tag. You can include multiple tags, \n" " and tag values, e.g. <code>tag:openlylocal AND tag:financial_transaction:335633</code>. Note that by default any of the tags\n" " can be present, you have to put <code>AND</code> explicitly if you only want results them all present." msgstr "" @@ -918,7 +918,7 @@ msgstr "" msgid "Forgotten your password?" msgstr "" -msgid "Found {{count}} public bodies {{description}}" +msgid "Found {{count}} public authorities {{description}}" msgstr "" msgid "Freedom of Information" diff --git a/locale/en_IE/app.po b/locale/en_IE/app.po index dfc576c0b..577ff1ec6 100644 --- a/locale/en_IE/app.po +++ b/locale/en_IE/app.po @@ -359,7 +359,7 @@ msgid "" msgstr "" msgid "" -"<strong><code>tag:charity</code></strong> to find all public bodies or requests with a given tag. You can include multiple tags, \n" +"<strong><code>tag:charity</code></strong> to find all public authorities or requests with a given tag. You can include multiple tags, \n" " and tag values, e.g. <code>tag:openlylocal AND tag:financial_transaction:335633</code>. Note that by default any of the tags\n" " can be present, you have to put <code>AND</code> explicitly if you only want results them all present." msgstr "" @@ -1051,7 +1051,7 @@ msgstr "" msgid "Forgotten your password?" msgstr "" -msgid "Found {{count}} public bodies {{description}}" +msgid "Found {{count}} public authorities {{description}}" msgstr "" msgid "Freedom of Information" diff --git a/locale/es/app.po b/locale/es/app.po index 5e571502c..b93fabe33 100644 --- a/locale/es/app.po +++ b/locale/es/app.po @@ -1,7 +1,7 @@ # SOME DESCRIPTIVE TITLE. # Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER # This file is distributed under the same license as the PACKAGE package. -# +# # Translators: # David Cabo <david.cabo@gmail.com>, 2011-2012. # <fabrizio.scrollini@gmail.com>, 2012. @@ -363,7 +363,7 @@ msgid "" msgstr "<strong><code>status:</code></strong> para filtrar en función del estado actual o histórico de la solicitud, consulte la <a href=\"{{statuses_url}}\">tabla de estados</a> a continuación." msgid "" -"<strong><code>tag:charity</code></strong> to find all public bodies or requests with a given tag. You can include multiple tags, \n" +"<strong><code>tag:charity</code></strong> to find all public authorities or requests with a given tag. You can include multiple tags, \n" " and tag values, e.g. <code>tag:openlylocal AND tag:financial_transaction:335633</code>. Note that by default any of the tags\n" " can be present, you have to put <code>AND</code> explicitly if you only want results them all present." msgstr "<strong><code>tag:salud</code></strong> para buscar todos los organismos públicos o solicitudes con la etiqueta dada. Puedes incluir múltiples etiquetas, \n y valores, e.g. <code>tag:salud AND tag:financial_transaction:335633</code>. Por defecto, basta con que cualquiera de las etiquetas\n esté presente, añade <code>AND</code> explícitamente si sólo quiere resultados con todas ellas presentes." @@ -1055,7 +1055,7 @@ msgstr "No es posible hacer una solicitud a este organismo, por motivos desconoc msgid "Forgotten your password?" msgstr "¿Has olvidado tu contraseña?" -msgid "Found {{count}} public bodies {{description}}" +msgid "Found {{count}} public authorities {{description}}" msgstr "Encontrados {{count}} organismos públicos {{description}}" msgid "Freedom of Information" diff --git a/locale/eu/app.po b/locale/eu/app.po index 6bceee0df..dd18f9eb4 100644 --- a/locale/eu/app.po +++ b/locale/eu/app.po @@ -360,7 +360,7 @@ msgid "" msgstr "<strong><code>egoera:</code></strong> eskabidearen oraingo egoera edo egoera historikoaren arabera iragazteko, kontsulta ezazu ondoko <a href=\"{{statuses_url}}\">egoeren taula</a>." msgid "" -"<strong><code>tag:charity</code></strong> to find all public bodies or requests with a given tag. You can include multiple tags, \n" +"<strong><code>tag:charity</code></strong> to find all public authorities or requests with a given tag. You can include multiple tags, \n" " and tag values, e.g. <code>tag:openlylocal AND tag:financial_transaction:335633</code>. Note that by default any of the tags\n" " can be present, you have to put <code>AND</code> explicitly if you only want results them all present." msgstr "<strong><code>tag:osasuna</code></strong> etiketa hau daukaten erakunde publiko zein eskabide guztiak bilatzeko. Etiketa eta balio ugari sar ditzakezu, e.g. <code>tag:osasuna AND tag:financial_transaction:335633</code>. Edozein etiketa agertzearekin nahiko da, lehenetsita dago, etiketa guztiak dakartzaten emaitzak nahi baldin badituzu zehazki <code>AND</code> gehitu beharko duzu." @@ -1052,7 +1052,7 @@ msgstr "Ez dakigun arrazoia dela eta, erakunde honi eskabidea egitea ezinezkoa d msgid "Forgotten your password?" msgstr "Zure pasahitza ahaztu al duzu?" -msgid "Found {{count}} public bodies {{description}}" +msgid "Found {{count}} public authorities {{description}}" msgstr "{{count}} erakunde publiko {{description}} aurkitu dira." msgid "Freedom of Information" diff --git a/locale/fr/app.po b/locale/fr/app.po index 2234e2f4b..d67b6f12e 100644 --- a/locale/fr/app.po +++ b/locale/fr/app.po @@ -364,7 +364,7 @@ msgid "" msgstr "" msgid "" -"<strong><code>tag:charity</code></strong> to find all public bodies or requests with a given tag. You can include multiple tags, \n" +"<strong><code>tag:charity</code></strong> to find all public authorities or requests with a given tag. You can include multiple tags, \n" " and tag values, e.g. <code>tag:openlylocal AND tag:financial_transaction:335633</code>. Note that by default any of the tags\n" " can be present, you have to put <code>AND</code> explicitly if you only want results them all present." msgstr "<strong><code>tag:charity</code></strong> pour trouvez tous les institutions publiques ou les sollicitudes avec la même étiquette. Vous pouvez inclure plusieurs étiquettes,\\n ou plusieurs étiquettes, ex. <code>tag:openlylocal AND tag:financial_transaction:335633</code>. Note that by default any of the tags \\n can be present, you have to put <code>AND</code> explicitly if you only want results them all present." @@ -1056,7 +1056,7 @@ msgstr "Par des raisons que nous ne pouvons pas déterminer, il est impossible d msgid "Forgotten your password?" msgstr "" -msgid "Found {{count}} public bodies {{description}}" +msgid "Found {{count}} public authorities {{description}}" msgstr "" msgid "Freedom of Information" diff --git a/locale/gl/app.po b/locale/gl/app.po index 269505180..5e06dd4ab 100644 --- a/locale/gl/app.po +++ b/locale/gl/app.po @@ -359,7 +359,7 @@ msgid "" msgstr "<strong><code>status:</code></strong> para filtrar en función del estado actual o histórico de la solicitud, consulte la <a href=\"{{statuses_url}}\">tabla de estados</a> a continuación." msgid "" -"<strong><code>tag:charity</code></strong> to find all public bodies or requests with a given tag. You can include multiple tags, \n" +"<strong><code>tag:charity</code></strong> to find all public authorities or requests with a given tag. You can include multiple tags, \n" " and tag values, e.g. <code>tag:openlylocal AND tag:financial_transaction:335633</code>. Note that by default any of the tags\n" " can be present, you have to put <code>AND</code> explicitly if you only want results them all present." msgstr "<strong><code>tag:salud</code></strong> para buscar todos los organismos públicos o solicitudes con la etiqueta dada. Puedes incluir múltiples etiquetas, \n y valores, e.g. <code>tag:salud AND tag:financial_transaction:335633</code>. Por defecto, basta con que cualquiera de las etiquetas\n esté presente, añade <code>AND</code> explícitamente si sólo quiere resultados con todas ellas presentes." @@ -1051,7 +1051,7 @@ msgstr "No es posible hacer una solicitud a este organismo, por motivos desconoc msgid "Forgotten your password?" msgstr "¿Has olvidado tu contraseña?" -msgid "Found {{count}} public bodies {{description}}" +msgid "Found {{count}} public authorities {{description}}" msgstr "Encontrados {{count}} organismos públicos {{description}}" msgid "Freedom of Information" diff --git a/locale/hu_HU/app.po b/locale/hu_HU/app.po index 286237b84..9e153390e 100644 --- a/locale/hu_HU/app.po +++ b/locale/hu_HU/app.po @@ -359,7 +359,7 @@ msgid "" msgstr "<strong><code>status:</code></strong> az igénylés állapota vagy korábbi állapota alapján történő kiválasztáshoz, lásd az alábbi <a href=\"{{statuses_url}}\">állapottáblázatot</a>. " msgid "" -"<strong><code>tag:charity</code></strong> to find all public bodies or requests with a given tag. You can include multiple tags, \n" +"<strong><code>tag:charity</code></strong> to find all public authorities or requests with a given tag. You can include multiple tags, \n" " and tag values, e.g. <code>tag:openlylocal AND tag:financial_transaction:335633</code>. Note that by default any of the tags\n" " can be present, you have to put <code>AND</code> explicitly if you only want results them all present." msgstr "<strong><code>tag:charity</code></strong> az összes adatgazda vagy igénylés kikereséséhez egy adott címkén belül. Több címkét \n és címkeértéket is szerepeltethet, pl. <code>tag:openlylocal AND tag:financial_transaction:335633</code>. Ne feledje, hogy alapértelmezés szerint bármely címke\n szerepelhet; világosan fel kell tüntetnie az <code>AND</code> kódot, ha az összes eredményt meg kívánja jeleníteni. " @@ -1051,7 +1051,7 @@ msgstr "Ismeretlen okból kifolyólag ennek a közintézménynek nem lehet igén msgid "Forgotten your password?" msgstr "Elfelejtette jelszavát? " -msgid "Found {{count}} public bodies {{description}}" +msgid "Found {{count}} public authorities {{description}}" msgstr " {{description}} összesen {{count}} adatgazda található a rendszerünkben" msgid "Freedom of Information" diff --git a/locale/id/app.po b/locale/id/app.po index dd56d7be6..d706245d6 100644 --- a/locale/id/app.po +++ b/locale/id/app.po @@ -357,7 +357,7 @@ msgid "" msgstr "<strong><code>status:</code></strong> untuk memilih berdasarkan status atau status historical dari permintaan, lihat <a href=\"{{statuses_url}}\">table status </a> di bawah." msgid "" -"<strong><code>tag:charity</code></strong> to find all public bodies or requests with a given tag. You can include multiple tags, \n" +"<strong><code>tag:charity</code></strong> to find all public authorities or requests with a given tag. You can include multiple tags, \n" " and tag values, e.g. <code>tag:openlylocal AND tag:financial_transaction:335633</code>. Note that by default any of the tags\n" " can be present, you have to put <code>AND</code> explicitly if you only want results them all present." msgstr "<strong><code>label:derma</code></strong> untuk mendapatkan semua badan publik atau permintaan-permintaan dengan label yang diberikan. Anda dapat menyertakan beberapa label sekaligus, \n dan menambahkan nilai label, misalnya <code>label:openlylocal DAN label:transaksi_keuangan:335633</code>. Perhatikan bahwa secara default setiap label \n dapat muncul, Anda harus menaruh <code>DAN</code> secara eksplisit jika Anda hanya ingin hasil yang mereka semua tampilkan." @@ -1049,7 +1049,7 @@ msgstr "Untuk alasan yang tidak diketahui, Anda tidak dapat mengajukan permintaa msgid "Forgotten your password?" msgstr "Lupa kode sandi Anda?" -msgid "Found {{count}} public bodies {{description}}" +msgid "Found {{count}} public authorities {{description}}" msgstr "Ditemukan{{count}} badan publik{{description}}" msgid "Freedom of Information" diff --git a/locale/nb_NO/app.po b/locale/nb_NO/app.po index 352e04bfe..460be18c7 100644 --- a/locale/nb_NO/app.po +++ b/locale/nb_NO/app.po @@ -292,7 +292,7 @@ msgid "<strong><code>status:</code></strong> to select based on the status or hi msgstr "" msgid "" -"<strong><code>tag:charity</code></strong> to find all public bodies or requests with a given tag. You can include multiple tags, \n" +"<strong><code>tag:charity</code></strong> to find all public authorities or requests with a given tag. You can include multiple tags, \n" " and tag values, e.g. <code>tag:openlylocal AND tag:financial_transaction:335633</code>. Note that by default any of the tags\n" " can be present, you have to put <code>AND</code> explicitly if you only want results them all present." msgstr "" @@ -919,7 +919,7 @@ msgstr "" msgid "Forgotten your password?" msgstr "" -msgid "Found {{count}} public bodies {{description}}" +msgid "Found {{count}} public authorities {{description}}" msgstr "" msgid "Freedom of Information" diff --git a/locale/pt_BR/app.po b/locale/pt_BR/app.po index 82b3a0447..64e93607c 100644 --- a/locale/pt_BR/app.po +++ b/locale/pt_BR/app.po @@ -372,7 +372,7 @@ msgid "" msgstr "<strong><code>situação:</code></strong> para selecionar com base na situação ou no histórico de situações do pedido, veja a <a href=\"{{statuses_url}}\">tabela de situações</a> abaixo." msgid "" -"<strong><code>tag:charity</code></strong> to find all public bodies or requests with a given tag. You can include multiple tags, \n" +"<strong><code>tag:charity</code></strong> to find all public authorities or requests with a given tag. You can include multiple tags, \n" " and tag values, e.g. <code>tag:openlylocal AND tag:financial_transaction:335633</code>. Note that by default any of the tags\n" " can be present, you have to put <code>AND</code> explicitly if you only want results them all present." msgstr "<strong><code>tag:saude</code></strong> para encontrar órgãos públicos ou pedidos com uma tag específica. Você pode incluir múltiplas tags ⏎\n e valores, por exemplo <code>tag:saude E tag:transacao_financeira:335633</code>. Perceba que, por padrão, qualquer uma das tags⏎\n pode estar presente em um resultado, e você deve colocar <code>E</code> para explicitar que deseja resultados com todas as tags presentes." @@ -1064,7 +1064,7 @@ msgstr "Devido a um erro desconhecido, não foi possível realizar seu pedido pa msgid "Forgotten your password?" msgstr "Esqueceu a sua senha?" -msgid "Found {{count}} public bodies {{description}}" +msgid "Found {{count}} public authorities {{description}}" msgstr "{{count}} orgãos encontrados {{description}}" msgid "Freedom of Information" diff --git a/locale/sq/app.po b/locale/sq/app.po index c9174ccdd..8839b8da7 100644 --- a/locale/sq/app.po +++ b/locale/sq/app.po @@ -364,7 +364,7 @@ msgid "" msgstr "<strong><code>status:</code></strong>për të selektuar në bazë të statusit apo historisë së statusit të kërkesës, shih<a href=\"{{statuses_url}}\">tabelën e statuseve</a> më poshtë." msgid "" -"<strong><code>tag:charity</code></strong> to find all public bodies or requests with a given tag. You can include multiple tags, \n" +"<strong><code>tag:charity</code></strong> to find all public authorities or requests with a given tag. You can include multiple tags, \n" " and tag values, e.g. <code>tag:openlylocal AND tag:financial_transaction:335633</code>. Note that by default any of the tags\n" " can be present, you have to put <code>AND</code> explicitly if you only want results them all present." msgstr "<strong><code>etiketa:organizatë</code></strong> për të gjetur të gjitha institucionet apo kërkesat me etiketën e dhënë. Mund të përfshihen edhe disa etiketa, \n dhe vlera të etiketave, psh. <code>tag:openlylocal AND tag:financial_transaction:335633</code>. Secila nga etiketat mund të jetë\n prezente, duhet të shkruash <code>AND</code> në mënyrë eksplicite nëse do që vetëm ato te përfshihen." @@ -1056,7 +1056,7 @@ msgstr "Për një arsye të panjohur, nuk është e mundur për të bërë një msgid "Forgotten your password?" msgstr "Ke harru fjalëkalimin?" -msgid "Found {{count}} public bodies {{description}}" +msgid "Found {{count}} public authorities {{description}}" msgstr "U gjetën {{count}} autoritete publike - {{description}}" msgid "Freedom of Information" diff --git a/locale/sq/app__.po b/locale/sq/app__.po index 502bed447..2583d4e77 100644 --- a/locale/sq/app__.po +++ b/locale/sq/app__.po @@ -441,7 +441,7 @@ msgstr "" #: app/views/general/search.rhtml:134 msgid "" -"<strong><code>tag:charity</code></strong> to find all public bodies or requests with a given tag. You can include multiple tags, \n" +"<strong><code>tag:charity</code></strong> to find all public authorities or requests with a given tag. You can include multiple tags, \n" " and tag values, e.g. <code>tag:openlylocal AND tag:financial_transaction:335633</code>. Note that by default any of the tags\n" " can be present, you have to put <code>AND</code> explicitly if you only want results them all present." msgstr "" diff --git a/locale/sq/app_old3.po b/locale/sq/app_old3.po index 07463d4e7..efca51075 100644 --- a/locale/sq/app_old3.po +++ b/locale/sq/app_old3.po @@ -469,7 +469,7 @@ msgstr "" #: app/views/general/search.rhtml:134 msgid "" -"<strong><code>tag:charity</code></strong> to find all public bodies or " +"<strong><code>tag:charity</code></strong> to find all public authorities or " "requests with a given tag. You can include multiple tags, \n" " and tag values, e.g. <code>tag:openlylocal AND tag:" "financial_transaction:335633</code>. Note that by default any of the tags\n" diff --git a/locale/sq/app_old4.po b/locale/sq/app_old4.po index d80e13397..a3a4b8534 100644 --- a/locale/sq/app_old4.po +++ b/locale/sq/app_old4.po @@ -459,7 +459,7 @@ msgstr "" #: app/views/general/search.rhtml:134 msgid "" -"<strong><code>tag:charity</code></strong> to find all public bodies or requests with a given tag. You can include multiple tags, \n" +"<strong><code>tag:charity</code></strong> to find all public authorities or requests with a given tag. You can include multiple tags, \n" " and tag values, e.g. <code>tag:openlylocal AND tag:financial_transaction:335633</code>. Note that by default any of the tags\n" " can be present, you have to put <code>AND</code> explicitly if you only want results them all present." msgstr "" diff --git a/locale/sq/app_old5.po b/locale/sq/app_old5.po index 40b79ed7b..7c19a89c0 100644 --- a/locale/sq/app_old5.po +++ b/locale/sq/app_old5.po @@ -487,7 +487,7 @@ msgstr "" #: app/views/general/search.rhtml:134 msgid "" -"<strong><code>tag:charity</code></strong> to find all public bodies or requests with a given tag. You can include multiple tags, \n" +"<strong><code>tag:charity</code></strong> to find all public authorities or requests with a given tag. You can include multiple tags, \n" " and tag values, e.g. <code>tag:openlylocal AND tag:financial_transaction:335633</code>. Note that by default any of the tags\n" " can be present, you have to put <code>AND</code> explicitly if you only want results them all present." msgstr "" diff --git a/locale/sr@latin/app.po b/locale/sr@latin/app.po index 88291fcbf..27e266424 100644 --- a/locale/sr@latin/app.po +++ b/locale/sr@latin/app.po @@ -364,7 +364,7 @@ msgid "" msgstr "<strong><code>status:</code></strong> da biste birali zasnovano na statusu ili historiji statusa zahteva, pogledajte <a href=\"{{statuses_url}}\">tabelu statusa</a> below." msgid "" -"<strong><code>tag:charity</code></strong> to find all public bodies or requests with a given tag. You can include multiple tags, \n" +"<strong><code>tag:charity</code></strong> to find all public authorities or requests with a given tag. You can include multiple tags, \n" " and tag values, e.g. <code>tag:openlylocal AND tag:financial_transaction:335633</code>. Note that by default any of the tags\n" " can be present, you have to put <code>AND</code> explicitly if you only want results them all present." msgstr "" @@ -1056,7 +1056,7 @@ msgstr "Iz nepoznatog razloga, nije moguće podneti zahtev ovoj ustanovi." msgid "Forgotten your password?" msgstr "Zaboravili ste Vaš password?" -msgid "Found {{count}} public bodies {{description}}" +msgid "Found {{count}} public authorities {{description}}" msgstr "Pronađeno {{count}} javnih tela {{description}}" msgid "Freedom of Information" diff --git a/locale/uk/app.po b/locale/uk/app.po index 98490f9ef..c0818c862 100644 --- a/locale/uk/app.po +++ b/locale/uk/app.po @@ -364,7 +364,7 @@ msgid "" msgstr "<strong><code>статус:</code></strong> щоб обрати на основі статусу або історичного статусу запиту, перейдіть до <a href=\"{{statuses_url}}\">таблиці статусів</a> унизу." msgid "" -"<strong><code>tag:charity</code></strong> to find all public bodies or requests with a given tag. You can include multiple tags, \n" +"<strong><code>tag:charity</code></strong> to find all public authorities or requests with a given tag. You can include multiple tags, \n" " and tag values, e.g. <code>tag:openlylocal AND tag:financial_transaction:335633</code>. Note that by default any of the tags\n" " can be present, you have to put <code>AND</code> explicitly if you only want results them all present." msgstr "" @@ -1056,7 +1056,7 @@ msgstr "З невідомих причин, зробити запит до ць msgid "Forgotten your password?" msgstr "Забули пароль?" -msgid "Found {{count}} public bodies {{description}}" +msgid "Found {{count}} public authorities {{description}}" msgstr "" msgid "Freedom of Information" diff --git a/spec/fixtures/locale/en/app.po b/spec/fixtures/locale/en/app.po index 5c40446d8..91af9b72b 100644 --- a/spec/fixtures/locale/en/app.po +++ b/spec/fixtures/locale/en/app.po @@ -356,7 +356,7 @@ msgstr "" #: app/views/general/_advanced_search_tips.rhtml:16 msgid "" -"<strong><code>tag:charity</code></strong> to find all public bodies or requests with a given tag. You can include multiple tags, \n" +"<strong><code>tag:charity</code></strong> to find all public authorities or requests with a given tag. You can include multiple tags, \n" " and tag values, e.g. <code>tag:openlylocal AND tag:financial_transaction:335633</code>. Note that by default any of the tags\n" " can be present, you have to put <code>AND</code> explicitly if you only want results them all present." msgstr "" @@ -1098,7 +1098,7 @@ msgid "Forgotten your password?" msgstr "" #: app/views/public_body/list.rhtml:47 -msgid "Found {{count}} public bodies {{description}}" +msgid "Found {{count}} public authorities {{description}}" msgstr "" #: app/models/info_request.rb:257 diff --git a/spec/fixtures/locale/en_GB/app.po b/spec/fixtures/locale/en_GB/app.po index 5c40446d8..91af9b72b 100644 --- a/spec/fixtures/locale/en_GB/app.po +++ b/spec/fixtures/locale/en_GB/app.po @@ -356,7 +356,7 @@ msgstr "" #: app/views/general/_advanced_search_tips.rhtml:16 msgid "" -"<strong><code>tag:charity</code></strong> to find all public bodies or requests with a given tag. You can include multiple tags, \n" +"<strong><code>tag:charity</code></strong> to find all public authorities or requests with a given tag. You can include multiple tags, \n" " and tag values, e.g. <code>tag:openlylocal AND tag:financial_transaction:335633</code>. Note that by default any of the tags\n" " can be present, you have to put <code>AND</code> explicitly if you only want results them all present." msgstr "" @@ -1098,7 +1098,7 @@ msgid "Forgotten your password?" msgstr "" #: app/views/public_body/list.rhtml:47 -msgid "Found {{count}} public bodies {{description}}" +msgid "Found {{count}} public authorities {{description}}" msgstr "" #: app/models/info_request.rb:257 diff --git a/spec/fixtures/locale/es/app.po b/spec/fixtures/locale/es/app.po index dd8e10969..4e54a1d40 100644 --- a/spec/fixtures/locale/es/app.po +++ b/spec/fixtures/locale/es/app.po @@ -424,7 +424,7 @@ msgstr "<strong><code>status:</code></strong> para filtrar en función del estad #: app/views/general/_advanced_search_tips.rhtml:16 msgid "" -"<strong><code>tag:charity</code></strong> to find all public bodies or requests with a given tag. You can include multiple tags, \n" +"<strong><code>tag:charity</code></strong> to find all public authorities or requests with a given tag. You can include multiple tags, \n" " and tag values, e.g. <code>tag:openlylocal AND tag:financial_transaction:335633</code>. Note that by default any of the tags\n" " can be present, you have to put <code>AND</code> explicitly if you only want results them all present." msgstr "<strong><code>tag:salud</code></strong> para buscar todos los organismos públicos o solicitudes con la etiqueta dada. Puedes incluir múltiples etiquetas, \n y valores, e.g. <code>tag:salud AND tag:financial_transaction:335633</code>. Por defecto, basta con que cualquiera de las etiquetas\n esté presente, añade <code>AND</code> explícitamente si sólo quiere resultados con todas ellas presentes." @@ -1221,7 +1221,7 @@ msgid "Forgotten your password?" msgstr "¿Has olvidado tu contraseña?" #: app/views/public_body/list.rhtml:47 -msgid "Found {{count}} public bodies {{description}}" +msgid "Found {{count}} public authorities {{description}}" msgstr "Encontrados {{count}} organismos públicos {{description}}" #: app/models/info_request.rb:257 diff --git a/spec/fixtures/theme_views/core/application_mailer/core_only.rhtml b/spec/fixtures/theme_views/core/application_mailer/core_only.rhtml new file mode 100644 index 000000000..53b7798ec --- /dev/null +++ b/spec/fixtures/theme_views/core/application_mailer/core_only.rhtml @@ -0,0 +1 @@ +Core only
\ No newline at end of file diff --git a/spec/fixtures/theme_views/core/application_mailer/multipart_core_only.rhtml b/spec/fixtures/theme_views/core/application_mailer/multipart_core_only.rhtml new file mode 100644 index 000000000..646a349f8 --- /dev/null +++ b/spec/fixtures/theme_views/core/application_mailer/multipart_core_only.rhtml @@ -0,0 +1 @@ +Core multipart
\ No newline at end of file diff --git a/spec/fixtures/theme_views/core/application_mailer/simple.rhtml b/spec/fixtures/theme_views/core/application_mailer/simple.rhtml new file mode 100644 index 000000000..a3937c940 --- /dev/null +++ b/spec/fixtures/theme_views/core/application_mailer/simple.rhtml @@ -0,0 +1 @@ +Core simple
\ No newline at end of file diff --git a/spec/fixtures/theme_views/theme_one/application_mailer/multipart_theme_only.rhtml b/spec/fixtures/theme_views/theme_one/application_mailer/multipart_theme_only.rhtml new file mode 100644 index 000000000..d6423fbb4 --- /dev/null +++ b/spec/fixtures/theme_views/theme_one/application_mailer/multipart_theme_only.rhtml @@ -0,0 +1 @@ +Theme multipart
\ No newline at end of file diff --git a/spec/fixtures/theme_views/theme_one/application_mailer/simple.rhtml b/spec/fixtures/theme_views/theme_one/application_mailer/simple.rhtml new file mode 100644 index 000000000..ad43e0c87 --- /dev/null +++ b/spec/fixtures/theme_views/theme_one/application_mailer/simple.rhtml @@ -0,0 +1 @@ +Theme simple
\ No newline at end of file diff --git a/spec/fixtures/theme_views/theme_one/application_mailer/theme_only.rhtml b/spec/fixtures/theme_views/theme_one/application_mailer/theme_only.rhtml new file mode 100644 index 000000000..865445815 --- /dev/null +++ b/spec/fixtures/theme_views/theme_one/application_mailer/theme_only.rhtml @@ -0,0 +1 @@ +Theme only
\ No newline at end of file diff --git a/spec/models/application_mailer_spec.rb b/spec/models/application_mailer_spec.rb index 12527c6e8..a90f79c01 100644 --- a/spec/models/application_mailer_spec.rb +++ b/spec/models/application_mailer_spec.rb @@ -1,8 +1,160 @@ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') -describe ApplicationMailer, " when blah" do - before do + +describe ApplicationMailer do + + context 'when using plugins' do + + def set_base_views + ApplicationMailer.class_eval do + @previous_view_paths = self.view_paths.dup + self.view_paths.clear + self.view_paths << File.join(Rails.root, 'spec', 'fixtures', 'theme_views', 'core') + end + end + + def add_mail_methods(method_names) + method_names.each{ |method_name| ApplicationMailer.send(:define_method, method_name){} } + end + + def remove_mail_methods(method_names) + method_names.each do |method_name| + if ApplicationMailer.respond_to?(method_name) + ApplicationMailer.send(:remove_method, method_name) + end + end + end + + def prepend_theme_views(theme_name) + ApplicationMailer.class_eval do + view_paths.unshift File.join(Rails.root, 'spec', 'fixtures', 'theme_views', theme_name) + end + end + + def append_theme_views(theme_name) + ApplicationMailer.class_eval do + view_paths << File.join(Rails.root, 'spec', 'fixtures', 'theme_views', theme_name) + end + end + + def reset_views + ApplicationMailer.class_eval do + self.view_paths = @previous_view_paths + end + end + + def create_multipart_method(method_name) + ApplicationMailer.send(:define_method, method_name) do + attachment :content_type => 'message/rfc822', + :body => 'xxx', + :filename => "original.eml", + :transfer_encoding => '7bit', + :content_disposition => 'inline' + end + end + + before do + set_base_views + add_mail_methods(['simple', 'theme_only', 'core_only', 'neither']) + end + + describe 'when a plugin prepends its mail templates to the view paths' do + + it 'should render a theme template in preference to a core template' do + prepend_theme_views('theme_one') + @mail = ApplicationMailer.create_simple() + @mail.body.should match('Theme simple') + end + + it 'should render the template provided by the theme if no template is available in core' do + prepend_theme_views('theme_one') + @mail = ApplicationMailer.create_theme_only() + @mail.body.should match('Theme only') + end + + it 'should render the template provided by core if there is no theme template' do + prepend_theme_views('theme_one') + @mail = ApplicationMailer.create_core_only() + @mail.body.should match('Core only') + end + + it 'should raise an error if the template is in neither core nor theme' do + prepend_theme_views('theme_one') + lambda{ ApplicationMailer.create_neither() }.should raise_error('Missing template application_mailer/neither.erb in view path spec/fixtures/theme_views/theme_one:spec/fixtures/theme_views/core') + end + + it 'should render a multipart email using a theme template' do + prepend_theme_views('theme_one') + create_multipart_method('multipart_theme_only') + @mail = ApplicationMailer.create_multipart_theme_only() + @mail.parts.size.should == 2 + message_part = @mail.parts[0].to_s + message_part.should match("Theme multipart") + end + + it 'should render a multipart email using a core template' do + prepend_theme_views('theme_one') + create_multipart_method('multipart_core_only') + @mail = ApplicationMailer.create_multipart_core_only() + @mail.parts.size.should == 2 + message_part = @mail.parts[0].to_s + message_part.should match("Core multipart") + end + + end + + describe 'when a plugin appends its mail templates to the view paths' do + + it 'should render a core template in preference to a theme template' do + append_theme_views('theme_one') + @mail = ApplicationMailer.create_simple() + @mail.body.should match('Core simple') + end + + it 'should render the template provided by the theme if no template is available in core' do + append_theme_views('theme_one') + @mail = ApplicationMailer.create_theme_only() + @mail.body.should match('Theme only') + end + + it 'should render the template provided by core if there is no theme template' do + append_theme_views('theme_one') + @mail = ApplicationMailer.create_core_only() + @mail.body.should match('Core only') + end + + it 'should raise an error if the template is in neither core nor theme' do + append_theme_views('theme_one') + lambda{ ApplicationMailer.create_neither() }.should raise_error('Missing template application_mailer/neither.erb in view path spec/fixtures/theme_views/core:spec/fixtures/theme_views/theme_one') + end + + it 'should render a multipart email using a core template' do + append_theme_views('theme_one') + create_multipart_method('multipart_core_only') + @mail = ApplicationMailer.create_multipart_core_only() + @mail.parts.size.should == 2 + message_part = @mail.parts[0].to_s + message_part.should match("Core multipart") + end + + it 'should render a multipart email using a theme template' do + append_theme_views('theme_one') + create_multipart_method('multipart_theme_only') + @mail = ApplicationMailer.create_multipart_theme_only() + @mail.parts.size.should == 2 + message_part = @mail.parts[0].to_s + message_part.should match("Theme multipart") + end + + end + + after do + reset_views + remove_mail_methods(['simple', 'theme_only', 'core_only', 'neither', 'multipart']) + end end + end + diff --git a/spec/models/public_body_spec.rb b/spec/models/public_body_spec.rb index 011824190..c2e0a6353 100644 --- a/spec/models/public_body_spec.rb +++ b/spec/models/public_body_spec.rb @@ -453,3 +453,11 @@ describe PublicBody do end end + +describe PublicBody, " when override all public body request emails set" do + it "should return the overridden request email" do + MySociety::Config.should_receive(:get).with("OVERRIDE_ALL_PUBLIC_BODY_REQUEST_EMAILS", "").twice.and_return("catch_all_test_email@foo.com") + @geraldine = public_bodies(:geraldine_public_body) + @geraldine.request_email.should == "catch_all_test_email@foo.com" + end +end diff --git a/spec/models/request_mailer_spec.rb b/spec/models/request_mailer_spec.rb index 269208405..84804d4ca 100644 --- a/spec/models/request_mailer_spec.rb +++ b/spec/models/request_mailer_spec.rb @@ -97,10 +97,12 @@ describe RequestMailer, " when receiving incoming mail" do # check attached bounce is good copy of incoming-request-plain.email mail.multipart?.should == true mail.parts.size.should == 2 + message_part = mail.parts[0].to_s bounced_mail = TMail::Mail.parse(mail.parts[1].body) bounced_mail.to.should == [ ir.incoming_email ] bounced_mail.from.should == [ 'geraldinequango@localhost' ] - bounced_mail.body.include?("That's so totally a rubbish question") + bounced_mail.body.include?("That's so totally a rubbish question").should be_true + message_part.include?("marked to no longer receive responses").should be_true deliveries.clear end @@ -324,3 +326,4 @@ describe RequestMailer, 'when sending mail when someone has updated an old uncla end end + diff --git a/spec/views/public_body/show.rhtml_spec.rb b/spec/views/public_body/show.rhtml_spec.rb index 1d21f80c4..a42516d72 100644 --- a/spec/views/public_body/show.rhtml_spec.rb +++ b/spec/views/public_body/show.rhtml_spec.rb @@ -12,6 +12,7 @@ describe "when viewing a body" do :info_requests => [1, 2, 3, 4], # out of sync with Xapian :publication_scheme => '', :calculated_home_page => '') + @pb.stub!(:override_request_email).and_return(nil) @pb.stub!(:is_requestable?).and_return(true) @pb.stub!(:has_notes?).and_return(false) @pb.stub!(:has_tag?).and_return(false) |