diff --git a/app/controllers/request_controller.rb b/app/controllers/request_controller.rb index 4e22f0e151..35a68c1f1d 100644 --- a/app/controllers/request_controller.rb +++ b/app/controllers/request_controller.rb @@ -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 diff --git a/app/views/request/details.html.erb b/app/views/request/details.html.erb index ac0f4489fb..daf2cde3ce 100644 --- a/app/views/request/details.html.erb +++ b/app/views/request/details.html.erb @@ -25,12 +25,12 @@ :site_name => site_name, :contact_path => help_contact_path) %>
-<% 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' ] %><%= column %> | <% end %>link | @@ -39,9 +39,17 @@ <% @info_request.info_request_events.each do |info_request_event| %>|
---|---|---|
- <%=h info_request_event.send(column) %> + <% for column in columns %> + | <% + 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 %> | <% end %>diff --git a/spec/controllers/request_controller_spec.rb b/spec/controllers/request_controller_spec.rb index 2fa0495b94..128d8cecc8 100644 --- a/spec/controllers/request_controller_spec.rb +++ b/spec/controllers/request_controller_spec.rb @@ -2011,17 +2011,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 diff --git a/spec/views/request/details.html.erb_spec.rb b/spec/views/request/details.html.erb_spec.rb new file mode 100644 index 0000000000..af47c2cc26 --- /dev/null +++ b/spec/views/request/details.html.erb_spec.rb @@ -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 |