aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.travis.yml2
-rw-r--r--Gemfile4
-rw-r--r--Gemfile.lock29
-rw-r--r--app/controllers/application_controller.rb30
-rw-r--r--app/controllers/general_controller.rb4
-rw-r--r--app/controllers/public_body_controller.rb6
-rw-r--r--app/controllers/request_controller.rb3
-rwxr-xr-xapp/helpers/link_to_helper.rb8
-rw-r--r--app/views/admin_general/debug.rhtml2
-rw-r--r--app/views/general/_frontpage_search_box.rhtml2
-rw-r--r--app/views/general/_locale_switcher.rhtml2
-rw-r--r--app/views/general/exception_caught.rhtml4
-rw-r--r--app/views/general/search.rhtml2
-rw-r--r--app/views/layouts/default.rhtml2
-rw-r--r--app/views/public_body/list.rhtml2
-rw-r--r--app/views/request/_sidebar.rhtml2
-rw-r--r--app/views/request/select_authority.rhtml2
-rw-r--r--app/views/user/show.rhtml2
-rw-r--r--spec/controllers/admin_censor_rule_controller_spec.rb10
-rw-r--r--spec/controllers/public_body_controller_spec.rb5
-rw-r--r--spec/controllers/request_controller_spec.rb4
-rw-r--r--spec/models/purge_request_spec.rb9
-rw-r--r--spec/models/request_mailer_spec.rb1
-rw-r--r--spec/script/mailin_spec.rb8
24 files changed, 74 insertions, 71 deletions
diff --git a/.travis.yml b/.travis.yml
index ffcfdbaa9..2f06f6cd9 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -13,6 +13,8 @@ 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/general.yml-example config/general.yml
+ - cp config/newrelic.yml-example config/newrelic.yml
- sudo apt-get update
- export DEBIAN_FRONTEND=noninteractive
- sudo apt-get -y install exim4-daemon-light
diff --git a/Gemfile b/Gemfile
index 460043793..7cd8c22dc 100644
--- a/Gemfile
+++ b/Gemfile
@@ -17,7 +17,7 @@ gem 'fast_gettext', '>= 0.6.0'
gem 'fastercsv', '>=1.5.5'
gem 'gettext_i18n_rails', '>= 0.7.1'
gem 'gettext', '~> 2.3.3'
-gem 'json', '~> 1.5.5'
+gem 'json'
gem 'mahoro'
gem 'mail', :platforms => :ruby_19
gem 'memcache-client', :require => 'memcache'
@@ -25,7 +25,7 @@ gem 'locale', '>= 2.0.5'
gem 'net-http-local'
gem 'net-purge'
gem 'rack', '~> 1.1.0'
-gem 'rdoc', '~> 2.4.3'
+gem 'rdoc'
gem 'recaptcha', '~> 0.3.1', :require => 'recaptcha/rails'
# :require avoids "already initialized constant" warnings
gem 'rmagick', :require => 'RMagick'
diff --git a/Gemfile.lock b/Gemfile.lock
index 28aa68468..25b156184 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -27,7 +27,7 @@ GEM
annotate (2.4.0)
archive-tar-minitar (0.5.2)
bootstrap-sass (2.1.1.0)
- capistrano (2.13.4)
+ capistrano (2.14.2)
highline
net-scp (>= 1.0.0)
net-sftp (>= 2.0.0)
@@ -51,11 +51,11 @@ GEM
gettext_i18n_rails (0.7.1)
fast_gettext (>= 0.4.8)
haml (3.1.7)
- highline (1.6.13)
+ highline (1.6.15)
hoe (3.0.8)
rake (~> 0.8)
i18n (0.6.1)
- json (1.5.5)
+ json (1.7.7)
linecache (0.46)
rbx-require-relative (> 0.0.4)
linecache19 (0.5.12)
@@ -80,20 +80,21 @@ GEM
mime-types (1.19)
net-http-local (0.1.2)
net-purge (0.1.0)
- net-scp (1.0.4)
- net-ssh (>= 1.99.1)
- net-sftp (2.0.5)
- net-ssh (>= 2.0.9)
- net-ssh (2.5.2)
- net-ssh-gateway (1.1.0)
- net-ssh (>= 1.99.1)
+ net-scp (1.1.0)
+ net-ssh (>= 2.6.5)
+ net-sftp (2.1.1)
+ net-ssh (>= 2.6.5)
+ net-ssh (2.6.5)
+ net-ssh-gateway (1.2.0)
+ net-ssh (>= 2.6.5)
newrelic_rpm (3.5.4.34)
pg (0.13.2)
polyglot (0.3.3)
- rack (1.1.5)
+ rack (1.1.6)
rake (0.9.2.2)
rbx-require-relative (0.0.9)
- rdoc (2.4.3)
+ rdoc (3.12.1)
+ json (~> 1.4)
recaptcha (0.3.4)
rmagick (2.13.1)
routing-filter (0.2.4)
@@ -162,7 +163,7 @@ DEPENDENCIES
fastercsv (>= 1.5.5)
gettext (~> 2.3.3)
gettext_i18n_rails (>= 0.7.1)
- json (~> 1.5.5)
+ json
locale (>= 2.0.5)
mahoro
mail
@@ -175,7 +176,7 @@ DEPENDENCIES
rack (~> 1.1.0)
rails!
rake (= 0.9.2.2)
- rdoc (~> 2.4.3)
+ rdoc
recaptcha (~> 0.3.1)
rmagick
routing-filter (~> 0.2.4)
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb
index ed1523f75..f3deeb64a 100644
--- a/app/controllers/application_controller.rb
+++ b/app/controllers/application_controller.rb
@@ -456,11 +456,7 @@ class ApplicationController < ActionController::Base
end
end
- def param_exists(item)
- return params[item] && !params[item].empty?
- end
-
- def get_request_variety_from_params
+ def get_request_variety_from_params(params)
query = ""
sortby = "newest"
varieties = []
@@ -482,7 +478,7 @@ class ApplicationController < ActionController::Base
return query
end
- def get_status_from_params
+ def get_status_from_params(params)
query = ""
if params[:latest_status]
statuses = []
@@ -517,24 +513,24 @@ class ApplicationController < ActionController::Base
return query
end
- def get_date_range_from_params
+ def get_date_range_from_params(params)
query = ""
- if param_exists(:request_date_after) && !param_exists(:request_date_before)
+ if params.has_key?(:request_date_after) && !params.has_key?(:request_date_before)
params[:request_date_before] = Time.now.strftime("%d/%m/%Y")
query += " #{params[:request_date_after]}..#{params[:request_date_before]}"
- elsif !param_exists(:request_date_after) && param_exists(:request_date_before)
+ elsif !params.has_key?(:request_date_after) && params.has_key?(:request_date_before)
params[:request_date_after] = "01/01/2001"
end
- if param_exists(:request_date_after)
+ if params.has_key?(:request_date_after)
query = " #{params[:request_date_after]}..#{params[:request_date_before]}"
end
return query
end
- def get_tags_from_params
+ def get_tags_from_params(params)
query = ""
tags = []
- if param_exists(:tags)
+ if params.has_key?(:tags)
params[:tags].split().each do |tag|
tags << "tag:#{tag}"
end
@@ -545,12 +541,12 @@ class ApplicationController < ActionController::Base
return query
end
- def make_query_from_params
+ def make_query_from_params(params)
query = params[:query] || "" if query.nil?
- query += get_date_range_from_params
- query += get_request_variety_from_params
- query += get_status_from_params
- query += get_tags_from_params
+ query += get_date_range_from_params(params)
+ query += get_request_variety_from_params(params)
+ query += get_status_from_params(params)
+ query += get_tags_from_params(params)
return query
end
diff --git a/app/controllers/general_controller.rb b/app/controllers/general_controller.rb
index 875e39494..a8bbc22ff 100644
--- a/app/controllers/general_controller.rb
+++ b/app/controllers/general_controller.rb
@@ -151,10 +151,10 @@ class GeneralController < ApplicationController
params[:query] = @query
end
if @variety_postfix != "all" && @requests
- @query, _ = make_query_from_params
+ @query, _ = make_query_from_params(params)
end
@inputted_sortby = @sortby
- @common_query = get_tags_from_params
+ @common_query = get_tags_from_params(params)
if @sortby.nil?
# Parse query, so can work out if it has prefix terms only - if so then it is a
# structured query which should show newest first, rather than a free text search
diff --git a/app/controllers/public_body_controller.rb b/app/controllers/public_body_controller.rb
index 8a4a65820..1bcc0145c 100644
--- a/app/controllers/public_body_controller.rb
+++ b/app/controllers/public_body_controller.rb
@@ -25,7 +25,7 @@ class PublicBodyController < ApplicationController
end
# If found by historic name, or alternate locale name, redirect to new name
if @public_body.url_name != params[:url_name]
- redirect_to show_public_body_url(:url_name => @public_body.url_name)
+ redirect_to :url_name => @public_body.url_name
return
end
@@ -38,9 +38,7 @@ class PublicBodyController < ApplicationController
@searched_to_send_request = true
end
@view = params[:view]
- params[:latest_status] = @view
-
- query = make_query_from_params
+ query = make_query_from_params(params.merge(:latest_status => @view))
query += " requested_from:#{@public_body.url_name}"
# Use search query for this so can collapse and paginate easily
# XXX really should just use SQL query here rather than Xapian.
diff --git a/app/controllers/request_controller.rb b/app/controllers/request_controller.rb
index dfa3a4834..6b8444f90 100644
--- a/app/controllers/request_controller.rb
+++ b/app/controllers/request_controller.rb
@@ -174,8 +174,7 @@ class RequestController < ApplicationController
raise ActiveRecord::RecordNotFound.new("Sorry. No pages after #{MAX_RESULTS / PER_PAGE}.")
end
- params[:latest_status] = @view
- query = make_query_from_params
+ query = make_query_from_params(params.merge(:latest_status => @view))
@title = _("View and search requests")
sortby = "newest"
xapian_object = perform_search([InfoRequestEvent], query, sortby, 'request_collapse')
diff --git a/app/helpers/link_to_helper.rb b/app/helpers/link_to_helper.rb
index 030fab20b..42c1e0549 100755
--- a/app/helpers/link_to_helper.rb
+++ b/app/helpers/link_to_helper.rb
@@ -269,13 +269,5 @@ module LinkToHelper
def year_from_date(date)
return date.strftime("%Y").strip
end
-
- #I18n locale switcher
-
- def locale_switcher(locale, params)
- params['locale'] = locale
- return url_for(params)
- end
-
end
diff --git a/app/views/admin_general/debug.rhtml b/app/views/admin_general/debug.rhtml
index 99488ba0c..b0749bedb 100644
--- a/app/views/admin_general/debug.rhtml
+++ b/app/views/admin_general/debug.rhtml
@@ -20,8 +20,6 @@ Rails::VERSION::STRING <%=h Rails::VERSION::STRING%>
TMail::VERSION::STRING <%=h TMail::VERSION::STRING%>
<br>
Xapian::version_string <%=h Xapian::version_string%>
-<br>
-Spec::VERSION::STRING <%=h Spec::VERSION::STRING%>
</p>
<h2>Configuration</h2>
diff --git a/app/views/general/_frontpage_search_box.rhtml b/app/views/general/_frontpage_search_box.rhtml
index d2718b3a3..890602416 100644
--- a/app/views/general/_frontpage_search_box.rhtml
+++ b/app/views/general/_frontpage_search_box.rhtml
@@ -6,7 +6,7 @@
</h2>
<form id="search_form" method="post" action="<%= search_redirect_path %>">
<div>
- <input id="query" type="text" size="30" name="query">
+ <input id="query" type="text" size="30" name="query" title="type your search term here" >
<input type="submit" value="<%= _('Search') %>">
</div>
</form>
diff --git a/app/views/general/_locale_switcher.rhtml b/app/views/general/_locale_switcher.rhtml
index 2521b5eb5..d0040bb0d 100644
--- a/app/views/general/_locale_switcher.rhtml
+++ b/app/views/general/_locale_switcher.rhtml
@@ -5,7 +5,7 @@
<% if possible_locale == I18n.locale.to_s %>
<a href="#" class="btn disabled"><%= locale_name(possible_locale) %></a>
<% else %>
- <a href="<%= locale_switcher(possible_locale, params) %>" class="btn"><%= locale_name(possible_locale) %></a>
+ <a href="<%= url_for params.merge(:locale => possible_locale) %>" class="btn"><%= locale_name(possible_locale) %></a>
<% end %>
<% end %>
</div>
diff --git a/app/views/general/exception_caught.rhtml b/app/views/general/exception_caught.rhtml
index 5f0dfe13d..f8fe4343b 100644
--- a/app/views/general/exception_caught.rhtml
+++ b/app/views/general/exception_caught.rhtml
@@ -7,8 +7,8 @@
<ul>
<li><%= _("Check for mistakes if you typed or copied the address.")%></li>
<li><%= _("Search the site to find what you were looking for.")%>
- <% form_tag({:controller => "general", :action => "search_redirect"}, {:id => "search_form"}) do %>
- <%= text_field_tag 'query', params[:query], { :size => 30 } %>
+ <% form_tag({:controller => "general", :action => "search_redirect"}, {:id => "search_form" }) do %>
+ <%= text_field_tag 'query', params[:query], { :size => 30, :title => "type your search term here" } %>
<%= submit_tag _("Search") %>
<% end %>
</li>
diff --git a/app/views/general/search.rhtml b/app/views/general/search.rhtml
index 6df12d980..7d402b9b9 100644
--- a/app/views/general/search.rhtml
+++ b/app/views/general/search.rhtml
@@ -37,7 +37,7 @@
<% else %>
<% form_tag(request.url, {:method => "get", :id => "search_form"}) do %>
<p>
- <%= text_field_tag 'query', params[:query], { :size => 40 } %>
+ <%= text_field_tag 'query', params[:query], { :size => 40, :title => "type your search term here" } %>
<%= hidden_field_tag 'sortby', @inputted_sortby %>
<% if @bodies %>
<%= hidden_field_tag 'bodies', 1 %>
diff --git a/app/views/layouts/default.rhtml b/app/views/layouts/default.rhtml
index 6ac7064a7..9eb967578 100644
--- a/app/views/layouts/default.rhtml
+++ b/app/views/layouts/default.rhtml
@@ -102,7 +102,7 @@
<div id="navigation_search">
<form id="navigation_search_form" method="post" action="<%= search_redirect_path %>">
<p>
- <%= text_field_tag 'query', params[:query], { :size => 40, :id => "navigation_search_query" } %>
+ <%= text_field_tag 'query', params[:query], { :size => 40, :id => "navigation_search_query", :title => "type your search term here" } %>
<input id="navigation_search_button" type="submit" value="search">
</p>
</form>
diff --git a/app/views/public_body/list.rhtml b/app/views/public_body/list.rhtml
index 94fbb759c..dd97b99fd 100644
--- a/app/views/public_body/list.rhtml
+++ b/app/views/public_body/list.rhtml
@@ -34,7 +34,7 @@
<% form_tag(list_public_bodies_default_url, :method => "get", :id=>"search_form") do %>
<div>
- <%= text_field_tag(:public_body_query, params[:public_body_query]) %>
+ <%= text_field_tag(:public_body_query, params[:public_body_query], { :title => "type your search term here" } ) %>
<%= submit_tag(_("Search")) %>
</div>
<% end %>
diff --git a/app/views/request/_sidebar.rhtml b/app/views/request/_sidebar.rhtml
index 5e0c6fd2d..884d4b2b1 100644
--- a/app/views/request/_sidebar.rhtml
+++ b/app/views/request/_sidebar.rhtml
@@ -4,7 +4,7 @@
<% follower_count = TrackThing.count(:all, :conditions => ["info_request_id = ?", @info_request.id]) + 1 %>
<p><%= n_("There is %d person following this request", "There are %d people following this request", follower_count) % follower_count %></p>
- <%= render :partial => 'track/tracking_links', :locals => { :track_thing => @track_thing, :own_request => @info_request.user == @user, :location => 'sidebar' } %>
+ <%= render :partial => 'track/tracking_links', :locals => { :track_thing => @track_thing, :own_request => @info_request.user && @info_request.user == @user, :location => 'sidebar' } %>
</div>
<% if @info_request.described_state != "attention_requested" %>
<h2><%= _('Offensive? Unsuitable?') %></h2>
diff --git a/app/views/request/select_authority.rhtml b/app/views/request/select_authority.rhtml
index 652c24da9..df0498d6a 100644
--- a/app/views/request/select_authority.rhtml
+++ b/app/views/request/select_authority.rhtml
@@ -37,7 +37,7 @@
like information from. <strong>By law, they have to respond</strong>
(<a href="%s#%s">why?</a>).') % [help_about_url, "whybother_them"]) %>
</p>
- <%= text_field_tag 'query', params[:query], { :size => 30 } %>
+ <%= text_field_tag 'query', params[:query], { :size => 30, :title => "type your search term here" } %>
<%= hidden_field_tag 'bodies', 1 %>
<%= submit_tag _('Search') %>
</div>
diff --git a/app/views/user/show.rhtml b/app/views/user/show.rhtml
index 31ea2a70b..9d8bf6f2f 100644
--- a/app/views/user/show.rhtml
+++ b/app/views/user/show.rhtml
@@ -109,7 +109,7 @@
<div id="user_profile_search">
<% form_tag(show_user_url, :method => "get", :id=>"search_form") do %>
<div>
- <%= text_field_tag(:user_query, params[:user_query]) %>
+ <%= text_field_tag(:user_query, params[:user_query], {:title => "type your search term here" }) %>
<% if @is_you %>
<%= submit_tag(_("Search your contributions")) %>
<% else %>
diff --git a/spec/controllers/admin_censor_rule_controller_spec.rb b/spec/controllers/admin_censor_rule_controller_spec.rb
index 8893a858b..fb9ddf594 100644
--- a/spec/controllers/admin_censor_rule_controller_spec.rb
+++ b/spec/controllers/admin_censor_rule_controller_spec.rb
@@ -2,10 +2,14 @@ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
describe AdminCensorRuleController, "when making censor rules from the admin interface" do
integrate_views
- before { basic_auth_login @request }
-
+ before do
+ basic_auth_login @request
+ PurgeRequest.destroy_all
+ end
+
+
it "should create a censor rule and purge the corresponding request from varnish" do
- ir = info_requests(:fancy_dog_request)
+ ir = info_requests(:fancy_dog_request)
post :create, :censor_rule => {
:text => "meat",
:replacement => "tofu",
diff --git a/spec/controllers/public_body_controller_spec.rb b/spec/controllers/public_body_controller_spec.rb
index 29ece18cb..5f4012737 100644
--- a/spec/controllers/public_body_controller_spec.rb
+++ b/spec/controllers/public_body_controller_spec.rb
@@ -67,6 +67,11 @@ describe PublicBodyController, "when showing a body" do
ActionController::Routing::Routes.filters = old_filters
end
+ it "should remember the filter (view) setting on redirecting" do
+ get :show, :show_locale => "es", :url_name => "tgq", :view => 'successful'
+ response.should redirect_to show_public_body_successful_url(:url_name => "etgq")
+ end
+
it "should redirect to newest name if you use historic name of public body in URL" do
get :show, :url_name => "hdink", :view => 'all'
response.should redirect_to(:controller => 'public_body', :action => 'show', :url_name => "dfh")
diff --git a/spec/controllers/request_controller_spec.rb b/spec/controllers/request_controller_spec.rb
index 6f25b605a..21dd0853a 100644
--- a/spec/controllers/request_controller_spec.rb
+++ b/spec/controllers/request_controller_spec.rb
@@ -121,7 +121,9 @@ end
describe RequestController, "when changing things that appear on the request page" do
- integrate_views
+ before do
+ PurgeRequest.destroy_all
+ end
it "should purge the downstream cache when mail is received" do
ir = info_requests(:fancy_dog_request)
diff --git a/spec/models/purge_request_spec.rb b/spec/models/purge_request_spec.rb
index 94fe01317..7b67fca52 100644
--- a/spec/models/purge_request_spec.rb
+++ b/spec/models/purge_request_spec.rb
@@ -1,12 +1,13 @@
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
require 'fakeweb'
-describe PurgeRequest, "purging things" do
+describe PurgeRequest, "purging things" do
before do
+ PurgeRequest.destroy_all
FakeWeb.last_request = nil
end
- it 'should issue purge requests to the server' do
+ it 'should issue purge requests to the server' do
req = PurgeRequest.new(:url => "/begone_from_here",
:model => "don't care",
:model_id => "don't care")
@@ -16,7 +17,7 @@ describe PurgeRequest, "purging things" do
PurgeRequest.all().count.should == 0
end
- it 'should fail silently for a misconfigured server' do
+ it 'should fail silently for a misconfigured server' do
FakeWeb.register_uri(:get, %r|brokenv|, :body => "BROKEN")
config = MySociety::Config.load_default()
config['VARNISH_HOST'] = "brokencache"
@@ -29,4 +30,4 @@ describe PurgeRequest, "purging things" do
PurgeRequest.all().count.should == 0
end
end
-
+
diff --git a/spec/models/request_mailer_spec.rb b/spec/models/request_mailer_spec.rb
index 20d401a63..000a0c12e 100644
--- a/spec/models/request_mailer_spec.rb
+++ b/spec/models/request_mailer_spec.rb
@@ -1,3 +1,4 @@
+# encoding: utf-8
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
describe RequestMailer, " when receiving incoming mail" do
diff --git a/spec/script/mailin_spec.rb b/spec/script/mailin_spec.rb
index d80789635..f9368996d 100644
--- a/spec/script/mailin_spec.rb
+++ b/spec/script/mailin_spec.rb
@@ -4,7 +4,11 @@ require "external_command"
def mailin_test(email_filename)
Dir.chdir Rails.root do
xc = ExternalCommand.new("script/mailin")
- xc.run(load_file_fixture(email_filename))
+ mail = load_file_fixture(email_filename)
+ ir = info_requests(:boring_request)
+ mail.gsub!('EMAIL_TO', ir.incoming_email)
+ mail.gsub!('EMAIL_FROM', 'responder@localhost')
+ xc.run(mail)
xc.err.should == ""
return xc
end
@@ -18,4 +22,4 @@ describe "When importing mail into the application" do
r.out.should == ""
end
-end \ No newline at end of file
+end