aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--app/models/public_body.rb5
-rw-r--r--app/views/public_body/_body_listing_single.html.erb13
-rw-r--r--app/views/public_body/show.html.erb10
-rw-r--r--app/views/public_body/view_email.html.erb2
-rw-r--r--spec/models/public_body_spec.rb22
-rw-r--r--spec/views/public_body/show.html.erb_spec.rb21
6 files changed, 50 insertions, 23 deletions
diff --git a/app/models/public_body.rb b/app/models/public_body.rb
index 36d66b665..5e5b35c5b 100644
--- a/app/models/public_body.rb
+++ b/app/models/public_body.rb
@@ -262,6 +262,11 @@ class PublicBody < ActiveRecord::Base
end
end
+ def special_not_requestable_reason?
+ self.defunct? || self.not_apply?
+ end
+
+
class Version
def last_edit_comment_for_html_display
diff --git a/app/views/public_body/_body_listing_single.html.erb b/app/views/public_body/_body_listing_single.html.erb
index 771027622..aa794c5d5 100644
--- a/app/views/public_body/_body_listing_single.html.erb
+++ b/app/views/public_body/_body_listing_single.html.erb
@@ -25,7 +25,7 @@
<%= _("Added on {{date}}", :date => simple_date(public_body.created_at)) %>.
</span>
<br>
- <% if !public_body.is_requestable? && public_body.not_requestable_reason != 'bad_contact' %>
+ <% if public_body.special_not_requestable_reason? %>
<% if public_body.not_requestable_reason == 'not_apply' %>
<%= _('FOI law does not apply to this authority.')%>
<% elsif public_body.not_requestable_reason == 'defunct' %>
@@ -33,12 +33,11 @@
<% end %>
<% end %>
</span>
- <% if @include_request_link_in_authority_listing %>
- <% if public_body.is_requestable? || public_body.not_requestable_reason == 'bad_contact' %>
- <div class="make-request-quick-button">
- <%= link_to _("Make a request"), new_request_to_body_path(:url_name => public_body.url_name), :class => "link_button_green" %>
- </div>
- <% end %>
+
+ <% if request_link && !public_body.special_not_requestable_reason? %>
+ <div class="make-request-quick-button">
+ <%= link_to _("Make a request"), new_request_to_body_path(:url_name => public_body.url_name), :class => "link_button_green" %>
+ </div>
<% end %>
</div>
diff --git a/app/views/public_body/show.html.erb b/app/views/public_body/show.html.erb
index 403216c6c..ac8f3a34e 100644
--- a/app/views/public_body/show.html.erb
+++ b/app/views/public_body/show.html.erb
@@ -39,7 +39,7 @@
<% end %>
</p>
- <% if @public_body.is_requestable? || @public_body.not_requestable_reason == 'bad_contact' %>
+ <% if !@public_body.special_not_requestable_reason? %>
<% if @public_body.has_notes? %>
<p><%= @public_body.notes_as_html.html_safe %></p>
<% end %>
@@ -52,15 +52,15 @@
a request to it.')%></p>
<% elsif @public_body.not_requestable_reason == 'defunct' %>
<p><%= _('This authority no longer exists, so you cannot make a request to it.')%></p>
- <% else %>
- <p><%= _('For an unknown reason, it is not possible to make a request to this authority.')%></p>
<% end %>
<% end %>
<div id="stepwise_make_request">
- <% if @public_body.is_requestable? || @public_body.not_requestable_reason == 'bad_contact' %>
+ <% if @public_body.is_requestable? %>
<%= link_to _("Make a request to this authority"), new_request_to_body_path(:url_name => @public_body.url_name), :class => "link_button_green" %>
- <% elsif @public_body.has_notes? %>
+ <% end %>
+
+ <% if @public_body.has_notes? %>
<%= @public_body.notes_as_html.html_safe %>
<% end %>
diff --git a/app/views/public_body/view_email.html.erb b/app/views/public_body/view_email.html.erb
index 5f4bc95f4..399caaa61 100644
--- a/app/views/public_body/view_email.html.erb
+++ b/app/views/public_body/view_email.html.erb
@@ -24,7 +24,7 @@
</p>
<p>
- <% if @public_body.is_requestable? || @public_body.not_requestable_reason != 'bad_contact' %>
+ <% if @public_body.has_request_email? %>
<%= raw(_('If the address is wrong, or you know a better address, please <a href="{{url}}">contact us</a>.', :url => help_contact_path.html_safe)) %>
<% else %>
<%= raw(_(' If you know the address to use, then please <a href="{{url}}">send it to us</a>.
diff --git a/spec/models/public_body_spec.rb b/spec/models/public_body_spec.rb
index c18de3013..7d48fa169 100644
--- a/spec/models/public_body_spec.rb
+++ b/spec/models/public_body_spec.rb
@@ -893,6 +893,28 @@ describe PublicBody do
@body.has_request_email?.should == true
end
end
+
+ describe :special_not_requestable_reason do
+
+ before do
+ @body = PublicBody.new
+ end
+
+ it 'should return true if the body is defunct' do
+ @body.stub!(:defunct?).and_return(true)
+ @body.special_not_requestable_reason?.should == true
+ end
+
+ it 'should return true if FOI does not apply' do
+ @body.stub!(:not_apply?).and_return(true)
+ @body.special_not_requestable_reason?.should == true
+ end
+
+ it 'should return false if the body is not defunct and FOI applies' do
+ @body.special_not_requestable_reason?.should == false
+ end
+ end
+
end
describe PublicBody, " when override all public body request emails set" do
diff --git a/spec/views/public_body/show.html.erb_spec.rb b/spec/views/public_body/show.html.erb_spec.rb
index 0559fc8ef..917c0c793 100644
--- a/spec/views/public_body/show.html.erb_spec.rb
+++ b/spec/views/public_body/show.html.erb_spec.rb
@@ -2,10 +2,10 @@ require File.expand_path(File.join('..', '..', '..', 'spec_helper'), __FILE__)
describe "public_body/show" do
before do
- @pb = mock_model(PublicBody,
- :name => 'Test Quango',
+ @pb = mock_model(PublicBody,
+ :name => 'Test Quango',
:short_name => 'tq',
- :url_name => 'testquango',
+ :url_name => 'testquango',
:notes => '',
:type_of_authority => 'A public body',
:eir_only? => nil,
@@ -15,6 +15,7 @@ describe "public_body/show" do
: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)
@pb.stub!(:has_tag?).and_return(false)
@xap = mock(ActsAsXapian::Search, :matches_estimated => 2)
@@ -69,7 +70,7 @@ describe "public_body/show" do
response.should have_selector("div#header_right") do
have_selector "a", :href => /www.charity-commission.gov.uk.*RegisteredCharityNumber=12345$/
end
- end
+ end
it "should link to Scottish Charity Regulator site if we have an SC number" do
@pb.stub!(:has_tag?).and_return(true)
@@ -79,7 +80,7 @@ describe "public_body/show" do
response.should have_selector("div#header_right") do
have_selector "a", :href => /www.oscr.org.uk.*id=SC1234$/
end
- end
+ end
it "should not link to Charity Commission site if we don't have number" do
@@ -87,15 +88,15 @@ describe "public_body/show" do
response.should have_selector("div#header_right") do
have_selector "a", :href => /charity-commission.gov.uk/
end
- end
+ end
end
-def mock_event
- return mock_model(InfoRequestEvent,
- :info_request => mock_model(InfoRequest,
- :title => 'Title',
+def mock_event
+ return mock_model(InfoRequestEvent,
+ :info_request => mock_model(InfoRequest,
+ :title => 'Title',
:url_title => 'title',
:display_status => 'waiting_response',
:calculate_status => 'waiting_response',