Skip to content

Commit

Permalink
Merge branch 'admin-citations-list' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
garethrees committed Feb 7, 2024
2 parents 0666a59 + b06a056 commit 2893fee
Show file tree
Hide file tree
Showing 7 changed files with 65 additions and 0 deletions.
7 changes: 7 additions & 0 deletions app/assets/stylesheets/admin.scss
Expand Up @@ -291,6 +291,13 @@ body.admin {
padding: 2em;
}


/* Citation */

#citations .item-title {
word-break: break-all;
}

/* Toolbox */
.toolbox {
summary {
Expand Down
8 changes: 8 additions & 0 deletions app/controllers/admin/citations_controller.rb
@@ -0,0 +1,8 @@
class Admin::CitationsController < AdminController
def index
@citations =
Citation.
order(created_at: :desc).
paginate(page: params[:page], per_page: 50)
end
end
20 changes: 20 additions & 0 deletions app/views/admin/citations/index.html.erb
@@ -0,0 +1,20 @@
<div class="row">
<div class="span12">
<div class="page-header">
<h1><%= @title = 'Citations' %></h1>
</div>
</div>
</div>

<div class="row">
<div class="span12">
<p class="lead">
Citations link requests to places they’re referenced elsewhere.
</p>
</div>
</div>

<%= render partial: 'admin/citations/list',
locals: { citations: @citations } %>
<%= will_paginate(@citations) %>
1 change: 1 addition & 0 deletions app/views/admin_general/_admin_navbar.html.erb
Expand Up @@ -38,6 +38,7 @@
<li><%= link_to 'Comments', admin_comments_path %></li>
<li><%= link_to 'Categories', admin_categories_path(model_type: 'InfoRequest') %></li>
<li><%= link_to 'Tags', admin_tags_path(model_type: 'InfoRequest') %></li>
<li><%= link_to 'Citations', admin_citations_path %></li>
<% if feature_enabled?(:refusal_snippets) %><li><%= link_to 'Snippets', admin_snippets_path %></li><% end %>
</ul>
</li>
Expand Down
6 changes: 6 additions & 0 deletions config/routes.rb
Expand Up @@ -527,6 +527,12 @@ def matches?(request)
resources :changelog, only: [:index]
end

#### Admin::Citations controller
namespace :admin do
resources :citations, only: [:index]
end
####

####
#### AdminTag controller
namespace :admin do
Expand Down
1 change: 1 addition & 0 deletions doc/CHANGES.md
Expand Up @@ -2,6 +2,7 @@

## Highlighted Features

* Add admin list of all citations (Gareth Rees)
* Improve redirection flow after user account closure actions (Gareth Rees)
* Fix duplicated attachment masking jobs (Graeme Porteous)
* Display metadata on admin attachment views (Graeme Porteous)
Expand Down
22 changes: 22 additions & 0 deletions spec/controllers/admin/citations_controller_spec.rb
@@ -0,0 +1,22 @@
require 'spec_helper'

RSpec.describe Admin::CitationsController do
before(:each) { basic_auth_login(@request) }

describe 'GET index' do
before { FactoryBot.create_list(:citation, 3) }
before { get :index }

it 'returns a successful response' do
expect(response).to be_successful
end

it 'assigns the citations' do
expect(assigns[:citations]).to all(be_a(Citation))
end

it 'renders the correct template' do
expect(response).to render_template(:index)
end
end
end

0 comments on commit 2893fee

Please sign in to comment.