diff options
-rw-r--r-- | .travis.yml | 1 | ||||
-rw-r--r-- | Gemfile | 4 | ||||
-rw-r--r-- | Gemfile.lock | 29 | ||||
-rw-r--r-- | app/controllers/application_controller.rb | 30 | ||||
-rw-r--r-- | app/controllers/general_controller.rb | 4 | ||||
-rw-r--r-- | app/controllers/public_body_controller.rb | 6 | ||||
-rw-r--r-- | app/controllers/request_controller.rb | 3 | ||||
-rwxr-xr-x | app/helpers/link_to_helper.rb | 8 | ||||
-rw-r--r-- | app/views/admin_general/debug.rhtml | 2 | ||||
-rw-r--r-- | app/views/general/_frontpage_search_box.rhtml | 2 | ||||
-rw-r--r-- | app/views/general/_locale_switcher.rhtml | 2 | ||||
-rw-r--r-- | app/views/general/exception_caught.rhtml | 4 | ||||
-rw-r--r-- | app/views/general/search.rhtml | 2 | ||||
-rw-r--r-- | app/views/layouts/default.rhtml | 2 | ||||
-rw-r--r-- | app/views/public_body/list.rhtml | 2 | ||||
-rw-r--r-- | app/views/request/_sidebar.rhtml | 2 | ||||
-rw-r--r-- | app/views/request/select_authority.rhtml | 2 | ||||
-rw-r--r-- | app/views/user/show.rhtml | 2 | ||||
-rw-r--r-- | spec/controllers/public_body_controller_spec.rb | 5 |
19 files changed, 51 insertions, 61 deletions
diff --git a/.travis.yml b/.travis.yml index ffcfdbaa9..2b06d9d23 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,6 +13,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/general.yml-example config/general.yml - sudo apt-get update - export DEBIAN_FRONTEND=noninteractive - sudo apt-get -y install exim4-daemon-light @@ -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/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") |