Skip to content

Commit

Permalink
Add basic admin list of all citations
Browse files Browse the repository at this point in the history
  • Loading branch information
garethrees committed Feb 1, 2024
1 parent 61878ae commit 4bd2384
Show file tree
Hide file tree
Showing 6 changed files with 58 additions and 0 deletions.
8 changes: 8 additions & 0 deletions app/controllers/admin/citations_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
class Admin::CitationsController < AdminController

Check warning on line 1 in app/controllers/admin/citations_controller.rb

View workflow job for this annotation

GitHub Actions / build

[rubocop] reported by reviewdog 🐶 Missing top-level documentation comment for `class Admin::CitationsController`. Raw Output: app/controllers/admin/citations_controller.rb:1:1: C: Style/Documentation: Missing top-level documentation comment for `class Admin::CitationsController`.
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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

## Highlighted Features

* Add admin list of all citations (Gareth Rees)
* Fix duplicated attachment masking jobs (Graeme Porteous)
* Display metadata on admin attachment views (Graeme Porteous)
* Change request URL patterns to be member routes (Alexander Griffen, Graeme
Expand Down
22 changes: 22 additions & 0 deletions spec/controllers/admin/citations_controller_spec.rb
Original file line number Diff line number Diff line change
@@ -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 4bd2384

Please sign in to comment.