Permalink
Browse files

Move organisation contact details to their own dedicated page

  • Loading branch information...
1 parent 8e8d193 commit f72f7a7bde5205267b848050a7fc495402fe31bb @tomafro tomafro committed Feb 2, 2012
@@ -1,6 +1,6 @@
class OrganisationsController < PublicFacingController
- before_filter :load_organisation, only: [:show, :about, :news]
+ before_filter :load_organisation, only: [:show, :about, :contact_details, :news]
def index
@organisations_by_type = Organisation.in_listing_order.group_by(&:organisation_type)
@@ -20,6 +20,9 @@ def show
def about
end
+ def contact_details
+ end
+
def news
@news_articles = NewsArticle.in_organisation(@organisation).published.by_published_at
end
@@ -2,4 +2,5 @@
<%= organisation_navigation_link_to 'Home', organisation_path(organisation) %>
<%= organisation_navigation_link_to 'About', about_organisation_path(organisation) %>
<%= organisation_navigation_link_to 'News', news_organisation_path(organisation) %>
+ <%= organisation_navigation_link_to 'Contact Details', contact_details_organisation_path(organisation) %>
</nav>
@@ -0,0 +1,38 @@
+<% page_title @organisation.name %>
+
+<%= content_tag_for :div, @organisation, class: "hcard" do %>
+ <div class="g3f">
+ <%= render 'header', organisation: @organisation %>
+ </div>
+
+ <div class="g3f page_detail">
+ <div class="g1 hcard">
+ <% @organisation.contacts.each do |contact| %>
+ <div class="organisation_contact">
+ <% if contact.address.present? %>
+ <div class="adr">
+ <h3><%= contact.description %></h3>
+ <p class="fn org name"><%= @organisation.name %></p>
+ <% if @organisation.acronym.present? %>
+ <p class="nickname"><%= @organisation.acronym %></p>
+ <% end %>
+ <p class="street-address"><%= format_with_html_line_breaks(contact.address) %></p>
+ <p class="postal-code"><%= contact.postcode %></p>
+ </div>
+ <% else %>
+ <h3><%= contact.description %></h3>
+ <% end %>
+ <% if contact.email.present? %>
+ <p class="email"><span class="type">Email</span> <%= mail_to contact.email, contact.email, :class => "email" %></p>
+ <% end %>
+ <% contact.contact_numbers.each do |number| %>
+ <p class="tel"><%= number.number %><span class="type"> <%= number.label %> </span></p>
+ <% end %>
+ <% if contact.mappable? %>
+ <p><%= link_to_google_map(contact) %></p>
+ <% end %>
+ </div>
+ <% end %>
+ </div>
+ </div>
+<% end %>
@@ -12,35 +12,6 @@
<%= link_to "Read more about #{@organisation.name}", about_organisation_path(@organisation), title: "Further information about #{@organisation.name}" %>
</p>
</div>
-
- <div class="g1 hcard">
- <% @organisation.contacts.each do |contact| %>
- <div class="organisation_contact">
- <% if contact.address.present? %>
- <div class="adr">
- <h3><%= contact.description %></h3>
- <p class="fn org name"><%= @organisation.name %></p>
- <% if @organisation.acronym.present? %>
- <p class="nickname"><%= @organisation.acronym %></p>
- <% end %>
- <p class="street-address"><%= format_with_html_line_breaks(contact.address) %></p>
- <p class="postal-code"><%= contact.postcode %></p>
- </div>
- <% else %>
- <h3><%= contact.description %></h3>
- <% end %>
- <% if contact.email.present? %>
- <p class="email"><span class="type">Email</span> <%= mail_to contact.email, contact.email, :class => "email" %></p>
- <% end %>
- <% contact.contact_numbers.each do |number| %>
- <p class="tel"><%= number.number %><span class="type"> <%= number.label %> </span></p>
- <% end %>
- <% if contact.mappable? %>
- <p><%= link_to_google_map(contact) %></p>
- <% end %>
- </div>
- <% end %>
- </div>
</div>
<% end %>
View
@@ -13,7 +13,6 @@ test: &test
username: whitehall
password: whitehall
-
production:
adapter: mysql2
database: whitehall_production
View
@@ -42,6 +42,7 @@ def redirect(path)
member do
get :about
get :news
+ get :contact_details, path: 'contact-details'
end
end
resources :ministerial_roles, path: 'ministers', only: [:index, :show]
@@ -13,45 +13,6 @@ class OrganisationsControllerTest < ActionController::TestCase
assert_select ".description", text: "organisation-description"
end
- test "presents the contact details of the organisation using hcard" do
- ministerial_department = create(:organisation_type, name: "Ministerial Department")
- organisation = create(:organisation, organisation_type: ministerial_department,
- name: "Ministry of Pomp", contacts_attributes: [{
- description: "Main",
- email: "pomp@gov.uk",
- address: "1 Smashing Place, London", postcode: "LO1 8DN",
- contact_numbers_attributes: [
- { label: "Helpline", number: "02079460000" },
- { label: "Fax", number: "02079460001" }
- ]
- }]
- )
- get :show, id: organisation
-
- assert_select ".organisation.hcard" do
- assert_select ".fn.org", "Ministry of Pomp"
- assert_select ".category", "Ministerial Department"
- assert_select ".adr" do
- assert_select ".street-address", "1 Smashing Place, London"
- assert_select ".postal-code", "LO1 8DN"
- end
- assert_select ".tel", /02079460000/ do
- assert_select ".type", "Helpline"
- end
- assert_select ".email", /pomp@gov\.uk/ do
- assert_select ".type", "Email"
- end
- end
- end
-
- test "should use html line breaks when displaying the address" do
- organisation = create(:organisation, contacts_attributes: [{description: "Main", address: "Line 1\nLine 2"}])
- get :show, id: organisation
- assert_select ".street-address", /Line 1/
- assert_select ".street-address", /Line 2/
- assert_select ".street-address br", count: 1
- end
-
test "shows only published policies associated with organisation" do
published_document = create(:published_policy)
draft_document = create(:draft_policy)
@@ -195,12 +156,6 @@ class OrganisationsControllerTest < ActionController::TestCase
refute_select "#parent_organisations"
end
- test "should link to a google map" do
- organisation = create(:organisation, contacts_attributes: [{description: "Main", latitude: 51.498772, longitude: -0.130974}])
- get :show, id: organisation
- assert_select "a[href='http://maps.google.co.uk/maps?q=51.498772,-0.130974']"
- end
-
test "should display the minister's picture if available" do
ministerial_role = create(:ministerial_role)
person = create(:person, image: File.open(File.join(Rails.root, 'test', 'fixtures', 'minister-of-funk.jpg')))
@@ -250,6 +205,51 @@ class OrganisationsControllerTest < ActionController::TestCase
assert_select ".all_news a[href='#{news_organisation_path(organisation)}']"
end
+ test "presents the contact details of the organisation using hcard" do
+ ministerial_department = create(:organisation_type, name: "Ministerial Department")
+ organisation = create(:organisation, organisation_type: ministerial_department,
+ name: "Ministry of Pomp", contacts_attributes: [{
+ description: "Main",
+ email: "pomp@gov.uk",
+ address: "1 Smashing Place, London", postcode: "LO1 8DN",
+ contact_numbers_attributes: [
+ { label: "Helpline", number: "02079460000" },
+ { label: "Fax", number: "02079460001" }
+ ]
+ }]
+ )
+ get :contact_details, id: organisation
+
+ assert_select ".organisation.hcard" do
+ assert_select ".fn.org", "Ministry of Pomp"
+ assert_select ".category", "Ministerial Department"
+ assert_select ".adr" do
+ assert_select ".street-address", "1 Smashing Place, London"
+ assert_select ".postal-code", "LO1 8DN"
+ end
+ assert_select ".tel", /02079460000/ do
+ assert_select ".type", "Helpline"
+ end
+ assert_select ".email", /pomp@gov\.uk/ do
+ assert_select ".type", "Email"
+ end
+ end
+ end
+
+ test "should use html line breaks when displaying the address" do
+ organisation = create(:organisation, contacts_attributes: [{description: "Main", address: "Line 1\nLine 2"}])
+ get :contact_details, id: organisation
+ assert_select ".street-address", /Line 1/
+ assert_select ".street-address", /Line 2/
+ assert_select ".street-address br", count: 1
+ end
+
+ test "should link to a google map" do
+ organisation = create(:organisation, contacts_attributes: [{description: "Main", latitude: 51.498772, longitude: -0.130974}])
+ get :contact_details, id: organisation
+ assert_select "a[href='http://maps.google.co.uk/maps?q=51.498772,-0.130974']"
+ end
+
test "should show only published news articles associated with organisation" do
published_news_article = create(:published_news_article)
draft_news_article = create(:draft_news_article)

0 comments on commit f72f7a7

Please sign in to comment.