aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--app/controllers/request_controller.rb14
-rw-r--r--config/general.yml-example5
-rw-r--r--lib/configuration.rb1
-rw-r--r--spec/controllers/request_controller_spec.rb28
4 files changed, 46 insertions, 2 deletions
diff --git a/app/controllers/request_controller.rb b/app/controllers/request_controller.rb
index 880a7b4b4..42693f867 100644
--- a/app/controllers/request_controller.rb
+++ b/app/controllers/request_controller.rb
@@ -461,9 +461,19 @@ class RequestController < ApplicationController
when 'rejected'
_("Oh no! Sorry to hear that your request was refused. Here is what to do now.")
when 'successful'
- _("<p>We're glad you got all the information that you wanted. If you write about or make use of the information, please come back and add an annotation below saying what you did.</p><p>If you found {{site_name}} useful, <a href=\"{{donation_url}}\">make a donation</a> to the charity which runs it.</p>", :site_name=>site_name, :donation_url => "http://www.mysociety.org/donate/")
+ if AlaveteliConfiguration::donation_url.blank?
+ _("<p>We're glad you got all the information that you wanted. If you write about or make use of the information, please come back and add an annotation below saying what you did.</p>")
+ else
+ _("<p>We're glad you got all the information that you wanted. If you write about or make use of the information, please come back and add an annotation below saying what you did.</p><p>If you found {{site_name}} useful, <a href=\"{{donation_url}}\">make a donation</a> to the charity which runs it.</p>",
+ :site_name => site_name, :donation_url => AlaveteliConfiguration::donation_url)
+ end
when 'partially_successful'
- _("<p>We're glad you got some of the information that you wanted. If you found {{site_name}} useful, <a href=\"{{donation_url}}\">make a donation</a> to the charity which runs it.</p><p>If you want to try and get the rest of the information, here's what to do now.</p>", :site_name=>site_name, :donation_url=>"http://www.mysociety.org/donate/")
+ if AlaveteliConfiguration::donation_url.blank?
+ _("<p>We're glad you got some of the information that you wanted.</p><p>If you want to try and get the rest of the information, here's what to do now.</p>")
+ else
+ _("<p>We're glad you got some of the information that you wanted. If you found {{site_name}} useful, <a href=\"{{donation_url}}\">make a donation</a> to the charity which runs it.</p><p>If you want to try and get the rest of the information, here's what to do now.</p>",
+ :site_name => site_name, :donation_url => AlaveteliConfiguration::donation_url)
+ end
when 'waiting_clarification'
_("Please write your follow up message containing the necessary clarifications below.")
when 'gone_postal'
diff --git a/config/general.yml-example b/config/general.yml-example
index 17e1aa552..0753af46b 100644
--- a/config/general.yml-example
+++ b/config/general.yml-example
@@ -187,3 +187,8 @@ MTA_LOG_PATH: '/var/log/exim4/exim-mainlog-*'
# Whether we are using "exim" or "postfix" for our MTA
MTA_LOG_TYPE: "exim"
+
+# URL where people can donate to the organisation running the site. If set,
+# this will be included in the message people see when their request is
+# successful.
+DONATION_URL: "http://www.mysociety.org/donate/"
diff --git a/lib/configuration.rb b/lib/configuration.rb
index 88890856b..03c4ac616 100644
--- a/lib/configuration.rb
+++ b/lib/configuration.rb
@@ -28,6 +28,7 @@ module AlaveteliConfiguration
:DEFAULT_LOCALE => '',
:DISABLE_EMERGENCY_USER => false,
:DOMAIN => 'localhost:3000',
+ :DONATION_URL => '',
:EXCEPTION_NOTIFICATIONS_FROM => '',
:EXCEPTION_NOTIFICATIONS_TO => '',
:FORCE_REGISTRATION_ON_NEW_REQUEST => false,
diff --git a/spec/controllers/request_controller_spec.rb b/spec/controllers/request_controller_spec.rb
index 734eb62fb..06862f5e2 100644
--- a/spec/controllers/request_controller_spec.rb
+++ b/spec/controllers/request_controller_spec.rb
@@ -1708,6 +1708,20 @@ describe RequestController, "when classifying an information request" do
expect_redirect('successful', request_url)
end
+ it 'should show a message including the donation url if there is one' do
+ AlaveteliConfiguration.stub!(:donation_url).and_return('http://donations.example.com')
+ post_status('successful')
+ flash[:notice].should match('make a donation')
+ flash[:notice].should match('http://donations.example.com')
+ end
+
+ it 'should show a message without reference to donations if there is no
+ donation url' do
+ AlaveteliConfiguration.stub!(:donation_url).and_return('')
+ post_status('successful')
+ flash[:notice].should_not match('make a donation')
+ end
+
end
context 'when status is updated to "waiting clarification"' do
@@ -1740,6 +1754,20 @@ describe RequestController, "when classifying an information request" do
expect_redirect('partially_successful', "help/unhappy/#{@dog_request.url_title}")
end
+ it 'should show a message including the donation url if there is one' do
+ AlaveteliConfiguration.stub!(:donation_url).and_return('http://donations.example.com')
+ post_status('successful')
+ flash[:notice].should match('make a donation')
+ flash[:notice].should match('http://donations.example.com')
+ end
+
+ it 'should show a message without reference to donations if there is no
+ donation url' do
+ AlaveteliConfiguration.stub!(:donation_url).and_return('')
+ post_status('successful')
+ flash[:notice].should_not match('make a donation')
+ end
+
end
context 'when status is updated to "gone postal"' do