Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Move organisation contact details to their own dedicated page

  • Loading branch information...
commit f72f7a7bde5205267b848050a7fc495402fe31bb 1 parent 8e8d193
Tom Ward authored February 02, 2012
5  app/controllers/organisations_controller.rb
... ...
@@ -1,6 +1,6 @@
1 1
 class OrganisationsController < PublicFacingController
2 2
 
3  
-  before_filter :load_organisation, only: [:show, :about, :news]
  3
+  before_filter :load_organisation, only: [:show, :about, :contact_details, :news]
4 4
 
5 5
   def index
6 6
     @organisations_by_type = Organisation.in_listing_order.group_by(&:organisation_type)
@@ -20,6 +20,9 @@ def show
20 20
   def about
21 21
   end
22 22
 
  23
+  def contact_details
  24
+  end
  25
+
23 26
   def news
24 27
     @news_articles = NewsArticle.in_organisation(@organisation).published.by_published_at
25 28
   end
1  app/views/organisations/_navigation.html.erb
@@ -2,4 +2,5 @@
2 2
   <%= organisation_navigation_link_to 'Home', organisation_path(organisation) %>
3 3
   <%= organisation_navigation_link_to 'About', about_organisation_path(organisation) %>
4 4
   <%= organisation_navigation_link_to 'News', news_organisation_path(organisation) %>
  5
+  <%= organisation_navigation_link_to 'Contact Details', contact_details_organisation_path(organisation) %>
5 6
 </nav>
38  app/views/organisations/contact_details.html.erb
... ...
@@ -0,0 +1,38 @@
  1
+<% page_title @organisation.name %>
  2
+
  3
+<%= content_tag_for :div, @organisation, class: "hcard" do %>
  4
+  <div class="g3f">
  5
+    <%= render 'header', organisation: @organisation %>
  6
+  </div>
  7
+
  8
+  <div class="g3f page_detail">
  9
+    <div class="g1 hcard">
  10
+      <% @organisation.contacts.each do |contact| %>
  11
+        <div class="organisation_contact">
  12
+          <% if contact.address.present? %>
  13
+            <div class="adr">
  14
+              <h3><%= contact.description %></h3>
  15
+              <p class="fn org name"><%= @organisation.name %></p>
  16
+              <% if @organisation.acronym.present? %>
  17
+                <p class="nickname"><%= @organisation.acronym %></p>
  18
+              <% end %>
  19
+              <p class="street-address"><%= format_with_html_line_breaks(contact.address) %></p>
  20
+              <p class="postal-code"><%= contact.postcode %></p>
  21
+            </div>
  22
+          <% else %>
  23
+            <h3><%= contact.description %></h3>
  24
+          <% end %>
  25
+          <% if contact.email.present? %>
  26
+            <p class="email"><span class="type">Email</span> <%= mail_to contact.email, contact.email, :class => "email" %></p>
  27
+          <% end %>
  28
+          <% contact.contact_numbers.each do |number| %>
  29
+            <p class="tel"><%= number.number %><span class="type"> <%= number.label %> </span></p>
  30
+          <% end %>
  31
+          <% if contact.mappable? %>
  32
+            <p><%= link_to_google_map(contact) %></p>
  33
+          <% end %>
  34
+        </div>
  35
+      <% end %>
  36
+    </div>
  37
+  </div>
  38
+<% end %>
29  app/views/organisations/show.html.erb
@@ -12,35 +12,6 @@
12 12
         <%= link_to "Read more about #{@organisation.name}", about_organisation_path(@organisation), title: "Further information about #{@organisation.name}" %>
13 13
       </p>
14 14
     </div>
15  
-
16  
-    <div class="g1 hcard">
17  
-      <% @organisation.contacts.each do |contact| %>
18  
-        <div class="organisation_contact">
19  
-          <% if contact.address.present? %>
20  
-            <div class="adr">
21  
-              <h3><%= contact.description %></h3>
22  
-              <p class="fn org name"><%= @organisation.name %></p>
23  
-              <% if @organisation.acronym.present? %>
24  
-                <p class="nickname"><%= @organisation.acronym %></p>
25  
-              <% end %>
26  
-              <p class="street-address"><%= format_with_html_line_breaks(contact.address) %></p>
27  
-              <p class="postal-code"><%= contact.postcode %></p>
28  
-            </div>
29  
-          <% else %>
30  
-            <h3><%= contact.description %></h3>
31  
-          <% end %>
32  
-          <% if contact.email.present? %>
33  
-            <p class="email"><span class="type">Email</span> <%= mail_to contact.email, contact.email, :class => "email" %></p>
34  
-          <% end %>
35  
-          <% contact.contact_numbers.each do |number| %>
36  
-            <p class="tel"><%= number.number %><span class="type"> <%= number.label %> </span></p>
37  
-          <% end %>
38  
-          <% if contact.mappable? %>
39  
-            <p><%= link_to_google_map(contact) %></p>
40  
-          <% end %>
41  
-        </div>
42  
-      <% end %>
43  
-    </div>
44 15
   </div>
45 16
 <% end %>
46 17
 
1  config/database.yml
@@ -13,7 +13,6 @@ test: &test
13 13
   username: whitehall
14 14
   password: whitehall
15 15
 
16  
-
17 16
 production:
18 17
   adapter: mysql2
19 18
   database: whitehall_production
1  config/routes.rb
@@ -42,6 +42,7 @@ def redirect(path)
42 42
       member do
43 43
         get :about
44 44
         get :news
  45
+        get :contact_details, path: 'contact-details'
45 46
       end
46 47
     end
47 48
     resources :ministerial_roles, path: 'ministers', only: [:index, :show]
90  test/functional/organisations_controller_test.rb
@@ -13,45 +13,6 @@ class OrganisationsControllerTest < ActionController::TestCase
13 13
     assert_select ".description", text: "organisation-description"
14 14
   end
15 15
 
16  
-  test "presents the contact details of the organisation using hcard" do
17  
-    ministerial_department = create(:organisation_type, name: "Ministerial Department")
18  
-    organisation = create(:organisation, organisation_type: ministerial_department,
19  
-      name: "Ministry of Pomp", contacts_attributes: [{
20  
-        description: "Main",
21  
-        email: "pomp@gov.uk",
22  
-        address: "1 Smashing Place, London", postcode: "LO1 8DN",
23  
-        contact_numbers_attributes: [
24  
-          { label: "Helpline", number: "02079460000" },
25  
-          { label: "Fax", number: "02079460001" }
26  
-        ]
27  
-      }]
28  
-    )
29  
-    get :show, id: organisation
30  
-
31  
-    assert_select ".organisation.hcard" do
32  
-      assert_select ".fn.org", "Ministry of Pomp"
33  
-      assert_select ".category", "Ministerial Department"
34  
-      assert_select ".adr" do
35  
-        assert_select ".street-address", "1 Smashing Place, London"
36  
-        assert_select ".postal-code", "LO1 8DN"
37  
-      end
38  
-      assert_select ".tel", /02079460000/ do
39  
-        assert_select ".type", "Helpline"
40  
-      end
41  
-      assert_select ".email", /pomp@gov\.uk/ do
42  
-        assert_select ".type", "Email"
43  
-      end
44  
-    end
45  
-  end
46  
-
47  
-  test "should use html line breaks when displaying the address" do
48  
-    organisation = create(:organisation, contacts_attributes: [{description: "Main", address: "Line 1\nLine 2"}])
49  
-    get :show, id: organisation
50  
-    assert_select ".street-address", /Line 1/
51  
-    assert_select ".street-address", /Line 2/
52  
-    assert_select ".street-address br", count: 1
53  
-  end
54  
-
55 16
   test "shows only published policies associated with organisation" do
56 17
     published_document = create(:published_policy)
57 18
     draft_document = create(:draft_policy)
@@ -195,12 +156,6 @@ class OrganisationsControllerTest < ActionController::TestCase
195 156
     refute_select "#parent_organisations"
196 157
   end
197 158
 
198  
-  test "should link to a google map" do
199  
-    organisation = create(:organisation, contacts_attributes: [{description: "Main", latitude: 51.498772, longitude: -0.130974}])
200  
-    get :show, id: organisation
201  
-    assert_select "a[href='http://maps.google.co.uk/maps?q=51.498772,-0.130974']"
202  
-  end
203  
-
204 159
   test "should display the minister's picture if available" do
205 160
     ministerial_role = create(:ministerial_role)
206 161
     person = create(:person, image: File.open(File.join(Rails.root, 'test', 'fixtures', 'minister-of-funk.jpg')))
@@ -250,6 +205,51 @@ class OrganisationsControllerTest < ActionController::TestCase
250 205
     assert_select ".all_news a[href='#{news_organisation_path(organisation)}']"
251 206
   end
252 207
 
  208
+  test "presents the contact details of the organisation using hcard" do
  209
+    ministerial_department = create(:organisation_type, name: "Ministerial Department")
  210
+    organisation = create(:organisation, organisation_type: ministerial_department,
  211
+      name: "Ministry of Pomp", contacts_attributes: [{
  212
+        description: "Main",
  213
+        email: "pomp@gov.uk",
  214
+        address: "1 Smashing Place, London", postcode: "LO1 8DN",
  215
+        contact_numbers_attributes: [
  216
+          { label: "Helpline", number: "02079460000" },
  217
+          { label: "Fax", number: "02079460001" }
  218
+        ]
  219
+      }]
  220
+    )
  221
+    get :contact_details, id: organisation
  222
+
  223
+    assert_select ".organisation.hcard" do
  224
+      assert_select ".fn.org", "Ministry of Pomp"
  225
+      assert_select ".category", "Ministerial Department"
  226
+      assert_select ".adr" do
  227
+        assert_select ".street-address", "1 Smashing Place, London"
  228
+        assert_select ".postal-code", "LO1 8DN"
  229
+      end
  230
+      assert_select ".tel", /02079460000/ do
  231
+        assert_select ".type", "Helpline"
  232
+      end
  233
+      assert_select ".email", /pomp@gov\.uk/ do
  234
+        assert_select ".type", "Email"
  235
+      end
  236
+    end
  237
+  end
  238
+
  239
+  test "should use html line breaks when displaying the address" do
  240
+    organisation = create(:organisation, contacts_attributes: [{description: "Main", address: "Line 1\nLine 2"}])
  241
+    get :contact_details, id: organisation
  242
+    assert_select ".street-address", /Line 1/
  243
+    assert_select ".street-address", /Line 2/
  244
+    assert_select ".street-address br", count: 1
  245
+  end
  246
+
  247
+  test "should link to a google map" do
  248
+    organisation = create(:organisation, contacts_attributes: [{description: "Main", latitude: 51.498772, longitude: -0.130974}])
  249
+    get :contact_details, id: organisation
  250
+    assert_select "a[href='http://maps.google.co.uk/maps?q=51.498772,-0.130974']"
  251
+  end
  252
+
253 253
   test "should show only published news articles associated with organisation" do
254 254
     published_news_article = create(:published_news_article)
255 255
     draft_news_article = create(:draft_news_article)

0 notes on commit f72f7a7

Please sign in to comment.
Something went wrong with that request. Please try again.