aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Gemfile6
-rw-r--r--Gemfile.lock6
-rw-r--r--app/controllers/admin_general_controller.rb3
-rw-r--r--app/controllers/application_controller.rb1
-rw-r--r--app/models/public_body.rb12
-rw-r--r--app/views/request/new_bad_contact.html.erb2
-rw-r--r--config/initializers/alaveteli.rb2
-rw-r--r--lib/acts_as_xapian/acts_as_xapian.rb72
-rw-r--r--locale/es_NI/app.po6
-rwxr-xr-xscript/switch-theme.rb2
-rw-r--r--spec/controllers/general_controller_spec.rb1
-rw-r--r--spec/integration/xapian_search_highlighting_spec.rb11
-rw-r--r--spec/models/info_request_spec.rb1
-rw-r--r--spec/models/public_body_spec.rb27
-rw-r--r--spec/views/public_body/show.html.erb_spec.rb1
15 files changed, 92 insertions, 61 deletions
diff --git a/Gemfile b/Gemfile
index 07cbdce9f..c4ac74273 100644
--- a/Gemfile
+++ b/Gemfile
@@ -5,7 +5,7 @@ gem 'rails', '3.2.21'
gem 'pg', '~> 0.17.1'
# New gem releases aren't being done. master is newer and supports Rails > 3.0
-gem 'acts_as_versioned', :git => 'git://github.com/technoweenie/acts_as_versioned.git', :ref => '63b1fc8529d028'
+gem 'acts_as_versioned', :git => 'https://github.com/technoweenie/acts_as_versioned.git', :ref => '63b1fc8529d028'
gem 'charlock_holmes', '~> 0.6.9.4'
gem 'dynamic_form', '~> 1.1.4'
gem 'exception_notification', '~> 3.0.1'
@@ -27,7 +27,7 @@ gem 'rake', '0.9.2.2'
gem 'rails-i18n', '~> 0.7.3'
gem 'recaptcha', '~> 0.3.1', :require => 'recaptcha/rails'
gem 'rmagick', '~> 2.14.0'
-gem 'ruby-msg', '~> 1.5.0', :git => 'git://github.com/mysociety/ruby-msg.git'
+gem 'ruby-msg', '~> 1.5.0', :git => 'https://github.com/mysociety/ruby-msg.git'
gem 'secure_headers', '~> 1.3.4'
gem 'statistics2', '~> 0.54'
gem 'syslog_protocol', '~> 0.9.2'
@@ -43,7 +43,7 @@ gem 'zip', '~> 2.0.2'
gem 'fast_gettext', '~> 0.7.0'
gem 'gettext_i18n_rails', '~> 0.9.4'
gem 'gettext', '~> 2.3.9'
-gem 'globalize3', :git => 'git://github.com/globalize/globalize.git', :ref => '5fd95f2389dff1'
+gem 'globalize3', :git => 'https://github.com/globalize/globalize.git', :ref => '5fd95f2389dff1'
gem 'locale', '~> 2.0.8'
gem 'routing-filter', '~> 0.3.1'
gem 'unicode', '~> 0.4.4'
diff --git a/Gemfile.lock b/Gemfile.lock
index 32b09a723..f00c26061 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -1,5 +1,5 @@
GIT
- remote: git://github.com/globalize/globalize.git
+ remote: https://github.com/globalize/globalize.git
revision: 5fd95f2389dff13c9368fb2e08c96c8a48798c72
ref: 5fd95f2389dff1
specs:
@@ -9,7 +9,7 @@ GIT
paper_trail (~> 2)
GIT
- remote: git://github.com/mysociety/ruby-msg.git
+ remote: https://github.com/mysociety/ruby-msg.git
revision: ee0086add16c755d2eaf8dbcb90ba65809061cef
specs:
ruby-msg (1.5.2)
@@ -17,7 +17,7 @@ GIT
vpim (>= 0.360)
GIT
- remote: git://github.com/technoweenie/acts_as_versioned.git
+ remote: https://github.com/technoweenie/acts_as_versioned.git
revision: 63b1fc8529d028fae632fe80ec0cb25df56cd76b
ref: 63b1fc8529d028
specs:
diff --git a/app/controllers/admin_general_controller.rb b/app/controllers/admin_general_controller.rb
index f2414eeab..13edec37d 100644
--- a/app/controllers/admin_general_controller.rb
+++ b/app/controllers/admin_general_controller.rb
@@ -23,8 +23,7 @@ class AdminGeneralController < AdminController
@requires_admin_requests = InfoRequest.find_in_state('requires_admin')
@error_message_requests = InfoRequest.find_in_state('error_message')
@attention_requests = InfoRequest.find_in_state('attention_requested')
- @blank_contacts = PublicBody.find(:all, :conditions => ["request_email = ''"],
- :order => "updated_at")
+ @blank_contacts = PublicBody.where(:request_email => "").order(:updated_at).select { |pb| !pb.defunct? }
@old_unclassified = InfoRequest.find_old_unclassified(:limit => 20,
:conditions => ["prominence = 'normal'"])
@holding_pen_messages = InfoRequest.holding_pen_request.incoming_messages
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb
index 044f8e10f..e80c6a823 100644
--- a/app/controllers/application_controller.rb
+++ b/app/controllers/application_controller.rb
@@ -132,7 +132,6 @@ class ApplicationController < ActionController::Base
def validate_session_timestamp
if session[:user_id] && session.key?(:ttl) && session[:ttl] < SESSION_TTL.ago
clear_session_credentials
- redirect_to signin_path
end
end
diff --git a/app/models/public_body.rb b/app/models/public_body.rb
index cb412f9dc..5bce8ecc7 100644
--- a/app/models/public_body.rb
+++ b/app/models/public_body.rb
@@ -577,17 +577,11 @@ class PublicBody < ActiveRecord::Base
return self.request_email_domain
end
- # Returns nil if configuration variable not set
- def override_request_email
- e = AlaveteliConfiguration::override_all_public_body_request_emails
- e if e != ""
- end
-
def request_email
- if override_request_email
- override_request_email
- else
+ if AlaveteliConfiguration::override_all_public_body_request_emails.blank? || read_attribute(:request_email).blank?
read_attribute(:request_email)
+ else
+ AlaveteliConfiguration::override_all_public_body_request_emails
end
end
diff --git a/app/views/request/new_bad_contact.html.erb b/app/views/request/new_bad_contact.html.erb
index 56f3f4168..f9881b62b 100644
--- a/app/views/request/new_bad_contact.html.erb
+++ b/app/views/request/new_bad_contact.html.erb
@@ -5,6 +5,6 @@
<p><%= _('Unfortunately, we do not have a working {{info_request_law_used_full}}
address for', :info_request_law_used_full => @info_request.law_used_full) %> <%=h @info_request.public_body.name %>. <%= _('You may be able to find
one on their website, or by phoning them up and asking. If you manage
-to find one, then please <a href="{{help_url}}">send it to us</a>.', :help_url => help_contact_path) %>
+to find one, then please <a href="{{help_url}}">send it to us</a>.', :help_url => new_change_request_path(:body => @info_request.public_body.url_name)) %>
</p>
diff --git a/config/initializers/alaveteli.rb b/config/initializers/alaveteli.rb
index 9787785db..27d40b223 100644
--- a/config/initializers/alaveteli.rb
+++ b/config/initializers/alaveteli.rb
@@ -10,7 +10,7 @@ load "debug_helpers.rb"
load "util.rb"
# Application version
-ALAVETELI_VERSION = '0.21.0.20'
+ALAVETELI_VERSION = '0.21.0.22'
# Add new inflection rules using the following format
# (all these examples are active by default):
diff --git a/lib/acts_as_xapian/acts_as_xapian.rb b/lib/acts_as_xapian/acts_as_xapian.rb
index 6520a20a4..f742bae52 100644
--- a/lib/acts_as_xapian/acts_as_xapian.rb
+++ b/lib/acts_as_xapian/acts_as_xapian.rb
@@ -487,41 +487,37 @@ module ActsAsXapian
# date ranges or similar. Use this for cheap highlighting with
# TextHelper::highlight, and excerpt.
def words_to_highlight(opts = {})
- default_opts = { :include_original => false, :regex => false }
- opts = default_opts.merge(opts)
-
- # Reject all prefixes other than Z, which we know is reserved for stems
- terms = query.terms.reject { |t| t.term.first.match(/^[A-Y]$/) }
- # Collect the stems including the Z prefix
- raw_stems = terms.map { |t| t.term if t.term.start_with?('Z') }.compact.uniq.sort
- # Collect stems, chopping the Z prefix off
- stems = raw_stems.map { |t| t[1..-1] }.compact.sort
- # Collect the non-stem terms
- words = terms.map { |t| t.term unless t.term.start_with?('Z') }.compact.sort
-
- # Add the unstemmed words from the original query
- # Sometimes stems can be unhelpful with the :regex option, for example
- # stemming 'boring' results in us trying to highlight 'bore'.
- if opts[:include_original]
- raw_stems.each do |raw_stem|
- words << ActsAsXapian.query_parser.unstem(raw_stem).uniq
- end
-
- words = words.any? ? words.flatten.uniq : []
- end
-
- if opts[:regex]
- stems.map! { |w| /\b(#{ w })\w*\b/iu }
- words.map! { |w| /\b(#{ w })\b/iu }
- end
-
- if RUBY_VERSION.to_f >= 1.9
- (stems + words).map! do |term|
- term.is_a?(String) ? term.force_encoding('UTF-8') : term
- end
- else
- stems + words
- end
+ default_opts = { :include_original => false, :regex => false }
+ opts = default_opts.merge(opts)
+
+ # Reject all prefixes other than Z, which we know is reserved for stems
+ terms = query.terms.reject { |t| t.term.first.match(/^[A-Y]$/) }
+ # Collect the stems including the Z prefix
+ raw_stems = terms.map { |t| t.term if t.term.start_with?('Z') }.compact.uniq.sort
+ # Collect stems, chopping the Z prefix off
+ stems = raw_stems.map { |t| t[1..-1] }.compact.sort
+ # Collect the non-stem terms
+ words = terms.map { |t| t.term unless t.term.start_with?('Z') }.compact.sort
+
+ # Add the unstemmed words from the original query
+ # Sometimes stems can be unhelpful with the :regex option, for example
+ # stemming 'boring' results in us trying to highlight 'bore'.
+ if opts[:include_original]
+ raw_stems.each do |raw_stem|
+ words << ActsAsXapian.query_parser.unstem(raw_stem).uniq
+ end
+
+ words = words.any? ? words.flatten.uniq : []
+ end
+
+ if opts[:regex]
+ stems.map! { |w| /\b(#{ correctly_encode(w) })\w*\b/iu }
+ words.map! { |w| /\b(#{ correctly_encode(w) })\b/iu }
+ end
+
+ (stems + words).map! do |term|
+ term.is_a?(String) ? correctly_encode(term) : term
+ end
end
# Text for lines in log file
@@ -529,6 +525,12 @@ module ActsAsXapian
"Search: " + self.query_string
end
+ private
+
+ def correctly_encode(w)
+ RUBY_VERSION.to_f >= 1.9 ? w.force_encoding('UTF-8') : w
+ end
+
end
# Search for models which contain theimportant terms taken from a specified
diff --git a/locale/es_NI/app.po b/locale/es_NI/app.po
index 2f6ad5a56..027562a91 100644
--- a/locale/es_NI/app.po
+++ b/locale/es_NI/app.po
@@ -19,8 +19,8 @@ msgstr ""
"Project-Id-Version: alaveteli\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2015-03-24 10:21+0000\n"
-"PO-Revision-Date: 2015-04-17 03:06+0000\n"
-"Last-Translator: jbaezni <jbaezni@gmail.com>\n"
+"PO-Revision-Date: 2015-04-24 16:21+0000\n"
+"Last-Translator: Gareth Rees <gareth@mysociety.org>\n"
"Language-Team: Spanish (Nicaragua) (http://www.transifex.com/projects/p/alaveteli/language/es_NI/)\n"
"Language: es_NI\n"
"MIME-Version: 1.0\n"
@@ -3757,7 +3757,7 @@ msgstr[0] "Sus {{count}} solicitudes por bloques"
msgstr[1] "Sus {{count}} solicitudes por bloques"
msgid "Your {{law_used_full}} request has been sent"
-msgstr "Su {{law_used_full}} ha sido enviada"
+msgstr "Su solicitud de {{law_used_full}} ha sido enviada"
msgid "Your {{site_name}} email alert"
msgstr "Tu alerta en {{site_name}}"
diff --git a/script/switch-theme.rb b/script/switch-theme.rb
index 980853687..146d1bf0c 100755
--- a/script/switch-theme.rb
+++ b/script/switch-theme.rb
@@ -129,5 +129,5 @@ STDERR.puts """Switched to #{requested_theme}!
You will need to:
1. restart any development server you have running.
2. run: bundle exec rake assets:clean
- 3. run: bundle exec rake assets:precompile
+ 3. run: bundle exec rake assets:precompile (if running in production mode)
"""
diff --git a/spec/controllers/general_controller_spec.rb b/spec/controllers/general_controller_spec.rb
index ae8d4f256..844fcd4e6 100644
--- a/spec/controllers/general_controller_spec.rb
+++ b/spec/controllers/general_controller_spec.rb
@@ -169,7 +169,6 @@ describe GeneralController, "when showing the frontpage" do
it 'should end a logged-in session whose ttl has expired' do
session[:ttl] = Time.now - 4.hours
get :frontpage
- response.should redirect_to signin_path
session[:user_id].should be_nil
end
diff --git a/spec/integration/xapian_search_highlighting_spec.rb b/spec/integration/xapian_search_highlighting_spec.rb
index b2994eb31..a91df341f 100644
--- a/spec/integration/xapian_search_highlighting_spec.rb
+++ b/spec/integration/xapian_search_highlighting_spec.rb
@@ -1,3 +1,5 @@
+# encoding: utf-8
+
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
describe 'highlighting search results' do
@@ -40,4 +42,13 @@ describe 'highlighting search results' do
highlight_matches(phrase, matches).should == '<mark>boring</mark>'
end
+ it 'handles macrons correctly' do
+ phrase = 'Māori'
+
+ search = ActsAsXapian::Search.new([PublicBody], phrase, :limit => 1)
+ matches = search.words_to_highlight(:regex => true, :include_original => true)
+
+ highlight_matches(phrase, matches).should == '<mark>Māori</mark>'
+ end
+
end
diff --git a/spec/models/info_request_spec.rb b/spec/models/info_request_spec.rb
index c8bd2c338..d8c0c59b1 100644
--- a/spec/models/info_request_spec.rb
+++ b/spec/models/info_request_spec.rb
@@ -1221,6 +1221,7 @@ describe InfoRequest do
describe InfoRequest, "when constructing a list of requests by query" do
before(:each) do
+ load_raw_emails_data
get_fixtures_xapian_index
end
diff --git a/spec/models/public_body_spec.rb b/spec/models/public_body_spec.rb
index 7b55efda1..cce017424 100644
--- a/spec/models/public_body_spec.rb
+++ b/spec/models/public_body_spec.rb
@@ -1237,6 +1237,33 @@ describe PublicBody do
end
+ describe :request_email do
+ context "when the email is set" do
+ subject(:public_body) { FactoryGirl.create(:public_body, :request_email => "request@example.com") }
+
+ it "should return the set email address" do
+ expect(public_body.request_email).to eq("request@example.com")
+ end
+
+ it "should return a different email address when overridden in configuration" do
+ AlaveteliConfiguration.stub!(:override_all_public_body_request_emails).and_return("tester@example.com")
+ expect(public_body.request_email).to eq("tester@example.com")
+ end
+ end
+
+ context "when no email is set" do
+ subject(:public_body) { FactoryGirl.create(:public_body, :request_email => "") }
+
+ it "should return a blank email address" do
+ expect(public_body.request_email).to be_blank
+ end
+
+ it "should still return a blank email address when overridden in configuration" do
+ AlaveteliConfiguration.stub!(:override_all_public_body_request_emails).and_return("tester@example.com")
+ expect(public_body.request_email).to be_blank
+ end
+ end
+ end
end
describe PublicBody::Translation do
diff --git a/spec/views/public_body/show.html.erb_spec.rb b/spec/views/public_body/show.html.erb_spec.rb
index 6ebc39caa..2a4c21d04 100644
--- a/spec/views/public_body/show.html.erb_spec.rb
+++ b/spec/views/public_body/show.html.erb_spec.rb
@@ -13,7 +13,6 @@ describe "public_body/show" do
:publication_scheme => '',
:disclosure_log => '',
:calculated_home_page => '')
- @pb.stub!(:override_request_email).and_return(nil)
@pb.stub!(:is_requestable?).and_return(true)
@pb.stub!(:special_not_requestable_reason?).and_return(false)
@pb.stub!(:has_notes?).and_return(false)