Skip to content

Commit

Permalink
Merge branch 'details-page-showing-keys-metadata' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
gbp committed Nov 6, 2023
2 parents 4ee067a + 0f3aae0 commit 00f13d2
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 20 deletions.
4 changes: 0 additions & 4 deletions app/controllers/request_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,6 @@ def details
long_cache
@info_request = InfoRequest.find_by_url_title!(params[:url_title])
return render_hidden if cannot?(:read, @info_request)
@columns = %w[
id event_type created_at described_state last_described_at
calculated_state
]
end

# Requests similar to this one
Expand Down
18 changes: 13 additions & 5 deletions app/views/request/details.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@
:site_name => site_name, :contact_path => help_contact_path) %>
</p>

<% columns = ['id', 'event_type', 'created_at', 'described_state', 'calculated_state', 'last_described_at' ] %>
<% columns = ['id', 'event_type', 'details', 'created_at', 'described_state', 'calculated_state', 'last_described_at' ] %>

<table>
<thead>
<tr scope="col">
<% for column in @columns%>
<% for column in columns %>
<th><%= column %></th>
<% end %>
<th scope="col">link</th>
Expand All @@ -39,9 +39,17 @@

<% @info_request.info_request_events.each do |info_request_event| %>
<tr class="<%= cycle('odd', 'even') %>">
<% for column in @columns %>
<td data-label="<%= column %>">
<%=h info_request_event.send(column) %>&nbsp;
<% for column in columns %>
<td data-label="<%= column %>"><%
if column == 'details'
d = info_request_event.params_diff[:new].keys().join(', ')
else
d = info_request_event.send(column)
end
if column == 'event_type' and d == 'edit'
d = 'edit metadata'
end
%><%=h d %>&nbsp;
</td>
<% end %>
<td data-label="link">
Expand Down
11 changes: 0 additions & 11 deletions spec/controllers/request_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2023,17 +2023,6 @@ def send_request
expect(assigns[:info_request]).to eq(info_request)
end

it 'assigns columns' do
get :details, params: { url_title: info_request.url_title }
expected_columns = %w[id
event_type
created_at
described_state
last_described_at
calculated_state]
expect(assigns[:columns]).to eq expected_columns
end

context 'when the request is hidden' do

before do
Expand Down
25 changes: 25 additions & 0 deletions spec/views/request/details.html.erb_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
require 'spec_helper'

RSpec.describe "request/details" do

let(:mock_request) do
FactoryBot.create(:info_request, title: "Test request")
end

it "should show the request" do
FactoryBot.create(
:info_request_event,
event_type: 'edit',
info_request: mock_request,
params: {
"allow_new_responses_from": "nobody",
"old_allow_new_responses_from": "authority_only"
}
)

assign :info_request, mock_request
render
expect(rendered).to have_content('edit metadata')
expect(rendered).to have_content('allow_new_responses_from')
end
end

0 comments on commit 00f13d2

Please sign in to comment.