From bf75167b01d660c2b646a37095cc29da7b490e8f Mon Sep 17 00:00:00 2001
From: Gareth Rees
Date: Wed, 9 Oct 2024 13:10:31 +0100
Subject: [PATCH] Simplify citation sidebar logic
* Always show the context text
* Use the same CTA irrespective of existing citations
---
.../info_request_batch/_citations.html.erb | 18 ++++++++++--------
app/views/request/_citations.html.erb | 18 ++++++++++--------
.../_citations.html.erb_spec.rb | 14 +++++---------
spec/views/request/_citations.html.erb_spec.rb | 10 +++++-----
4 files changed, 30 insertions(+), 30 deletions(-)
diff --git a/app/views/info_request_batch/_citations.html.erb b/app/views/info_request_batch/_citations.html.erb
index fe453dc27c..8ff0531469 100644
--- a/app/views/info_request_batch/_citations.html.erb
+++ b/app/views/info_request_batch/_citations.html.erb
@@ -8,18 +8,20 @@
collection: citations,
as: :citation %>
- <% elsif can? :create_citation, info_request_batch %>
+ <% end %>
+
+ <% if can? :create_citation, info_request_batch %>
<%= _('Has this batch request been referenced in journalism, ' \
'campaigning, or research?') %>
-
- <% end %>
- <% if can? :create_citation, info_request_batch %>
- <%= link_to new_info_request_batch_citation_path(info_request_batch),
- class: 'citations-new' do %>
- <%= citations.any? ? _('New Citation') : _('Let us know') %>
- <% end %>
+
+
+ <%= link_to new_info_request_batch_citation_path(info_request_batch),
+ class: 'citations-new' do %>
+ <%= _('Let us know') %>
+ <% end %>
+
<% end %>
<% end %>
diff --git a/app/views/request/_citations.html.erb b/app/views/request/_citations.html.erb
index d5397d6eb9..e0ac5cb961 100644
--- a/app/views/request/_citations.html.erb
+++ b/app/views/request/_citations.html.erb
@@ -8,18 +8,20 @@
collection: citations,
as: :citation %>
- <% elsif can? :create_citation, info_request %>
+ <% end %>
+
+ <% if can? :create_citation, info_request %>
<%= _('Has this request been referenced in journalism, ' \
'campaigning, or research?') %>
-
- <% end %>
- <% if can? :create_citation, info_request %>
- <%= link_to new_citation_path(url_title: info_request.url_title),
- class: 'citations-new' do %>
- <%= citations.any? ? _('New Citation') : _('Let us know') %>
- <% end %>
+
+
+ <%= link_to new_citation_path(url_title: info_request.url_title),
+ class: 'citations-new' do %>
+ <%= _('Let us know') %>
+ <% end %>
+
<% end %>
<% end %>
diff --git a/spec/views/info_request_batch/_citations.html.erb_spec.rb b/spec/views/info_request_batch/_citations.html.erb_spec.rb
index 23657dcefc..6142dfb209 100644
--- a/spec/views/info_request_batch/_citations.html.erb_spec.rb
+++ b/spec/views/info_request_batch/_citations.html.erb_spec.rb
@@ -62,10 +62,6 @@ def render_view
expect(rendered).to match(/FOI in Action/)
end
- it 'does not render the blank slate text' do
- expect(rendered).not_to match(/Has this batch request been referenced/)
- end
-
it 'renders the citations' do
expect(rendered).to match(/citations-list/)
end
@@ -84,16 +80,16 @@ def render_view
expect(rendered).to match(/FOI in Action/)
end
- it 'does not render the blank slate text' do
- expect(rendered).not_to match(/Has this request been referenced/)
- end
-
it 'renders the citations' do
expect(rendered).to match(/citations-list/)
end
+ it 'renders the blank slate text' do
+ expect(rendered).to match(/Has this batch request been referenced/)
+ end
+
it 'renders the link to add citations' do
- expect(rendered).to match('New Citation')
+ expect(rendered).to match('Let us know')
end
end
end
diff --git a/spec/views/request/_citations.html.erb_spec.rb b/spec/views/request/_citations.html.erb_spec.rb
index e481468001..c8354085e1 100644
--- a/spec/views/request/_citations.html.erb_spec.rb
+++ b/spec/views/request/_citations.html.erb_spec.rb
@@ -82,16 +82,16 @@ def render_view
expect(rendered).to match(/FOI in Action/)
end
- it 'does not render the blank slate text' do
- expect(rendered).not_to match(/Has this request been referenced/)
- end
-
it 'renders the citations' do
expect(rendered).to match(/citations-list/)
end
+ it 'renders the blank slate text' do
+ expect(rendered).to match(/Has this request been referenced/)
+ end
+
it 'renders the link to add citations' do
- expect(rendered).to match('New Citation')
+ expect(rendered).to match('Let us know')
end
end
end