Permalink
Browse files

Stop showing unique reference & ISBN labels if they are blank

  • Loading branch information...
1 parent 05924a9 commit 0f8814b4bc1724b3192d409c0ff6bcb349c92c8d @tomstuart tomstuart committed Feb 3, 2012
Showing with 26 additions and 2 deletions.
  1. +6 −2 app/views/publications/show.html.erb
  2. +20 −0 test/functional/publications_controller_test.rb
@@ -26,8 +26,12 @@
<section class="contextual_info">
<h1>About this publication</h1>
<p>Publication date: <span class="publication_date"><%= @document.publication_date.to_s(:long_ordinal) %></span></p>
- <p>Unique reference: <span class="unique_reference"><%= @document.unique_reference %></span></p>
- <p>ISBN: <span class="isbn"><%= @document.isbn %></span></p>
+ <% if @document.unique_reference.present? %>
+ <p>Unique reference: <span class="unique_reference"><%= @document.unique_reference %></span></p>
+ <% end %>
+ <% if @document.isbn.present? %>
+ <p>ISBN: <span class="isbn"><%= @document.isbn %></span></p>
+ <% end %>
<% if @document.research? %>
<p class="research">This is a research paper.</p>
<% end %>
@@ -76,6 +76,26 @@ class PublicationsControllerTest < ActionController::TestCase
end
end
+ test "should not mention the unique reference if there isn't one" do
+ publication = create(:published_publication, unique_reference: '')
+
+ get :show, id: publication.document_identity
+
+ assert_select ".contextual_info" do
+ refute_select ".unique_reference"
+ end
+ end
+
+ test "should not mention the ISBN if there isn't one" do
+ publication = create(:published_publication, isbn: '')
+
+ get :show, id: publication.document_identity
+
+ assert_select ".contextual_info" do
+ refute_select ".isbn"
+ end
+ end
+
test "should not display an order link if no order url exists" do
publication = create(:published_publication, order_url: nil)

0 comments on commit 0f8814b

Please sign in to comment.