aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--app/controllers/general_controller.rb36
-rw-r--r--app/controllers/request_controller.rb10
-rw-r--r--app/controllers/services_controller.rb10
-rw-r--r--app/controllers/user_controller.rb3
-rwxr-xr-xapp/helpers/link_to_helper.rb27
-rw-r--r--app/models/raw_email.rb26
-rw-r--r--app/views/general/search.rhtml10
-rw-r--r--app/views/request/list.rhtml2
-rw-r--r--app/views/user/show.rhtml82
-rw-r--r--public/images/navimg/logo-trans.pngbin4763 -> 6040 bytes
-rw-r--r--public/stylesheets/main.css77
-rwxr-xr-xscript/load-sample-data12
-rwxr-xr-xscript/rebuild-xapian-index4
-rwxr-xr-xscript/spec-all-pairs70
-rw-r--r--spec/controllers/admin_user_controller_spec.rb2
-rw-r--r--spec/controllers/general_controller_spec.rb4
-rw-r--r--spec/controllers/request_controller_spec.rb59
-rw-r--r--spec/controllers/user_controller_spec.rb8
-rw-r--r--spec/integration/search_request_spec.rb7
-rw-r--r--spec/lib/sendmail_return_path_spec.rb1
-rw-r--r--spec/models/request_mailer_spec.rb1
-rw-r--r--spec/models/track_mailer_spec.rb1
-rw-r--r--spec/models/xapian_spec.rb52
23 files changed, 258 insertions, 246 deletions
diff --git a/app/controllers/general_controller.rb b/app/controllers/general_controller.rb
index c715b547d..8ac41b05a 100644
--- a/app/controllers/general_controller.rb
+++ b/app/controllers/general_controller.rb
@@ -86,34 +86,19 @@ class GeneralController < ApplicationController
# Just does a redirect from ?query= search to /query
def search_redirect
- if params[:advanced].nil?
- @query, _ = make_query_from_params
- else
- @query, _ = params[:query]
- end
- @sortby = params[:sortby]
- path = request.path.split("/")
- if path.size > 0 && (['newest', 'described', 'relevant'].include?(path[-1]))
- @sort_postfix = path.pop
- end
- if path.size > 0 && (['bodies', 'requests', 'users', 'all'].include?(path[-1]))
- @variety_postfix = path.pop
- end
- @variety_postfix = "bodies" if @variety_postfix.nil? && !params[:bodies].nil?
- @variety_postfix = "all" if @variety_postfix.nil?
- if @variety_postfix != "users"
- @common_query = get_tags_from_params
- end
- [:latest_status, :request_variety, :request_date_after, :request_date_before, :query, :tags].each do |x|
- session[x] = params[x]
- end
+ @query = params.delete(:query)
if @query.nil? || @query.empty?
@query = nil
@page = 1
@advanced = !params[:advanced].nil?
render :action => "search"
else
- redirect_to search_url(@query, @variety_postfix, @sort_postfix, params[:advanced])
+ query_parts = @query.split("/")
+ if !['bodies', 'requests', 'users', 'all'].include?(query_parts[-1])
+ redirect_to search_url([@query, "all"], params)
+ else
+ redirect_to search_url(@query, params)
+ end
end
end
@@ -121,13 +106,6 @@ class GeneralController < ApplicationController
def search
# XXX Why is this so complicated with arrays and stuff? Look at the route
# in config/routes.rb for comments.
- if !params[:commit].nil?
- search_redirect
- return
- end
- [:latest_status, :request_variety, :request_date_after, :request_date_before, :query, :tags].each do |x|
- params[x] = session[x] if params[x].nil?
- end
combined = params[:combined]
@sortby = nil
@bodies = @requests = @users = true
diff --git a/app/controllers/request_controller.rb b/app/controllers/request_controller.rb
index 11812b729..a70e8d16c 100644
--- a/app/controllers/request_controller.rb
+++ b/app/controllers/request_controller.rb
@@ -74,8 +74,9 @@ class RequestController < ApplicationController
@info_request_events = @info_request.info_request_events
@status = @info_request.calculate_status
@collapse_quotes = params[:unfold] ? false : true
- @update_status = params[:update_status] ? true : false
+ @update_status = params[:update_status] ? true : false
@old_unclassified = @info_request.is_old_unclassified? && !authenticated_user.nil?
+ @is_owning_user = @info_request.is_owning_user?(authenticated_user)
if @update_status
return if !@is_owning_user && !authenticated_as_user?(@info_request.user,
@@ -108,7 +109,6 @@ class RequestController < ApplicationController
# For send followup link at bottom
@last_response = @info_request.get_last_response
- @is_owning_user = @info_request.is_owning_user?(authenticated_user)
respond_to do |format|
format.html { @has_json = true; render :template => 'request/show'}
format.json { render :json => @info_request.json_for_api(true) }
@@ -168,7 +168,8 @@ class RequestController < ApplicationController
query = make_query_from_params
@title = _("View and search requests")
sortby = "newest"
- behavior_cache :tag => [@query, @page, I18n.locale] do
+ @cache_tag = Digest::MD5.hexdigest(query + @page.to_s)
+ behavior_cache :tag => [@cache_tag] do
xapian_object = perform_search([InfoRequestEvent], query, sortby, 'request_collapse')
@list_results = xapian_object.results.map { |r| r[:model] }
@matches_estimated = xapian_object.matches_estimated
@@ -696,7 +697,8 @@ class RequestController < ApplicationController
@incoming_message.parse_raw_email!
@info_request = @incoming_message.info_request
if @incoming_message.info_request_id != params[:id].to_i
- raise ActiveRecord::RecordNotFound.new(sprintf("Incoming message %d does not belong to request %d", @incoming_message.info_request_id, params[:id]))
+ message = "Incoming message %d does not belong to request %d" % [@incoming_message.info_request_id, params[:id]]
+ raise ActiveRecord::RecordNotFound.new(message)
end
@part_number = params[:part].to_i
@filename = params[:file_name].join("/")
diff --git a/app/controllers/services_controller.rb b/app/controllers/services_controller.rb
index 6fb20336e..225790d71 100644
--- a/app/controllers/services_controller.rb
+++ b/app/controllers/services_controller.rb
@@ -1,12 +1,4 @@
-# controllers/application.rb:
-# Parent class of all controllers in FOI site. Filters added to this controller
-# apply to all controllers in the application. Likewise, all the methods added
-# will be available for all controllers.
-#
-# Copyright (c) 2007 UK Citizens Online Democracy. All rights reserved.
-# Email: francis@mysociety.org; WWW: http://www.mysociety.org/
-#
-# $Id: application.rb,v 1.59 2009-09-17 13:01:56 francis Exp $
+# controllers/services_controller.rb:
require 'open-uri'
diff --git a/app/controllers/user_controller.rb b/app/controllers/user_controller.rb
index 45b71a3a9..f49fc9165 100644
--- a/app/controllers/user_controller.rb
+++ b/app/controllers/user_controller.rb
@@ -489,7 +489,8 @@ class UserController < ApplicationController
raise ActiveRecord::RecordNotFound.new("user not found, url_name=" + params[:url_name])
end
if !@display_user.profile_photo
- raise "user has no profile photo, url_name=" + params[:url_name]
+ raise ActiveRecord::RecordNotFound.new("user has no profile photo, url_name=" + params[:url_name])
+
end
response.content_type = "image/png"
diff --git a/app/helpers/link_to_helper.rb b/app/helpers/link_to_helper.rb
index 7903dee2a..56c33e512 100755
--- a/app/helpers/link_to_helper.rb
+++ b/app/helpers/link_to_helper.rb
@@ -136,9 +136,19 @@ module LinkToHelper
end
# General pages.
- def search_url(query, variety_postfix = nil, sort_postfix = nil, advanced = nil)
- query = query - ["", nil] if query.kind_of?(Array)
- url = search_general_url(:combined => query)
+ def search_url(query, params = nil)
+ if query.kind_of?(Array)
+ query = query - ["", nil]
+ query = query.join("/")
+ end
+ routing_info = {:controller => 'general',
+ :action => 'search',
+ :combined => query,
+ :view => nil}
+ if !params.nil?
+ routing_info = params.merge(routing_info)
+ end
+ url = url_for(routing_info)
# Here we can't escape the slashes, as RFC 2396 doesn't allow slashes
# within a path component. Rails is assuming when generating URLs that
# either there aren't slashes, or we are in a query part where you can
@@ -150,19 +160,10 @@ module LinkToHelper
# http://rails.lighthouseapp.com/projects/8994/tickets/144-patch-bug-in-rails-route-globbing
url = url.gsub("%2F", "/")
- if !variety_postfix.nil? && !variety_postfix.empty?
- url = url + "/" + variety_postfix
- end
- if !sort_postfix.nil? && !sort_postfix.empty?
- url = url + "/" + sort_postfix
- end
- if !advanced.nil? && (advanced)
- url = url + "/advanced"
- end
return url
end
def search_link(query, variety_postfix = nil, sort_postfix = nil, advanced = nil)
- link_to h(query), search_url(query, variety_postfix, sort_postfix, advanced)
+ link_to h(query), search_url(query)
end
# Admin pages
diff --git a/app/models/raw_email.rb b/app/models/raw_email.rb
index 6e073aa27..3e12a6feb 100644
--- a/app/models/raw_email.rb
+++ b/app/models/raw_email.rb
@@ -27,7 +27,7 @@ class RawEmail < ActiveRecord::Base
def directory
request_id = self.incoming_message.info_request.id.to_s
if ENV["RAILS_ENV"] == "test"
- return 'files/raw_email_test'
+ return File.join(RAILS_ROOT, 'files/raw_email_test')
else
return File.join(MySociety::Config.get('RAW_EMAILS_LOCATION',
'files/raw_emails'),
@@ -49,35 +49,13 @@ class RawEmail < ActiveRecord::Base
end
def data
- if !File.exists?(self.filepath)
- dbdata
- else
- File.open(self.filepath, "rb" ).read
- end
+ File.open(self.filepath, "rb").read
end
def destroy_file_representation!
File.delete(self.filepath)
end
- def dbdata=(d)
- write_attribute(:data_binary, d)
- end
-
- def dbdata
- d = read_attribute(:data_binary)
- if !d.nil?
- return d
- end
-
- d = read_attribute(:data_text)
- if !d.nil?
- return d
- end
-
- raise "internal error, double nil value in RawEmail"
- end
-
end
diff --git a/app/views/general/search.rhtml b/app/views/general/search.rhtml
index fe6229293..90ace809e 100644
--- a/app/views/general/search.rhtml
+++ b/app/views/general/search.rhtml
@@ -56,11 +56,7 @@
["all", _("everything")]]%>
<% for variety, label in labels %>
<% if @variety_postfix != variety %>
- <% if variety != "users" %>
- <%= link_to label, search_url([params[:query], @common_query], variety, @sort_postfix) %>
- <% else %>
- <%= link_to label, search_url(params[:query], variety, @sort_postfix) %>
- <% end %>
+ <%= link_to label, search_url([params[:query], variety, @sort_postfix]) %>
<% else %>
<%= label %>
<% end %>
@@ -126,9 +122,9 @@
<% if !@query.nil? %>
<p id="search_controls">
- <%=link_to_unless @sortby == 'relevant', _("Show most relevant results first"), search_url(@query, @variety_postfix, 'relevant') %>
+ <%=link_to_unless @sortby == 'relevant', _("Show most relevant results first"), search_url([params[:query], @variety_postfix, 'relevant'], params) %>
|
- <%=link_to_unless @sortby == 'newest', _("Newest results first"), search_url(@query, @variety_postfix, 'newest') %>
+ <%=link_to_unless @sortby == 'newest', _("Newest results first"), search_url([params[:query], @variety_postfix, 'newest'], params) %>
<% if @sortby == 'described' %>
| <%= _('Recently described results first') %>
<% end %>
diff --git a/app/views/request/list.rhtml b/app/views/request/list.rhtml
index 42cd41498..7cbd982f1 100644
--- a/app/views/request/list.rhtml
+++ b/app/views/request/list.rhtml
@@ -14,7 +14,7 @@
<div style="clear:both"></div>
<div class="results_section">
- <% view_cache :ttl => 5.minutes.to_i, :tag => [@query, @page, I18n.locale] do %>
+ <% view_cache :ttl => 5.minutes.to_i, :tag => [@cache_tag] do %>
<% if @list_results.empty? %>
<p> <%= _('No requests of this sort yet.')%></p>
<% else %>
diff --git a/app/views/user/show.rhtml b/app/views/user/show.rhtml
index 4fa29f00d..a4466f5f4 100644
--- a/app/views/user/show.rhtml
+++ b/app/views/user/show.rhtml
@@ -190,56 +190,56 @@
<% end %>
<% end %>
- <% if @show_profile && @is_you %>
- <% if @track_things.empty? %>
- <h2 id="email_subscriptions"> <%= _('Your email subscriptions')%></h2>
- <p><%= _('None made.')%></p>
- <% else %>
- <h2 id="email_subscriptions"> Your <%=pluralize(@track_things.size, _('email subscription')) %> </h2>
- <% if @track_things_grouped.size == 1 %>
+</div>
+<% end %>
+<% if @show_profile && @is_you %>
+ <% if @track_things.empty? %>
+ <h2 id="email_subscriptions"> <%= _('Your email subscriptions')%></h2>
+ <p><%= _('None made.')%></p>
+ <% else %>
+ <h2 id="email_subscriptions"> Your <%=pluralize(@track_things.size, _('email subscription')) %> </h2>
+ <% if @track_things_grouped.size == 1 %>
+ <% form_tag({:controller => 'track', :action => 'delete_all_type'}, :class => "feed_form") do %>
+ <h3>
+ <%=TrackThing.track_type_description(@track_things[0].track_type)%>
+ <%= hidden_field_tag 'track_type', @track_things[0].track_type %>
+ <%= hidden_field_tag 'user', @display_user.id %>
+ <%= hidden_field_tag 'r', request.request_uri %>
+ <% if @track_things.size > 1 %>
+ <%= submit_tag _('unsubscribe all') %>
+ <% end %>
+ </h3>
+ <% end %>
+ <% end %>
+ <% for track_type, track_things in @track_things_grouped %>
+ <% if @track_things_grouped.size > 1 %>
<% form_tag({:controller => 'track', :action => 'delete_all_type'}, :class => "feed_form") do %>
<h3>
- <%=TrackThing.track_type_description(@track_things[0].track_type)%>
- <%= hidden_field_tag 'track_type', @track_things[0].track_type %>
+ <%=TrackThing.track_type_description(track_type)%>
+ <%= hidden_field_tag 'track_type', track_type %>
<%= hidden_field_tag 'user', @display_user.id %>
<%= hidden_field_tag 'r', request.request_uri %>
- <% if @track_things.size > 1 %>
- <%= submit_tag _('unsubscribe all') %>
- <% end %>
+ <% if track_things.size > 1 %>
+ <%= submit_tag _('unsubscribe all')%>
+ <% end %>
</h3>
<% end %>
<% end %>
- <% for track_type, track_things in @track_things_grouped %>
- <% if @track_things_grouped.size > 1 %>
- <% form_tag({:controller => 'track', :action => 'delete_all_type'}, :class => "feed_form") do %>
- <h3>
- <%=TrackThing.track_type_description(track_type)%>
- <%= hidden_field_tag 'track_type', track_type %>
- <%= hidden_field_tag 'user', @display_user.id %>
- <%= hidden_field_tag 'r', request.request_uri %>
- <% if track_things.size > 1 %>
- <%= submit_tag _('unsubscribe all')%>
- <% end %>
- </h3>
- <% end %>
- <% end %>
- <ul>
- <% for track_thing in track_things %>
- <li>
- <% form_tag({:controller => 'track', :action => 'update', :track_id => track_thing.id}, :class => "feed_form") do %>
- <div>
- <%= track_thing.params[:list_description] %>
- <%= hidden_field_tag 'track_medium', "delete", { :id => 'track_medium_' + track_thing.id.to_s } %>
- <%= hidden_field_tag 'r', request.request_uri, { :id => 'r_' + track_thing.id.to_s } %>
- <%= submit_tag _('unsubscribe') %>
- </div>
- <% end %>
- </li>
- <% end %>
- </ul>
+ <ul>
+ <% for track_thing in track_things %>
+ <li>
+ <% form_tag({:controller => 'track', :action => 'update', :track_id => track_thing.id}, :class => "feed_form") do %>
+ <div>
+ <%= track_thing.params[:list_description] %>
+ <%= hidden_field_tag 'track_medium', "delete", { :id => 'track_medium_' + track_thing.id.to_s } %>
+ <%= hidden_field_tag 'r', request.request_uri, { :id => 'r_' + track_thing.id.to_s } %>
+ <%= submit_tag _('unsubscribe') %>
+ </div>
+ <% end %>
+ </li>
<% end %>
+ </ul>
<% end %>
<% end %>
-</div>
<% end %>
diff --git a/public/images/navimg/logo-trans.png b/public/images/navimg/logo-trans.png
index 917bec8b0..320a52efd 100644
--- a/public/images/navimg/logo-trans.png
+++ b/public/images/navimg/logo-trans.png
Binary files differ
diff --git a/public/stylesheets/main.css b/public/stylesheets/main.css
index 2d3eaa38e..ad55af570 100644
--- a/public/stylesheets/main.css
+++ b/public/stylesheets/main.css
@@ -1,7 +1,7 @@
body {
text-align:center;
color:#444;
-font-size:12px;
+font-size:15px;
font-family:Arial, sans-serif;
margin:0;
padding:0;
@@ -10,7 +10,7 @@ padding:0;
#banner {
position:absolute;
top:0;
-background-color:#EEE;
+background-color:#F3F3F3;
left:0;
width:100%;
border:none;
@@ -60,7 +60,7 @@ top:120px;
margin-left:115px;
width:auto;
font-family:Arial, sans-serif;
-font-size:18px;
+font-size:1.2em;
padding:0;
}
@@ -84,11 +84,11 @@ color:#000;
#logged_in_bar {
clear:none;
-font-size:0.8em;
+font-size:0.9em;
z-index:200;
color:#444;
top:18px;
-right:210px;
+right:22em;
float:none;
position:absolute;
padding:0.2em 10px 0.25em 1em;
@@ -135,7 +135,7 @@ clear:left;
}
h1 {
-font-size:42px;
+font-size:2.2em;
margin-bottom:15px;
margin-top:10px;
}
@@ -171,7 +171,7 @@ border:1px solid #222;
border-radius:5px;
-moz-border-radius:5px;
color:#222;
-font-size:18px;
+font-size:1.1em;
text-align:left;
width:412px;
margin:0 14em 40px 0;
@@ -223,7 +223,7 @@ margin-bottom:2em;
}
.request_listing,.body_listing,.user_listing {
-font-size:0.8em;
+font-size:0.9em;
margin-top:1.5em;
border-bottom:#9C9C9C;
overflow:hidden;
@@ -401,7 +401,6 @@ color:#FFF;
#error,.errorExplanation,#hidden_request {
color:#FF0606;
-font-size:1.4em;
font-weight:700;
background-color:#fee;
border-color:#FF0C11;
@@ -424,7 +423,7 @@ border-width:1px;
padding:0.2em;
}
-#notice,.describe_state_form,.undescribed_requests,.gone_postal_help {
+#notice, {
color:#16C132;
font-size:1.4em;
font-weight:700;
@@ -487,7 +486,7 @@ div[id|="outgoing"] p {
}
div[id|="incoming"] {
-background-color:#DEDEDE;
+background-color:#F3F3F3;
}
div[id|="incoming"] p {
@@ -712,13 +711,13 @@ padding:0.5em 0;
background-color:#fc9;
border:solid 2px #f60;
border-top:none;
-opacity:0.97px;
--moz-border-radius-bottomleft:10px;
--moz-border-radius-bottomright:10px;
+opacity:0.97;
+border-bottom-left-radius:10px;
+border-bottom-right-radius:10px;
position:fixed;
width:70%;
left:15%;
-z-index:200;
+z-index:2000;
max-height:95%;
overflow:auto;
padding:4px;
@@ -878,12 +877,12 @@ text-decoration:none;
}
h2,dt {
-font-size:21px;
+font-size:1.8em;
}
h3 {
text-decoration:none;
-font-size:20px;
+font-size:1.6em;
margin-top:3px;
margin-bottom:10px;
}
@@ -902,7 +901,7 @@ margin:auto;
position:absolute;
left:0;
top:70px;
-z-index:100;
+z-index:1000;
}
a img {
@@ -916,7 +915,6 @@ margin-left:-4px;
}
#navigation_search input[type=text] {
-font-size:12px;
border-radius:5px 0 0 5px;
-moz-border-radius:5px 0 0 5px;
border-color:#222;
@@ -951,7 +949,7 @@ margin-left:6px;
p.subtitle {
margin-top:10px;
margin-bottom:20px;
-font-size:18px;
+font-size:1.2em;
font-style:normal;
color:#222;
}
@@ -973,27 +971,25 @@ padding:12px 0 6px;
.request_listing span.head,.user_listing span.head,.body_listing span.head {
background:none;
-font-size:21px;
+font-size: 1.5em;
margin-bottom:6px;
padding:0;
}
.request_listing span.head a,.user_listing span.head a,.body_listing span.head a {
text-decoration:none;
-font-size:20px;
+font-size:1.3em;
margin-top:3px;
display:block;
margin-bottom:-6px;
}
.request_listing .requester {
-font-size:12px;
padding-bottom:0;
}
.body_listing span.desc,.body_listing span.bottomline,.user_listing span.bottomline {
font-style:normal;
-font-size:12px;
font-weight:400;
margin:0;
padding:0;
@@ -1004,7 +1000,7 @@ font-style:normal;
margin-bottom:0;
margin-top:12px;
background-position:top left;
-font-size:14px;
+font-size:1.1em;
font-weight:400;
min-height:36px;
padding:3px 0 0 27px;
@@ -1022,7 +1018,6 @@ color:#C1272D;
#request_sidebar {
width:212px;
-font-size:12px;
}
.feed_link {
@@ -1032,7 +1027,6 @@ padding:4px 0;
.request_listing span.desc {
background:url(/images/quote-marks.png) no-repeat;
min-height:60px;
-font-size:12px;
width:auto;
color:#444;
line-height:18px;
@@ -1072,7 +1066,6 @@ padding-right:2px;
}
form.feed_form input[type="submit"] {
-font-size:12px;
line-height:12px;
padding:2px 4px;
}
@@ -1113,7 +1106,7 @@ padding-bottom:5px;
}
#request_form label,label.form_label,span#to_public_body {
-font-size:18px;
+font-size: 1.1em;
}
#date_range label,#filter_requests_form label {
@@ -1187,7 +1180,7 @@ width:10%;
height:100px;
text-align:center;
margin-top:45px;
-font-size:16px;
+font-size:1.2em;
font-family:Georgia;
font-style:italic;
color:#444;
@@ -1203,7 +1196,7 @@ margin-left:10.5em;
}
form input[type=text],form input[type=password] {
-font-size:14px;
+font-size:1.1em;
width:200px;
color:#555;
border-radius:3px;
@@ -1219,7 +1212,7 @@ width:130px !important;
background:url(/images/calendar.png) no-repeat 115px 3px;
border-radius:3px !important;
-moz-border-radius:3px !important;
-font-size:14px !important;
+font-size:1.1em !important;
margin:0 !important;
}
@@ -1233,20 +1226,20 @@ border:solid 1px #69952F;
border-radius:2px;
-moz-border-radius:2px;
text-shadow:1px 1px 0 #5B841D;
-font-size:18px;
+font-size:14px;
cursor:hand;
padding:5px 11px;
}
a.link_button_green_large {
background:url(/images/button-gradient-large.png);
-font-size:22px;
+font-size:2em;
line-height:22px;
padding-bottom:7px;
}
form input[type=submit].small {
-font-size:15px;
+font-size:1.1em;
line-height:10px;
padding:4px 9px;
}
@@ -1281,7 +1274,6 @@ border:1px solid #DEBEDD;
border-radius:5px;
-moz-border-radius:5px;
color:#DDD;
-font-size:18px;
text-align:center;
width:255px;
height:210px;
@@ -1314,7 +1306,6 @@ padding:5px 0;
#frontpage_examples .excerpt {
cursor:pointer;
background:url(/images/quote-marks.png) no-repeat;
-font-size:12px;
color:#444;
line-height:18px;
min-height:30px;
@@ -1328,7 +1319,6 @@ background:url(/images/defaultprofilepic.png);
div.correspondence,div.comment_in_request {
width:600px;
-font-size:13px;
border-radius:6px;
-moz-border-radius:6px;
border-width:1px;
@@ -1336,11 +1326,10 @@ padding:4px 20px 0 9px;
}
div.outgoing.correspondence {
- background: #EFEFEF;
+ background: #FFFFD2;
}
div[id|="comment"] p {
-font-size:13px;
}
div.comment_in_request {
@@ -1489,7 +1478,7 @@ opacity:1px;
#other-country-notice {
background:#222;
color:#FFF;
-font-size:16px;
+font-size:1.1em;
width:100%;
z-index:999;
display:block;
@@ -1502,7 +1491,7 @@ p.public-body-name-prefix {
color:#888;
margin-top:15px;
margin-bottom:-15px;
-font-size: 16px;
+font-size: 1.2em;
}
#other-country-notice a {
@@ -1565,14 +1554,12 @@ border:solid 1px Red !important;
.errorExplanation {
border-radius:6px;
-moz-border-radius:6px;
-font-size:12px;
font-weight:400;
width:554px;
margin:20px 0 30px;
}
#notice,.describe_state_form,#other_recipients {
-font-size:12px;
font-weight:400;
background:#E9FDD3 !important;
color:#517704;
@@ -1603,7 +1590,7 @@ margin-bottom:0;
}
div.correspondence p.preview_subject {
-font-size:18px !important;
+font-size:1.2em !important;
margin-left:10px;
line-height:25px;
}
diff --git a/script/load-sample-data b/script/load-sample-data
index 0521ef849..84b8a28eb 100755
--- a/script/load-sample-data
+++ b/script/load-sample-data
@@ -6,7 +6,15 @@
LOC=`dirname $0`
rake --silent spec:db:fixtures:load
-"$LOC/runner" 'puts File.expand_path(File.dirname(__FILE__) + "/spec/spec_helper"); require File.expand_path(File.dirname(__FILE__) + "/spec/spec_helper"); RawEmail.all().each {|email| email.data = load_file_fixture("useless_raw_email.email")}'
+"$LOC/runner" /dev/stdin <<END
+env = ENV["RAILS_ENV"]
+require "spec/spec_helper.rb" # Sets RAILS_ENV to 'test'
+ENV["RAILS_ENV"] = env
+RawEmail.all().each do |email|
+ puts "Writing #{email.filepath}"
+ email.data = load_file_fixture("useless_raw_email.email")
+end
+END
-echo "Loaded fixtures." \ No newline at end of file
+echo "Loaded fixtures."
diff --git a/script/rebuild-xapian-index b/script/rebuild-xapian-index
index 11e4a46be..5986f5259 100755
--- a/script/rebuild-xapian-index
+++ b/script/rebuild-xapian-index
@@ -1,6 +1,4 @@
#!/bin/bash
cd `dirname $0`
-rake --silent xapian:rebuild_index models="PublicBody User InfoRequestEvent"
-
-
+rake --silent "$@" xapian:rebuild_index models="PublicBody User InfoRequestEvent"
diff --git a/script/spec-all-pairs b/script/spec-all-pairs
index 0d83f5837..6f27e6b8e 100755
--- a/script/spec-all-pairs
+++ b/script/spec-all-pairs
@@ -3,18 +3,64 @@
# Try all ordered pairs of spec files,
# to winkle out order-dependent failures.
-specs=spec/*/*.rb
+test_pair () {
+ rake db:test:purge > /dev/null
+ rake db:test:clone_structure > /dev/null
+ if script/spec "$1" "$2" > /dev/null 2>&1
+ then
+ echo "OK: $1 $2"
+ return 0
+ else
+ echo "FAILED: $1 $2"
+ return 1
+ fi
+}
-for spec1 in $specs
-do
- seen=false
- for spec2 in $specs
+all_pairs() {
+ specs=spec/*/*.rb
+
+ for spec1 in $specs
+ do
+ all_okay=true
+ for spec2 in $specs
+ do
+ if ! test_pair "$spec1" "$spec2"
+ then
+ all_okay=false
+ fi
+ done
+ done
+
+ $all_okay
+ return $?
+}
+
+pairs_from_stdin() {
+ all_okay=true
+ while read line
do
- rake db:test:purge > /dev/null
- rake db:test:clone_structure > /dev/null
- if ! ( script/spec "$spec1" "$spec2" ) > /dev/null 2>&1
- then
- echo "FAILED: $spec1 $spec2"
- fi
+ case "$line" in
+ \*\ FAILED:\ *)
+ line=${line#\* FAILED: }
+ if ! test_pair $line
+ then
+ all_okay=false
+ fi
+ ;;
+ *)
+ echo "No match: $line"
+ ;;
+ esac
done
-done
+
+ $all_okay
+ return $?
+}
+
+if [ "$1" = "-" ]
+then
+ pairs_from_stdin
+else
+ all_pairs
+fi
+exit $? \ No newline at end of file
diff --git a/spec/controllers/admin_user_controller_spec.rb b/spec/controllers/admin_user_controller_spec.rb
index b2b2d0626..55b49f9da 100644
--- a/spec/controllers/admin_user_controller_spec.rb
+++ b/spec/controllers/admin_user_controller_spec.rb
@@ -2,7 +2,7 @@ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
describe AdminUserController, "when administering users" do
integrate_views
- fixtures :users, :info_requests, :incoming_messages, :outgoing_messages, :comments, :info_request_events, :track_things
+ fixtures :users, :info_requests, :incoming_messages, :outgoing_messages, :comments, :info_request_events, :track_things, :public_bodies, :public_body_versions, :public_body_translations
before { basic_auth_login @request }
it "shows the index/list page" do
diff --git a/spec/controllers/general_controller_spec.rb b/spec/controllers/general_controller_spec.rb
index bcd577484..2750a33f3 100644
--- a/spec/controllers/general_controller_spec.rb
+++ b/spec/controllers/general_controller_spec.rb
@@ -35,6 +35,7 @@ describe GeneralController, "when searching" do
before(:each) do
load_raw_emails_data(raw_emails)
+ rebuild_xapian_index
end
it "should render the front page successfully" do
@@ -111,7 +112,8 @@ describe GeneralController, "when searching" do
describe 'when using xapian search' do
# rebuild xapian index after fixtures loaded
- before(:all) do
+ before(:each) do
+ load_raw_emails_data(raw_emails)
rebuild_xapian_index
end
diff --git a/spec/controllers/request_controller_spec.rb b/spec/controllers/request_controller_spec.rb
index 6c6ccc76a..055c9b3d4 100644
--- a/spec/controllers/request_controller_spec.rb
+++ b/spec/controllers/request_controller_spec.rb
@@ -39,6 +39,11 @@ describe RequestController, "when listing recent requests" do
assigns[:list_results].size.should == 1
end
+ it "should make a sane-sized cache tag" do
+ get :list, :view => 'all', :request_date_after => '13/10/2007', :request_date_before => '01/11/2007'
+ assigns[:cache_tag].size.should <= 32
+ end
+
it "should list internal_review requests as unresolved ones" do
get :list, :view => 'awaiting'
assigns[:list_results].size.should == 0
@@ -103,24 +108,40 @@ describe RequestController, "when showing one request" do
describe 'when handling an update_status parameter' do
-
- before do
- mock_request = mock_model(InfoRequest, :url_title => 'test_title',
- :title => 'test title',
- :null_object => true)
- InfoRequest.stub!(:find_by_url_title).and_return(mock_request)
- end
-
it 'should assign the "update status" flag to the view as true if the parameter is present' do
- get :show, :url_title => 'test_title', :update_status => 1
+ get :show, :url_title => 'why_do_you_have_such_a_fancy_dog', :update_status => 1
assigns[:update_status].should be_true
end
- it 'should assign the "update status" flag to the view as true if the parameter is present' do
- get :show, :url_title => 'test_title'
+ it 'should assign the "update status" flag to the view as false if the parameter is not present' do
+ get :show, :url_title => 'why_do_you_have_such_a_fancy_dog'
assigns[:update_status].should be_false
end
+ it 'should require login' do
+ session[:user_id] = nil
+ get :show, :url_title => 'why_do_you_have_such_a_fancy_dog', :update_status => 1
+ post_redirect = PostRedirect.get_last_post_redirect
+ response.should redirect_to(:controller => 'user', :action => 'signin', :token => post_redirect.token)
+ end
+
+ it 'should work if logged in as the requester' do
+ session[:user_id] = users(:bob_smith_user).id
+ get :show, :url_title => 'why_do_you_have_such_a_fancy_dog', :update_status => 1
+ response.should render_template "request/show"
+ end
+
+ it 'should not work if logged in as not the requester' do
+ session[:user_id] = users(:silly_name_user).id
+ get :show, :url_title => 'why_do_you_have_such_a_fancy_dog', :update_status => 1
+ response.should render_template "user/wrong_user"
+ end
+
+ it 'should work if logged in as an admin user' do
+ session[:user_id] = users(:admin_user).id
+ get :show, :url_title => 'why_do_you_have_such_a_fancy_dog', :update_status => 1
+ response.should render_template "request/show"
+ end
end
describe 'when handling incoming mail' do
@@ -190,6 +211,15 @@ describe RequestController, "when showing one request" do
get :get_attachment_as_html, :incoming_message_id => ir.incoming_messages[1].id, :id => ugly_id, :part => 2, :file_name => ['hello.txt.html'], :skip_cache => 1
}.should raise_error(ActiveRecord::RecordNotFound)
end
+ it "should return 404 when incoming message and request ids don't match " do
+ ir = info_requests(:fancy_dog_request)
+ wrong_id = info_requests(:naughty_chicken_request).id
+ receive_incoming_mail('incoming-request-two-same-name.email', ir.incoming_email)
+ ir.reload
+ lambda {
+ get :get_attachment_as_html, :incoming_message_id => ir.incoming_messages[1].id, :id => wrong_id, :part => 2, :file_name => ['hello.txt.html'], :skip_cache => 1
+ }.should raise_error(ActiveRecord::RecordNotFound)
+ end
it "should generate valid HTML verson of PDF attachments " do
ir = info_requests(:fancy_dog_request)
@@ -339,14 +369,19 @@ describe RequestController, "when showing one request" do
zipfile = Zip::ZipFile.open(File.join(File.dirname(__FILE__), "../../cache/zips", old_path)) { |zipfile|
zipfile.count.should == 3 # the message plus two "hello.txt" files
}
+
+ # The path of the zip file is based on the hash of the timestamp of the last request
+ # in the thread, so we wait for a second to make sure this one will have a different
+ # timestamp than the previous.
+ sleep 1
receive_incoming_mail('incoming-request-attachment-unknown-extension.email', ir.incoming_email)
get :download_entire_request, :url_title => title
assigns[:url_path].should have_text(/#{title}.zip$/)
+ assigns[:url_path].should_not == old_path
response.location.should have_text(/#{assigns[:url_path]}/)
zipfile = Zip::ZipFile.open(File.join(File.dirname(__FILE__), "../../cache/zips", assigns[:url_path])) { |zipfile|
zipfile.count.should == 5 # the message, two hello.txt, the unknown attachment, and its empty message
}
- assigns[:url_path].should_not == old_path
end
end
end
diff --git a/spec/controllers/user_controller_spec.rb b/spec/controllers/user_controller_spec.rb
index d8e92fbd0..a90fa18df 100644
--- a/spec/controllers/user_controller_spec.rb
+++ b/spec/controllers/user_controller_spec.rb
@@ -11,6 +11,7 @@ describe UserController, "when showing a user" do
fixtures :users, :public_bodies, :public_body_translations, :public_body_versions, :info_requests, :raw_emails, :incoming_messages, :outgoing_messages, :comments, :info_request_events, :track_things
before(:each) do
load_raw_emails_data(raw_emails)
+ rebuild_xapian_index
end
it "should be successful" do
@@ -542,6 +543,13 @@ describe UserController, "when using profile photos" do
post :set_profile_photo, { :id => @user.id, :file => @uploadedfile, :submitted_draft_profile_photo => 1, :automatically_crop => 1 }
end
+ it "should return a 404 not a 500 when a profile photo has not been set" do
+ @user.profile_photo.should be_nil
+ lambda {
+ get :get_profile_photo, {:url_name => @user.url_name }
+ }.should raise_error(ActiveRecord::RecordNotFound)
+ end
+
it "should let you change profile photo if you're logged in as the user" do
@user.profile_photo.should be_nil
session[:user_id] = @user.id
diff --git a/spec/integration/search_request_spec.rb b/spec/integration/search_request_spec.rb
index 5733dea22..d0a457923 100644
--- a/spec/integration/search_request_spec.rb
+++ b/spec/integration/search_request_spec.rb
@@ -19,6 +19,7 @@ describe "When searching" do
before(:each) do
emails = raw_emails.clone
load_raw_emails_data(emails)
+ rebuild_xapian_index
end
it "should not strip quotes from quoted query" do
@@ -45,19 +46,19 @@ describe "When searching" do
end
it "should correctly filter searches for successful requests" do
- request_via_redirect("post", "/search",
+ request_via_redirect("post", "/search/requests",
:query => "bob",
:latest_status => ['successful'])
response.body.should include("no results matching your query")
end
it "should correctly filter searches for comments" do
- request_via_redirect("post", "/search",
+ request_via_redirect("post", "/search/requests",
:query => "daftest",
:request_variety => ['comments'])
response.body.should include("One FOI request found")
- request_via_redirect("post", "/search",
+ request_via_redirect("post", "/search/requests",
:query => "daftest",
:request_variety => ['response','sent'])
response.body.should include("no results matching your query")
diff --git a/spec/lib/sendmail_return_path_spec.rb b/spec/lib/sendmail_return_path_spec.rb
index f1a91240b..7708edb35 100644
--- a/spec/lib/sendmail_return_path_spec.rb
+++ b/spec/lib/sendmail_return_path_spec.rb
@@ -3,6 +3,7 @@
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
describe "when sending email with an altered return path" do
+ before(:each) { ActionMailer::Base.deliveries = [] }
it "should default to delivery method test" do
ActionMailer::Base.delivery_method.should == :test
diff --git a/spec/models/request_mailer_spec.rb b/spec/models/request_mailer_spec.rb
index ef4ed8074..2888213d7 100644
--- a/spec/models/request_mailer_spec.rb
+++ b/spec/models/request_mailer_spec.rb
@@ -4,6 +4,7 @@ describe RequestMailer, " when receiving incoming mail" do
fixtures :public_bodies, :public_body_translations, :public_body_versions, :users, :info_requests, :raw_emails, :incoming_messages, :outgoing_messages, :comments, :info_request_events, :track_things
before(:each) do
load_raw_emails_data(raw_emails)
+ ActionMailer::Base.deliveries = []
end
it "should append it to the appropriate request" do
diff --git a/spec/models/track_mailer_spec.rb b/spec/models/track_mailer_spec.rb
index 67a64ee10..4f5499a90 100644
--- a/spec/models/track_mailer_spec.rb
+++ b/spec/models/track_mailer_spec.rb
@@ -155,6 +155,7 @@ describe TrackMailer do
@post_redirect = mock_model(PostRedirect, :save! => true,
:email_token => "token")
PostRedirect.stub!(:new).and_return(@post_redirect)
+ ActionMailer::Base.deliveries = []
end
it 'should deliver one email, with right headers' do
diff --git a/spec/models/xapian_spec.rb b/spec/models/xapian_spec.rb
index ebd6b1890..412146b53 100644
--- a/spec/models/xapian_spec.rb
+++ b/spec/models/xapian_spec.rb
@@ -3,17 +3,19 @@ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
describe User, " when indexing users with Xapian" do
fixtures :public_bodies, :public_body_translations, :public_body_versions, :users, :info_requests, :raw_emails, :incoming_messages, :outgoing_messages, :comments, :info_request_events, :track_things
- it "should search by name" do
- parse_all_incoming_messages
+ before(:each) do
+ load_raw_emails_data(raw_emails)
rebuild_xapian_index
- # def InfoRequest.full_search(models, query, order, ascending, collapse, per_page, page)
+ end
+
+ it "should search by name" do
+ # def InfoRequest.full_search(models, query, order, ascending, collapse, per_page, page)
xapian_object = InfoRequest.full_search([User], "Silly", 'created_at', true, nil, 100, 1)
xapian_object.results.size.should == 1
xapian_object.results[0][:model].should == users(:silly_name_user)
end
it "should search by 'about me' text" do
- rebuild_xapian_index
user = users(:bob_smith_user)
# def InfoRequest.full_search(models, query, order, ascending, collapse, per_page, page)
@@ -38,27 +40,22 @@ describe PublicBody, " when indexing public bodies with Xapian" do
fixtures :public_bodies, :public_body_translations, :public_body_versions, :users, :info_requests, :raw_emails, :incoming_messages, :outgoing_messages, :comments, :info_request_events, :track_things
before(:each) do
load_raw_emails_data(raw_emails)
+ rebuild_xapian_index
end
it "should search index the main name field" do
- rebuild_xapian_index
-
xapian_object = InfoRequest.full_search([PublicBody], "humpadinking", 'created_at', true, nil, 100, 1)
xapian_object.results.size.should == 1
xapian_object.results[0][:model].should == public_bodies(:humpadink_public_body)
end
it "should search index the notes field" do
- rebuild_xapian_index
-
xapian_object = InfoRequest.full_search([PublicBody], "albatross", 'created_at', true, nil, 100, 1)
xapian_object.results.size.should == 1
xapian_object.results[0][:model].should == public_bodies(:humpadink_public_body)
end
it "should delete public bodies from the index when they are destroyed" do
- rebuild_xapian_index
-
xapian_object = InfoRequest.full_search([PublicBody], "albatross", 'created_at', true, nil, 100, 1)
xapian_object.results.size.should == 1
xapian_object.results[0][:model].should == public_bodies(:humpadink_public_body)
@@ -80,17 +77,16 @@ describe PublicBody, " when indexing requests by body they are to" do
before(:each) do
load_raw_emails_data(raw_emails)
+ rebuild_xapian_index
end
it "should find requests to the body" do
- rebuild_xapian_index
xapian_object = InfoRequest.full_search([InfoRequestEvent], "requested_from:tgq", 'created_at', true, nil, 100, 1)
xapian_object.results.size.should == 4
end
it "should update index correctly when URL name of body changes" do
# initial search
- rebuild_xapian_index
xapian_object = InfoRequest.full_search([InfoRequestEvent], "requested_from:tgq", 'created_at', true, nil, 100, 1)
xapian_object.results.size.should == 4
models_found_before = xapian_object.results.map { |x| x[:model] }
@@ -115,8 +111,6 @@ describe PublicBody, " when indexing requests by body they are to" do
# if you index via the Xapian TermGenerator, it ignores terms of this length,
# this checks we're using Document:::add_term() instead
it "should work with URL names that are longer than 64 characters" do
- rebuild_xapian_index
-
# change the URL name of the body
body = public_bodies(:geraldine_public_body)
body.short_name = 'The Uncensored, Complete Name of the Quasi-Autonomous Public Body Also Known As Geraldine'
@@ -139,16 +133,15 @@ describe User, " when indexing requests by user they are from" do
fixtures :users, :info_requests, :raw_emails, :incoming_messages, :outgoing_messages, :comments, :info_request_events, :track_things
before(:each) do
load_raw_emails_data(raw_emails)
+ rebuild_xapian_index
end
it "should find requests from the user" do
- rebuild_xapian_index
xapian_object = InfoRequest.full_search([InfoRequestEvent], "requested_by:bob_smith", 'created_at', true, nil, 100, 1)
xapian_object.results.size.should == 5
end
it "should find just the sent message events from a particular user" do
- rebuild_xapian_index
# def InfoRequest.full_search(models, query, order, ascending, collapse, per_page, page)
xapian_object = InfoRequest.full_search([InfoRequestEvent], "requested_by:bob_smith variety:sent", 'created_at', true, nil, 100, 1)
xapian_object.results.size.should == 3
@@ -157,7 +150,6 @@ describe User, " when indexing requests by user they are from" do
end
it "should not find it when one of the request's users is changed" do
- rebuild_xapian_index
silly_user = users(:silly_name_user)
naughty_chicken_request = info_requests(:naughty_chicken_request)
naughty_chicken_request.user = silly_user
@@ -172,8 +164,6 @@ describe User, " when indexing requests by user they are from" do
end
it "should not get confused searching for requests when one user has a name which has same stem as another" do
- rebuild_xapian_index
-
bob_smith_user = users(:bob_smith_user)
bob_smith_user.name = "John King"
bob_smith_user.url_name.should == 'john_king'
@@ -199,7 +189,6 @@ describe User, " when indexing requests by user they are from" do
it "should update index correctly when URL name of user changes" do
# initial search
- rebuild_xapian_index
xapian_object = InfoRequest.full_search([InfoRequestEvent], "requested_by:bob_smith", 'created_at', true, nil, 100, 1)
xapian_object.results.size.should == 5
models_found_before = xapian_object.results.map { |x| x[:model] }
@@ -226,17 +215,16 @@ describe User, " when indexing comments by user they are by" do
fixtures :users, :info_requests, :raw_emails, :incoming_messages, :outgoing_messages, :comments, :info_request_events, :track_things
before(:each) do
load_raw_emails_data(raw_emails)
+ rebuild_xapian_index
end
it "should find requests from the user" do
- rebuild_xapian_index
xapian_object = InfoRequest.full_search([InfoRequestEvent], "commented_by:silly_emnameem", 'created_at', true, nil, 100, 1)
xapian_object.results.size.should == 1
end
it "should update index correctly when URL name of user changes" do
# initial search
- rebuild_xapian_index
xapian_object = InfoRequest.full_search([InfoRequestEvent], "commented_by:silly_emnameem", 'created_at', true, nil, 100, 1)
xapian_object.results.size.should == 1
models_found_before = xapian_object.results.map { |x| x[:model] }
@@ -263,10 +251,10 @@ describe InfoRequest, " when indexing requests by their title" do
fixtures :users, :info_requests, :raw_emails, :incoming_messages, :outgoing_messages, :comments, :info_request_events, :track_things
before(:each) do
load_raw_emails_data(raw_emails)
+ rebuild_xapian_index
end
it "should find events for the request" do
- rebuild_xapian_index
xapian_object = InfoRequest.full_search([InfoRequestEvent], "request:how_much_public_money_is_wasted_o", 'created_at', true, nil, 100, 1)
xapian_object.results.size.should == 1
xapian_object.results[0][:model] == info_request_events(:silly_outgoing_message_event)
@@ -274,7 +262,6 @@ describe InfoRequest, " when indexing requests by their title" do
it "should update index correctly when URL title of request changes" do
# change the URL name of the body
- rebuild_xapian_index
ir = info_requests(:naughty_chicken_request)
ir.title = 'Really naughty'
ir.save!
@@ -294,10 +281,10 @@ describe InfoRequest, " when indexing requests by tag" do
fixtures :users, :info_requests, :raw_emails, :incoming_messages, :outgoing_messages, :comments, :info_request_events, :track_things
before(:each) do
load_raw_emails_data(raw_emails)
+ rebuild_xapian_index
end
it "should find request by tag, even when changes" do
- rebuild_xapian_index
ir = info_requests(:naughty_chicken_request)
ir.tag_string = 'bunnyrabbit'
ir.save!
@@ -316,10 +303,10 @@ describe PublicBody, " when indexing authorities by tag" do
fixtures :public_bodies, :public_body_translations, :public_body_versions, :users, :info_requests, :raw_emails, :incoming_messages, :outgoing_messages, :comments, :info_request_events, :track_things
before(:each) do
load_raw_emails_data(raw_emails)
+ rebuild_xapian_index
end
it "should find request by tag, even when changes" do
- rebuild_xapian_index
body = public_bodies(:geraldine_public_body)
body.tag_string = 'mice:3'
body.save!
@@ -341,10 +328,10 @@ describe PublicBody, " when only indexing selected things on a rebuild" do
fixtures :public_bodies, :public_body_translations, :public_body_versions, :users, :info_requests, :raw_emails, :incoming_messages, :outgoing_messages, :comments, :info_request_events, :track_things
before(:each) do
load_raw_emails_data(raw_emails)
+ rebuild_xapian_index
end
it "should only index what we ask it to" do
- rebuild_xapian_index
body = public_bodies(:geraldine_public_body)
body.tag_string = 'mice:3'
body.name = 'frobzn'
@@ -396,14 +383,3 @@ describe PublicBody, " when only indexing selected things on a rebuild" do
end
end
-
-
-
-
-
-
-
-
-
-
-