Skip to content

Commit

Permalink
fixup! Adding comment deletion
Browse files Browse the repository at this point in the history
  • Loading branch information
gbp committed Jul 23, 2024
1 parent 2e0229b commit 322019a
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions spec/integration/admin_comment_controller_destroy_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
require 'spec_helper'
require 'integration/alaveteli_dsl'

RSpec.describe 'Destroying a Comment' do
before do
allow(AlaveteliConfiguration).to receive(:skip_admin_auth).and_return(false)

confirm(:admin_user)
@admin = login(:admin_user)

@comment = FactoryBot.create(:comment, :with_event, body: 'PII')
@comment.reindex_request_events
update_xapian_index
end

it 'destroing a comment removes it from the search index' do
# prove the comment is in the search index
using_session(without_login) do
visit search_requests_path(query: 'PII')
expect(page).to have_content('One FOI request found')
expect(page).to have_selector('.results_block div', text: 'PII')
end

# remove the comment from the admin
using_session(@admin) do
visit edit_admin_comment_path(@comment)
find('form input[value="Destroy comment"]').click
end

# run the search indexed update manually
update_xapian_index

# show the comment has been removed from the search index
using_session(without_login) do
visit search_requests_path(query: 'PII')
expect(page).to have_content('no results matching your query.')
expect(page).to_not have_selector('.results_block div', text: 'PII')
end
end
end

0 comments on commit 322019a

Please sign in to comment.